add a prompt for deleting note

This commit is contained in:
tibbi 2016-10-01 21:30:01 +02:00
parent 642feedd48
commit 6ee62f46d8
6 changed files with 27 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package com.simplemobiletools.notes.activities;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
@ -78,7 +79,7 @@ public class MainActivity extends SimpleActivity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.delete_note:
deleteNote();
displayDeleteNotePrompt();
return true;
case R.id.open_note:
displayOpenNoteDialog();
@ -127,6 +128,21 @@ public class MainActivity extends SimpleActivity {
});
}
private void displayDeleteNotePrompt() {
final Resources res = getResources();
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(res.getString(R.string.delete_note_prompt_title));
builder.setMessage(String.format(res.getString(R.string.delete_note_prompt_message), mCurrentNote.getTitle()));
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
deleteNote();
}
});
builder.setNegativeButton(R.string.cancel, null);
builder.show();
}
private void deleteNote() {
}

View File

@ -15,6 +15,8 @@
<string name="title_taken">A note with that title already exists</string>
<string name="open_note">Open note</string>
<string name="delete_note">Delete note</string>
<string name="delete_note_prompt_title">Delete note</string>
<string name="delete_note_prompt_message">Are you sure you want to delete note \"%1$s\"?</string>
<!-- Settings -->
<string name="settings">Einstellungen</string>

View File

@ -15,6 +15,8 @@
<string name="title_taken">A note with that title already exists</string>
<string name="open_note">Open note</string>
<string name="delete_note">Delete note</string>
<string name="delete_note_prompt_title">Delete note</string>
<string name="delete_note_prompt_message">Are you sure you want to delete note \"%1$s\"?</string>
<!-- Settings -->
<string name="settings">Impostazioni</string>

View File

@ -15,6 +15,8 @@
<string name="title_taken">A note with that title already exists</string>
<string name="open_note">Open note</string>
<string name="delete_note">Delete note</string>
<string name="delete_note_prompt_title">Delete note</string>
<string name="delete_note_prompt_message">Are you sure you want to delete note \"%1$s\"?</string>
<!-- Settings -->
<string name="settings">設定</string>

View File

@ -15,6 +15,8 @@
<string name="title_taken">A note with that title already exists</string>
<string name="open_note">Open note</string>
<string name="delete_note">Delete note</string>
<string name="delete_note_prompt_title">Delete note</string>
<string name="delete_note_prompt_message">Are you sure you want to delete note \"%1$s\"?</string>
<!-- Settings -->
<string name="settings">Inställningar</string>

View File

@ -15,6 +15,8 @@
<string name="title_taken">A note with that title already exists</string>
<string name="open_note">Open note</string>
<string name="delete_note">Delete note</string>
<string name="delete_note_prompt_title">Delete note</string>
<string name="delete_note_prompt_message">Are you sure you want to delete note \"%1$s\"?</string>
<!-- Settings -->
<string name="settings">Settings</string>