Closed appatalks closed 1 year ago
I will give it a try...I'm going to update soon.
I believe I found the relevant code aside from the account_context_menu.xml to add the option on screen, and I believe AccountsList.java where we should execute the code under the"case R.id.edit_account:" code.
In ViewAccountDetails.jave is where I found reference to actually deleting an account.
case R.id.delete:
if (Utilities.isSyncRequired(this)) {
UIUtilities.showToast(this, R.string.sync_required);
} else {
showDialog(CONFIRM_DELETE_DIALOG);
}
break;
}
return optionConsumed;
}
@Override
protected Dialog onCreateDialog(int id) {
Dialog dialog = null;
switch(id) {
case CONFIRM_DELETE_DIALOG:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure?")
.setTitle("Confirm Delete")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
getPasswordDatabase().deleteAccount(account.getAccountName());
final String accountName = account.getAccountName();
new SaveDatabaseAsyncTask(ViewAccountDetails.this, new Callback() {
@Override
public void execute() {
String message = String.format(getString(R.string.account_deleted), accountName);
Toast.makeText(ViewAccountDetails.this, message, Toast.LENGTH_SHORT).show();
//Â Set this flag so that when we're returned to the FullAccountList
// activity the list is refreshed
ViewAccountDetails.this.setResult(AddEditAccount.EDIT_ACCOUNT_RESULT_CODE_TRUE);
finish();
}
}).execute(getPasswordDatabase());
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
dialog = builder.create();
}
return dialog;
}
But since this is calling it from the account its already in, I'm not sure how to make it call the same account from AccountsList.
Option to Delete Account from the List View from on the Account Context Menu Thank you!