Implement delete functionality of EditProfileActivity

This commit is contained in:
Alexander Bakker 2018-01-01 22:53:10 +01:00
parent 97f3d9e2c6
commit 7bc4f19cf0
2 changed files with 20 additions and 6 deletions

View file

@ -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;
}

View file

@ -369,9 +369,17 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen
return;
}
_keyProfileView.replaceKey(profile);
// 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();
}
}
}
private void onEnterKeyInfoResult(int resultCode, Intent data) {
if (resultCode == RESULT_OK) {