mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
use same color detection as https://github.com/nextcloud/server/pull/5953/files#diff-3de1769d04fcc4f13f8d546d9fbdac19
This commit is contained in:
parent
424e2cdbc0
commit
fa35cc5914
1 changed files with 10 additions and 7 deletions
|
@ -125,12 +125,9 @@ public class ThemeUtils {
|
|||
*/
|
||||
public static boolean darkTheme() {
|
||||
int primaryColor = primaryColor();
|
||||
float[] hsl = colorToHSL(primaryColor);
|
||||
|
||||
int red = Color.red(primaryColor);
|
||||
int green = Color.green(primaryColor);
|
||||
int blue = Color.blue(primaryColor);
|
||||
|
||||
return ((0.299 * red + 0.587 * green + 0.114 * blue) / 255) <= 0.5;
|
||||
return (hsl[2] / 100) <= 0.5;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,14 +169,20 @@ public class ThemeUtils {
|
|||
}
|
||||
|
||||
public static int adjustLightness(float lightnessDelta, int color) {
|
||||
float[] hsl = new float[3];
|
||||
ColorUtils.RGBToHSL(Color.red(color), Color.green(color), Color.blue(color), hsl);
|
||||
float[] hsl = colorToHSL(color);
|
||||
|
||||
hsl[2] += lightnessDelta;
|
||||
|
||||
return ColorUtils.HSLToColor(hsl);
|
||||
}
|
||||
|
||||
private static float[] colorToHSL(int color) {
|
||||
float[] hsl = new float[3];
|
||||
ColorUtils.RGBToHSL(Color.red(color), Color.green(color), Color.blue(color), hsl);
|
||||
|
||||
return hsl;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the tinting of the given ImageButton's icon to color_accent.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue