Updater: Minor UI improvements
Change-Id: I5028aaa154991806ab911be0119fed0836e6851b
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
<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="#FF000000"
|
||||
android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2zM17,15.59L15.59,17 12,13.41 8.41,17 7,15.59 10.59,12 7,8.41 8.41,7 12,10.59 15.59,7 17,8.41 13.41,12 17,15.59z"/>
|
||||
</vector>
|
@@ -1,9 +0,0 @@
|
||||
<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,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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="#FF000000"
|
||||
android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z"/>
|
||||
</vector>
|
@@ -1,9 +0,0 @@
|
||||
<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="#FF000000"
|
||||
android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z"/>
|
||||
</vector>
|
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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="#FF000000"
|
||||
android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z"/>
|
||||
</vector>
|
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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="#FF000000"
|
||||
android:pathData="M8,5v14l11,-7z"/>
|
||||
</vector>
|
@@ -43,7 +43,7 @@
|
||||
android:textSize="56sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/header_build_date"
|
||||
android:id="@+id/header_build_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/header_title"
|
||||
@@ -51,10 +51,10 @@
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/header_build_version"
|
||||
android:id="@+id/header_build_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/header_build_date"
|
||||
android:layout_below="@id/header_build_version"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
android:id="@+id/header_last_check"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/header_build_version"
|
||||
android:layout_below="@id/header_build_date"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="12sp" />
|
||||
</RelativeLayout>
|
||||
|
@@ -1,105 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/card_view"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
android:nextFocusRight="@+id/update_action">
|
||||
android:nextFocusRight="@+id/update_action"
|
||||
app:cardCornerRadius="0dp"
|
||||
app:contentPadding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:weightSum="1">
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/build_layout_not_active"
|
||||
<TextView
|
||||
android:id="@+id/build_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.87"
|
||||
android:drawablePadding="8dp"
|
||||
android:maxLines="1"
|
||||
android:paddingBottom="8sp"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"
|
||||
tools:text="LineageOS 15.1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/build_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:textSize="14sp"
|
||||
tools:text="29 February 2018" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true">
|
||||
android:paddingTop="8dp"
|
||||
android:visibility="gone"
|
||||
tools:progress="65"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/build_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="8sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/build_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/build_version" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/build_layout_active"
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:id="@+id/progress_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="invisible">
|
||||
android:ellipsize="marquee"
|
||||
android:singleLine="true"
|
||||
tools:text="162 of 300 MB (3 minutes left) • 65%" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/build_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/build_info"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:progress="30" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progress_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/progress_bar"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progress_percentage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@id/progress_bar"
|
||||
android:textSize="12sp" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageButton
|
||||
android:id="@id/update_action"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/action_description_download"
|
||||
android:nextFocusLeft="@id/card_view"
|
||||
android:src="@drawable/ic_download" />
|
||||
</RelativeLayout>
|
||||
<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>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
@@ -83,18 +83,18 @@
|
||||
|
||||
<string name="list_build_version">LineageOS <xliff:g id="version" example="14.1">%1$s</xliff:g></string>
|
||||
<string name="list_build_version_date">LineageOS <xliff:g id="version" example="14.1">%1$s</xliff:g> - <xliff:g id="date" example="July 11, 2017">%2$s</xliff:g></string>
|
||||
<string name="list_download_progress"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g></string>
|
||||
<string name="list_download_progress_eta"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g> - <xliff:g id="duration" example="3 minutes">%3$s</xliff:g> left</string>
|
||||
<string name="list_download_progress_new"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g> • <xliff:g id="percentage" example="56">%3$s</xliff:g></string>
|
||||
<string name="list_download_progress_eta_new"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g> (<xliff:g id="duration" example="3 minutes">%3$s</xliff:g> left) • <xliff:g id="percentage" example="56">%4$s</xliff:g></string>
|
||||
<string name="list_verifying_update">Verifying update</string>
|
||||
<string name="list_no_updates">No new updates found. To manually check for new updates, use the Refresh button.</string>
|
||||
|
||||
<string name="action_description_download">Download</string>
|
||||
<string name="action_description_pause">Pause download</string>
|
||||
<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="action_description_cancel">Cancel installation</string>
|
||||
<string name="action_download">Download</string>
|
||||
<string name="action_pause">Pause</string>
|
||||
<string name="action_resume">Resume</string>
|
||||
<string name="action_install">Install</string>
|
||||
<string name="action_info">Info</string>
|
||||
<string name="action_delete">Delete</string>
|
||||
<string name="action_cancel">Cancel</string>
|
||||
|
||||
<string name="confirm_delete_dialog_title">Delete file</string>
|
||||
<string name="confirm_delete_dialog_message">Delete the selected update file?</string>
|
||||
|
@@ -151,7 +151,7 @@ public class ExportUpdateService extends Service {
|
||||
notificationStyle.bigText(destination.getName());
|
||||
notificationBuilder.setStyle(notificationStyle);
|
||||
notificationBuilder.setSmallIcon(R.drawable.ic_system_update);
|
||||
notificationBuilder.addAction(R.drawable.ic_pause,
|
||||
notificationBuilder.addAction(com.android.internal.R.drawable.ic_media_pause,
|
||||
getString(android.R.string.cancel),
|
||||
getStopPendingIntent());
|
||||
|
||||
|
@@ -35,8 +35,8 @@ import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
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;
|
||||
|
||||
@@ -78,31 +78,23 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageButton mAction;
|
||||
private Button mAction;
|
||||
|
||||
private View mNotActiveLayout;
|
||||
private TextView mBuildDate;
|
||||
private TextView mBuildVersion;
|
||||
|
||||
private View mActiveLayout;
|
||||
private TextView mBuildInfo;
|
||||
private ProgressBar mProgressBar;
|
||||
private TextView mProgressText;
|
||||
private TextView mProgressPercentage;
|
||||
|
||||
public ViewHolder(final View view) {
|
||||
super(view);
|
||||
mAction = (ImageButton) view.findViewById(R.id.update_action);
|
||||
mAction = (Button) view.findViewById(R.id.update_action);
|
||||
|
||||
mNotActiveLayout = view.findViewById(R.id.build_layout_not_active);
|
||||
mBuildDate = (TextView) view.findViewById(R.id.build_date);
|
||||
mBuildVersion = (TextView) view.findViewById(R.id.build_version);
|
||||
|
||||
mActiveLayout = view.findViewById(R.id.build_layout_active);
|
||||
mBuildInfo = (TextView) view.findViewById(R.id.build_info);
|
||||
mProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
|
||||
mProgressText = (TextView) view.findViewById(R.id.progress_text);
|
||||
mProgressPercentage = (TextView) view.findViewById(R.id.progress_percentage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,12 +119,6 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
}
|
||||
|
||||
private void handleActiveStatus(ViewHolder viewHolder, UpdateInfo update) {
|
||||
String buildDate = StringGenerator.getDateLocalizedUTC(mActivity,
|
||||
DateFormat.MEDIUM, update.getTimestamp());
|
||||
String buildInfoText = mActivity.getString(R.string.list_build_version_date,
|
||||
BuildInfoUtils.getBuildVersion(), buildDate);
|
||||
viewHolder.mBuildInfo.setText(buildInfoText);
|
||||
|
||||
boolean canDelete = false;
|
||||
|
||||
final String downloadId = update.getDownloadId();
|
||||
@@ -141,21 +127,21 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
String downloaded = StringGenerator.bytesToMegabytes(mActivity,
|
||||
update.getFile().length());
|
||||
String total = Formatter.formatShortFileSize(mActivity, update.getFileSize());
|
||||
String percentage = NumberFormat.getPercentInstance().format(
|
||||
update.getProgress() / 100.f);
|
||||
long eta = update.getEta();
|
||||
if (eta > 0) {
|
||||
CharSequence etaString = StringGenerator.formatDuration(mActivity, eta * 1000);
|
||||
viewHolder.mProgressText.setText(mActivity.getString(
|
||||
R.string.list_download_progress_eta, downloaded, total, etaString));
|
||||
R.string.list_download_progress_eta_new, downloaded, total, etaString,
|
||||
percentage));
|
||||
} else {
|
||||
viewHolder.mProgressText.setText(mActivity.getString(
|
||||
R.string.list_download_progress, downloaded, total));
|
||||
R.string.list_download_progress_new, downloaded, total, percentage));
|
||||
}
|
||||
setButtonAction(viewHolder.mAction, Action.PAUSE, downloadId, true);
|
||||
viewHolder.mProgressBar.setIndeterminate(update.getStatus() == UpdateStatus.STARTING);
|
||||
viewHolder.mProgressBar.setProgress(update.getProgress());
|
||||
String percentage = NumberFormat.getPercentInstance().format(
|
||||
update.getProgress() / 100.f);
|
||||
viewHolder.mProgressPercentage.setText(percentage);
|
||||
} else if (mUpdaterController.isInstallingUpdate(downloadId)) {
|
||||
setButtonAction(viewHolder.mAction, Action.CANCEL_INSTALLATION, downloadId, true);
|
||||
boolean notAB = !mUpdaterController.isInstallingABUpdate();
|
||||
@@ -164,38 +150,31 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
R.string.finalizing_package :
|
||||
R.string.preparing_ota_first_boot);
|
||||
viewHolder.mProgressBar.setProgress(update.getInstallProgress());
|
||||
String percentage = NumberFormat.getPercentInstance().format(
|
||||
update.getInstallProgress() / 100.f);
|
||||
viewHolder.mProgressPercentage.setText(percentage);
|
||||
} else if (mUpdaterController.isVerifyingUpdate(downloadId)) {
|
||||
setButtonAction(viewHolder.mAction, Action.INSTALL, downloadId, false);
|
||||
viewHolder.mProgressText.setText(R.string.list_verifying_update);
|
||||
viewHolder.mProgressBar.setIndeterminate(true);
|
||||
viewHolder.mProgressPercentage.setText(NumberFormat.getPercentInstance().format(1));
|
||||
} else {
|
||||
canDelete = true;
|
||||
setButtonAction(viewHolder.mAction, Action.RESUME, downloadId, !isBusy());
|
||||
String downloaded = StringGenerator.bytesToMegabytes(mActivity,
|
||||
update.getFile().length());
|
||||
String total = Formatter.formatShortFileSize(mActivity, update.getFileSize());
|
||||
viewHolder.mProgressText.setText(mActivity.getString(R.string.list_download_progress,
|
||||
downloaded, total));
|
||||
String percentage = NumberFormat.getPercentInstance().format(
|
||||
update.getProgress() / 100.f);
|
||||
viewHolder.mProgressText.setText(mActivity.getString(R.string.list_download_progress_new,
|
||||
downloaded, total, percentage));
|
||||
viewHolder.mProgressBar.setIndeterminate(false);
|
||||
viewHolder.mProgressBar.setProgress(update.getProgress());
|
||||
}
|
||||
|
||||
viewHolder.itemView.setOnLongClickListener(getLongClickListener(update, canDelete,
|
||||
viewHolder.mBuildDate));
|
||||
viewHolder.mProgressBar.setVisibility(View.VISIBLE);
|
||||
viewHolder.mProgressText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void handleNotActiveStatus(ViewHolder viewHolder, UpdateInfo update) {
|
||||
String buildDate = StringGenerator.getDateLocalizedUTC(mActivity,
|
||||
DateFormat.LONG, update.getTimestamp());
|
||||
String buildVersion = mActivity.getString(R.string.list_build_version,
|
||||
update.getVersion());
|
||||
viewHolder.mBuildDate.setText(buildDate);
|
||||
viewHolder.mBuildVersion.setText(buildVersion);
|
||||
|
||||
if (update.getPersistentStatus() == UpdateStatus.Persistent.VERIFIED) {
|
||||
viewHolder.itemView.setOnLongClickListener(
|
||||
getLongClickListener(update, true, viewHolder.mBuildDate));
|
||||
@@ -211,6 +190,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
getLongClickListener(update, false, viewHolder.mBuildDate));
|
||||
setButtonAction(viewHolder.mAction, Action.DOWNLOAD, update.getDownloadId(), !isBusy());
|
||||
}
|
||||
viewHolder.mProgressBar.setVisibility(View.GONE);
|
||||
viewHolder.mProgressText.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -225,7 +206,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
if (update == null) {
|
||||
// The update was deleted
|
||||
viewHolder.mAction.setEnabled(false);
|
||||
viewHolder.mAction.setImageResource(R.drawable.ic_download);
|
||||
viewHolder.mAction.setText(R.string.action_download);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -246,14 +227,18 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
throw new RuntimeException("Unknown update status");
|
||||
}
|
||||
|
||||
String buildDate = StringGenerator.getDateLocalizedUTC(mActivity,
|
||||
DateFormat.LONG, update.getTimestamp());
|
||||
String buildVersion = mActivity.getString(R.string.list_build_version,
|
||||
update.getVersion());
|
||||
viewHolder.mBuildDate.setText(buildDate);
|
||||
viewHolder.mBuildVersion.setText(buildVersion);
|
||||
viewHolder.mBuildVersion.setCompoundDrawables(null, null, null, null);
|
||||
|
||||
if (activeLayout) {
|
||||
handleActiveStatus(viewHolder, update);
|
||||
viewHolder.mActiveLayout.setVisibility(View.VISIBLE);
|
||||
viewHolder.mNotActiveLayout.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
handleNotActiveStatus(viewHolder, update);
|
||||
viewHolder.mActiveLayout.setVisibility(View.INVISIBLE);
|
||||
viewHolder.mNotActiveLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +278,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
.setTitle(R.string.update_on_mobile_data_title)
|
||||
.setMessage(R.string.update_on_mobile_data_message)
|
||||
.setView(checkboxView)
|
||||
.setPositiveButton(R.string.action_description_download,
|
||||
.setPositiveButton(R.string.action_download,
|
||||
(dialog, which) -> {
|
||||
if (checkbox.isChecked()) {
|
||||
preferences.edit()
|
||||
@@ -307,29 +292,23 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
.show();
|
||||
}
|
||||
|
||||
private void setButtonAction(ImageButton button, Action action, final String downloadId,
|
||||
private void setButtonAction(Button button, Action action, final String downloadId,
|
||||
boolean enabled) {
|
||||
final View.OnClickListener clickListener;
|
||||
switch (action) {
|
||||
case DOWNLOAD:
|
||||
button.setImageResource(R.drawable.ic_download);
|
||||
button.setContentDescription(
|
||||
mActivity.getString(R.string.action_description_download));
|
||||
button.setText(R.string.action_download);
|
||||
button.setEnabled(enabled);
|
||||
clickListener = enabled ? view -> startDownloadWithWarning(downloadId) : null;
|
||||
break;
|
||||
case PAUSE:
|
||||
button.setImageResource(R.drawable.ic_pause);
|
||||
button.setContentDescription(
|
||||
mActivity.getString(R.string.action_description_pause));
|
||||
button.setText(R.string.action_pause);
|
||||
button.setEnabled(enabled);
|
||||
clickListener = enabled ? view -> mUpdaterController.pauseDownload(downloadId)
|
||||
: null;
|
||||
break;
|
||||
case RESUME: {
|
||||
button.setImageResource(R.drawable.ic_resume);
|
||||
button.setContentDescription(
|
||||
mActivity.getString(R.string.action_description_resume));
|
||||
button.setText(R.string.action_resume);
|
||||
button.setEnabled(enabled);
|
||||
UpdateInfo update = mUpdaterController.getUpdate(downloadId);
|
||||
final boolean canInstall = Utils.canInstall(update) ||
|
||||
@@ -345,9 +324,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
}
|
||||
break;
|
||||
case INSTALL: {
|
||||
button.setImageResource(R.drawable.ic_system_update);
|
||||
button.setContentDescription(
|
||||
mActivity.getString(R.string.action_description_install));
|
||||
button.setText(R.string.action_install);
|
||||
button.setEnabled(enabled);
|
||||
UpdateInfo update = mUpdaterController.getUpdate(downloadId);
|
||||
final boolean canInstall = Utils.canInstall(update);
|
||||
@@ -362,24 +339,19 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
||||
}
|
||||
break;
|
||||
case INFO: {
|
||||
button.setImageResource(R.drawable.ic_info);
|
||||
button.setContentDescription(mActivity.getString(R.string.action_description_info));
|
||||
button.setText(R.string.action_info);
|
||||
button.setEnabled(enabled);
|
||||
clickListener = enabled ? view -> showInfoDialog() : null;
|
||||
}
|
||||
break;
|
||||
case DELETE: {
|
||||
button.setImageResource(R.drawable.ic_delete_black);
|
||||
button.setContentDescription(
|
||||
mActivity.getString(R.string.action_description_delete));
|
||||
button.setText(R.string.action_delete);
|
||||
button.setEnabled(enabled);
|
||||
clickListener = enabled ? view -> getDeleteDialog(downloadId).show() : null;
|
||||
}
|
||||
break;
|
||||
case CANCEL_INSTALLATION: {
|
||||
button.setImageResource(R.drawable.ic_cancel);
|
||||
button.setContentDescription(
|
||||
mActivity.getString(R.string.action_description_cancel));
|
||||
button.setText(R.string.action_cancel);
|
||||
button.setEnabled(enabled);
|
||||
clickListener = enabled ? view -> getCancelInstallationDialog().show() : null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user