mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
[android] Remove display of speed from navigation panel
Signed-off-by: Gonzalo Pesquero <gpesquero@yahoo.es>
This commit is contained in:
@@ -1,20 +1,14 @@
|
||||
package app.organicmaps.widget.menu;
|
||||
|
||||
import android.location.Location;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import app.organicmaps.MwmApplication;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.sdk.routing.RoutingInfo;
|
||||
import app.organicmaps.sdk.sound.TtsPlayer;
|
||||
import app.organicmaps.sdk.util.Config;
|
||||
import app.organicmaps.sdk.util.StringUtils;
|
||||
import app.organicmaps.sdk.util.DateUtils;
|
||||
import app.organicmaps.util.Graphics;
|
||||
import app.organicmaps.util.ThemeUtils;
|
||||
import app.organicmaps.util.UiUtils;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
@@ -32,14 +26,12 @@ public class NavMenu
|
||||
private final View mHeaderFrame;
|
||||
|
||||
private final ShapeableImageView mTts;
|
||||
private final View mSpeedViewContainer;
|
||||
private final MaterialTextView mSpeedValue;
|
||||
private final MaterialTextView mSpeedUnits;
|
||||
private final MaterialTextView mEtaValue;
|
||||
private final MaterialTextView mEtaAmPm;
|
||||
private final MaterialTextView mTimeHourValue;
|
||||
private final MaterialTextView mTimeHourUnits;
|
||||
private final MaterialTextView mTimeMinuteValue;
|
||||
private final MaterialTextView mTimeMinuteUnits;
|
||||
private final MaterialTextView mTimeEstimate;
|
||||
private final MaterialTextView mDistanceValue;
|
||||
private final MaterialTextView mDistanceUnits;
|
||||
private final LinearProgressIndicator mRouteProgress;
|
||||
@@ -94,14 +86,12 @@ public class NavMenu
|
||||
});
|
||||
|
||||
// Bottom frame
|
||||
mSpeedViewContainer = bottomFrame.findViewById(R.id.speed_view_container);
|
||||
mSpeedValue = bottomFrame.findViewById(R.id.speed_value);
|
||||
mSpeedUnits = bottomFrame.findViewById(R.id.speed_dimen);
|
||||
mEtaValue = bottomFrame.findViewById(R.id.eta_value);
|
||||
mEtaAmPm = bottomFrame.findViewById(R.id.eta_am_pm);
|
||||
mTimeHourValue = bottomFrame.findViewById(R.id.time_hour_value);
|
||||
mTimeHourUnits = bottomFrame.findViewById(R.id.time_hour_dimen);
|
||||
mTimeMinuteValue = bottomFrame.findViewById(R.id.time_minute_value);
|
||||
mTimeMinuteUnits = bottomFrame.findViewById(R.id.time_minute_dimen);
|
||||
mTimeEstimate = bottomFrame.findViewById(R.id.time_estimate);
|
||||
mDistanceValue = bottomFrame.findViewById(R.id.distance_value);
|
||||
mDistanceUnits = bottomFrame.findViewById(R.id.distance_dimen);
|
||||
mRouteProgress = bottomFrame.findViewById(R.id.navigation_progress);
|
||||
@@ -199,38 +189,34 @@ public class NavMenu
|
||||
|
||||
private void updateTimeEstimate(int seconds)
|
||||
{
|
||||
final String format =
|
||||
android.text.format.DateFormat.is24HourFormat(mTimeMinuteValue.getContext()) ? "HH:mm" : "h:mm a";
|
||||
// Calculate ETA from current local time and remaining seconds.
|
||||
final LocalTime localTime = LocalTime.now().plusSeconds(seconds);
|
||||
mTimeEstimate.setText(localTime.format(DateTimeFormatter.ofPattern(format)));
|
||||
}
|
||||
|
||||
private void updateSpeedView(@NonNull RoutingInfo info)
|
||||
{
|
||||
final Location last = MwmApplication.from(mActivity).getLocationHelper().getSavedLocation();
|
||||
if (last == null)
|
||||
return;
|
||||
// String to set the format of the ETA value (24h or AM/PM).
|
||||
final String etaValueFormat;
|
||||
|
||||
Pair<String, String> speedAndUnits = StringUtils.nativeFormatSpeedAndUnits(last.getSpeed());
|
||||
mSpeedValue.setText(speedAndUnits.first);
|
||||
// Text of the AM/PM view.
|
||||
final String etaAmPmText;
|
||||
|
||||
if (info.speedLimitMps > 0.0 && last.getSpeed() > info.speedLimitMps)
|
||||
if (DateUtils.is24HourFormat(mTimeMinuteValue.getContext()))
|
||||
{
|
||||
if (info.isSpeedCamLimitExceeded())
|
||||
mSpeedValue.setTextColor(ContextCompat.getColor(mActivity, R.color.white_primary));
|
||||
else
|
||||
mSpeedValue.setTextColor(ContextCompat.getColor(mActivity, R.color.base_red));
|
||||
// 24 hours time format.
|
||||
etaValueFormat = "HH:mm";
|
||||
etaAmPmText = "";
|
||||
}
|
||||
else
|
||||
mSpeedValue.setTextColor(ThemeUtils.getColor(mActivity, android.R.attr.textColorPrimary));
|
||||
{
|
||||
// AM/PM time format.
|
||||
etaValueFormat = "h:mm";
|
||||
etaAmPmText = localTime.format(DateTimeFormatter.ofPattern("a"));
|
||||
}
|
||||
|
||||
mSpeedUnits.setText(speedAndUnits.second);
|
||||
mSpeedViewContainer.setActivated(info.isSpeedCamLimitExceeded());
|
||||
mEtaValue.setText(localTime.format(DateTimeFormatter.ofPattern(etaValueFormat)));
|
||||
mEtaAmPm.setText(etaAmPmText);
|
||||
}
|
||||
|
||||
public void update(@NonNull RoutingInfo info)
|
||||
{
|
||||
updateSpeedView(info);
|
||||
updateTime(info.totalTimeInSeconds);
|
||||
mDistanceValue.setText(info.distToTarget.mDistanceStr);
|
||||
mDistanceUnits.setText(info.distToTarget.getUnitsStr(mActivity.getApplicationContext()));
|
||||
|
||||
@@ -13,35 +13,35 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.5"/>
|
||||
|
||||
<!-- Speed -->
|
||||
<!-- ETA (Estimated Time of Arrival) -->
|
||||
<LinearLayout
|
||||
android:id="@+id/speed_view_container"
|
||||
android:id="@+id/eta_view_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/speed_cams_bg"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/nav_numbers_side_min_width">
|
||||
|
||||
<!-- ETA value -->
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/speed_value"
|
||||
android:id="@+id/eta_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number"
|
||||
tools:text="999" />
|
||||
tools:text="99:99" />
|
||||
|
||||
<!-- Speed -->
|
||||
<!-- ETA AM/PM -->
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/speed_dimen"
|
||||
android:id="@+id/eta_am_pm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
|
||||
tools:background="#20FF0000"
|
||||
tools:text="km/h" />
|
||||
tools:text="AM/PM" />
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
@@ -103,14 +103,14 @@
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/time_estimate"
|
||||
android:id="@+id/disused_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
|
||||
tools:text="99:99 AM" />
|
||||
tools:text="----" />
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
|
||||
Reference in New Issue
Block a user