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
diff --git a/app/src/main/java/org/lineageos/updater/UpdatesListAdapter.java b/app/src/main/java/org/lineageos/updater/UpdatesListAdapter.java
index e01825d..0956449 100644
--- a/app/src/main/java/org/lineageos/updater/UpdatesListAdapter.java
+++ b/app/src/main/java/org/lineageos/updater/UpdatesListAdapter.java
@@ -532,11 +532,15 @@
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();