From 740c9030ca503487f428c47c983bce377511c448 Mon Sep 17 00:00:00 2001 From: Aryan Date: Thu, 9 Mar 2023 21:09:57 +0530 Subject: [PATCH 1/4] [navigation]eta time switches with eta minutes on tap. Signed-off-by: Aryan --- .../src/app/organicmaps/widget/menu/NavMenu.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/android/src/app/organicmaps/widget/menu/NavMenu.java b/android/src/app/organicmaps/widget/menu/NavMenu.java index 32cd16d337..3541dfdabf 100644 --- a/android/src/app/organicmaps/widget/menu/NavMenu.java +++ b/android/src/app/organicmaps/widget/menu/NavMenu.java @@ -49,6 +49,8 @@ public class NavMenu private int currentPeekHeight = 0; + private int check = 0; + public NavMenu(AppCompatActivity activity, NavMenuListener navMenuListener) { mActivity = activity; @@ -189,6 +191,12 @@ public class NavMenu private void updateTimeEstimate(int seconds) { + if(check == 1){ + mTimeEstimate.setAlpha(0f); + } else if (check == 2) { + mTimeEstimate.setAlpha(1f); + } + final Calendar currentTime = Calendar.getInstance(); currentTime.add(Calendar.SECOND, seconds); DateFormat timeFormat; @@ -197,6 +205,12 @@ public class NavMenu else timeFormat = new SimpleDateFormat("h:mm aa", Locale.getDefault()); mTimeEstimate.setText(timeFormat.format(currentTime.getTime())); + mTimeEstimate.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + check = (check==1)?2:1; + } + }); } -- 2.45.3 From 82c752e3d9731e531b9af06da4921dee5a04fba9 Mon Sep 17 00:00:00 2001 From: Aryan Date: Sat, 18 Mar 2023 11:50:07 +0530 Subject: [PATCH 2/4] Eta minutes switch with Eta time on tap Signed-off-by: Aryan --- .../app/organicmaps/widget/menu/NavMenu.java | 53 ++++++++++++++----- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/android/src/app/organicmaps/widget/menu/NavMenu.java b/android/src/app/organicmaps/widget/menu/NavMenu.java index 3541dfdabf..27127a7f3b 100644 --- a/android/src/app/organicmaps/widget/menu/NavMenu.java +++ b/android/src/app/organicmaps/widget/menu/NavMenu.java @@ -2,9 +2,11 @@ package app.organicmaps.widget.menu; import android.location.Location; import android.util.Pair; +import android.util.TypedValue; import android.view.View; import android.widget.Button; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; @@ -43,14 +45,13 @@ public class NavMenu private final TextView mDistanceValue; private final TextView mDistanceUnits; private final FlatProgressView mRouteProgress; + private final LinearLayout mTimeValueContainer; private final AppCompatActivity mActivity; private final NavMenuListener mNavMenuListener; private int currentPeekHeight = 0; - private int check = 0; - public NavMenu(AppCompatActivity activity, NavMenuListener navMenuListener) { mActivity = activity; @@ -64,6 +65,7 @@ public class NavMenu mBottomSheetBackground.setOnClickListener(v -> collapseNavBottomSheet()); mBottomSheetBackground.setVisibility(View.GONE); mBottomSheetBackground.setAlpha(0); + mTimeValueContainer = bottomFrame.findViewById(R.id.time_values_container); mNavBottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { @Override @@ -161,8 +163,8 @@ public class NavMenu public void refreshTts() { mTts.setImageDrawable(TtsPlayer.isEnabled() ? Graphics.tint(mActivity, R.drawable.ic_voice_on, - R.attr.colorAccent) - : Graphics.tint(mActivity, R.drawable.ic_voice_off)); + R.attr.colorAccent) + : Graphics.tint(mActivity, R.drawable.ic_voice_off)); } @@ -179,6 +181,14 @@ public class NavMenu mTimeMinuteValue.setText(String.valueOf(minutes)); String min = mActivity.getResources().getString(R.string.minute); mTimeMinuteUnits.setText(min); + mTimeValueContainer.setOnClickListener(new View.OnClickListener() + { + @Override + public void onClick(View v) + { + changeTimes(); + } + }); if (hours == 0) { UiUtils.hide(mTimeHourUnits, mTimeHourValue); @@ -189,14 +199,26 @@ public class NavMenu UiUtils.setTextAndShow(mTimeHourUnits, hour); } + private void changeTimes(){ + float s1 = mTimeEstimate.getTextSize(), s2 = mTimeMinuteValue.getTextSize(); + mTimeEstimate.setTextSize(TypedValue.COMPLEX_UNIT_PX, s2); + mTimeHourValue.setTextSize(TypedValue.COMPLEX_UNIT_PX, s1); + mTimeMinuteValue.setTextSize(TypedValue.COMPLEX_UNIT_PX, s1); + + if(mTimeValueContainer.getY() < mTimeEstimate.getY()) + { + mTimeValueContainer.setY(95); + mTimeEstimate.setY(40); + } + else + { + mTimeEstimate.setY(50); + mTimeValueContainer.setY(0); + } + } + private void updateTimeEstimate(int seconds) { - if(check == 1){ - mTimeEstimate.setAlpha(0f); - } else if (check == 2) { - mTimeEstimate.setAlpha(1f); - } - final Calendar currentTime = Calendar.getInstance(); currentTime.add(Calendar.SECOND, seconds); DateFormat timeFormat; @@ -205,10 +227,13 @@ public class NavMenu else timeFormat = new SimpleDateFormat("h:mm aa", Locale.getDefault()); mTimeEstimate.setText(timeFormat.format(currentTime.getTime())); - mTimeEstimate.setOnClickListener(new View.OnClickListener() { + + mTimeEstimate.setOnClickListener(new View.OnClickListener() + { @Override - public void onClick(View v) { - check = (check==1)?2:1; + public void onClick(View v) + { + changeTimes(); } }); } @@ -242,4 +267,4 @@ public class NavMenu void onSettingsClicked(); } -} +} \ No newline at end of file -- 2.45.3 From bc6d89885f2d00766b8fac073197ece7cb953131 Mon Sep 17 00:00:00 2001 From: Aryan Date: Tue, 21 Mar 2023 00:47:37 +0530 Subject: [PATCH 3/4] removed the hardcoding on time switching Signed-off-by: Aryan --- .../src/app/organicmaps/widget/menu/NavMenu.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/android/src/app/organicmaps/widget/menu/NavMenu.java b/android/src/app/organicmaps/widget/menu/NavMenu.java index 27127a7f3b..3778bef219 100644 --- a/android/src/app/organicmaps/widget/menu/NavMenu.java +++ b/android/src/app/organicmaps/widget/menu/NavMenu.java @@ -1,5 +1,6 @@ package app.organicmaps.widget.menu; +import android.content.res.ColorStateList; import android.location.Location; import android.util.Pair; import android.util.TypedValue; @@ -204,16 +205,22 @@ public class NavMenu mTimeEstimate.setTextSize(TypedValue.COMPLEX_UNIT_PX, s2); mTimeHourValue.setTextSize(TypedValue.COMPLEX_UNIT_PX, s1); mTimeMinuteValue.setTextSize(TypedValue.COMPLEX_UNIT_PX, s1); + ColorStateList col = mTimeEstimate.getTextColors(); + mTimeEstimate.setTextColor(mTimeMinuteValue.getTextColors()); + mTimeMinuteUnits.setTextColor(col); + mTimeHourUnits.setTextColor(col); + mTimeMinuteValue.setTextColor(col); + mTimeHourValue.setTextColor(col); if(mTimeValueContainer.getY() < mTimeEstimate.getY()) { - mTimeValueContainer.setY(95); - mTimeEstimate.setY(40); + mTimeValueContainer.setY(mSpeedUnits.getY()); + mTimeEstimate.setY(mTimeEstimate.getY()/2); } else { - mTimeEstimate.setY(50); - mTimeValueContainer.setY(0); + mTimeValueContainer.setY(mSpeedValue.getY()); + mTimeEstimate.setY(mSpeedUnits.getY()/2); } } -- 2.45.3 From 6aab1bc313851d1f340829b4afa49f551a531861 Mon Sep 17 00:00:00 2001 From: Aryan Date: Mon, 27 Mar 2023 22:16:01 +0530 Subject: [PATCH 4/4] made changes in xml files to switch eta times on tap Signed-off-by: Aryan --- .../res/layout/layout_nav_bottom_numbers.xml | 115 +++++++++++++----- .../app/organicmaps/widget/menu/NavMenu.java | 84 ++++++------- 2 files changed, 121 insertions(+), 78 deletions(-) diff --git a/android/res/layout/layout_nav_bottom_numbers.xml b/android/res/layout/layout_nav_bottom_numbers.xml index 0a798f06a6..7a4576f88a 100644 --- a/android/res/layout/layout_nav_bottom_numbers.xml +++ b/android/res/layout/layout_nav_bottom_numbers.xml @@ -1,5 +1,6 @@ - - - + android:layout_weight="0.5" /> - + android:minWidth="@dimen/nav_numbers_side_min_width" + android:orientation="vertical"> - - - + android:layout_weight="1.25" /> - + android:minWidth="@dimen/nav_numbers_side_min_width" + android:orientation="vertical"> - - - - - - - - + android:layout_weight="1" + android:gravity="center" + android:minWidth="@dimen/nav_numbers_side_min_width" + android:orientation="vertical"> + + + + + + + + + - + android:minWidth="@dimen/nav_numbers_side_min_width" + android:orientation="vertical"> - - - + android:layout_weight="0.5" /> + \ No newline at end of file diff --git a/android/src/app/organicmaps/widget/menu/NavMenu.java b/android/src/app/organicmaps/widget/menu/NavMenu.java index 3778bef219..0e06689904 100644 --- a/android/src/app/organicmaps/widget/menu/NavMenu.java +++ b/android/src/app/organicmaps/widget/menu/NavMenu.java @@ -1,9 +1,7 @@ package app.organicmaps.widget.menu; -import android.content.res.ColorStateList; import android.location.Location; import android.util.Pair; -import android.util.TypedValue; import android.view.View; import android.widget.Button; import android.widget.ImageView; @@ -12,15 +10,15 @@ 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; @@ -42,14 +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 LinearLayout mTimeValueContainer; - private final AppCompatActivity mActivity; private final NavMenuListener mNavMenuListener; + private LinearLayout mTimeValueContainer; + private LinearLayout mTimeValueContainer2; private int currentPeekHeight = 0; @@ -66,7 +69,6 @@ public class NavMenu mBottomSheetBackground.setOnClickListener(v -> collapseNavBottomSheet()); mBottomSheetBackground.setVisibility(View.GONE); mBottomSheetBackground.setAlpha(0); - mTimeValueContainer = bottomFrame.findViewById(R.id.time_values_container); mNavBottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { @Override @@ -97,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); @@ -163,9 +172,9 @@ public class NavMenu public void refreshTts() { - mTts.setImageDrawable(TtsPlayer.isEnabled() ? Graphics.tint(mActivity, R.drawable.ic_voice_on, - R.attr.colorAccent) - : Graphics.tint(mActivity, R.drawable.ic_voice_off)); + mTts.setImageDrawable(TtsPlayer.isEnabled() ? Graphics.tint(mActivity, + R.drawable.ic_voice_on, R.attr.colorAccent) + : Graphics.tint(mActivity, R.drawable.ic_voice_off)); } @@ -180,47 +189,39 @@ public class NavMenu final long hours = TimeUnit.SECONDS.toHours(seconds); final long minutes = TimeUnit.SECONDS.toMinutes(seconds) % 60; mTimeMinuteValue.setText(String.valueOf(minutes)); + mTimeMinuteValue2.setText(String.valueOf(minutes)); String min = mActivity.getResources().getString(R.string.minute); mTimeMinuteUnits.setText(min); - mTimeValueContainer.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - changeTimes(); - } - }); + mTimeMinuteUnits2.setText(min); + mTimeValueContainer.setOnClickListener(v -> changeTimes()); if (hours == 0) { UiUtils.hide(mTimeHourUnits, mTimeHourValue); + 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); } - private void changeTimes(){ - float s1 = mTimeEstimate.getTextSize(), s2 = mTimeMinuteValue.getTextSize(); - mTimeEstimate.setTextSize(TypedValue.COMPLEX_UNIT_PX, s2); - mTimeHourValue.setTextSize(TypedValue.COMPLEX_UNIT_PX, s1); - mTimeMinuteValue.setTextSize(TypedValue.COMPLEX_UNIT_PX, s1); - ColorStateList col = mTimeEstimate.getTextColors(); - mTimeEstimate.setTextColor(mTimeMinuteValue.getTextColors()); - mTimeMinuteUnits.setTextColor(col); - mTimeHourUnits.setTextColor(col); - mTimeMinuteValue.setTextColor(col); - mTimeHourValue.setTextColor(col); - - if(mTimeValueContainer.getY() < mTimeEstimate.getY()) + public void changeTimes() + { + if (mTimeValueContainer.getVisibility() == View.VISIBLE) { - mTimeValueContainer.setY(mSpeedUnits.getY()); - mTimeEstimate.setY(mTimeEstimate.getY()/2); + UiUtils.hide(mTimeValueContainer); + UiUtils.show(mTimeValueContainer2); + UiUtils.hide(mTimeEstimate); + UiUtils.show(mTimeEstimate2); } else { - mTimeValueContainer.setY(mSpeedValue.getY()); - mTimeEstimate.setY(mSpeedUnits.getY()/2); + UiUtils.show(mTimeValueContainer); + UiUtils.hide(mTimeValueContainer2); + UiUtils.show(mTimeEstimate); + UiUtils.hide(mTimeEstimate2); } } @@ -234,18 +235,9 @@ public class NavMenu else timeFormat = new SimpleDateFormat("h:mm aa", Locale.getDefault()); mTimeEstimate.setText(timeFormat.format(currentTime.getTime())); - - mTimeEstimate.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - changeTimes(); - } - }); + mTimeEstimate2.setText(timeFormat.format(currentTime.getTime())); + mTimeEstimate2.setOnClickListener(v -> changeTimes()); } - - private void updateSpeedView(@NonNull RoutingInfo info) { final Location last = LocationHelper.INSTANCE.getSavedLocation(); -- 2.45.3