Add confirm dialog to delete action

This commit is contained in:
Adrian Ulrich 2014-04-12 17:24:32 +02:00
parent 750fbb47b3
commit 43b13d9684
2 changed files with 18 additions and 3 deletions

View File

@ -89,13 +89,14 @@ THE SOFTWARE.
<item quantity="one">1 song added to playlist %2$s.</item>
<item quantity="other">%1$d songs added to playlist %2$s.</item>
</plurals>
<string name="deleted">%s deleted.</string>
<plurals name="deleted">
<item quantity="one">1 song deleted.</item>
<item quantity="other">%d songs deleted.</item>
</plurals>
<string name="delete_file_failed">Failed to delete %s.</string>
<string name="delete_item">Delete \'%s\'?</string>
<string name="artists">Artists</string>
<string name="albums">Albums</string>
<string name="songs">Songs</string>

View File

@ -775,7 +775,7 @@ public class LibraryActivity
if (item.getGroupId() != 0)
return super.onContextItemSelected(item);
Intent intent = item.getIntent();
final Intent intent = item.getIntent();
switch (item.getItemId()) {
case MENU_EXPAND:
@ -810,7 +810,21 @@ public class LibraryActivity
break;
}
case MENU_DELETE:
mHandler.sendMessage(mHandler.obtainMessage(MSG_DELETE, intent));
String delete_message = getString(R.string.delete_item, intent.getStringExtra("title"));
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle(R.string.delete);
dialog
.setMessage(delete_message)
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_DELETE, intent));
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
dialog.create().show();
break;
case MENU_ADD_TO_PLAYLIST: {
SubMenu playlistMenu = item.getSubMenu();