protected MainActivity mActivity;
protected RecyclerView root;
protected void themeChanged(Integer counter) {
- swiper.setColorSchemeColors(Colors.primary);
+ swiper.setColorSchemeColors(Colors.getColors());
}
public void onBackgroundTaskRunningChanged(Boolean isRunning) {
if (mActivity == null) return;
public void onRetrieveStart() {
ProgressBar progressBar = findViewById(R.id.transaction_list_progress_bar);
bTransactionListCancelDownload.setEnabled(true);
- progressBar.setIndeterminateTintList(ColorStateList.valueOf(Colors.primary));
- progressBar.setProgressTintList(ColorStateList.valueOf(Colors.primary));
+ ColorStateList csl = Colors.getColorStateList();
+ progressBar.setIndeterminateTintList(csl);
+ progressBar.setProgressTintList(csl);
progressBar.setIndeterminate(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) progressBar.setProgress(0, false);
else progressBar.setProgress(0);
package net.ktnx.mobileledger.utils;
import android.app.Activity;
+import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.util.TypedValue;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorLong;
+import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import static java.lang.Math.abs;
public static final int DEFAULT_HUE_DEG = 261;
private static final float blueLightness = 0.665f;
private static final float yellowLightness = 0.350f;
+ private static final int[][] EMPTY_STATES = new int[][]{new int[0]};
public static @ColorInt
int accent;
@ColorInt
refreshColors(activity.getTheme());
}
+ public static @NonNull
+ ColorStateList getColorStateList() {
+ return getColorStateList(profileThemeId);
+ }
+ public static @NonNull
+ ColorStateList getColorStateList(int hue) {
+ return new ColorStateList(EMPTY_STATES, getColors(hue));
+ }
+ public static int[] getColors() {
+ return getColors(profileThemeId);
+ }
+ public static int[] getColors(int hue) {
+ int[] colors = new int[]{0, 0, 0, 0, 0, 0};
+ for (int i = 0; i < 6; i++, hue = (hue + 60) % 360) {
+ colors[i] = getPrimaryColorForHue(hue);
+ }
+ return colors;
+ }
}