[navigation]eta time switches with eta minutes on tap. #4741
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -7,22 +8,19 @@
|
|||
android:orientation="horizontal"
|
||||
tools:background="#3000FF00"
|
||||
tools:ignore="RtlSymmetry">
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.5"/>
|
||||
|
||||
android:layout_weight="0.5" />
|
||||
<!-- Speed -->
|
||||
<LinearLayout
|
||||
android:id="@+id/speed_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">
|
||||
|
||||
android:minWidth="@dimen/nav_numbers_side_min_width"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/speed_value"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -31,7 +29,6 @@
|
|||
android:lines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number"
|
||||
tools:text="999" />
|
||||
|
||||
<!-- Speed -->
|
||||
<TextView
|
||||
android:id="@+id/speed_dimen"
|
||||
|
@ -43,26 +40,25 @@
|
|||
tools:background="#20FF0000"
|
||||
tools:text="km/h" />
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.25"/>
|
||||
|
||||
android:layout_weight="1.25" />
|
||||
<!-- Time -->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginRight="-100sp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/nav_numbers_side_min_width">
|
||||
|
||||
android:minWidth="@dimen/nav_numbers_side_min_width"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:id="@+id/time_values_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
tools:background="#20FF0000">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time_hour_value"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -71,7 +67,6 @@
|
|||
android:lines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Time"
|
||||
tools:text="999" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time_hour_dimen"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -81,7 +76,6 @@
|
|||
android:lines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Time.Dimension"
|
||||
tools:text="h" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time_minute_value"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -91,7 +85,6 @@
|
|||
android:textAlignment="center"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Time"
|
||||
tools:text="99" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time_minute_dimen"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -101,7 +94,6 @@
|
|||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Time.Dimension"
|
||||
tools:text="m" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time_estimate"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -112,20 +104,81 @@
|
|||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
|
||||
tools:text="99:99 AM" />
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.25"/>
|
||||
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/nav_numbers_side_min_width"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/time_estimate2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Time.Dimension"
|
||||
android:textSize="24sp"
|
||||
android:visibility="gone"
|
||||
tools:text="99:99 AM" />
|
||||
<LinearLayout
|
||||
android:id="@+id/time_values_container2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
tools:background="#20FF0000">
|
||||
<TextView
|
||||
android:id="@+id/time_hour_value2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
|
||||
android:textSize="16sp"
|
||||
tools:text="999" />
|
||||
<TextView
|
||||
android:id="@+id/time_hour_dimen2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/margin_quarter"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
|
||||
android:textSize="12sp"
|
||||
tools:text="h" />
|
||||
<TextView
|
||||
android:id="@+id/time_minute_value2"
|
||||
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"
|
||||
android:textSize="16sp"
|
||||
tools:text="99" />
|
||||
<TextView
|
||||
android:id="@+id/time_minute_dimen2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number.Dimension"
|
||||
android:textSize="12sp"
|
||||
tools:text="m" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<Space
|
||||
android:layout_width="19dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1.25" />
|
||||
<!-- Distance -->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:minWidth="@dimen/nav_numbers_side_min_width">
|
||||
|
||||
android:minWidth="@dimen/nav_numbers_side_min_width"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/distance_value"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -134,7 +187,6 @@
|
|||
android:lines="1"
|
||||
android:textAppearance="@style/MwmTextAppearance.NavMenu.Number"
|
||||
tools:text="99999" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance_dimen"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -145,9 +197,8 @@
|
|||
tools:background="#20FF0000"
|
||||
tools:text="km" />
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.5"/>
|
||||
</LinearLayout>
|
||||
android:layout_weight="0.5" />
|
||||
</LinearLayout>
|
|
@ -5,19 +5,20 @@ import android.util.Pair;
|
|||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import app.organicmaps.R;
|
||||
import app.organicmaps.location.LocationHelper;
|
||||
import app.organicmaps.routing.RoutingInfo;
|
||||
import app.organicmaps.sound.TtsPlayer;
|
||||
import app.organicmaps.widget.FlatProgressView;
|
||||
import app.organicmaps.util.Graphics;
|
||||
import app.organicmaps.util.StringUtils;
|
||||
import app.organicmaps.util.UiUtils;
|
||||
import app.organicmaps.widget.FlatProgressView;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -39,13 +40,19 @@ public class NavMenu
|
|||
private final TextView mTimeHourUnits;
|
||||
private final TextView mTimeMinuteValue;
|
||||
private final TextView mTimeMinuteUnits;
|
||||
private final TextView mTimeHourValue2;
|
||||
private final TextView mTimeHourUnits2;
|
||||
private final TextView mTimeMinuteValue2;
|
||||
private final TextView mTimeMinuteUnits2;
|
||||
private final TextView mTimeEstimate;
|
||||
private final TextView mTimeEstimate2;
|
||||
private final TextView mDistanceValue;
|
||||
private final TextView mDistanceUnits;
|
||||
private final FlatProgressView mRouteProgress;
|
||||
|
||||
private final AppCompatActivity mActivity;
|
||||
private final NavMenuListener mNavMenuListener;
|
||||
private LinearLayout mTimeValueContainer;
|
||||
private LinearLayout mTimeValueContainer2;
|
||||
|
||||
private int currentPeekHeight = 0;
|
||||
|
||||
|
@ -92,10 +99,17 @@ public class NavMenu
|
|||
mTimeHourUnits = bottomFrame.findViewById(R.id.time_hour_dimen);
|
||||
mTimeMinuteValue = bottomFrame.findViewById(R.id.time_minute_value);
|
||||
mTimeMinuteUnits = bottomFrame.findViewById(R.id.time_minute_dimen);
|
||||
mTimeHourValue2 = bottomFrame.findViewById(R.id.time_hour_value2);
|
||||
mTimeHourUnits2 = bottomFrame.findViewById(R.id.time_hour_dimen2);
|
||||
mTimeMinuteValue2 = bottomFrame.findViewById(R.id.time_minute_value2);
|
||||
mTimeMinuteUnits2 = bottomFrame.findViewById(R.id.time_minute_dimen2);
|
||||
mTimeEstimate = bottomFrame.findViewById(R.id.time_estimate);
|
||||
mTimeEstimate2 = bottomFrame.findViewById(R.id.time_estimate2);
|
||||
mDistanceValue = bottomFrame.findViewById(R.id.distance_value);
|
||||
mDistanceUnits = bottomFrame.findViewById(R.id.distance_dimen);
|
||||
mRouteProgress = bottomFrame.findViewById(R.id.navigation_progress);
|
||||
mTimeValueContainer = bottomFrame.findViewById(R.id.time_values_container);
|
||||
mTimeValueContainer2 = bottomFrame.findViewById(R.id.time_values_container2);
|
||||
|
||||
// Bottom frame buttons
|
||||
ImageView mSettings = bottomFrame.findViewById(R.id.settings);
|
||||
|
@ -158,8 +172,8 @@ public class NavMenu
|
|||
|
||||
public void refreshTts()
|
||||
{
|
||||
mTts.setImageDrawable(TtsPlayer.isEnabled() ? Graphics.tint(mActivity, R.drawable.ic_voice_on,
|
||||
R.attr.colorAccent)
|
||||
mTts.setImageDrawable(TtsPlayer.isEnabled() ? Graphics.tint(mActivity,
|
||||
R.drawable.ic_voice_on, R.attr.colorAccent)
|
||||
: Graphics.tint(mActivity, R.drawable.ic_voice_off));
|
||||
}
|
||||
|
||||
|
@ -175,16 +189,40 @@ public class NavMenu
|
|||
final long hours = TimeUnit.SECONDS.toHours(seconds);
|
||||
final long minutes = TimeUnit.SECONDS.toMinutes(seconds) % 60;
|
||||
![]() it checks whether estimated min is displayed or eta time. Switches between the two on tap. People with weak eye sights would require both times in large font. it checks whether estimated min is displayed or eta time. Switches between the two on tap. People with weak eye sights would require both times in large font.
|
||||
mTimeMinuteValue.setText(String.valueOf(minutes));
|
||||
mTimeMinuteValue2.setText(String.valueOf(minutes));
|
||||
String min = mActivity.getResources().getString(R.string.minute);
|
||||
mTimeMinuteUnits.setText(min);
|
||||
mTimeMinuteUnits2.setText(min);
|
||||
mTimeValueContainer.setOnClickListener(v -> changeTimes());
|
||||
if (hours == 0)
|
||||
{
|
||||
UiUtils.hide(mTimeHourUnits, mTimeHourValue);
|
||||
![]() I'm not convinced yet that all these calculations are necessary. We have two TextView elements, defined in the layout with custom colors already. What is necessary, is to replace the content in them (and make sure that updates to this content will go into the appropriate top or bottom element). I'm not convinced yet that all these calculations are necessary. We have two TextView elements, defined in the layout with custom colors already. What is necessary, is to replace the content in them (and make sure that updates to this content will go into the appropriate top or bottom element).
![]() There are actually 4 textview elements in a linear layout(minutevalue minuteunit hour value hour unit) and 5th one is the eta(the one on the bottom by default). It made me uncomfortable too writing all those lines to change colour. There are actually 4 textview elements in a linear layout(minutevalue minuteunit hour value hour unit) and 5th one is the eta(the one on the bottom by default). It made me uncomfortable too writing all those lines to change colour.
I'll try to find an alternative.
![]() Can layouts be swapped somehow? Can layouts be swapped somehow?
![]() Or maybe they can be defined (duplicated) in XML, and can be switched by the code? Or maybe they can be defined (duplicated) in XML, and can be switched by the code?
![]() Yes that is a good idea. Yes that is a good idea.
We can set the alpha to 0 and switch it on tap?
![]() No alpha, please. Views should be made No alpha, please. Views should be made `gone` and `visible`.
![]() Okay. Understood Okay. Understood
|
||||
UiUtils.hide(mTimeHourUnits2, mTimeHourValue2);
|
||||
return;
|
||||
}
|
||||
UiUtils.setTextAndShow(mTimeHourValue, String.valueOf(hours));
|
||||
UiUtils.setTextAndShow(mTimeHourValue2, String.valueOf(hours));
|
||||
String hour = mActivity.getResources().getString(R.string.hour);
|
||||
UiUtils.setTextAndShow(mTimeHourUnits, hour);
|
||||
UiUtils.setTextAndShow(mTimeHourUnits2, hour);
|
||||
}
|
||||
|
||||
public void changeTimes()
|
||||
{
|
||||
if (mTimeValueContainer.getVisibility() == View.VISIBLE)
|
||||
{
|
||||
UiUtils.hide(mTimeValueContainer);
|
||||
UiUtils.show(mTimeValueContainer2);
|
||||
UiUtils.hide(mTimeEstimate);
|
||||
UiUtils.show(mTimeEstimate2);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiUtils.show(mTimeValueContainer);
|
||||
UiUtils.hide(mTimeValueContainer2);
|
||||
UiUtils.show(mTimeEstimate);
|
||||
UiUtils.hide(mTimeEstimate2);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTimeEstimate(int seconds)
|
||||
|
@ -197,9 +235,9 @@ public class NavMenu
|
|||
else
|
||||
timeFormat = new SimpleDateFormat("h:mm aa", Locale.getDefault());
|
||||
mTimeEstimate.setText(timeFormat.format(currentTime.getTime()));
|
||||
mTimeEstimate2.setText(timeFormat.format(currentTime.getTime()));
|
||||
mTimeEstimate2.setOnClickListener(v -> changeTimes());
|
||||
}
|
||||
|
||||
|
||||
private void updateSpeedView(@NonNull RoutingInfo info)
|
||||
{
|
||||
final Location last = LocationHelper.INSTANCE.getSavedLocation();
|
||||
|
@ -228,4 +266,4 @@ public class NavMenu
|
|||
|
||||
void onSettingsClicked();
|
||||
}
|
||||
}
|
||||
}
|
What does this code do?