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

Commit 8c9976d6 authored by Gabriele M's avatar Gabriele M
Browse files

Show delete button for old updates

Old updates can't be installed if the current build is newer, so show
a delete button instead.

Change-Id: Ib34aad31d93e87a1009c23f86686fc4a008129e7
parent 9dc1349c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#000000"
        android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
</vector>
+1 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@
    <string name="action_description_resume">Resume download</string>
    <string name="action_description_install">Install update</string>
    <string name="action_description_info">Show information</string>
    <string name="action_description_delete">Delete update</string>

    <string name="confirm_delete_dialog_title">Delete file</string>
    <string name="confirm_delete_dialog_message">Delete the selected update file?</string>
+17 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
        RESUME,
        INSTALL,
        INFO,
        DELETE,
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
@@ -189,7 +190,9 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.

        if (update.getPersistentStatus() == UpdateStatus.Persistent.VERIFIED) {
            viewHolder.itemView.setOnLongClickListener(getLongClickListener(update, true));
            setButtonAction(viewHolder.mAction, Action.INSTALL, update.getDownloadId(), !isBusy());
            setButtonAction(viewHolder.mAction,
                    Utils.canInstall(update) ? Action.INSTALL : Action.DELETE,
                    update.getDownloadId(), !isBusy());
        } else if (!Utils.canInstall(update)) {
            viewHolder.itemView.setOnLongClickListener(getLongClickListener(update, false));
            setButtonAction(viewHolder.mAction, Action.INFO, update.getDownloadId(), !isBusy());
@@ -377,6 +380,19 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
                };
            }
            break;
            case DELETE: {
                button.setImageResource(R.drawable.ic_delete_black);
                button.setContentDescription(
                        mActivity.getString(R.string.action_description_delete));
                button.setEnabled(enabled);
                clickListener = !enabled ? null : new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        getDeleteDialog(downloadId).show();
                    }
                };
            }
            break;
            default:
                clickListener = null;
        }