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
This commit is contained in:
Gabriele M
2017-11-12 11:05:53 +01:00
parent 9dc1349c1a
commit 8c9976d622
3 changed files with 27 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
<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>

View File

@@ -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>

View File

@@ -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;
}