Updater: Don't show delete twice

* If an update exists and can be deleted, the action button AND the
  popup menu both show the delete action
* By checking wether the action already shows "Delete" we can hide
  that action from the submenu
* Additionally check for online availability to only hide it when it's
  not the last item - otherwise a click on the menu icon wouldn't do
  anything

Change-Id: Idc5da3962be4e0a69847f47b3c5f014b251bd438
This commit is contained in:
Michael W
2023-06-18 16:22:39 +02:00
committed by Nolen Johnson
parent 613fbacdbf
commit 185b5de51d

View File

@@ -532,11 +532,15 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
R.attr.actionOverflowMenuStyle, 0);
popupMenu.inflate(R.menu.menu_action_mode);
boolean shouldShowDelete = canDelete;
boolean isVerified = update.getPersistentStatus() == UpdateStatus.Persistent.VERIFIED;
if (isVerified && !Utils.canInstall(update) && !update.getAvailableOnline()) {
shouldShowDelete = false;
}
MenuBuilder menu = (MenuBuilder) popupMenu.getMenu();
menu.findItem(R.id.menu_delete_action).setVisible(canDelete);
menu.findItem(R.id.menu_delete_action).setVisible(shouldShowDelete);
menu.findItem(R.id.menu_copy_url).setVisible(update.getAvailableOnline());
menu.findItem(R.id.menu_export_update).setVisible(
update.getPersistentStatus() == UpdateStatus.Persistent.VERIFIED);
menu.findItem(R.id.menu_export_update).setVisible(isVerified);
popupMenu.setOnMenuItemClickListener(item -> {
int itemId = item.getItemId();