]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java
migrate to surrogate IDs for all database objects
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / profiles / ProfileDetailFragment.java
index 36e39af20dfb712e798a6668e07c82d5c75e5ac6..f5b48aef3e22c5dc4d0ec52f9ef8670f6bbdd485 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2020 Damyan Ivanov.
+ * Copyright © 2021 Damyan Ivanov.
  * This file is part of MoLe.
  * MoLe is free software: you can distribute it and/or modify it
  * under the term of the GNU General Public License as published by
@@ -52,7 +52,6 @@ import net.ktnx.mobileledger.model.Data;
 import net.ktnx.mobileledger.model.MobileLedgerProfile;
 import net.ktnx.mobileledger.ui.CurrencySelectorFragment;
 import net.ktnx.mobileledger.ui.HueRingDialog;
-import net.ktnx.mobileledger.ui.activity.ProfileDetailActivity;
 import net.ktnx.mobileledger.utils.Colors;
 import net.ktnx.mobileledger.utils.Misc;
 
@@ -63,7 +62,6 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Objects;
-import java.util.UUID;
 
 import static net.ktnx.mobileledger.utils.Logger.debug;
 
@@ -112,7 +110,7 @@ public class ProfileDetailFragment extends Fragment {
         builder.setTitle(mProfile.getName());
         builder.setMessage(R.string.remove_profile_dialog_message);
         builder.setPositiveButton(R.string.Remove, (dialog, which) -> {
-            debug("profiles", String.format("[fragment] removing profile %s", mProfile.getUuid()));
+            debug("profiles", String.format("[fragment] removing profile %s", mProfile.getId()));
             mProfile.removeFromDB();
             ArrayList<MobileLedgerProfile> oldList = Data.profiles.getValue();
             if (oldList == null)
@@ -206,7 +204,7 @@ public class ProfileDetailFragment extends Fragment {
                 resetDefaultCommodity();
         });
 
-        FloatingActionButton fab = context.findViewById(R.id.fab);
+        FloatingActionButton fab = context.findViewById(R.id.fabAdd);
         fab.setOnClickListener(v -> onSaveFabClicked());
 
         hookTextChangeSyncRoutine(binding.profileName, model::setProfileName);
@@ -432,9 +430,7 @@ public class ProfileDetailFragment extends Fragment {
 //                debug("profiles", String.format("Selected item is %d", mProfile.getThemeHue()));
 
             final MobileLedgerProfile currentProfile = Data.getProfile();
-            if (mProfile.getUuid()
-                        .equals(currentProfile.getUuid()))
-            {
+            if (mProfile.getId() == currentProfile.getId()) {
                 Data.setCurrentProfile(mProfile);
             }
 
@@ -443,7 +439,7 @@ public class ProfileDetailFragment extends Fragment {
                 viewAdapter.notifyItemChanged(pos);
         }
         else {
-            mProfile = new MobileLedgerProfile(String.valueOf(UUID.randomUUID()));
+            mProfile = new MobileLedgerProfile(0);
             model.updateProfile(mProfile);
             mProfile.storeInDB();
             final ArrayList<MobileLedgerProfile> newList = new ArrayList<>(profiles);
@@ -497,7 +493,8 @@ public class ProfileDetailFragment extends Fragment {
 
         if (model.getUseAuthentication()) {
             String urlText = model.getUrl();
-            if (urlText.startsWith("http") && !urlText.startsWith("https"))
+            if (urlText.startsWith("http://") ||
+                urlText.length() >= 8 && !urlText.startsWith("https://"))
                 showWarning = true;
         }