diff --git a/app/src/main/java/com/jens/automation2/ActivityMainPoi.java b/app/src/main/java/com/jens/automation2/ActivityMainPoi.java index f395977f..27d11989 100644 --- a/app/src/main/java/com/jens/automation2/ActivityMainPoi.java +++ b/app/src/main/java/com/jens/automation2/ActivityMainPoi.java @@ -190,8 +190,27 @@ public class ActivityMainPoi extends ActivityGeneric startActivityForResult(manageSpecificPoiIntent, 2000); break; case 1: - if(pointOfInterest.delete(Miscellaneous.getAnyContext())) - updateListView(); + AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainPoi.this); + deleteDialog.setMessage(getResources().getString(R.string.areYouSure)); + deleteDialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() + { + @Override + public void onClick(DialogInterface dialogInterface, int i) + { + if(pointOfInterest.delete(Miscellaneous.getAnyContext())) + updateListView(); + } + }); + deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() + { + @Override + public void onClick(DialogInterface dialogInterface, int i) + { + + } + }); + + deleteDialog.show(); break; } } diff --git a/app/src/main/java/com/jens/automation2/ActivityMainProfiles.java b/app/src/main/java/com/jens/automation2/ActivityMainProfiles.java index d83ffa8f..17a20d6f 100644 --- a/app/src/main/java/com/jens/automation2/ActivityMainProfiles.java +++ b/app/src/main/java/com/jens/automation2/ActivityMainProfiles.java @@ -187,10 +187,29 @@ public class ActivityMainProfiles extends ActivityGeneric Rule user = profile.isInUseByRules(); if(user == null) { - if (profile.delete(ActivityMainProfiles.this)) - updateListView(); - else - Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.profileCouldNotBeDeleted), Toast.LENGTH_LONG).show(); + AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainProfiles.this); + deleteDialog.setMessage(getResources().getString(R.string.areYouSure)); + deleteDialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() + { + @Override + public void onClick(DialogInterface dialogInterface, int i) + { + if (profile.delete(ActivityMainProfiles.this)) + updateListView(); + else + Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.profileCouldNotBeDeleted), Toast.LENGTH_LONG).show(); + } + }); + deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() + { + @Override + public void onClick(DialogInterface dialogInterface, int i) + { + + } + }); + + deleteDialog.show(); } else Toast.makeText(ActivityMainProfiles.this, String.format(getResources().getString(R.string.ruleXIsUsingProfileY), user.getName(), profile.getName()), Toast.LENGTH_LONG).show(); diff --git a/app/src/main/java/com/jens/automation2/ActivityMainRules.java b/app/src/main/java/com/jens/automation2/ActivityMainRules.java index eba0a962..ed5bb741 100644 --- a/app/src/main/java/com/jens/automation2/ActivityMainRules.java +++ b/app/src/main/java/com/jens/automation2/ActivityMainRules.java @@ -18,6 +18,7 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.jens.automation2.AutomationService.serviceCommands; import com.jens.automation2.receivers.DateTimeListener; @@ -213,11 +214,30 @@ public class ActivityMainRules extends ActivityGeneric startActivityForResult(manageSpecificRuleIntent, requestCodeChangeRule); break; case 2: - if(ruleThisIsAbout.delete()) + AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainRules.this); + deleteDialog.setMessage(getResources().getString(R.string.areYouSure)); + deleteDialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() { - ruleToEdit = null; //clear cache - updateListView(); - } + @Override + public void onClick(DialogInterface dialogInterface, int i) + { + if(ruleThisIsAbout.delete()) + { + ruleToEdit = null; //clear cache + updateListView(); + } + } + }); + deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() + { + @Override + public void onClick(DialogInterface dialogInterface, int i) + { + + } + }); + + deleteDialog.show(); break; case 3: ruleToEdit = ruleThisIsAbout; diff --git a/fastlane/metadata/android/en-US/changelogs/123.txt b/fastlane/metadata/android/en-US/changelogs/123.txt new file mode 100644 index 00000000..7adb999b --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/123.txt @@ -0,0 +1 @@ +* New: Confirmation dialog before deleting locations, rules and profile \ No newline at end of file