profile details: confirm profile deletion
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 28 Mar 2019 21:40:01 +0000 (23:40 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 28 Mar 2019 21:40:01 +0000 (23:40 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java
app/src/main/res/values-bg/strings.xml
app/src/main/res/values/strings.xml

index 0a532e8..dbbe85f 100644 (file)
@@ -18,6 +18,8 @@
 package net.ktnx.mobileledger.ui.profiles;
 
 import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
 import android.os.Bundle;
 import android.text.Editable;
 import android.text.TextWatcher;
@@ -91,13 +93,23 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
         inflater.inflate(R.menu.profile_details, menu);
         final MenuItem menuDeleteProfile = menu.findItem(R.id.menuDelete);
         menuDeleteProfile.setOnMenuItemClickListener(item -> {
-            Log.d("profiles", String.format("[fragment] removing profile %s", mProfile.getUuid()));
-            mProfile.removeFromDB();
-            Data.profiles.remove(mProfile);
-            if (Data.profile.get().equals(mProfile)) {
-                Log.d("profiles", "[fragment] setting current profile to 0");
-                Data.setCurrentProfile(Data.profiles.get(0));
-            }
+            AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
+            builder.setTitle(mProfile.getName());
+            builder.setMessage(R.string.remove_profile_dialog_message);
+            builder.setPositiveButton(R.string.Remove, new DialogInterface.OnClickListener() {
+                @Override
+                public void onClick(DialogInterface dialog, int which) {
+                    Log.d("profiles", String.format("[fragment] removing profile %s", mProfile.getUuid()));
+                    mProfile.removeFromDB();
+                    Data.profiles.remove(mProfile);
+                    if (Data.profile.get().equals(mProfile)) {
+                        Log.d("profiles", "[fragment] setting current profile to 0");
+                        Data.setCurrentProfile(Data.profiles.get(0));
+                    }
+                    getActivity().finish();
+                }
+            });
+            builder.show();
             return false;
         });
         menuDeleteProfile.setVisible((mProfile != null) && (Data.profiles.size() > 1));
index ab4f238..2632606 100644 (file)
     <string name="btn_ok">Добре</string>
     <string name="profile_list_rearrange_handle_label">Манипулатор за промяна на подредбата</string>
     <string name="color_label">Цвят</string>
+    <string name="pref_preferred_autocompletion_account_filter_hint" >Филтър при избор на предишна трансакция</string>
+    <string name="remove_profile_dialog_message">Потвърдете окончателното премахване на профила</string>
+    <string name="Remove">Премахване</string>
 
 </resources>
index 50b808c..784bc4d 100644 (file)
     <string name="default_color_btn">Default</string>
     <string name="profile_color_label">Profile color</string>
     <string name="btn_select_label">Select</string>
+    <string name="pref_preferred_autocompletion_account_filter_hint">Filter for transaction auto-completion</string>
+    <string name="remove_profile_dialog_message">Permanently remove this profile?</string>
+    <string name="Remove">Remove</string>
 </resources>