fix the 'Posting committed' switch in the profile editor
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 28 Jan 2019 19:07:29 +0000 (21:07 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 28 Jan 2019 19:08:28 +0000 (21:08 +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/profiles/ProfileDetailFragment.java
app/src/main/res/values/strings.xml

index bbd9a2be00ad982f8755984f7a44e8441b6b8611..d619c4bb5bca72d868f5ee6c49a2f1158d44e3af 100644 (file)
@@ -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;
     }
index 83b608bff321561f3b0caac9ce191fead44beeff..fb8a732748a5a4bfc63246df8aa5dd2eb520386e 100644 (file)
@@ -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();
+                }
             });
         });
 
index 7cbfa0e7062c20abf3b7c2d6b75a6b128fccb7e7..0288378393766a3331270154616079a0ecb3d937 100644 (file)
@@ -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());
index dc8003515555cefe8320b7e07f3d379cb98d306d..f4ae09f5b50e93930dbc3a0bf06976cde0133074 100644 (file)
         <item>December</item>
     </string-array>
     <string name="posting_permitted">Posting of new transactions enabled</string>
+    <string name="profile_subitlte_read_only">(Read only)</string>
 </resources>