From 1738aee062f23cc9a69ed11cade1cb048f083def Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 25 Jan 2020 09:25:22 +0200 Subject: [PATCH] themeId -> themeHue --- .../model/MobileLedgerProfile.java | 27 +++++++++---------- .../ui/activity/MainActivity.java | 4 +-- .../ui/activity/ProfileDetailActivity.java | 2 +- .../ui/profiles/ProfileDetailFragment.java | 6 ++--- .../profiles/ProfilesRecyclerViewAdapter.java | 2 +- .../net/ktnx/mobileledger/utils/Colors.java | 2 +- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java b/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java index 347e1142..5fbb5ba0 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java @@ -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}); diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index da5ac23a..876f8da8 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -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(); diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java index 4536e0d9..f14a5b5a 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java @@ -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())); } } diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java index a94bbab7..6b6883df 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java @@ -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); } diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java index 6f533b01..84dab3c9 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java @@ -180,7 +180,7 @@ public class ProfilesRecyclerViewAdapter profile.getUuid(), (currentProfile == 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)); diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/Colors.java b/app/src/main/java/net/ktnx/mobileledger/utils/Colors.java index 277de9ff..3c89df9c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/Colors.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/Colors.java @@ -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) { -- 2.39.5