From f91571ec4aac9e97dc818f1a7557a839515b771a Mon Sep 17 00:00:00 2001 From: Thejas Elandassery Date: Fri, 5 Jul 2024 03:39:23 +0530 Subject: [PATCH 1/5] Fix navigation buttons barely visible on dark and light mode --- .../com/amaze/filemanager/ui/activities/MainActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 fe7dec1436..dcdb806f31 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 @@ -1781,11 +1781,11 @@ public void updateViews(ColorDrawable colorDrawable) { if (getAppTheme().equals(AppTheme.LIGHT)) { mainActivity .getWindow() - .setNavigationBarColor(Utils.getColor(this, android.R.color.white)); + .setNavigationBarColor(Utils.getColor(this, android.R.color.black)); } else if (getAppTheme().equals(AppTheme.BLACK)) { mainActivity .getWindow() - .setNavigationBarColor(Utils.getColor(this, android.R.color.black)); + .setNavigationBarColor(Utils.getColor(this, android.R.color.white)); } else { mainActivity .getWindow() From c9e7ca13a9e07d0af95952ca2c2b3e2ff7d615c5 Mon Sep 17 00:00:00 2001 From: Vishnu Sanal T Date: Tue, 15 Oct 2024 20:31:13 +0530 Subject: [PATCH 2/5] remove redundant code --- .../ui/activities/AboutActivity.java | 15 -------- .../ui/activities/MainActivity.java | 34 ------------------- 2 files changed, 49 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 e74c7f46e9..f0c31af941 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,7 +20,6 @@ package com.amaze.filemanager.ui.activities; -import static com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_COLORED_NAVIGATION; import static com.amaze.filemanager.utils.Utils.openURL; import java.io.File; @@ -35,7 +34,6 @@ import com.amaze.filemanager.ui.dialogs.share.ShareTask; 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; @@ -148,19 +146,6 @@ 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 6ca065acaa..d31b54ad1e 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 @@ -23,7 +23,6 @@ import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; import static android.os.Build.VERSION_CODES.KITKAT; -import static android.os.Build.VERSION_CODES.KITKAT_WATCH; import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; @@ -55,7 +54,6 @@ import static com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_USERNAME; import static com.amaze.filemanager.ui.fragments.FtpServerFragment.REQUEST_CODE_SAF_FTP; import static com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_BOOKMARKS_ADDED; -import static com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_COLORED_NAVIGATION; import static com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_NEED_TO_SET_HOME; import static com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_VIEW; @@ -132,7 +130,6 @@ import com.amaze.filemanager.ui.fragments.data.MainFragmentViewModel; import com.amaze.filemanager.ui.fragments.preferencefragments.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; @@ -154,7 +151,6 @@ import com.leinardi.android.speeddial.SpeedDialActionItem; import com.leinardi.android.speeddial.SpeedDialOverlayLayout; import com.leinardi.android.speeddial.SpeedDialView; -import com.readystatesoftware.systembartint.SystemBarTintManager; import com.topjohnwu.superuser.Shell; import android.annotation.SuppressLint; @@ -1767,36 +1763,6 @@ public void updateViews(ColorDrawable colorDrawable) { mainActivity.getSupportActionBar().setBackgroundDrawable(colorDrawable); drawer.setBackgroundColor(colorDrawable.getColor()); - - if (SDK_INT >= LOLLIPOP) { - // for lollipop devices, the status bar color - mainActivity.getWindow().setStatusBarColor(colorDrawable.getColor()); - 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.black)); - } else if (getAppTheme().equals(AppTheme.BLACK)) { - mainActivity - .getWindow() - .setNavigationBarColor(Utils.getColor(this, android.R.color.white)); - } 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 - SystemBarTintManager tintManager = new SystemBarTintManager(this); - tintManager.setStatusBarTintEnabled(true); - tintManager.setStatusBarTintColor(colorDrawable.getColor()); - } } void initialiseFab() { From f2eed3349c9f3fbe6a80bc6591ad910711e762b2 Mon Sep 17 00:00:00 2001 From: Vishnu Sanal T Date: Tue, 15 Oct 2024 20:31:19 +0530 Subject: [PATCH 3/5] fix #4211 --- .../superclasses/ThemedActivity.java | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 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 cbee76f25d..7bfd377d2e 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 @@ -49,6 +49,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; +import android.view.WindowInsetsController; import android.view.WindowManager; import android.widget.FrameLayout; @@ -142,11 +143,33 @@ public void initStatusBarResources(View parentView) { 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)); + // do nothing: since the default android colors were better than the ones we set. + // setting white led to usability issues too. ref: #4211 } else { - window.setNavigationBarColor(Utils.getColor(this, R.color.holo_dark_background)); + + if (SDK_INT >= Build.VERSION_CODES.R) { + WindowInsetsController windowInsetController = getWindow().getInsetsController(); + if (windowInsetController != null) + windowInsetController.setSystemBarsAppearance( + WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS, + WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS); + + 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)); + } + + } else if (SDK_INT >= Build.VERSION_CODES.O) { + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + + 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)); + } + } + } } } else if (SDK_INT == Build.VERSION_CODES.KITKAT_WATCH From 047bf7675b3d9601112323a7e536881fc2100844 Mon Sep 17 00:00:00 2001 From: Vishnu Sanal T Date: Tue, 15 Oct 2024 20:33:59 +0530 Subject: [PATCH 4/5] fix #4211: removed setting the nav bar colors since the default android colors were better than the ones we set + they were leading to usability issues too. --- .../superclasses/ThemedActivity.java | 30 ------------------- 1 file changed, 30 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 7bfd377d2e..7af6540cc9 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 @@ -141,36 +141,6 @@ public void initStatusBarResources(View parentView) { } if (getBoolean(PREFERENCE_COLORED_NAVIGATION)) { window.setNavigationBarColor(PreferenceUtils.getStatusColor(getPrimary())); - } else { - if (getAppTheme().equals(AppTheme.LIGHT)) { - // do nothing: since the default android colors were better than the ones we set. - // setting white led to usability issues too. ref: #4211 - } else { - - if (SDK_INT >= Build.VERSION_CODES.R) { - WindowInsetsController windowInsetController = getWindow().getInsetsController(); - if (windowInsetController != null) - windowInsetController.setSystemBarsAppearance( - WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS, - WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS); - - 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)); - } - - } else if (SDK_INT >= Build.VERSION_CODES.O) { - window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); - - 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)); - } - } - - } } } else if (SDK_INT == Build.VERSION_CODES.KITKAT_WATCH || SDK_INT == Build.VERSION_CODES.KITKAT) { From c3fb487ffdcb9ad17cbb5418fcb6cf4eb539e27c Mon Sep 17 00:00:00 2001 From: Vishnu Sanal T Date: Tue, 15 Oct 2024 20:36:18 +0530 Subject: [PATCH 5/5] chore: spotless --- .../filemanager/ui/activities/superclasses/ThemedActivity.java | 2 -- 1 file changed, 2 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 7af6540cc9..93944e2af5 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 @@ -32,7 +32,6 @@ import com.amaze.filemanager.ui.theme.AppTheme; import com.amaze.filemanager.ui.theme.AppThemePreference; import com.amaze.filemanager.utils.PreferenceUtils; -import com.amaze.filemanager.utils.Utils; import com.readystatesoftware.systembartint.SystemBarTintManager; import android.app.ActivityManager; @@ -49,7 +48,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; -import android.view.WindowInsetsController; import android.view.WindowManager; import android.widget.FrameLayout;