mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[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 <coderang.gk@gmail.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
5bb2569e76
commit
9e8accc8f5
@@ -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;
|
||||
@@ -513,6 +515,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
||||
|
||||
if (newUiModeIsCarConnected || newUiModeIsCarDisconnected)
|
||||
return;
|
||||
|
||||
makeNavigationBarTransparentInLightMode();
|
||||
recreate();
|
||||
}
|
||||
|
||||
@@ -529,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);
|
||||
@@ -1102,6 +1107,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
||||
ThemeSwitcher.INSTANCE.restart(isMapRendererActive());
|
||||
refreshSearchToolbar();
|
||||
setFullscreen(isFullscreen());
|
||||
makeNavigationBarTransparentInLightMode();
|
||||
if (ChoosePositionMode.get() != ChoosePositionMode.None)
|
||||
{
|
||||
UiUtils.show(mPointChooser);
|
||||
@@ -2447,4 +2453,26 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
||||
if (level >= TRIM_MEMORY_RUNNING_LOW)
|
||||
Framework.nativeMemoryWarning();
|
||||
}
|
||||
|
||||
private void makeNavigationBarTransparentInLightMode()
|
||||
{
|
||||
int nightMask = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
if (nightMask == Configuration.UI_MODE_NIGHT_NO) // if light mode
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user