Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ad96eca authored by Michael W's avatar Michael W Committed by Bruno Martins
Browse files

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
parent 27f04e5b
Loading
Loading
Loading
Loading
+23 −8
Original line number Diff line number Diff line
@@ -49,25 +49,40 @@
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/progress"
                    android:visibility="invisible"
                    tools:visibility="visible">

                    <ProgressBar
                        android:id="@+id/progress_bar"
                        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
                    android:layout_width="match_parent"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_height="wrap_content"
                        android:paddingTop="4sp"
                    android:visibility="invisible"
                    tools:progress="65"
                    tools:visibility="visible" />
                        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
+23 −8
Original line number Diff line number Diff line
@@ -48,25 +48,40 @@
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/progress"
                    android:visibility="invisible"
                    tools:visibility="visible">

                    <ProgressBar
                        android:id="@+id/progress_bar"
                        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
                    android:layout_width="match_parent"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_height="wrap_content"
                        android:paddingTop="4sp"
                    android:visibility="invisible"
                    tools:progress="65"
                    tools:visibility="visible" />
                        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
+2 −2
Original line number Diff line number Diff line
@@ -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>

+12 −6
Original line number Diff line number Diff line
@@ -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);
    }