Merge pull request #1547 from theimpulson/917

CatimaAppCompatActivity: Set navigation bar color on Android 8.1+
This commit is contained in:
Sylvia van Os
2023-10-05 12:33:05 +02:00
committed by GitHub
2 changed files with 17 additions and 0 deletions

View File

@@ -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();

View File

@@ -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) {