]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java
add two more limit options for the future date entry limit - one and two weeks
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / profiles / ProfileDetailFragment.java
index 6eed96a4f2a267e646161396a20e9f8e9f043df6..1ca52ddd371c7a6e32ad05b664ed781e1afb47f4 100644 (file)
@@ -72,6 +72,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
      * represents.
      */
     public static final String ARG_ITEM_ID = "item_id";
+    public static final String ARG_HUE = "hue";
     @NonNls
     private static final String HTTPS_URL_START = "https://";
 
@@ -163,9 +164,9 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
             throw new AssertionError();
         profiles.set(index, newProfile);
 
-        ProfilesRecyclerViewAdapter prva = ProfilesRecyclerViewAdapter.getInstance();
-        if (prva != null)
-            prva.notifyItemChanged(index);
+        ProfilesRecyclerViewAdapter viewAdapter = ProfilesRecyclerViewAdapter.getInstance();
+        if (viewAdapter != null)
+            viewAdapter.notifyItemChanged(index);
 
         if (mProfile.equals(Data.profile.getValue()))
             Data.profile.setValue(newProfile);
@@ -211,6 +212,12 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
                    menu.inflate(R.menu.future_dates);
                    menu.setOnMenuItemClickListener(item -> {
                        switch (item.getItemId()) {
+                           case R.id.menu_future_dates_7:
+                               futureDates = MobileLedgerProfile.FutureDates.OneWeek;
+                               break;
+                           case R.id.menu_future_dates_14:
+                               futureDates = MobileLedgerProfile.FutureDates.TwoWeeks;
+                               break;
                            case R.id.menu_future_dates_30:
                                futureDates = MobileLedgerProfile.FutureDates.OneMonth;
                                break;
@@ -293,7 +300,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
         hookClearErrorOnFocusListener(userName, userNameLayout);
         hookClearErrorOnFocusListener(password, passwordLayout);
 
-        int profileThemeId;
+        final int profileThemeId;
         if (mProfile != null) {
             profileName.setText(mProfile.getName());
             postingPermitted.setChecked(mProfile.isPostingPermitted());
@@ -307,7 +314,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("");
@@ -322,7 +329,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
             userName.setText("");
             password.setText("");
             preferredAccountsFilter.setText(null);
-            profileThemeId = -1;
+            profileThemeId = getArguments().getInt(ARG_HUE, -1);
         }
 
         checkInsecureSchemeWithAuth();
@@ -363,7 +370,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 +404,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);
     }