Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Long Press Delete Account on Context Menu #16

Closed
appatalks opened this issue May 29, 2013 · 2 comments
Closed

Feature Request: Long Press Delete Account on Context Menu #16

appatalks opened this issue May 29, 2013 · 2 comments

Comments

@appatalks
Copy link

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

@valch
Copy link

valch commented May 29, 2013

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

@appatalks
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants