/*
- * Copyright © 2019 Damyan Ivanov.
+ * Copyright © 2020 Damyan Ivanov.
* This file is part of MoLe.
* MoLe is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
public static @ColorInt
int accent;
@ColorInt
- public static int tableRowLightBG;
- @ColorInt
public static int tableRowDarkBG;
- @ColorInt
- public static int primary, defaultTextColor, defaultTextColorDisabled;
public static int profileThemeId = -1;
public static MutableLiveData<Integer> themeWatch = new MutableLiveData<>(0);
- public static int errorTextColor;
+ private static int SWIPE_COLOR_COUNT = 6;
private static int[] themeIDs =
{R.style.AppTheme_000, R.style.AppTheme_005,
R.style.AppTheme_010, R.style.AppTheme_015,
TypedValue tv = new TypedValue();
theme.resolveAttribute(R.attr.table_row_dark_bg, tv, true);
tableRowDarkBG = tv.data;
- theme.resolveAttribute(R.attr.table_row_light_bg, tv, true);
- tableRowLightBG = tv.data;
- theme.resolveAttribute(R.attr.colorPrimary, tv, true);
- primary = tv.data;
- theme.resolveAttribute(R.attr.textColor, tv, true);
- defaultTextColor = tv.data;
- defaultTextColorDisabled = 0x7f000000 | 0x00ffffff & defaultTextColor;
theme.resolveAttribute(R.attr.colorAccent, tv, true);
accent = tv.data;
- theme.resolveAttribute(R.attr.errorTextColor, tv, true);
- errorTextColor = tv.data;
// trigger theme observers
themeWatch.postValue(themeWatch.getValue() + 1);
}
if (themeId < 0) {
- themeId = R.style.AppTheme;
+ themeId = R.style.AppTheme_default;
debug("profiles",
String.format(Locale.ENGLISH, "Theme hue %d not supported, using the default",
themeHue));
refreshColors(activity.getTheme());
}
-
public static @NonNull
ColorStateList getColorStateList() {
return getColorStateList(profileThemeId);
return getSwipeCircleColors(profileThemeId);
}
public static int[] getSwipeCircleColors(int hue) {
- int[] colors = new int[]{0, 0, 0, 0, 0, 0};
- for (int i = 0; i < 6; i++, hue = (hue + 60) % 360) {
+ int[] colors = new int[SWIPE_COLOR_COUNT];
+ for (int i = 0; i < SWIPE_COLOR_COUNT; i++, hue = (hue + 360 / SWIPE_COLOR_COUNT) % 360) {
colors[i] = getPrimaryColorForHue(hue);
}
return colors;
for (int h : hues) {
if (huesSB.length() > 0)
huesSB.append(", ");
- huesSB.append(String.valueOf(h));
+ huesSB.append(h);
}
debug("profiles", String.format("used hues: %s", huesSB.toString()));
}