From 0e2937f7e472c52675d47ff7a5dcb214adbeb35d Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Mon, 28 Jan 2019 21:07:29 +0200 Subject: [PATCH] fix the 'Posting committed' switch in the profile editor --- .../ktnx/mobileledger/model/MobileLedgerProfile.java | 4 +++- .../ktnx/mobileledger/ui/activity/MainActivity.java | 10 ++++++++-- .../ui/profiles/ProfileDetailFragment.java | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 13 insertions(+), 3 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 bbd9a2be..d619c4bb 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java @@ -95,10 +95,12 @@ public final class MobileLedgerProfile { db.endTransaction(); } } - public boolean isPostingPermitted() { return permitPosting; } + public void setPostingPermitted(boolean permitPosting) { + this.permitPosting = permitPosting; + } public String getUuid() { return 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 83b608bf..fb8a7327 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 @@ -97,8 +97,14 @@ public class MainActivity extends AppCompatActivity { if (profile == null) setTitle(R.string.app_name); else setTitle(profile.getName()); updateLastUpdateTextFromDB(); - if (profile.isPostingPermitted()) fab.show(); - else fab.hide(); + if (profile.isPostingPermitted()) { + toolbar.setSubtitle(null); + fab.show(); + } + else { + toolbar.setSubtitle(R.string.profile_subitlte_read_only); + fab.hide(); + } }); }); 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 7cbfa0e7..02883783 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 @@ -127,6 +127,7 @@ public class ProfileDetailFragment extends Fragment { if (mProfile != null) { mProfile.setName(profileName.getText()); mProfile.setUrl(url.getText()); + mProfile.setPostingPermitted(postingPermitted.isChecked()); mProfile.setAuthEnabled(useAuthentication.isChecked()); mProfile.setAuthUserName(userName.getText()); mProfile.setAuthPassword(password.getText()); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dc800351..f4ae09f5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -132,4 +132,5 @@ December Posting of new transactions enabled + (Read only) -- 2.39.5