From 9025c1b76042b2b666ee6e4dd0b3c27f54889310 Mon Sep 17 00:00:00 2001 From: Carles Sentis Date: Wed, 10 May 2023 16:23:11 +0200 Subject: [PATCH] Added altitude chart to the NavMenu while Expanded Signed-off-by: Carles Sentis --- android/res/layout/layout_nav_bottom.xml | 7 +++ .../app/organicmaps/widget/menu/NavMenu.java | 43 +++++++++++++++---- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/android/res/layout/layout_nav_bottom.xml b/android/res/layout/layout_nav_bottom.xml index 0296076e76..37d1047b29 100644 --- a/android/res/layout/layout_nav_bottom.xml +++ b/android/res/layout/layout_nav_bottom.xml @@ -21,6 +21,13 @@ + + mNavBottomSheetBehavior; @@ -33,6 +36,7 @@ public class NavMenu private final View mHeaderFrame; private final ImageView mTts; + private final ImageView mRoutingChart; private final View mSpeedViewContainer; private final TextView mSpeedValue; private final TextView mSpeedUnits; @@ -108,6 +112,7 @@ public class NavMenu mRouteProgress = bottomFrame.findViewById(R.id.navigation_progress); // Bottom frame buttons + mRoutingChart = bottomFrame.findViewById(R.id.nav_routing_chart); ImageView mSettings = bottomFrame.findViewById(R.id.settings); mSettings.setOnClickListener(v -> onSettingsClicked()); mTts = bottomFrame.findViewById(R.id.tts_volume); @@ -154,11 +159,13 @@ public class NavMenu public void collapseNavBottomSheet() { + updateRouteAltitudeChart(BottomSheetBehavior.STATE_COLLAPSED); mNavBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } public void expandNavBottomSheet() { + updateRouteAltitudeChart(BottomSheetBehavior.STATE_EXPANDED); mNavBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); } @@ -239,4 +246,22 @@ public class NavMenu void onSettingsClicked(); } + + private void updateRouteAltitudeChart(int state) + { + if (state == BottomSheetBehavior.STATE_COLLAPSED) { + mRoutingChart.setVisibility(View.GONE); + } else { + mRoutingChart.setVisibility(View.VISIBLE); + final int chartWidth = ((View) mRoutingChart.getParent()).getWidth(); + final int chartHeight = UiUtils.dimen(mActivity, R.dimen.altitude_chart_image_height); + final Framework.RouteAltitudeLimits limits = new Framework.RouteAltitudeLimits(); + final Bitmap bm = Framework.generateRouteAltitudeChart(chartWidth, chartHeight, limits); + if (bm != null) { + mRoutingChart.setImageBitmap(bm); + } else { + mRoutingChart.setVisibility(View.GONE); + } + } + } } -- 2.45.3