confirmation dialog for deletions

This commit is contained in:
Jens 2022-09-21 23:29:54 +02:00
parent 2fd79140cb
commit 374a5c4263
4 changed files with 69 additions and 10 deletions

View File

@ -190,8 +190,27 @@ public class ActivityMainPoi extends ActivityGeneric
startActivityForResult(manageSpecificPoiIntent, 2000); startActivityForResult(manageSpecificPoiIntent, 2000);
break; break;
case 1: case 1:
if(pointOfInterest.delete(Miscellaneous.getAnyContext())) AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainPoi.this);
updateListView(); 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; break;
} }
} }

View File

@ -187,10 +187,29 @@ public class ActivityMainProfiles extends ActivityGeneric
Rule user = profile.isInUseByRules(); Rule user = profile.isInUseByRules();
if(user == null) if(user == null)
{ {
if (profile.delete(ActivityMainProfiles.this)) AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainProfiles.this);
updateListView(); deleteDialog.setMessage(getResources().getString(R.string.areYouSure));
else deleteDialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.profileCouldNotBeDeleted), Toast.LENGTH_LONG).show(); {
@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 else
Toast.makeText(ActivityMainProfiles.this, String.format(getResources().getString(R.string.ruleXIsUsingProfileY), user.getName(), profile.getName()), Toast.LENGTH_LONG).show(); Toast.makeText(ActivityMainProfiles.this, String.format(getResources().getString(R.string.ruleXIsUsingProfileY), user.getName(), profile.getName()), Toast.LENGTH_LONG).show();

View File

@ -18,6 +18,7 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.jens.automation2.AutomationService.serviceCommands; import com.jens.automation2.AutomationService.serviceCommands;
import com.jens.automation2.receivers.DateTimeListener; import com.jens.automation2.receivers.DateTimeListener;
@ -213,11 +214,30 @@ public class ActivityMainRules extends ActivityGeneric
startActivityForResult(manageSpecificRuleIntent, requestCodeChangeRule); startActivityForResult(manageSpecificRuleIntent, requestCodeChangeRule);
break; break;
case 2: 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 @Override
updateListView(); 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; break;
case 3: case 3:
ruleToEdit = ruleThisIsAbout; ruleToEdit = ruleThisIsAbout;

View File

@ -0,0 +1 @@
* New: Confirmation dialog before deleting locations, rules and profile