mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
proper toolbar theming ignoring dark/light theme for toolbar colors
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
76a093e63f
commit
27e6c7b205
4 changed files with 18 additions and 8 deletions
|
@ -288,6 +288,9 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
}
|
||||
};
|
||||
|
||||
// proper coloring of drawer menu icon
|
||||
mDrawerToggle.getDrawerArrowDrawable().setColor(ThemeUtils.toolbarTextColor(this));
|
||||
|
||||
// Set the drawer toggle as the DrawerListener
|
||||
mDrawerLayout.addDrawerListener(mDrawerToggle);
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
||||
|
|
|
@ -751,8 +751,8 @@ public class SettingsActivity extends ThemedPreferenceActivity
|
|||
actionBar.setBackgroundDrawable(new ColorDrawable(ThemeUtils.primaryColor(this)));
|
||||
|
||||
Drawable backArrow = getResources().getDrawable(R.drawable.ic_arrow_back);
|
||||
actionBar.setHomeAsUpIndicator(ThemeUtils.tintDrawable(backArrow, ThemeUtils.fontColor(this,
|
||||
!ThemeUtils.darkTheme(this))));
|
||||
actionBar.setHomeAsUpIndicator(ThemeUtils.tintDrawable(backArrow,
|
||||
ThemeUtils.toolbarTextColor(this)));
|
||||
}
|
||||
|
||||
Window window = getWindow();
|
||||
|
|
|
@ -65,7 +65,7 @@ public abstract class ToolbarActivity extends BaseActivity {
|
|||
*/
|
||||
protected void setupToolbar(boolean useBackgroundImage) {
|
||||
int primaryColor = ThemeUtils.primaryColor(this, false);
|
||||
int fontColor = ThemeUtils.fontColor(this, !ThemeUtils.darkTheme(getApplicationContext()));
|
||||
int toolbarTextColor = ThemeUtils.toolbarTextColor(this);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
@ -86,11 +86,11 @@ public abstract class ToolbarActivity extends BaseActivity {
|
|||
ThemeUtils.colorStatusBar(this, primaryColor);
|
||||
|
||||
if (toolbar.getOverflowIcon() != null) {
|
||||
ThemeUtils.tintDrawable(toolbar.getOverflowIcon(), fontColor);
|
||||
ThemeUtils.tintDrawable(toolbar.getOverflowIcon(), toolbarTextColor);
|
||||
}
|
||||
|
||||
if (toolbar.getNavigationIcon() != null) {
|
||||
ThemeUtils.tintDrawable(toolbar.getNavigationIcon(), fontColor);
|
||||
ThemeUtils.tintDrawable(toolbar.getNavigationIcon(), toolbarTextColor);
|
||||
}
|
||||
|
||||
if (!useBackgroundImage) {
|
||||
|
|
|
@ -188,8 +188,11 @@ public final class ThemeUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* returns the font color based on the server side theming and uses black/white as a fallback based on replaceWhite.
|
||||
*
|
||||
* @param context the context
|
||||
* @param replaceWhite FLAG to return white/black if server side color isn't available
|
||||
* @return int font color to use
|
||||
* adapted from https://github.com/nextcloud/server/blob/master/apps/theming/lib/Util.php#L90-L102
|
||||
*/
|
||||
public static int fontColor(Context context, boolean replaceWhite) {
|
||||
if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES) {
|
||||
|
@ -200,6 +203,10 @@ public final class ThemeUtils {
|
|||
}
|
||||
}
|
||||
|
||||
return toolbarTextColor(context);
|
||||
}
|
||||
|
||||
public static int toolbarTextColor(Context context) {
|
||||
try {
|
||||
return Color.parseColor(getCapability(context).getServerTextColor());
|
||||
} catch (Exception e) {
|
||||
|
@ -249,7 +256,7 @@ public final class ThemeUtils {
|
|||
actionBar.setTitle(title);
|
||||
} else {
|
||||
Spannable text = new SpannableString(title);
|
||||
text.setSpan(new ForegroundColorSpan(fontColor(context, !darkTheme(context))),
|
||||
text.setSpan(new ForegroundColorSpan(toolbarTextColor(context)),
|
||||
0,
|
||||
text.length(),
|
||||
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
|
@ -612,7 +619,7 @@ public final class ThemeUtils {
|
|||
drawable, Context context) {
|
||||
button.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(context)));
|
||||
button.setRippleColor(ThemeUtils.primaryDarkColor(context));
|
||||
button.setImageDrawable(ThemeUtils.tintDrawable(drawable, ThemeUtils.fontColor(context)));
|
||||
button.setImageDrawable(ThemeUtils.tintDrawable(drawable, ThemeUtils.toolbarTextColor(context)));
|
||||
}
|
||||
|
||||
private static OCCapability getCapability(Context context) {
|
||||
|
|
Loading…
Reference in a new issue