PowerEditor: added confirmation for back press
This commit is contained in:
parent
63ae84f1f5
commit
2f8895ff17
3 changed files with 36 additions and 2 deletions
|
@ -1,9 +1,11 @@
|
|||
package com.kauron.dungeonmanager;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
@ -24,6 +26,28 @@ public class PowerEditor extends ActionBarActivity {
|
|||
private SharedPreferences p;
|
||||
private Drawable background;
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
alert.setTitle(R.string.sure);
|
||||
alert.setMessage(R.string.progress_lost);
|
||||
|
||||
alert.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
PowerEditor.super.onBackPressed();
|
||||
}
|
||||
});
|
||||
|
||||
alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
// Canceled.
|
||||
}
|
||||
});
|
||||
|
||||
alert.show();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -153,7 +153,7 @@
|
|||
|
||||
|
||||
<string-array name="races">
|
||||
<item>Race</item>
|
||||
<item>Raza</item>
|
||||
<item>Dracónidos</item>
|
||||
<item>Eladrines</item>
|
||||
<item>Elfos</item>
|
||||
|
@ -181,4 +181,12 @@
|
|||
<string name="use">Usar</string>
|
||||
<string name="no_powers">No tienes poderes, añade uno</string>
|
||||
<string name="show_stats">Mostrar ataque/defensa</string>
|
||||
<string name="action_settings">Ajustes</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="title_activity_display">Display</string>
|
||||
<string name="title_section1">Sección 1</string>
|
||||
<string name="title_section2">Sección 2</string>
|
||||
<string name="title_section3">Sección 3</string>
|
||||
<string name="progress_lost">Tus cambios se perderán</string>
|
||||
<string name="yes">Sí</string>
|
||||
</resources>
|
|
@ -200,5 +200,7 @@
|
|||
<string name="hello_world">Hello world!</string>
|
||||
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="progress_lost">Your changes will be lost</string>
|
||||
<string name="yes">Yes</string>
|
||||
|
||||
</resources>
|
||||
|
|
Reference in a new issue