Updater: Move progress next to progressbar
Author: Michael W <baddaemon87@gmail.com> Date: Fri Feb 11 18:16:02 2022 +0100 Updater: Move progress next to progressbar * The progress text can get very long, resulting in jumping marquee text * In order to reduce the length, move the percentage out of the text and next to the progressbar * The behavior can be observed e.g. on pro1 in german, where the button is also wider due to the german text Change-Id: I0276182efed757c0929b31434edad9be548b841c Author: Timi Rautamäki <timi.rautamaki@gmail.com> Date: Thu Mar 3 16:12:16 2022 +0000 fixup! Updater: Move progress next to progressbar Fix crash on ATV devices by applying same layout changes to layout-large-notouch. Change-Id: Id6eabcf8b1960106eb63bd15bcf97f9b4cf0bbc8 Change-Id: I8aed4c35c6ac4261c0536a6b263d63f5b1fd11ba
This commit is contained in:
@@ -49,25 +49,40 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ProgressBar
|
<LinearLayout
|
||||||
android:id="@+id/progress_bar"
|
|
||||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="4sp"
|
android:id="@+id/progress"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
tools:progress="65"
|
tools:visibility="visible">
|
||||||
tools:visibility="visible" />
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="4sp"
|
||||||
|
tools:progress="65" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/progress_percent"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
tools:text="65%" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/progress_text"
|
android:id="@+id/progress_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/progress_bar"
|
android:layout_below="@id/progress"
|
||||||
android:ellipsize="marquee"
|
android:ellipsize="marquee"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
tools:text="162 of 300 MB (3 minutes left) • 65%"
|
tools:text="162 of 300 MB (3 minutes left)"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@@ -48,25 +48,40 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ProgressBar
|
<LinearLayout
|
||||||
android:id="@+id/progress_bar"
|
|
||||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="4sp"
|
android:id="@+id/progress"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
tools:progress="65"
|
tools:visibility="visible">
|
||||||
tools:visibility="visible" />
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="4sp"
|
||||||
|
tools:progress="65" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/progress_percent"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
tools:text="65%" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/progress_text"
|
android:id="@+id/progress_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/progress_bar"
|
android:layout_below="@id/progress"
|
||||||
android:ellipsize="marquee"
|
android:ellipsize="marquee"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
tools:text="162 of 300 MB (3 minutes left) • 65%"
|
tools:text="162 of 300 MB (3 minutes left)"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@@ -96,8 +96,8 @@
|
|||||||
|
|
||||||
<string name="list_build_version">LineageOS <xliff:g id="version" example="14.1">%1$s</xliff:g></string>
|
<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_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_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_newer"><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_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="eta" example="3 minutes left">%3$s</xliff:g>) • <xliff:g id="percentage" example="56">%4$s</xliff:g></string>
|
<string name="list_download_progress_eta_newer"><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="eta" example="3 minutes left">%3$s</xliff:g>)</string>
|
||||||
<string name="list_verifying_update">Verifying update</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="list_no_updates">No new updates found. To manually check for new updates, use the Refresh button.</string>
|
||||||
|
|
||||||
|
@@ -37,6 +37,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -104,8 +105,10 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
|||||||
private final TextView mBuildVersion;
|
private final TextView mBuildVersion;
|
||||||
private final TextView mBuildSize;
|
private final TextView mBuildSize;
|
||||||
|
|
||||||
|
private final LinearLayout mProgress;
|
||||||
private final ProgressBar mProgressBar;
|
private final ProgressBar mProgressBar;
|
||||||
private final TextView mProgressText;
|
private final TextView mProgressText;
|
||||||
|
private final TextView mPercentage;
|
||||||
|
|
||||||
public ViewHolder(final View view) {
|
public ViewHolder(final View view) {
|
||||||
super(view);
|
super(view);
|
||||||
@@ -116,8 +119,10 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
|||||||
mBuildVersion = view.findViewById(R.id.build_version);
|
mBuildVersion = view.findViewById(R.id.build_version);
|
||||||
mBuildSize = view.findViewById(R.id.build_size);
|
mBuildSize = view.findViewById(R.id.build_size);
|
||||||
|
|
||||||
|
mProgress = view.findViewById(R.id.progress);
|
||||||
mProgressBar = view.findViewById(R.id.progress_bar);
|
mProgressBar = view.findViewById(R.id.progress_bar);
|
||||||
mProgressText = view.findViewById(R.id.progress_text);
|
mProgressText = view.findViewById(R.id.progress_text);
|
||||||
|
mPercentage = view.findViewById(R.id.progress_percent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,15 +167,15 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
|||||||
String total = Formatter.formatShortFileSize(mActivity, update.getFileSize());
|
String total = Formatter.formatShortFileSize(mActivity, update.getFileSize());
|
||||||
String percentage = NumberFormat.getPercentInstance().format(
|
String percentage = NumberFormat.getPercentInstance().format(
|
||||||
update.getProgress() / 100.f);
|
update.getProgress() / 100.f);
|
||||||
|
viewHolder.mPercentage.setText(percentage);
|
||||||
long eta = update.getEta();
|
long eta = update.getEta();
|
||||||
if (eta > 0) {
|
if (eta > 0) {
|
||||||
CharSequence etaString = StringGenerator.formatETA(mActivity, eta * 1000);
|
CharSequence etaString = StringGenerator.formatETA(mActivity, eta * 1000);
|
||||||
viewHolder.mProgressText.setText(mActivity.getString(
|
viewHolder.mProgressText.setText(mActivity.getString(
|
||||||
R.string.list_download_progress_eta_new, downloaded, total, etaString,
|
R.string.list_download_progress_eta_newer, downloaded, total, etaString));
|
||||||
percentage));
|
|
||||||
} else {
|
} else {
|
||||||
viewHolder.mProgressText.setText(mActivity.getString(
|
viewHolder.mProgressText.setText(mActivity.getString(
|
||||||
R.string.list_download_progress_new, downloaded, total, percentage));
|
R.string.list_download_progress_newer, downloaded, total));
|
||||||
}
|
}
|
||||||
setButtonAction(viewHolder.mAction, Action.PAUSE, downloadId, true);
|
setButtonAction(viewHolder.mAction, Action.PAUSE, downloadId, true);
|
||||||
viewHolder.mProgressBar.setIndeterminate(update.getStatus() == UpdateStatus.STARTING);
|
viewHolder.mProgressBar.setIndeterminate(update.getStatus() == UpdateStatus.STARTING);
|
||||||
@@ -196,14 +201,15 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
|||||||
String total = Formatter.formatShortFileSize(mActivity, update.getFileSize());
|
String total = Formatter.formatShortFileSize(mActivity, update.getFileSize());
|
||||||
String percentage = NumberFormat.getPercentInstance().format(
|
String percentage = NumberFormat.getPercentInstance().format(
|
||||||
update.getProgress() / 100.f);
|
update.getProgress() / 100.f);
|
||||||
|
viewHolder.mPercentage.setText(percentage);
|
||||||
viewHolder.mProgressText.setText(mActivity.getString(
|
viewHolder.mProgressText.setText(mActivity.getString(
|
||||||
R.string.list_download_progress_new, downloaded, total, percentage));
|
R.string.list_download_progress_newer, downloaded, total));
|
||||||
viewHolder.mProgressBar.setIndeterminate(false);
|
viewHolder.mProgressBar.setIndeterminate(false);
|
||||||
viewHolder.mProgressBar.setProgress(update.getProgress());
|
viewHolder.mProgressBar.setProgress(update.getProgress());
|
||||||
}
|
}
|
||||||
|
|
||||||
viewHolder.mMenu.setOnClickListener(getClickListener(update, canDelete, viewHolder.mMenu));
|
viewHolder.mMenu.setOnClickListener(getClickListener(update, canDelete, viewHolder.mMenu));
|
||||||
viewHolder.mProgressBar.setVisibility(View.VISIBLE);
|
viewHolder.mProgress.setVisibility(View.VISIBLE);
|
||||||
viewHolder.mProgressText.setVisibility(View.VISIBLE);
|
viewHolder.mProgressText.setVisibility(View.VISIBLE);
|
||||||
viewHolder.mBuildSize.setVisibility(View.INVISIBLE);
|
viewHolder.mBuildSize.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
@@ -228,7 +234,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
|
|||||||
String fileSize = Formatter.formatShortFileSize(mActivity, update.getFileSize());
|
String fileSize = Formatter.formatShortFileSize(mActivity, update.getFileSize());
|
||||||
viewHolder.mBuildSize.setText(fileSize);
|
viewHolder.mBuildSize.setText(fileSize);
|
||||||
|
|
||||||
viewHolder.mProgressBar.setVisibility(View.INVISIBLE);
|
viewHolder.mProgress.setVisibility(View.INVISIBLE);
|
||||||
viewHolder.mProgressText.setVisibility(View.INVISIBLE);
|
viewHolder.mProgressText.setVisibility(View.INVISIBLE);
|
||||||
viewHolder.mBuildSize.setVisibility(View.VISIBLE);
|
viewHolder.mBuildSize.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user