From ed56b9be579e359119202bec9a806dc8ac04c5f7 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 8 Jul 2023 08:19:11 +0200 Subject: [PATCH] Set statusbar color --- .../main/java/eu/faircode/email/Helper.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index f283727913..f4fec93fa3 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -92,6 +92,8 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; +import android.view.Window; +import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; @@ -864,6 +866,25 @@ public class Helper { // View + static void setStatusBarColor(Activity activity, Integer color) { + if (!BuildConfig.DEBUG) + return; + if (activity == null) + return; + Window window = activity.getWindow(); + if (window == null) + return; + + if (color == null) { + //window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + window.setStatusBarColor(Helper.resolveColor(window.getContext(), R.attr.colorPrimaryDark)); + } else { + //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + //window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.setStatusBarColor(color); + } + } + static Integer actionBarHeight = null; static int getActionBarHeight(Context context) {