]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/utils/Colors.java
more pronounced day/month delimiters in the transaction list
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / utils / Colors.java
index adefa6f30e701d538b4f6c02a452f15a4873adff..348a5598a324073ea2415f353cd32a1019b72542 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2021 Damyan Ivanov.
+ * Copyright © 2024 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
@@ -17,6 +17,8 @@
 
 package net.ktnx.mobileledger.utils;
 
+import static net.ktnx.mobileledger.utils.Logger.debug;
+
 import android.app.Activity;
 import android.content.res.ColorStateList;
 import android.content.res.Resources;
@@ -28,17 +30,16 @@ import androidx.lifecycle.MutableLiveData;
 
 import net.ktnx.mobileledger.BuildConfig;
 import net.ktnx.mobileledger.R;
-import net.ktnx.mobileledger.model.MobileLedgerProfile;
+import net.ktnx.mobileledger.db.Profile;
 import net.ktnx.mobileledger.ui.HueRing;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Locale;
 import java.util.Objects;
 
-import static net.ktnx.mobileledger.utils.Logger.debug;
-
 public class Colors {
     public static final int DEFAULT_HUE_DEG = 261;
     public static final MutableLiveData<Integer> themeWatch = new MutableLiveData<>(0);
@@ -67,7 +68,7 @@ public class Colors {
              };
     private static final HashMap<Integer, Integer> themePrimaryColor = new HashMap<>();
     public static @ColorInt
-    int secondary;
+    int primary;
     @ColorInt
     public static int tableRowDarkBG;
     public static int profileThemeId = DEFAULT_HUE_DEG;
@@ -75,15 +76,15 @@ public class Colors {
         TypedValue tv = new TypedValue();
         theme.resolveAttribute(R.attr.table_row_dark_bg, tv, true);
         tableRowDarkBG = tv.data;
-        theme.resolveAttribute(R.attr.colorSecondary, tv, true);
-        secondary = tv.data;
+        theme.resolveAttribute(androidx.appcompat.R.attr.colorPrimary, tv, true);
+        primary = tv.data;
 
         if (themePrimaryColor.size() == 0) {
             for (int themeId : themeIDs) {
                 Resources.Theme tmpTheme = theme.getResources()
                                                 .newTheme();
                 tmpTheme.applyStyle(themeId, true);
-                tmpTheme.resolveAttribute(R.attr.colorPrimary, tv, false);
+                tmpTheme.resolveAttribute(androidx.appcompat.R.attr.colorPrimary, tv, false);
                 themePrimaryColor.put(themeId, tv.data);
             }
         }
@@ -151,7 +152,7 @@ public class Colors {
         }
         return colors;
     }
-    public static int getNewProfileThemeHue(ArrayList<MobileLedgerProfile> profiles) {
+    public static int getNewProfileThemeHue(List<Profile> profiles) {
         if ((profiles == null) || (profiles.size() == 0))
             return DEFAULT_HUE_DEG;
 
@@ -159,14 +160,14 @@ public class Colors {
 
         if (profiles.size() == 1) {
             int opposite = profiles.get(0)
-                                   .getThemeHue() + 180;
+                                   .getTheme() + 180;
             opposite %= 360;
             chosenHue = opposite;
         }
         else {
             ArrayList<Integer> hues = new ArrayList<>();
-            for (MobileLedgerProfile p : profiles) {
-                int hue = p.getThemeHue();
+            for (Profile p : profiles) {
+                int hue = p.getTheme();
                 if (hue == -1)
                     hue = DEFAULT_HUE_DEG;
                 hues.add(hue);
@@ -179,7 +180,7 @@ public class Colors {
                         huesSB.append(", ");
                     huesSB.append(h);
                 }
-                debug("profiles", String.format("used hues: %s", huesSB.toString()));
+                debug("profiles", String.format("used hues: %s", huesSB));
             }
             hues.add(hues.get(0));