From: Damyan Ivanov Date: Thu, 28 Mar 2019 21:40:01 +0000 (+0200) Subject: profile details: confirm profile deletion X-Git-Tag: v0.9~52 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=b28bf4ffbb472757066aea324d40b739828a2f7d;p=mobile-ledger.git profile details: confirm profile deletion --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java index 0a532e8f..dbbe85ff 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java @@ -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)); diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index ab4f238d..2632606c 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -107,5 +107,8 @@ Добре Манипулатор за промяна на подредбата Цвят + Филтър при избор на предишна трансакция + Потвърдете окончателното премахване на профила + Премахване diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 50b808c8..784bc4d5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -149,4 +149,7 @@ Default Profile color Select + Filter for transaction auto-completion + Permanently remove this profile? + Remove