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