Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 185b5de5 authored by Michael W's avatar Michael W Committed by Nolen Johnson
Browse files

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
parent 613fbacd
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -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();