]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java
profile flag for enabling/disabling addition of new transactions
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / profiles / ProfileDetailFragment.java
index 004763a7ac87a45343018d67b095872aa612efc6..7cbfa0e7062c20abf3b7c2d6b75a6b128fccb7e7 100644 (file)
@@ -61,6 +61,7 @@ public class ProfileDetailFragment extends Fragment {
      */
     private MobileLedgerProfile mProfile;
     private TextView url;
+    private Switch postingPermitted;
     private TextInputLayout urlLayout;
     private LinearLayout authParams;
     private Switch useAuthentication;
@@ -140,11 +141,15 @@ public class ProfileDetailFragment extends Fragment {
                 }
             }
             else {
-                mProfile = new MobileLedgerProfile(profileName.getText(), url.getText(),
-                        useAuthentication.isChecked(), userName.getText(), password.getText());
+                mProfile = new MobileLedgerProfile(profileName.getText(), postingPermitted.isChecked(),
+                        url.getText(), useAuthentication.isChecked(), userName.getText(),
+                        password.getText());
                 mProfile.storeInDB();
                 Data.profiles.add(mProfile);
                 MobileLedgerProfile.storeProfilesOrder();
+
+                // first profile ever?
+                if (Data.profiles.getList().size() == 1) Data.profile.set(mProfile);
             }
 
             Activity activity = getActivity();
@@ -162,6 +167,7 @@ public class ProfileDetailFragment extends Fragment {
         profileNameLayout = rootView.findViewById(R.id.profile_name_layout);
         url = rootView.findViewById(R.id.url);
         urlLayout = rootView.findViewById(R.id.url_layout);
+        postingPermitted = rootView.findViewById(R.id.profile_permit_posting);
         authParams = rootView.findViewById(R.id.auth_params);
         useAuthentication = rootView.findViewById(R.id.enable_http_auth);
         userName = rootView.findViewById(R.id.auth_user_name);
@@ -182,6 +188,7 @@ public class ProfileDetailFragment extends Fragment {
 
         if (mProfile != null) {
             profileName.setText(mProfile.getName());
+            postingPermitted.setChecked(mProfile.isPostingPermitted());
             url.setText(mProfile.getUrl());
             useAuthentication.setChecked(mProfile.isAuthEnabled());
             authParams.setVisibility(mProfile.isAuthEnabled() ? View.VISIBLE : View.GONE);
@@ -191,6 +198,7 @@ public class ProfileDetailFragment extends Fragment {
         else {
             profileName.setText("");
             url.setText("");
+            postingPermitted.setChecked(true);
             useAuthentication.setChecked(false);
             authParams.setVisibility(View.GONE);
             userName.setText("");