From 4cd0653df5cbb891615c60c655cc740f311d1f35 Mon Sep 17 00:00:00 2001 From: coderang-gk Date: Wed, 5 Mar 2025 01:20:30 +0530 Subject: [PATCH 1/2] [android] Make navigation bar transparent in light mode Add functionality to make the navigation bar fully transparent when the app is in light mode. This improves the map view by allowing it to extend beneath the navigation bar for a more immersive experience. Implementation includes clearing translucency flags and adding necessary system UI flags to ensure proper transparency. Also handles proper configuration changes and maintains transparency when returning from fullscreen mode. The transparency is only applied in light mode to maintain readability of navigation buttons, with appropriate contrast settings for different Android API levels. Fixes: #10393 Signed-off-by: coderang-gk --- .../java/app/organicmaps/MwmActivity.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/android/app/src/main/java/app/organicmaps/MwmActivity.java b/android/app/src/main/java/app/organicmaps/MwmActivity.java index 416f528e24..ca85fc8198 100644 --- a/android/app/src/main/java/app/organicmaps/MwmActivity.java +++ b/android/app/src/main/java/app/organicmaps/MwmActivity.java @@ -8,6 +8,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; +import android.graphics.Color; import android.location.Location; import android.net.Uri; import android.os.Build; @@ -17,6 +18,7 @@ import android.text.method.LinkMovementMethod; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; +import android.view.Window; import android.view.WindowManager; import android.widget.TextView; import android.widget.Toast; @@ -509,6 +511,10 @@ public class MwmActivity extends BaseMwmFragmentActivity final boolean newUiModeIsCarDisconnected = mLastUiMode == Configuration.UI_MODE_TYPE_CAR && newUiMode == Configuration.UI_MODE_TYPE_NORMAL; mLastUiMode = newUiMode; + if (!newUiModeIsCarConnected && !newUiModeIsCarDisconnected) { + makeNavigationBarTransparentInLightMode(); + } + if (newUiModeIsCarConnected || newUiModeIsCarDisconnected) return; recreate(); @@ -527,6 +533,7 @@ public class MwmActivity extends BaseMwmFragmentActivity getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); setContentView(R.layout.activity_map); + makeNavigationBarTransparentInLightMode(); mPlacePageViewModel = new ViewModelProvider(this).get(PlacePageViewModel.class); mMapButtonsViewModel = new ViewModelProvider(this).get(MapButtonsViewModel.class); @@ -1100,6 +1107,7 @@ public class MwmActivity extends BaseMwmFragmentActivity ThemeSwitcher.INSTANCE.restart(isMapRendererActive()); refreshSearchToolbar(); setFullscreen(isFullscreen()); + makeNavigationBarTransparentInLightMode(); if (Framework.nativeGetChoosePositionMode() != Framework.ChoosePositionMode.NONE) { UiUtils.show(mPointChooser); @@ -2471,4 +2479,32 @@ public class MwmActivity extends BaseMwmFragmentActivity if (level >= TRIM_MEMORY_RUNNING_LOW) Framework.nativeMemoryWarning(); } + + private void makeNavigationBarTransparentInLightMode() { + boolean isLightMode = (getResources().getConfiguration().uiMode & + Configuration.UI_MODE_NIGHT_MASK) == + Configuration.UI_MODE_NIGHT_NO; + + if (isLightMode) { + Window window = getWindow(); + + window.setNavigationBarColor(Color.TRANSPARENT); + + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); + + int flags = window.getDecorView().getSystemUiVisibility(); + + flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + } + + window.getDecorView().setSystemUiVisibility(flags); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + window.setNavigationBarContrastEnforced(false); + } + } + } } -- 2.45.3 From 75635d74d68b23e0320e48023910899c3fc70b72 Mon Sep 17 00:00:00 2001 From: coderang-gk Date: Wed, 5 Mar 2025 01:20:30 +0530 Subject: [PATCH 2/2] [android] Make navigation bar transparent in light mode Add functionality to make the navigation bar fully transparent when the app is in light mode. This improves the map view by allowing it to extend beneath the navigation bar for a more immersive experience. Implementation includes clearing translucency flags and adding necessary system UI flags to ensure proper transparency. Also handles proper configuration changes and maintains transparency when returning from fullscreen mode. The transparency is only applied in light mode to maintain readability of navigation buttons, with appropriate contrast settings for different Android API levels. Fixes: #10393 Signed-off-by: coderang-gk --- .../java/app/organicmaps/MwmActivity.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/android/app/src/main/java/app/organicmaps/MwmActivity.java b/android/app/src/main/java/app/organicmaps/MwmActivity.java index 416f528e24..d05f25b0cb 100644 --- a/android/app/src/main/java/app/organicmaps/MwmActivity.java +++ b/android/app/src/main/java/app/organicmaps/MwmActivity.java @@ -8,6 +8,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; +import android.graphics.Color; import android.location.Location; import android.net.Uri; import android.os.Build; @@ -17,6 +18,7 @@ import android.text.method.LinkMovementMethod; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; +import android.view.Window; import android.view.WindowManager; import android.widget.TextView; import android.widget.Toast; @@ -509,6 +511,11 @@ public class MwmActivity extends BaseMwmFragmentActivity final boolean newUiModeIsCarDisconnected = mLastUiMode == Configuration.UI_MODE_TYPE_CAR && newUiMode == Configuration.UI_MODE_TYPE_NORMAL; mLastUiMode = newUiMode; + if (!newUiModeIsCarConnected && !newUiModeIsCarDisconnected) + { + makeNavigationBarTransparentInLightMode(); + } + if (newUiModeIsCarConnected || newUiModeIsCarDisconnected) return; recreate(); @@ -527,6 +534,7 @@ public class MwmActivity extends BaseMwmFragmentActivity getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); setContentView(R.layout.activity_map); + makeNavigationBarTransparentInLightMode(); mPlacePageViewModel = new ViewModelProvider(this).get(PlacePageViewModel.class); mMapButtonsViewModel = new ViewModelProvider(this).get(MapButtonsViewModel.class); @@ -1100,6 +1108,7 @@ public class MwmActivity extends BaseMwmFragmentActivity ThemeSwitcher.INSTANCE.restart(isMapRendererActive()); refreshSearchToolbar(); setFullscreen(isFullscreen()); + makeNavigationBarTransparentInLightMode(); if (Framework.nativeGetChoosePositionMode() != Framework.ChoosePositionMode.NONE) { UiUtils.show(mPointChooser); @@ -2471,4 +2480,35 @@ public class MwmActivity extends BaseMwmFragmentActivity if (level >= TRIM_MEMORY_RUNNING_LOW) Framework.nativeMemoryWarning(); } + + private void makeNavigationBarTransparentInLightMode() { + boolean isLightMode = (getResources().getConfiguration().uiMode & + Configuration.UI_MODE_NIGHT_MASK) == + Configuration.UI_MODE_NIGHT_NO; + + if (isLightMode) + { + Window window = getWindow(); + + window.setNavigationBarColor(Color.TRANSPARENT); + + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); + + int flags = window.getDecorView().getSystemUiVisibility(); + + flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) + { + flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + } + + window.getDecorView().setSystemUiVisibility(flags); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) + { + window.setNavigationBarContrastEnforced(false); + } + } + } } -- 2.45.3