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

Commit 41b93115 authored by Rohit Sekhar's avatar Rohit Sekhar Committed by Nishith Khanna
Browse files

Updater: Improve UX for users taking version upgrades

Conflicts:
	res/values/strings.xml
	src/org/lineageos/updater/UpdatesDbHelper.java
	src/org/lineageos/updater/UpdatesListAdapter.java
	src/org/lineageos/updater/misc/Utils.java
parent 9b4ffc56
Loading
Loading
Loading
Loading
+51 −11
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package org.lineageos.updater;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Build;
import android.os.PowerManager;
import android.text.SpannableString;
import android.text.format.Formatter;
@@ -94,6 +95,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
        private final Button mAction;
        private final ImageButton mMenu;

        private final TextView mUpgradeType;
        private final TextView mBuildDate;
        private final TextView mBuildVersion;
        private final TextView mBuildSize;
@@ -108,6 +110,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
            mAction = view.findViewById(R.id.update_action);
            mMenu = view.findViewById(R.id.update_menu);

            mUpgradeType = view.findViewById(R.id.upgrade_type);
            mBuildDate = view.findViewById(R.id.build_date);
            mBuildVersion = view.findViewById(R.id.build_version);
            mBuildSize = view.findViewById(R.id.build_size);
@@ -273,6 +276,11 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
                DateFormat.LONG, update.getTimestamp());
        String buildVersion = mActivity.getString(R.string.list_build_version_e,
                update.getDisplayVersion());

        if (!Build.VERSION.RELEASE.equals(update.getAndroidVersion())) {
            viewHolder.mUpgradeType.setVisibility(TextView.VISIBLE);
        }

        viewHolder.mBuildDate.setText(buildDate);
        viewHolder.mBuildVersion.setText(buildVersion);
        viewHolder.mBuildVersion.setCompoundDrawables(null, null, null, null);
@@ -526,26 +534,58 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
                    .setPositiveButton(android.R.string.ok, null);
        }
        UpdateInfo update = mUpdaterController.getUpdate(downloadId);
        int resId;

        int title;
        String message;
        try {
            String buildDate =
                    StringGenerator.getDateLocalizedUTC(
                            mActivity, DateFormat.MEDIUM, update.getTimestamp());
            String buildInfoText =
                    mActivity.getString(
                            R.string.list_build_version_date, update.getVersion(), buildDate);

            if (Build.VERSION.RELEASE.equals(update.getAndroidVersion())) {
                title = R.string.apply_update_dialog_title;
                if (Utils.isABUpdate(update.getFile())) {
                resId = R.string.apply_update_dialog_message_ab;
                    message =
                            mActivity.getString(
                                    R.string.apply_update_dialog_message_ab,
                                    buildInfoText,
                                    mActivity.getString(android.R.string.ok));
                } else {
                resId = R.string.apply_update_dialog_message;
                    message =
                            mActivity.getString(
                                    R.string.apply_update_dialog_message,
                                    buildInfoText,
                                    mActivity.getString(android.R.string.ok));
                }
            } else {
                title = R.string.version_upgrade_dialog_title;
                if (Utils.isABUpdate(update.getFile())) {
                    message =
                            mActivity.getString(
                                    R.string.version_upgrade_dialog_message_ab,
                                    buildInfoText,
                                    update.getAndroidVersion(),
                                    mActivity.getString(android.R.string.ok));
                } else {
                    message =
                            mActivity.getString(
                                    R.string.version_upgrade_dialog_message,
                                    buildInfoText,
                                    update.getAndroidVersion(),
                                    mActivity.getString(android.R.string.ok));
                }
            }
        } catch (IOException e) {
            Log.e(TAG, "Could not determine the type of the update");
            return null;
        }

        String buildDate = StringGenerator.getDateLocalizedUTC(mActivity,
                DateFormat.MEDIUM, update.getTimestamp());
        String buildInfoText = mActivity.getString(R.string.list_build_version_date_e,
                update.getDisplayVersion(), buildDate);
        return new AlertDialog.Builder(mActivity)
                .setTitle(R.string.apply_update_dialog_title)
                .setMessage(mActivity.getString(resId, buildInfoText,
                        mActivity.getString(android.R.string.ok)))
                .setTitle(title)
                .setMessage(message)
                .setPositiveButton(android.R.string.ok,
                        (dialog, which) -> {
                            Utils.triggerUpdate(mActivity, downloadId);
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public class UpdateBase implements UpdateBaseInfo {
        mType = update.getType();
        mVersion = update.getVersion();
        mDisplayVersion = update.getDisplayVersion();
        mAndroidVersion = update.getAndroidVersion();
        mFileSize = update.getFileSize();
    }

+12 −0
Original line number Diff line number Diff line
@@ -39,6 +39,18 @@
                android:textSize="16sp"
                tools:text="LineageOS 20" />

            <TextView
                android:id="@+id/upgrade_type"
                android:textColor="@color/theme_accent"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:maxLines="1"
                android:text="@string/version_upgrade_dialog_title"
                android:textSize="14sp"
                android:visibility="gone"
                tools:text="@string/version_upgrade_dialog_title"
                tools:visibility="visible" />

            <TextView
                android:id="@+id/build_date"
                android:layout_width="wrap_content"
+6 −2
Original line number Diff line number Diff line
@@ -128,8 +128,12 @@
    <string name="confirm_delete_dialog_message">Delete the selected update file?</string>

    <string name="apply_update_dialog_title">Apply update</string>
    <string name="apply_update_dialog_message">You are about to install <xliff:g id="update_name">%1$s</xliff:g>.\n\nIf you press <xliff:g id="ok">%2$s</xliff:g>, the device will restart itself in recovery mode to install the update.\n\nNote: This feature requires a compatible Recovery or updates will need to be installed manually.</string>
    <string name="apply_update_dialog_message_ab">You are about to install <xliff:g id="update_name">%1$s</xliff:g>.\n\nIf you press <xliff:g id="ok">%2$s</xliff:g>, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot.</string>
    <string name="apply_update_dialog_message">You are about to update to <xliff:g id="update_name">%1$s</xliff:g>.\n\nIf you press <xliff:g id="ok">%2$s</xliff:g>, the device will restart itself in recovery mode to install the update.</string>
    <string name="apply_update_dialog_message_ab">You are about to update to <xliff:g id="update_name">%1$s</xliff:g>.\n\nIf you press <xliff:g id="ok">%2$s</xliff:g>, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot.</string>

    <string name="version_upgrade_dialog_title">Version Upgrade!</string>
    <string name="version_upgrade_dialog_message">You are about to upgrade to <xliff:g id="update_name">%1$s</xliff:g>, based on Android <xliff:g id="version_android">%2$s</xliff:g>\n\nRemember: it is always recommended to backup your data before upgrades.\n\nIf you press <xliff:g id="ok">%3$s</xliff:g>, the device will restart itself into recovery mode to install the update.</string>
    <string name="version_upgrade_dialog_message_ab">You are about to upgrade to <xliff:g id="update_name">%1$s</xliff:g>, based on Android <xliff:g id="version_android">%2$s</xliff:g>.\n\nRemember: it is always recommended to backup your data before upgrades.\n\nIf you press <xliff:g id="ok">%3$s</xliff:g>, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot.</string>

    <string name="cancel_installation_dialog_message">Cancel the installation?</string>