mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-27 09:16:08 +00:00
Don't close the EditProfileActivity to show a delete entry dialog
This commit is contained in:
parent
da529608fa
commit
e45735faa1
3 changed files with 37 additions and 19 deletions
|
@ -31,6 +31,7 @@ import me.impy.aegis.encoding.Base32;
|
||||||
import me.impy.aegis.helpers.EditTextHelper;
|
import me.impy.aegis.helpers.EditTextHelper;
|
||||||
import me.impy.aegis.helpers.SpinnerHelper;
|
import me.impy.aegis.helpers.SpinnerHelper;
|
||||||
import me.impy.aegis.helpers.TextDrawableHelper;
|
import me.impy.aegis.helpers.TextDrawableHelper;
|
||||||
|
import me.impy.aegis.ui.dialogs.Dialogs;
|
||||||
import me.impy.aegis.ui.views.KeyProfile;
|
import me.impy.aegis.ui.views.KeyProfile;
|
||||||
|
|
||||||
public class EditProfileActivity extends AegisActivity {
|
public class EditProfileActivity extends AegisActivity {
|
||||||
|
@ -231,14 +232,20 @@ public class EditProfileActivity extends AegisActivity {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
return true;
|
break;
|
||||||
case R.id.action_save:
|
case R.id.action_save:
|
||||||
return onSave();
|
onSave();
|
||||||
|
break;
|
||||||
case R.id.action_delete:
|
case R.id.action_delete:
|
||||||
return onDelete();
|
Dialogs.showDeleteEntryDialog(this, (dialog, which) -> {
|
||||||
|
finish(true);
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -258,11 +265,6 @@ public class EditProfileActivity extends AegisActivity {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onDelete() {
|
|
||||||
finish(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean onSave() {
|
private boolean onSave() {
|
||||||
if (_textSecret.length() == 0) {
|
if (_textSecret.length() == 0) {
|
||||||
onError("Secret is a required field.");
|
onError("Secret is a required field.");
|
||||||
|
|
|
@ -27,6 +27,7 @@ import me.impy.aegis.db.DatabaseManagerException;
|
||||||
import me.impy.aegis.db.DatabaseEntry;
|
import me.impy.aegis.db.DatabaseEntry;
|
||||||
import me.impy.aegis.db.DatabaseManager;
|
import me.impy.aegis.db.DatabaseManager;
|
||||||
import me.impy.aegis.helpers.PermissionHelper;
|
import me.impy.aegis.helpers.PermissionHelper;
|
||||||
|
import me.impy.aegis.ui.dialogs.Dialogs;
|
||||||
import me.impy.aegis.ui.views.KeyProfile;
|
import me.impy.aegis.ui.views.KeyProfile;
|
||||||
import me.impy.aegis.ui.views.KeyProfileView;
|
import me.impy.aegis.ui.views.KeyProfileView;
|
||||||
|
|
||||||
|
@ -378,7 +379,9 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen
|
||||||
|
|
||||||
deleteLayout.setOnClickListener(view -> {
|
deleteLayout.setOnClickListener(view -> {
|
||||||
bottomDialog.dismiss();
|
bottomDialog.dismiss();
|
||||||
deleteProfile(profile);
|
Dialogs.showDeleteEntryDialog(this, (dialog, which) -> {
|
||||||
|
deleteProfile(profile);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
editLayout.setOnClickListener(view -> {
|
editLayout.setOnClickListener(view -> {
|
||||||
|
@ -390,17 +393,10 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteProfile(KeyProfile profile) {
|
private void deleteProfile(KeyProfile profile) {
|
||||||
new AlertDialog.Builder(MainActivity.this)
|
_db.removeKey(profile.getEntry());
|
||||||
.setTitle("Delete entry")
|
saveDatabase();
|
||||||
.setMessage("Are you sure you want to delete this profile?")
|
|
||||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
|
||||||
_db.removeKey(profile.getEntry());
|
|
||||||
saveDatabase();
|
|
||||||
|
|
||||||
_keyProfileView.removeKey(profile);
|
_keyProfileView.removeKey(profile);
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.no, null)
|
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
20
app/src/main/java/me/impy/aegis/ui/dialogs/Dialogs.java
Normal file
20
app/src/main/java/me/impy/aegis/ui/dialogs/Dialogs.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package me.impy.aegis.ui.dialogs;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
|
||||||
|
public class Dialogs {
|
||||||
|
private Dialogs() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AlertDialog showDeleteEntryDialog(Context context, DialogInterface.OnClickListener onDelete) {
|
||||||
|
return new AlertDialog.Builder(context)
|
||||||
|
.setTitle("Delete entry")
|
||||||
|
.setMessage("Are you sure you want to delete this entry?")
|
||||||
|
.setPositiveButton(android.R.string.yes, onDelete)
|
||||||
|
.setNegativeButton(android.R.string.no, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue