X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Futils%2FColors.java;h=e702d4f8eb917145bbd4d2622dcc9630ef34a0f2;hp=edd9c7715d8c3b645b335ac3ec6c2fb0dc8b45dc;hb=692eb1d7cedd8a53c509445a95ed0187405df859;hpb=e6e7e00fa8e02f5de38a88dcb2b71db379d0be35 diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/Colors.java b/app/src/main/java/net/ktnx/mobileledger/utils/Colors.java index edd9c771..e702d4f8 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/Colors.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/Colors.java @@ -2,8 +2,8 @@ package net.ktnx.mobileledger.utils; import android.app.Activity; import android.content.res.Resources; -import android.support.annotation.ColorInt; -import android.support.annotation.ColorLong; +import androidx.annotation.ColorInt; +import androidx.annotation.ColorLong; import android.util.Log; import android.util.TypedValue; @@ -32,6 +32,10 @@ public class Colors { tableRowLightBG = tv.data; theme.resolveAttribute(R.attr.colorPrimary, tv, true); primary = tv.data; + theme.resolveAttribute(android.R.color.tab_indicator_text, tv, true); + defaultTextColor = tv.data; + theme.resolveAttribute(R.attr.colorAccent, tv, true); + accent = tv.data; // trigger theme observers themeWatch.notifyObservers(); @@ -55,9 +59,10 @@ public class Colors { @ColorLong long result; int r, g, b; - if ((hue < 0) || (hue > 1) || (saturation < 0) || (saturation > 1) || (value < 0) || - (value > 1)) throw new IllegalArgumentException( - "hue, saturation, value and alpha must all be between 0 and 1"); + if ((hue < -0.00005) || (hue > 1.0000005) || (saturation < 0) || (saturation > 1) || + (value < 0) || (value > 1)) throw new IllegalArgumentException(String.format( + "hue, saturation, value and alpha must all be between 0 and 1. Arguments given: " + + "hue=%1.5f, sat=%1.5f, val=%1.5f", hue, saturation, value)); int h = (int) (hue * 6); float f = hue * 6 - h; @@ -95,6 +100,8 @@ public class Colors { } public static @ColorInt int getPrimaryColorForHue(int degrees) { + // 0/360f becomes -0.000something for some reason + if (degrees == 0) return getPrimaryColorForHue(0f); return getPrimaryColorForHue(degrees / 360f); } public static @ColorInt