Skip to content

Commit

Permalink
Merge pull request #3272 from deltachat/adb/issue-3266
Browse files Browse the repository at this point in the history
allow to delete selected account
  • Loading branch information
adbenitez authored Aug 30, 2024
2 parents fd8311c + bfb1fc0 commit 8ef136d
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMen
int accountId = listItem.getAccountId();
DcAccounts dcAccounts = DcHelper.getAccounts(getActivity());

if (accountId == dcAccounts.getSelectedAccount().getAccountId()) {
menu.findItem(R.id.delete).setVisible(false);
} else {
Util.redMenuItem(menu, R.id.delete);
}
Util.redMenuItem(menu, R.id.delete);

if (dcAccounts.getAccount(accountId).isMuted()) {
menu.findItem(R.id.menu_mute_notifications).setTitle(R.string.menu_unmute);
Expand Down Expand Up @@ -122,9 +118,15 @@ private void onDeleteAccount(int accountId) {
.setMessage(R.string.forget_login_confirmation_desktop)
.setNegativeButton(R.string.cancel, (d, which) -> AccountManager.getInstance().showSwitchAccountMenu(activity))
.setPositiveButton(R.string.delete, (d2, which2) -> {
boolean selected = accountId == accounts.getSelectedAccount().getAccountId();
DcHelper.getNotificationCenter(activity).removeAllNotifiations(accountId);
accounts.removeAccount(accountId);
AccountManager.getInstance().showSwitchAccountMenu(activity);
if (selected) {
DcContext selAcc = accounts.getSelectedAccount();
AccountManager.getInstance().switchAccountAndStartActivity(activity, selAcc.isOk()? selAcc.getAccountId() : 0);
} else {
AccountManager.getInstance().showSwitchAccountMenu(activity);
}
})
.show();
Util.redPositiveButton(dialog);
Expand Down

0 comments on commit 8ef136d

Please sign in to comment.