From 1283ad62bb01ecabf03862b0a757b9448ac8c20c Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Mon, 19 Oct 2020 12:13:43 +0800 Subject: Fix DrawerLayout in MainActivity has extra background color in immersive interface on Android 11. --- .../ml/docilealligator/infinityforreddit/Activity/MainActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 79481f1e..452016ee 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.ColorStateList; +import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.view.Gravity; @@ -247,6 +248,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } if (isImmersiveInterface()) { + drawer.setStatusBarBackgroundColor(Color.TRANSPARENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { drawer.setFitsSystemWindows(false); drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | @@ -266,6 +268,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb linearLayoutBottomAppBar.getPaddingTop(), 0, navBarHeight); navDrawerRecyclerView.setPadding(0, 0, 0, navBarHeight); } + } else { + drawer.setStatusBarBackgroundColor(mCustomThemeWrapper.getColorPrimaryDark()); } } @@ -343,7 +347,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb protected void applyCustomTheme() { int backgroundColor = mCustomThemeWrapper.getBackgroundColor(); drawer.setBackgroundColor(backgroundColor); - drawer.setStatusBarBackgroundColor(mCustomThemeWrapper.getColorPrimaryDark()); int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor(); option1BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN); option2BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN); -- cgit v1.2.3