[android] Transparent navbar light mode #10410
1 changed files with 40 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue