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); + } + } + } }