Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/status bar color #3241

Merged
merged 4 commits into from
Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

package com.amaze.filemanager.ui.activities;

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;
import com.amaze.filemanager.R;
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;
Expand Down Expand Up @@ -79,15 +81,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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And for versions older that lollipop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked the official documentation and found that the color of the navigation bar cannot be manipulated for sdk versions before Lollipop, the closest you can get is making the bar translucent

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);
Expand Down Expand Up @@ -133,6 +135,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));
}
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,19 @@ 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)
}
appTheme == AppTheme.LIGHT -> {
window.navigationBarColor = Color.WHITE
}
}
}
if (appTheme == AppTheme.BLACK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -104,15 +105,22 @@ public void initStatusBarResources(View parentView) {
} else {
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
if (getBoolean(PREFERENCE_COLORED_NAVIGATION)) {
Copy link
Contributor Author

@DoozyDoz DoozyDoz Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EmmanuelMess I have transfered the code to the right block as requested hope its fine now

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

@Override
Expand Down