diff options
author | Michael W <baddaemon87@gmail.com> | 2022-02-11 18:16:02 +0100 |
---|---|---|
committer | Bruno Martins <bgcngm@gmail.com> | 2022-03-07 14:08:01 +0000 |
commit | 9ad96eca85add960b3acb7716e89e9881fe4b0a1 (patch) | |
tree | 00a55efd2fcf50827d3cbe4461aa9d783d02123d | |
parent | 27f04e5b78373ba6219234ce217b39c686762c65 (diff) |
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
-rw-r--r-- | res/layout-large-notouch/update_item_view.xml | 31 | ||||
-rw-r--r-- | res/layout/update_item_view.xml | 31 | ||||
-rw-r--r-- | res/values/strings.xml | 4 | ||||
-rw-r--r-- | src/org/lineageos/updater/UpdatesListAdapter.java | 18 |
4 files changed, 60 insertions, 24 deletions
diff --git a/res/layout-large-notouch/update_item_view.xml b/res/layout-large-notouch/update_item_view.xml index b7b7fd8..c6898f2 100644 --- a/res/layout-large-notouch/update_item_view.xml +++ b/res/layout-large-notouch/update_item_view.xml @@ -49,25 +49,40 @@ android:layout_width="wrap_content" android:layout_height="wrap_content"> - <ProgressBar - android:id="@+id/progress_bar" - style="@style/Widget.AppCompat.ProgressBar.Horizontal" + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="4sp" + android:id="@+id/progress" 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 android:id="@+id/progress_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@id/progress_bar" + android:layout_below="@id/progress" android:ellipsize="marquee" android:singleLine="true" 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" /> <TextView diff --git a/res/layout/update_item_view.xml b/res/layout/update_item_view.xml index 2f04ba6..c778334 100644 --- a/res/layout/update_item_view.xml +++ b/res/layout/update_item_view.xml @@ -48,25 +48,40 @@ android:layout_width="wrap_content" android:layout_height="wrap_content"> - <ProgressBar - android:id="@+id/progress_bar" - style="@style/Widget.AppCompat.ProgressBar.Horizontal" + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="4sp" + android:id="@+id/progress" 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 android:id="@+id/progress_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@id/progress_bar" + android:layout_below="@id/progress" android:ellipsize="marquee" android:singleLine="true" 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" /> <TextView diff --git a/res/values/strings.xml b/res/values/strings.xml index a1d2b8e..bfb2627 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -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_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_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_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_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_no_updates">No new updates found. To manually check for new updates, use the Refresh button.</string> diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 3b75a54..c06b4e0 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -37,6 +37,7 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckBox; import android.widget.ImageButton; +import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; @@ -104,8 +105,10 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. private final TextView mBuildVersion; private final TextView mBuildSize; + private final LinearLayout mProgress; private final ProgressBar mProgressBar; private final TextView mProgressText; + private final TextView mPercentage; public ViewHolder(final View view) { super(view); @@ -116,8 +119,10 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. mBuildVersion = view.findViewById(R.id.build_version); mBuildSize = view.findViewById(R.id.build_size); + mProgress = view.findViewById(R.id.progress); mProgressBar = view.findViewById(R.id.progress_bar); 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 percentage = NumberFormat.getPercentInstance().format( update.getProgress() / 100.f); + viewHolder.mPercentage.setText(percentage); long eta = update.getEta(); if (eta > 0) { CharSequence etaString = StringGenerator.formatETA(mActivity, eta * 1000); viewHolder.mProgressText.setText(mActivity.getString( - R.string.list_download_progress_eta_new, downloaded, total, etaString, - percentage)); + R.string.list_download_progress_eta_newer, downloaded, total, etaString)); } else { 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); 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 percentage = NumberFormat.getPercentInstance().format( update.getProgress() / 100.f); + viewHolder.mPercentage.setText(percentage); 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.setProgress(update.getProgress()); } viewHolder.mMenu.setOnClickListener(getClickListener(update, canDelete, viewHolder.mMenu)); - viewHolder.mProgressBar.setVisibility(View.VISIBLE); + viewHolder.mProgress.setVisibility(View.VISIBLE); viewHolder.mProgressText.setVisibility(View.VISIBLE); viewHolder.mBuildSize.setVisibility(View.INVISIBLE); } @@ -228,7 +234,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. String fileSize = Formatter.formatShortFileSize(mActivity, update.getFileSize()); viewHolder.mBuildSize.setText(fileSize); - viewHolder.mProgressBar.setVisibility(View.INVISIBLE); + viewHolder.mProgress.setVisibility(View.INVISIBLE); viewHolder.mProgressText.setVisibility(View.INVISIBLE); viewHolder.mBuildSize.setVisibility(View.VISIBLE); } |