diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-07-04 23:09:01 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-07-04 23:09:01 +0300 |
commit | 4db96f47c98fc23ab07d3b278c7737be9918a98d (patch) | |
tree | f72a1eb866a05bd857fbd698b06240e6f7d7bc50 /app/src/main/java/it/niedermann/nextcloud/deck/util | |
parent | a8d8a5538fb0dddb8a0f762ca3d84919fdaa4b93 (diff) | |
parent | 6cf7a252e57bfea325101ff5d2f9bfca36099171 (diff) |
Merge branch 'master' into 289-upload-sources
# Conflicts:
# app/src/main/res/values/strings.xml
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/util')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/util/ColorUtil.java | 13 | ||||
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/util/ViewUtil.java | 5 |
2 files changed, 15 insertions, 3 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/util/ColorUtil.java b/app/src/main/java/it/niedermann/nextcloud/deck/util/ColorUtil.java index 4adf43b34..08354c5fb 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/util/ColorUtil.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/util/ColorUtil.java @@ -109,7 +109,18 @@ public final class ColorUtil { return ret; } - private static double getContrastRatio(@ColorInt int colorOne, @ColorInt int colorTwo) { + public static boolean contrastRatioIsSufficientBigAreas(@ColorInt int colorOne, @ColorInt int colorTwo) { + ColorPair key = new ColorPair(colorOne, colorTwo); + Boolean ret = CONTRAST_RATIO_SUFFICIENT_CACHE.get(key); + if (ret == null) { + ret = getContrastRatio(colorOne, colorTwo) > 1.47d; + CONTRAST_RATIO_SUFFICIENT_CACHE.put(key, ret); + return ret; + } + return ret; + } + + public static double getContrastRatio(@ColorInt int colorOne, @ColorInt int colorTwo) { final double lum1 = getLuminanace(colorOne); final double lum2 = getLuminanace(colorTwo); final double brightest = Math.max(lum1, lum2); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/util/ViewUtil.java b/app/src/main/java/it/niedermann/nextcloud/deck/util/ViewUtil.java index 1039b5c95..6abbde557 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/util/ViewUtil.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/util/ViewUtil.java @@ -27,11 +27,12 @@ import com.bumptech.glide.request.transition.Transition; import java.util.Date; import java.util.List; -import it.niedermann.nextcloud.deck.Application; import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.model.Account; import it.niedermann.nextcloud.deck.model.ocs.comment.Mention; +import static it.niedermann.nextcloud.deck.DeckApplication.isDarkTheme; + public final class ViewUtil { private ViewUtil() { } @@ -53,7 +54,7 @@ public final class ViewUtil { long diff = DateUtil.getDayDifference(new Date(), dueDate); int backgroundDrawable = 0; - int textColor = Application.getAppTheme(context) ? R.color.dark_fg_primary : R.color.grey600; + int textColor = isDarkTheme(context) ? R.color.dark_fg_primary : R.color.grey600; if (diff == 1) { // due date: tomorrow |