]> git.ktnx.net Git - mobile-ledger.git/commitdiff
themeId -> themeHue
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 25 Jan 2020 07:25:22 +0000 (09:25 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 25 Jan 2020 07:25:22 +0000 (09:25 +0200)
app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java
app/src/main/java/net/ktnx/mobileledger/utils/Colors.java

index 347e1142408e22ff99c71902938846140dd26722..5fbb5ba04c69061d7999fde0936a6215b61f4855 100644 (file)
@@ -50,7 +50,7 @@ public final class MobileLedgerProfile {
     private boolean authEnabled;
     private String authUserName;
     private String authPassword;
-    private int themeId;
+    private int themeHue;
     private int orderNo = -1;
     private FutureDates futureDates = FutureDates.None;
     private SendTransactionTask.API apiVersion = SendTransactionTask.API.auto;
@@ -69,7 +69,7 @@ public final class MobileLedgerProfile {
         authEnabled = origin.authEnabled;
         authUserName = origin.authUserName;
         authPassword = origin.authPassword;
-        themeId = origin.themeId;
+        themeHue = origin.themeHue;
         orderNo = origin.orderNo;
         futureDates = origin.futureDates;
         apiVersion = origin.apiVersion;
@@ -208,15 +208,15 @@ public final class MobileLedgerProfile {
         try {
 //            debug("profiles", String.format("Storing profile in DB: uuid=%s, name=%s, " +
 //                                            "url=%s, permit_posting=%s, authEnabled=%s, " +
-//                                            "themeId=%d", uuid, name, url,
-//                    permitPosting ? "TRUE" : "FALSE", authEnabled ? "TRUE" : "FALSE", themeId));
+//                                            "themeHue=%d", uuid, name, url,
+//                    permitPosting ? "TRUE" : "FALSE", authEnabled ? "TRUE" : "FALSE", themeHue));
             db.execSQL("REPLACE INTO profiles(uuid, name, permit_posting, url, " +
                        "use_authentication, auth_user, " +
                        "auth_password, theme, order_no, preferred_accounts_filter, future_dates, " +
                        "api_version) " + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
                     new Object[]{uuid, name, permitPosting, url, authEnabled,
                                  authEnabled ? authUserName : null,
-                                 authEnabled ? authPassword : null, themeId, orderNo,
+                                 authEnabled ? authPassword : null, themeHue, orderNo,
                                  preferredAccountsFilter, futureDates.toInt(), apiVersion.toInt()
                     });
             db.setTransactionSuccessful();
@@ -390,17 +390,16 @@ public final class MobileLedgerProfile {
 
         return tr;
     }
-    public int getThemeId() {
-//        debug("profile", String.format("Profile.getThemeId() returning %d", themeId));
-        return this.themeId;
+    public int getThemeHue() {
+//        debug("profile", String.format("Profile.getThemeHue() returning %d", themeHue));
+        return this.themeHue;
     }
-    public void setThemeId(Object o) {
-        setThemeId(Integer.valueOf(String.valueOf(o))
-                          .intValue());
+    public void setThemeHue(Object o) {
+        setThemeId(Integer.valueOf(String.valueOf(o)));
     }
-    public void setThemeId(int themeId) {
-//        debug("profile", String.format("Profile.setThemeId(%d) called", themeId));
-        this.themeId = themeId;
+    public void setThemeId(int themeHue) {
+//        debug("profile", String.format("Profile.setThemeHue(%d) called", themeHue));
+        this.themeHue = themeHue;
     }
     public void markTransactionsAsNotPresent(SQLiteDatabase db) {
         db.execSQL("UPDATE transactions set keep=0 where profile=?", new String[]{uuid});
index da5ac23a83709aafe75af8a358160993925b1d58..876f8da8c4e60f8f411f4eeba803ba3b5fdbac03 100644 (file)
@@ -399,7 +399,7 @@ public class MainActivity extends ProfileThemedActivity {
 
         mProfileListAdapter.notifyDataSetChanged();
 
-        int newProfileTheme = haveProfile ? profile.getThemeId() : -1;
+        int newProfileTheme = haveProfile ? profile.getThemeHue() : -1;
         if (newProfileTheme != Colors.profileThemeId) {
             debug("profiles",
                     String.format(Locale.ENGLISH, "profile theme %d → %d", Colors.profileThemeId,
@@ -458,7 +458,7 @@ public class MainActivity extends ProfileThemedActivity {
         Bundle bundle = new Bundle();
         onSaveInstanceState(bundle);
 
-        storeThemeIdInPrefs(profile.getThemeId());
+        storeThemeIdInPrefs(profile.getThemeHue());
 
         // restart activity to reflect theme change
         finish();
index 4536e0d91f66aa6d22f1d6a48fadf6f64e9d9bad..f14a5b5aaa7b7bf3f08b12e70e615a015047b277 100644 (file)
@@ -57,7 +57,7 @@ public class ProfileDetailActivity extends CrashReportingActivity {
                                     index));
 
                 debug("profiles", String.format(Locale.ENGLISH, "Editing profile %s (%s); hue=%d",
-                        profile.getName(), profile.getUuid(), profile.getThemeId()));
+                        profile.getName(), profile.getUuid(), profile.getThemeHue()));
             }
         }
 
index a94bbab7fe10e9e97c0b99dc9ead36154c102c67..6b6883dfbf20b14d5ae9e3b9c99495559704f518 100644 (file)
@@ -307,7 +307,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
             userName.setText(mProfile.isAuthEnabled() ? mProfile.getAuthUserName() : "");
             password.setText(mProfile.isAuthEnabled() ? mProfile.getAuthPassword() : "");
             preferredAccountsFilter.setText(mProfile.getPreferredAccountsFilter());
-            profileThemeId = mProfile.getThemeId();
+            profileThemeId = mProfile.getThemeHue();
         }
         else {
             profileName.setText("");
@@ -363,7 +363,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
 
         if (mProfile != null) {
             updateProfileFromUI();
-//                debug("profiles", String.format("Selected item is %d", mProfile.getThemeId()));
+//                debug("profiles", String.format("Selected item is %d", mProfile.getThemeHue()));
             mProfile.storeInDB();
             debug("profiles", "profile stored in DB");
             triggerProfileChange();
@@ -397,7 +397,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
         mProfile.setAuthEnabled(useAuthentication.isChecked());
         mProfile.setAuthUserName(userName.getText());
         mProfile.setAuthPassword(password.getText());
-        mProfile.setThemeId(huePickerView.getTag());
+        mProfile.setThemeHue(huePickerView.getTag());
         mProfile.setFutureDates(futureDates);
         mProfile.setApiVersion(apiVersion);
     }
index 6f533b01d3abffab5ef4d0a2e1afec955a278bea..84dab3c9b7d44d6c014e0b2bef352a19ad18f143 100644 (file)
@@ -180,7 +180,7 @@ public class ProfilesRecyclerViewAdapter
                 profile.getUuid(), (currentProfile == null) ? "<NULL>" : currentProfile.getUuid()));
         holder.itemView.setTag(profile);
 
-        int hue = profile.getThemeId();
+        int hue = profile.getThemeHue();
         if (hue == -1) holder.mColorTag
                 .setBackgroundColor(Colors.getPrimaryColorForHue(Colors.DEFAULT_HUE_DEG));
         else holder.mColorTag.setBackgroundColor(Colors.getPrimaryColorForHue(hue));
index 277de9ff0c99c172c13c7262c78479fdfafaae4e..3c89df9c788a82dab020919e54d6ef7b4214ffd7 100644 (file)
@@ -206,7 +206,7 @@ public class Colors {
         setupTheme(activity, profile);
     }
     public static void setupTheme(Activity activity, MobileLedgerProfile profile) {
-        final int themeHue = (profile == null) ? -1 : profile.getThemeId();
+        final int themeHue = (profile == null) ? -1 : profile.getThemeHue();
         setupTheme(activity, themeHue);
     }
     public static void setupTheme(Activity activity, int themeHue) {