]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java
default new profile URL is 'https://'
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / profiles / ProfileDetailFragment.java
index 8b4136a593bb30e026f618265104933541cb87fc..0a532e8facec161b62aa5cd37935c8d4803e3df3 100644 (file)
@@ -158,7 +158,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
                 MobileLedgerProfile.storeProfilesOrder();
 
                 // first profile ever?
-                if (Data.profiles.getList().size() == 1) Data.profile.set(mProfile);
+                if (Data.profiles.size() == 1) Data.profile.set(mProfile);
             }
 
             Activity activity = getActivity();
@@ -196,6 +196,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
         hookClearErrorOnFocusListener(userName, userNameLayout);
         hookClearErrorOnFocusListener(password, passwordLayout);
 
+        int profileThemeId;
         if (mProfile != null) {
             profileName.setText(mProfile.getName());
             postingPermitted.setChecked(mProfile.isPostingPermitted());
@@ -204,27 +205,24 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
             authParams.setVisibility(mProfile.isAuthEnabled() ? View.VISIBLE : View.GONE);
             userName.setText(mProfile.isAuthEnabled() ? mProfile.getAuthUserName() : "");
             password.setText(mProfile.isAuthEnabled() ? mProfile.getAuthPassword() : "");
-
-            huePickerView.setBackgroundColor(Colors.getPrimaryColorForHue(
-                    (mProfile.getThemeId() == -1) ? Colors.DEFAULT_HUE_DEG
-                                                  : mProfile.getThemeId()));
+            profileThemeId = mProfile.getThemeId();
         }
         else {
             profileName.setText("");
-            url.setText("");
+            url.setText("https://");
             postingPermitted.setChecked(true);
             useAuthentication.setChecked(false);
             authParams.setVisibility(View.GONE);
             userName.setText("");
             password.setText("");
-            huePickerView.setBackgroundColor(Colors.getPrimaryColorForHue(Colors.DEFAULT_HUE_DEG));
+            profileThemeId = -1;
         }
 
-        int profileThemeId = (mProfile == null) ? -1 : mProfile.getThemeId();
         final int hue = (profileThemeId == -1) ? Colors.DEFAULT_HUE_DEG : profileThemeId;
         final int profileColor = Colors.getPrimaryColorForHue(hue);
 
         huePickerView.setBackgroundColor(profileColor);
+        huePickerView.setTag(profileThemeId);
         huePickerView.setOnClickListener(v -> {
             HueRingDialog d = new HueRingDialog(
                     Objects.requireNonNull(ProfileDetailFragment.this.getContext()), hue);