X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Fprofiles%2FProfileDetailModel.java;h=57c992180d265bbda33e61655429d8a9140e7e45;hp=e64c4bc1dc13c8a19caee33efab7eef631aeaf7d;hb=c434526b687162a4ebf4c268e521404e2b58fcc7;hpb=aca020bc5f699663a7389f50d5ea4e034e5d6976 diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java index e64c4bc1..57c99218 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java @@ -25,6 +25,7 @@ import androidx.lifecycle.ViewModel; import net.ktnx.mobileledger.async.SendTransactionTask; import net.ktnx.mobileledger.model.Currency; import net.ktnx.mobileledger.model.MobileLedgerProfile; +import net.ktnx.mobileledger.utils.Colors; import net.ktnx.mobileledger.utils.Misc; public class ProfileDetailModel extends ViewModel { @@ -35,6 +36,7 @@ public class ProfileDetailModel extends ViewModel { private final MutableLiveData futureDates = new MutableLiveData<>(MobileLedgerProfile.FutureDates.None); private final MutableLiveData showCommodityByDefault = new MutableLiveData<>(false); + private final MutableLiveData showCommentsByDefault = new MutableLiveData<>(true); private final MutableLiveData useAuthentication = new MutableLiveData<>(false); private final MutableLiveData apiVersion = new MutableLiveData<>(SendTransactionTask.API.auto); @@ -43,6 +45,7 @@ public class ProfileDetailModel extends ViewModel { private final MutableLiveData authPassword = new MutableLiveData<>(null); private final MutableLiveData preferredAccountsFilter = new MutableLiveData<>(null); private final MutableLiveData themeId = new MutableLiveData<>(-1); + public int initialThemeHue = Colors.DEFAULT_HUE_DEG; public ProfileDetailModel() { } String getProfileName() { @@ -69,6 +72,13 @@ public class ProfileDetailModel extends ViewModel { void observePostingPermitted(LifecycleOwner lfo, Observer o) { postingPermitted.observe(lfo, o); } + public void setShowCommentsByDefault(boolean newValue) { + if (newValue != showCommentsByDefault.getValue()) + showCommentsByDefault.setValue(newValue); + } + void observeShowCommentsByDefault(LifecycleOwner lfo, Observer o) { + showCommentsByDefault.observe(lfo, o); + } MobileLedgerProfile.FutureDates getFutureDates() { return futureDates.getValue(); } @@ -189,6 +199,7 @@ public class ProfileDetailModel extends ViewModel { if (mProfile != null) { profileName.setValue(mProfile.getName()); postingPermitted.setValue(mProfile.isPostingPermitted()); + showCommentsByDefault.setValue(mProfile.getShowCommentsByDefault()); showCommodityByDefault.setValue(mProfile.getShowCommodityByDefault()); { String comm = mProfile.getDefaultCommodity(); @@ -210,6 +221,7 @@ public class ProfileDetailModel extends ViewModel { profileName.setValue(null); url.setValue(HTTPS_URL_START); postingPermitted.setValue(true); + showCommentsByDefault.setValue(true); showCommodityByDefault.setValue(false); setFutureDates(MobileLedgerProfile.FutureDates.None); setApiVersion(SendTransactionTask.API.auto); @@ -226,6 +238,7 @@ public class ProfileDetailModel extends ViewModel { mProfile.setName(profileName.getValue()); mProfile.setUrl(url.getValue()); mProfile.setPostingPermitted(postingPermitted.getValue()); + mProfile.setShowCommentsByDefault(showCommentsByDefault.getValue()); Currency c = defaultCommodity.getValue(); mProfile.setDefaultCommodity((c == null) ? null : c.getName()); mProfile.setShowCommodityByDefault(showCommodityByDefault.getValue());