From cc2bb7ede6a0badd7a6df0a4061abf0058a7e424 Mon Sep 17 00:00:00 2001 From: Doozy Date: Mon, 28 Mar 2022 12:30:00 +0300 Subject: [PATCH 1/4] [bugfix] navigation bar color not respecting theme --- .../ui/activities/PreferencesActivity.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/PreferencesActivity.kt b/app/src/main/java/com/amaze/filemanager/ui/activities/PreferencesActivity.kt index 2b82c56da0..56a38572ac 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/PreferencesActivity.kt +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/PreferencesActivity.kt @@ -145,10 +145,16 @@ class PreferencesActivity : ThemedActivity(), FolderChooserDialog.FolderCallback window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) val tabStatusColor = PreferenceUtils.getStatusColor(primaryColor) window.statusBarColor = tabStatusColor - if (colouredNavigation) { - window.navigationBarColor = tabStatusColor - } else if (window.navigationBarColor != Color.BLACK) { - window.navigationBarColor = Color.BLACK + when { + colouredNavigation -> { + window.navigationBarColor = tabStatusColor + } + appTheme == AppTheme.BLACK -> { + window.navigationBarColor = Color.BLACK + } + appTheme == AppTheme.DARK -> { + window.navigationBarColor = Utils.getColor(this, R.color.holo_dark_background) + } } } if (appTheme == AppTheme.BLACK) { From c05ee4e8a78009c1ca37be81d985e5ca2a737c89 Mon Sep 17 00:00:00 2001 From: Doozy Date: Mon, 28 Mar 2022 15:38:57 +0300 Subject: [PATCH 2/4] [bugfix] persist navigation bar color --- .../ui/activities/AboutActivity.java | 34 ++++++++++++++----- .../ui/activities/MainActivity.java | 15 +++++++- .../ui/activities/PreferencesActivity.kt | 3 ++ .../superclasses/ThemedActivity.java | 9 +++++ 4 files changed, 52 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java index e41b3ef2d5..ff8d5eb74b 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java @@ -20,6 +20,9 @@ package com.amaze.filemanager.ui.activities; +import static android.os.Build.VERSION.SDK_INT; +import static android.os.Build.VERSION_CODES.LOLLIPOP; +import static com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_COLORED_NAVIGATION; import static com.amaze.filemanager.utils.Utils.openURL; import com.amaze.filemanager.LogHelper; @@ -27,6 +30,7 @@ import com.amaze.filemanager.ui.activities.superclasses.ThemedActivity; import com.amaze.filemanager.ui.theme.AppTheme; import com.amaze.filemanager.utils.Billing; +import com.amaze.filemanager.utils.PreferenceUtils; import com.amaze.filemanager.utils.Utils; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; @@ -41,6 +45,7 @@ import android.view.MenuItem; import android.view.View; import android.widget.TextView; +import android.widget.Toast; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; @@ -79,15 +84,15 @@ public class AboutActivity extends ThemedActivity implements View.OnClickListene @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - if (getAppTheme().equals(AppTheme.DARK)) { - setTheme(R.style.aboutDark); - } else if (getAppTheme().equals(AppTheme.BLACK)) { - setTheme(R.style.aboutBlack); - } else { - setTheme(R.style.aboutLight); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + if (getAppTheme().equals(AppTheme.DARK)) { + setTheme(R.style.aboutDark); + } else if (getAppTheme().equals(AppTheme.BLACK)) { + setTheme(R.style.aboutBlack); + } else { + setTheme(R.style.aboutLight); + } } - setContentView(R.layout.activity_about); mAppBarLayout = findViewById(R.id.appBarLayout); @@ -133,6 +138,19 @@ public void onCreate(@Nullable Bundle savedInstanceState) { (v, hasFocus) -> { mAppBarLayout.setExpanded(hasFocus, true); }); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (getBoolean(PREFERENCE_COLORED_NAVIGATION)) { + getWindow().setNavigationBarColor(PreferenceUtils.getStatusColor(getPrimary())); + } else { + if (getAppTheme().equals(AppTheme.LIGHT)) { + getWindow().setNavigationBarColor(Utils.getColor(this, android.R.color.white)); + } else if (getAppTheme().equals(AppTheme.BLACK)) { + getWindow().setNavigationBarColor(Utils.getColor(this, android.R.color.black)); + } else { + getWindow().setNavigationBarColor(Utils.getColor(this, R.color.holo_dark_background)); + } + } + } } /** diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java index 56eacea750..9bba20d395 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivity.java @@ -158,6 +158,7 @@ import com.amaze.filemanager.ui.fragments.TabFragment; import com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants; import com.amaze.filemanager.ui.strings.StorageNamingHelper; +import com.amaze.filemanager.ui.theme.AppTheme; import com.amaze.filemanager.ui.views.CustomZoomFocusChange; import com.amaze.filemanager.ui.views.appbar.AppBar; import com.amaze.filemanager.ui.views.drawer.Drawer; @@ -1677,10 +1678,22 @@ public void updateViews(ColorDrawable colorDrawable) { if (SDK_INT >= LOLLIPOP) { // for lollipop devices, the status bar color mainActivity.getWindow().setStatusBarColor(colorDrawable.getColor()); - if (getBoolean(PREFERENCE_COLORED_NAVIGATION)) + if (getBoolean(PREFERENCE_COLORED_NAVIGATION)) { mainActivity .getWindow() .setNavigationBarColor(PreferenceUtils.getStatusColor(colorDrawable.getColor())); + } else { + if (getAppTheme().equals(AppTheme.LIGHT)) { + mainActivity + .getWindow().setNavigationBarColor(Utils.getColor(this, android.R.color.white)); + } else if (getAppTheme().equals(AppTheme.BLACK)) { + mainActivity + .getWindow().setNavigationBarColor(Utils.getColor(this, android.R.color.black)); + } else { + mainActivity + .getWindow().setNavigationBarColor(Utils.getColor(this, R.color.holo_dark_background)); + } + } } else if (SDK_INT == KITKAT_WATCH || SDK_INT == KITKAT) { // for kitkat devices, the status bar color diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/PreferencesActivity.kt b/app/src/main/java/com/amaze/filemanager/ui/activities/PreferencesActivity.kt index 56a38572ac..e4081ba095 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/PreferencesActivity.kt +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/PreferencesActivity.kt @@ -155,6 +155,9 @@ class PreferencesActivity : ThemedActivity(), FolderChooserDialog.FolderCallback appTheme == AppTheme.DARK -> { window.navigationBarColor = Utils.getColor(this, R.color.holo_dark_background) } + appTheme == AppTheme.LIGHT -> { + window.navigationBarColor = Color.WHITE + } } } if (appTheme == AppTheme.BLACK) { diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/superclasses/ThemedActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/superclasses/ThemedActivity.java index 8bec67c80d..9023b0b1c0 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/superclasses/ThemedActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/superclasses/ThemedActivity.java @@ -30,6 +30,7 @@ import com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants; import com.amaze.filemanager.ui.theme.AppTheme; import com.amaze.filemanager.utils.PreferenceUtils; +import com.amaze.filemanager.utils.Utils; import com.readystatesoftware.systembartint.SystemBarTintManager; import android.app.ActivityManager; @@ -112,6 +113,14 @@ public void initStatusBarResources(View parentView) { if (getBoolean(PREFERENCE_COLORED_NAVIGATION) && SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.setNavigationBarColor(PreferenceUtils.getStatusColor(getPrimary())); + } else if (!getBoolean(PREFERENCE_COLORED_NAVIGATION) && SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (getAppTheme().equals(AppTheme.LIGHT)) { + window.setNavigationBarColor(Utils.getColor(this, android.R.color.white)); + } else if (getAppTheme().equals(AppTheme.BLACK)) { + window.setNavigationBarColor(Utils.getColor(this, android.R.color.black)); + } else { + window.setNavigationBarColor(Utils.getColor(this, R.color.holo_dark_background)); + } } } From 446e653566a77536f3cbcff9218968c52bf349b1 Mon Sep 17 00:00:00 2001 From: Doozy Date: Mon, 28 Mar 2022 17:53:56 +0300 Subject: [PATCH 3/4] [code quality fix] removed unused imports --- .../com/amaze/filemanager/ui/activities/AboutActivity.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java index ff8d5eb74b..bcedbf1ac7 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java @@ -20,8 +20,6 @@ package com.amaze.filemanager.ui.activities; -import static android.os.Build.VERSION.SDK_INT; -import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_COLORED_NAVIGATION; import static com.amaze.filemanager.utils.Utils.openURL; @@ -45,7 +43,6 @@ import android.view.MenuItem; import android.view.View; import android.widget.TextView; -import android.widget.Toast; import androidx.annotation.Nullable; import androidx.appcompat.widget.Toolbar; From a71fc4439107b4554d41aef666c1073ff99598d1 Mon Sep 17 00:00:00 2001 From: Doozy Date: Mon, 4 Apr 2022 17:52:48 +0300 Subject: [PATCH 4/4] code cleanup --- .../superclasses/ThemedActivity.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/superclasses/ThemedActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/superclasses/ThemedActivity.java index 9023b0b1c0..49bad9b06f 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/superclasses/ThemedActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/superclasses/ThemedActivity.java @@ -105,23 +105,22 @@ public void initStatusBarResources(View parentView) { } else { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } + if (getBoolean(PREFERENCE_COLORED_NAVIGATION)) { + window.setNavigationBarColor(PreferenceUtils.getStatusColor(getPrimary())); + } else { + if (getAppTheme().equals(AppTheme.LIGHT)) { + window.setNavigationBarColor(Utils.getColor(this, android.R.color.white)); + } else if (getAppTheme().equals(AppTheme.BLACK)) { + window.setNavigationBarColor(Utils.getColor(this, android.R.color.black)); + } else { + window.setNavigationBarColor(Utils.getColor(this, R.color.holo_dark_background)); + } + } } else if (SDK_INT == Build.VERSION_CODES.KITKAT_WATCH || SDK_INT == Build.VERSION_CODES.KITKAT) { setKitkatStatusBarMargin(parentView); setKitkatStatusBarTint(); } - - if (getBoolean(PREFERENCE_COLORED_NAVIGATION) && SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - window.setNavigationBarColor(PreferenceUtils.getStatusColor(getPrimary())); - } else if (!getBoolean(PREFERENCE_COLORED_NAVIGATION) && SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - if (getAppTheme().equals(AppTheme.LIGHT)) { - window.setNavigationBarColor(Utils.getColor(this, android.R.color.white)); - } else if (getAppTheme().equals(AppTheme.BLACK)) { - window.setNavigationBarColor(Utils.getColor(this, android.R.color.black)); - } else { - window.setNavigationBarColor(Utils.getColor(this, R.color.holo_dark_background)); - } - } } @Override