proper coloring of drawer items in black/white edge case scenarios

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2020-06-22 17:41:27 +02:00
parent 20d2ef989d
commit 643454c1d7
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 29 additions and 3 deletions

View file

@ -703,7 +703,7 @@ public abstract class DrawerActivity extends ToolbarActivity
mCheckedMenuItem = menuItemId;
MenuItem currentItem = mNavigationView.getMenu().findItem(menuItemId);
int drawerColor = getResources().getColor(R.color.drawer_text_color);
int activeColor = ThemeUtils.elementColor(this);
int activeColor = ThemeUtils.primaryColor(null, true, true, this);
currentItem.setChecked(true);

View file

@ -133,6 +133,24 @@ public final class ThemeUtils {
}
public static int primaryColor(Account account, boolean replaceEdgeColors, Context context) {
return primaryColor(account, replaceEdgeColors, false, context);
}
/**
* return the primary color defined in the server-side theming respecting Android dark/light theming and edge case
* scenarios including drawer menu.
*
* @param account the Nextcloud user
* @param replaceEdgeColors flag if edge case color scenarios should be handled
* @param replaceEdgeColorsByInvertedColor flag in edge case handling should be done via color inversion
* (black/white)
* @param context the context (needed to load client-side colors)
* @return the color
*/
public static int primaryColor(Account account,
boolean replaceEdgeColors,
boolean replaceEdgeColorsByInvertedColor,
Context context) {
if (context == null) {
return Color.GRAY;
}
@ -142,13 +160,21 @@ public final class ThemeUtils {
if (replaceEdgeColors) {
if (isDarkModeActive(context)) {
if (Color.BLACK == color) {
return getNeutralGrey(context);
if (replaceEdgeColorsByInvertedColor) {
return Color.WHITE;
} else {
return getNeutralGrey(context);
}
} else {
return color;
}
} else {
if (Color.WHITE == color) {
return getNeutralGrey(context);
if (replaceEdgeColorsByInvertedColor) {
return Color.BLACK;
} else {
return getNeutralGrey(context);
}
} else {
return color;
}