Code Monkey home page Code Monkey logo

Comments (2)

valch avatar valch commented on August 13, 2024

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

from upm-android.

appatalks avatar appatalks commented on August 13, 2024

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.

from upm-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.