From 76b65b45bcedd3e3ed520d52bc6da48f2ba0e5b5 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Tue, 3 Oct 2023 11:28:54 +0530 Subject: [PATCH] CatimaAppCompatActivity: Set navigation bar color on Android 8.1+ Signed-off-by: Aayush Gupta --- .../protect/card_locker/LoyaltyCardViewActivity.java | 9 +++++++++ app/src/main/java/protect/card_locker/Utils.java | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 0a60a7f0f..35f80e0bb 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -50,6 +50,7 @@ import androidx.core.graphics.BlendModeCompat; import androidx.core.graphics.ColorUtils; import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsControllerCompat; import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; import androidx.core.widget.TextViewCompat; @@ -634,7 +635,15 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements int darkenedColor = ColorUtils.blendARGB(backgroundHeaderColor, Color.BLACK, 0.1f); binding.barcodeScaler.setProgressTintList(ColorStateList.valueOf(darkenedColor)); binding.barcodeScaler.setThumbTintList(ColorStateList.valueOf(darkenedColor)); + + // Set bottomAppBar and system navigation bar color binding.bottomAppBar.setBackgroundColor(darkenedColor); + if (Build.VERSION.SDK_INT >= 27) { + WindowInsetsControllerCompat wic = new WindowInsetsControllerCompat(getWindow(), binding.getRoot()); + wic.setAppearanceLightNavigationBars(false); + getWindow().setNavigationBarColor(darkenedColor); + } + int complementaryColor = Utils.getComplementaryColor(darkenedColor); binding.fabEdit.setBackgroundTintList(ColorStateList.valueOf(complementaryColor)); Drawable editButtonIcon = binding.fabEdit.getDrawable(); diff --git a/app/src/main/java/protect/card_locker/Utils.java b/app/src/main/java/protect/card_locker/Utils.java index 304b6baef..b377e8ea1 100644 --- a/app/src/main/java/protect/card_locker/Utils.java +++ b/app/src/main/java/protect/card_locker/Utils.java @@ -32,6 +32,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; import androidx.core.graphics.ColorUtils; import androidx.core.os.LocaleListCompat; +import androidx.core.view.WindowInsetsControllerCompat; import androidx.exifinterface.media.ExifInterface; import androidx.palette.graphics.Palette; @@ -670,6 +671,13 @@ public class Utils { TypedValue typedValue = new TypedValue(); activity.getTheme().resolveAttribute(android.R.attr.colorBackground, typedValue, true); activity.findViewById(android.R.id.content).setBackgroundColor(typedValue.data); + + if (Build.VERSION.SDK_INT >= 27) { + View decorView = activity.getWindow().getDecorView(); + WindowInsetsControllerCompat wic = new WindowInsetsControllerCompat(activity.getWindow(), decorView); + wic.setAppearanceLightNavigationBars(!isDarkModeEnabled(activity)); + activity.getWindow().setNavigationBarColor(typedValue.data); + } } public static int getHeaderColorFromImage(Bitmap image, int fallback) {