upm-android icon indicating copy to clipboard operation
upm-android copied to clipboard

Feature Request: Long Press Delete Account on Context Menu

Open appatalks opened this issue 11 years ago • 2 comments

Option to Delete Account from the List View from on the Account Context Menu Thank you!

appatalks avatar May 29 '13 05:05 appatalks

I will give it a try...I'm going to update soon.

valch avatar May 29 '13 18:05 valch

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.

appatalks avatar Jun 06 '13 14:06 appatalks