aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-07-17 01:51:30 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-07-17 01:51:30 +0000
commitcf63ccaad1e8176b78c65c7857704ef765a68b51 (patch)
treee5ab94688a6f28406a01cf69b18bf8d53a5d0d0a /app
parente10fc4c96ea9344fbcce80e47c3cffbd0ac437a3 (diff)
downloadinfinity-for-reddit-cf63ccaad1e8176b78c65c7857704ef765a68b51.tar
infinity-for-reddit-cf63ccaad1e8176b78c65c7857704ef765a68b51.tar.gz
infinity-for-reddit-cf63ccaad1e8176b78c65c7857704ef765a68b51.tar.bz2
infinity-for-reddit-cf63ccaad1e8176b78c65c7857704ef765a68b51.tar.lz
infinity-for-reddit-cf63ccaad1e8176b78c65c7857704ef765a68b51.tar.xz
infinity-for-reddit-cf63ccaad1e8176b78c65c7857704ef765a68b51.tar.zst
infinity-for-reddit-cf63ccaad1e8176b78c65c7857704ef765a68b51.zip
Generate a better theme in Material You.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java28
1 files changed, 13 insertions, 15 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
index 6c93b42b..520719b9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
@@ -55,12 +55,12 @@ public class MaterialYouUtils {
CustomTheme darkTheme = CustomThemeWrapper.getIndigoDark(context);
CustomTheme amoledTheme = CustomThemeWrapper.getIndigoAmoled(context);
- int colorPrimaryInt = shiftColorTo255(wallpaperColors.getPrimaryColor().toArgb(), 0.4);
- int colorPrimaryDarkInt = shiftColorTo0(colorPrimaryInt, 0.3);
- int backgroundColor = shiftColorTo255(colorPrimaryInt, 0.6);
- int cardViewBackgroundColor = shiftColorTo255(colorPrimaryInt, 0.9);
+ int colorPrimaryInt = lightenColor(wallpaperColors.getPrimaryColor().toArgb(), 0.4);
+ int colorPrimaryDarkInt = darkenColor(colorPrimaryInt, 0.3);
+ int backgroundColor = lightenColor(colorPrimaryInt, 0.2);
+ int cardViewBackgroundColor = lightenColor(colorPrimaryInt, 0.6);
Color colorAccent = wallpaperColors.getSecondaryColor();
- int colorAccentInt = shiftColorTo255(colorAccent == null ? customThemeWrapper.getColorAccent() : colorAccent.toArgb(), 0.4);
+ int colorAccentInt = lightenColor(colorAccent == null ? customThemeWrapper.getColorAccent() : colorAccent.toArgb(), 0.4);
int colorPrimaryAppropriateTextColor = getAppropriateTextColor(colorPrimaryInt);
int backgroundColorAppropriateTextColor = getAppropriateTextColor(backgroundColor);
@@ -120,18 +120,16 @@ public class MaterialYouUtils {
});
}
- private static int shiftColorTo255(int color, double ratio) {
- int offset = (int) (Math.min(Math.min(255 - Color.red(color), 255 - Color.green(color)), 255 - Color.blue(color)) * ratio);
- return Color.argb(Color.alpha(color), Color.red(color) + offset,
- Color.green(color) + offset,
- Color.blue(color) + offset);
+ private static int lightenColor(int color, double ratio) {
+ return Color.argb(Color.alpha(color), (int) (Color.red(color) + (255 - Color.red(color)) * ratio),
+ (int) (Color.green(color) + (255 - Color.green(color)) * ratio),
+ (int) (Color.blue(color) + (255 - Color.blue(color)) * ratio));
}
- private static int shiftColorTo0(int color, double ratio) {
- int offset = (int) (Math.min(Math.min(Color.red(color), Color.green(color)), Color.blue(color)) * ratio);
- return Color.argb(Color.alpha(color), Color.red(color) - offset,
- Color.green(color) - offset,
- Color.blue(color) - offset);
+ private static int darkenColor(int color, double ratio) {
+ return Color.argb(Color.alpha(color), (int) (Color.red(color) * (1 - ratio)),
+ (int) (Color.green(color) * (1 - ratio)),
+ (int) (Color.blue(color) * (1 - ratio)));
}