Updater: Add a 3-dot menu for update item
Author: Timi Rautamaki <timi.rautamaki@gmail.com> Date: Wed Oct 13 16:06:51 2021 +0000 Updater: add a 3-dot menu for update item A menu opening with only a long press is not intuitive and often not found by user. Change-Id: I7f819b77e2cbc534cafe488edadc4d3dd9b87d01 Author: Luca Stefani <luca.stefani.ge1@gmail.com> Date: Mon Nov 1 21:01:11 2021 +0100 fixup! Updater: add a 3-dot menu for update item Change-Id: I10fe453c5f14d1a0ca49b734df517047cb7ee802 Change-Id: I8abf95327906bd6d3fb98978b931418f15d3dd00
This commit is contained in:
committed by
Nolen Johnson
parent
ad604c69e4
commit
c8ae33d9ba
@@ -80,12 +80,24 @@
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@id/update_action"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
tools:text="Pause" />
|
||||
android:orientation="vertical">
|
||||
<ImageButton
|
||||
android:id="@+id/update_menu"
|
||||
style="?android:attr/actionOverflowButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:padding="8dp" />
|
||||
<Button
|
||||
android:id="@id/update_action"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
tools:text="Pause" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@@ -79,12 +79,24 @@
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@id/update_action"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
tools:text="Pause" />
|
||||
android:orientation="vertical">
|
||||
<ImageButton
|
||||
android:id="@+id/update_menu"
|
||||
style="?android:attr/actionOverflowButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:padding="8dp" />
|
||||
<Button
|
||||
android:id="@id/update_action"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
tools:text="Pause" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -93,6 +94,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private Button mAction;
|
||||
private ImageButton mMenu;
|
||||
|
||||
private TextView mBuildDate;
|
||||
private TextView mBuildVersion;
|
||||
@@ -104,6 +106,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
public ViewHolder(final View view) {
|
||||
super(view);
|
||||
mAction = (Button) view.findViewById(R.id.update_action);
|
||||
mMenu = (ImageButton) view.findViewById(R.id.update_menu);
|
||||
|
||||
mBuildDate = (TextView) view.findViewById(R.id.build_date);
|
||||
mBuildVersion = (TextView) view.findViewById(R.id.build_version);
|
||||
@@ -194,8 +197,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
viewHolder.mProgressBar.setProgress(update.getProgress());
|
||||
}
|
||||
|
||||
viewHolder.itemView.setOnLongClickListener(getLongClickListener(update, canDelete,
|
||||
viewHolder.mBuildDate));
|
||||
viewHolder.mMenu.setOnClickListener(getClickListener(update, canDelete, viewHolder.mMenu));
|
||||
viewHolder.mProgressBar.setVisibility(View.VISIBLE);
|
||||
viewHolder.mProgressText.setVisibility(View.VISIBLE);
|
||||
viewHolder.mBuildSize.setVisibility(View.INVISIBLE);
|
||||
@@ -204,22 +206,18 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
private void handleNotActiveStatus(ViewHolder viewHolder, UpdateInfo update) {
|
||||
final String downloadId = update.getDownloadId();
|
||||
if (mUpdaterController.isWaitingForReboot(downloadId)) {
|
||||
viewHolder.itemView.setOnLongClickListener(
|
||||
getLongClickListener(update, false, viewHolder.mBuildDate));
|
||||
viewHolder.mMenu.setOnClickListener(getClickListener(update, false, viewHolder.mMenu));
|
||||
setButtonAction(viewHolder.mAction, Action.REBOOT, downloadId, true);
|
||||
} else if (update.getPersistentStatus() == UpdateStatus.Persistent.VERIFIED) {
|
||||
viewHolder.itemView.setOnLongClickListener(
|
||||
getLongClickListener(update, true, viewHolder.mBuildDate));
|
||||
viewHolder.mMenu.setOnClickListener(getClickListener(update, true, viewHolder.mMenu));
|
||||
setButtonAction(viewHolder.mAction,
|
||||
Utils.canInstall(update) ? Action.INSTALL : Action.DELETE,
|
||||
downloadId, !isBusy());
|
||||
} else if (!Utils.canInstall(update)) {
|
||||
viewHolder.itemView.setOnLongClickListener(
|
||||
getLongClickListener(update, false, viewHolder.mBuildDate));
|
||||
viewHolder.mMenu.setOnClickListener(getClickListener(update, false, viewHolder.mMenu));
|
||||
setButtonAction(viewHolder.mAction, Action.INFO, downloadId, !isBusy());
|
||||
} else {
|
||||
viewHolder.itemView.setOnLongClickListener(
|
||||
getLongClickListener(update, false, viewHolder.mBuildDate));
|
||||
viewHolder.mMenu.setOnClickListener(getClickListener(update, false, viewHolder.mMenu));
|
||||
setButtonAction(viewHolder.mAction, Action.DOWNLOAD, downloadId, !isBusy());
|
||||
}
|
||||
String fileSize = Formatter.formatShortFileSize(mActivity, update.getFileSize());
|
||||
@@ -438,11 +436,10 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
.setNegativeButton(android.R.string.cancel, null);
|
||||
}
|
||||
|
||||
private View.OnLongClickListener getLongClickListener(final UpdateInfo update,
|
||||
private View.OnClickListener getClickListener(final UpdateInfo update,
|
||||
final boolean canDelete, View anchor) {
|
||||
return view -> {
|
||||
startActionMode(update, canDelete, anchor);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user