diff --git a/app/src/main/java/me/impy/aegis/EditProfileActivity.java b/app/src/main/java/me/impy/aegis/EditProfileActivity.java index c6e2de4e..b01d411b 100644 --- a/app/src/main/java/me/impy/aegis/EditProfileActivity.java +++ b/app/src/main/java/me/impy/aegis/EditProfileActivity.java @@ -153,8 +153,17 @@ public class EditProfileActivity extends AegisActivity { return true; } + private void finish(boolean delete) { + Intent intent = new Intent(); + intent.putExtra("KeyProfile", _profile); + intent.putExtra("delete", delete); + setResult(RESULT_OK, intent); + finish(); + } + private boolean onDelete() { - return false; + finish(true); + return true; } private boolean onSave() { @@ -200,10 +209,7 @@ public class EditProfileActivity extends AegisActivity { return false; } - Intent intent = new Intent(); - intent.putExtra("KeyProfile", _profile); - setResult(RESULT_OK, intent); - finish(); + finish(false); return true; } diff --git a/app/src/main/java/me/impy/aegis/MainActivity.java b/app/src/main/java/me/impy/aegis/MainActivity.java index db53584b..baf9e560 100644 --- a/app/src/main/java/me/impy/aegis/MainActivity.java +++ b/app/src/main/java/me/impy/aegis/MainActivity.java @@ -369,7 +369,15 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen return; } _keyProfileView.replaceKey(profile); - saveDatabase(); + + // because of what's explained in the comment above, we had to replace the key before we can delete it + // this is an ugly solution and should be improved at some point + // TODO: make _db.removeKey and _db.replaceKey -> _db.updateKey work with id's instead of instances + if (data.getBooleanExtra("delete", false)) { + deleteProfile(profile); + } else { + saveDatabase(); + } } }