]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/utils/Colors.java
Room-based profile management
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / utils / Colors.java
index 9d0c6aaaf51cf90713c96a4a108064c0495a9d82..fa56c19fdaead8e9436c74aefa9890ca6effebf9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2020 Damyan Ivanov.
+ * Copyright © 2021 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
@@ -28,12 +28,13 @@ 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;
 
@@ -70,7 +71,7 @@ public class Colors {
     int secondary;
     @ColorInt
     public static int tableRowDarkBG;
-    public static int profileThemeId = -1;
+    public static int profileThemeId = DEFAULT_HUE_DEG;
     public static void refreshColors(Resources.Theme theme) {
         TypedValue tv = new TypedValue();
         theme.resolveAttribute(R.attr.table_row_dark_bg, tv, true);
@@ -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);