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

Commit bbef9c62 authored by Rohit Sekhar's avatar Rohit Sekhar Committed by Romain Hunault
Browse files

[pie] Updater: Improve UX for users taking version upgrades

parent 63ed5396
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -35,6 +35,18 @@
                android:textSize="16sp"
                tools:text="LineageOS 15.1" />

            <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
@@ -112,8 +112,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 upgrade 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.\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 upgrade 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="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>

+8 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import java.util.List;

public class UpdatesDbHelper extends SQLiteOpenHelper {

    public static final int DATABASE_VERSION = 2;
    public static final int DATABASE_VERSION = 3;
    public static final String DATABASE_NAME = "updates.db";

    public static class UpdateEntry implements BaseColumns {
@@ -42,6 +42,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
        public static final String COLUMN_NAME_TYPE = "type";
        public static final String COLUMN_NAME_VERSION = "version";
        public static final String COLUMN_NAME_DISPLAY_VERSION = "display_version";
        public static final String COLUMN_NAME_ANDROID_VERSION = "android_version";
        public static final String COLUMN_NAME_SIZE = "size";
    }

@@ -55,6 +56,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
                    UpdateEntry.COLUMN_NAME_TYPE + " TEXT," +
                    UpdateEntry.COLUMN_NAME_VERSION + " TEXT," +
                    UpdateEntry.COLUMN_NAME_DISPLAY_VERSION + " TEXT," +
                    UpdateEntry.COLUMN_NAME_ANDROID_VERSION + " TEXT," +
                    UpdateEntry.COLUMN_NAME_SIZE + " INTEGER)";

    private static final String SQL_DELETE_ENTRIES =
@@ -87,6 +89,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
        values.put(UpdateEntry.COLUMN_NAME_TYPE, update.getType());
        values.put(UpdateEntry.COLUMN_NAME_VERSION, update.getVersion());
        values.put(UpdateEntry.COLUMN_NAME_DISPLAY_VERSION, update.getDisplayVersion());
        values.put(UpdateEntry.COLUMN_NAME_ANDROID_VERSION, update.getAndroidVersion());
        values.put(UpdateEntry.COLUMN_NAME_SIZE, update.getFileSize());
        return db.insert(UpdateEntry.TABLE_NAME, null, values);
    }
@@ -101,6 +104,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
        values.put(UpdateEntry.COLUMN_NAME_TYPE, update.getType());
        values.put(UpdateEntry.COLUMN_NAME_VERSION, update.getVersion());
        values.put(UpdateEntry.COLUMN_NAME_DISPLAY_VERSION, update.getDisplayVersion());
        values.put(UpdateEntry.COLUMN_NAME_ANDROID_VERSION, update.getAndroidVersion());
        values.put(UpdateEntry.COLUMN_NAME_SIZE, update.getFileSize());
        return db.insertWithOnConflict(UpdateEntry.TABLE_NAME, null, values, conflictAlgorithm);
    }
@@ -166,6 +170,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
                UpdateEntry.COLUMN_NAME_TYPE,
                UpdateEntry.COLUMN_NAME_VERSION,
                UpdateEntry.COLUMN_NAME_DISPLAY_VERSION,
                UpdateEntry.COLUMN_NAME_ANDROID_VERSION,
                UpdateEntry.COLUMN_NAME_STATUS,
                UpdateEntry.COLUMN_NAME_SIZE,
        };
@@ -189,6 +194,8 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
                update.setVersion(cursor.getString(index));
                index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_DISPLAY_VERSION);
                update.setDisplayVersion(cursor.getString(index));
                index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_ANDROID_VERSION);
                update.setAndroidVersion(cursor.getString(index));
                index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_STATUS);
                update.setPersistentStatus(cursor.getInt(index));
                index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_SIZE);
+33 −11
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.BatteryManager;
import android.os.Build;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
@@ -86,6 +87,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
    public static class ViewHolder extends RecyclerView.ViewHolder {
        private Button mAction;

        private TextView mUpgradeType;
        private TextView mBuildDate;
        private TextView mBuildVersion;
        private TextView mBuildSize;
@@ -97,6 +99,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
            super(view);
            mAction = (Button) view.findViewById(R.id.update_action);

            mUpgradeType = (TextView) view.findViewById(R.id.upgrade_type);
            mBuildDate = (TextView) view.findViewById(R.id.build_date);
            mBuildVersion = (TextView) view.findViewById(R.id.build_version);
            mBuildSize = (TextView) view.findViewById(R.id.build_size);
@@ -251,6 +254,9 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
        String buildVersion = mActivity.getString(R.string.list_build_version,
                update.getVersion());
        
        if (!update.getAndroidVersion().equals(Build.VERSION.RELEASE)){
          viewHolder.mUpgradeType.setVisibility(TextView.VISIBLE);
        }
        viewHolder.mBuildDate.setText(buildDate);
        viewHolder.mBuildVersion.setText(buildVersion);
        viewHolder.mBuildVersion.setCompoundDrawables(null, null, null, null);
@@ -442,26 +448,42 @@ 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(update.getAndroidVersion().equals(Build.VERSION.RELEASE)){
              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,
                update.getVersion(), 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))
                .setNegativeButton(android.R.string.cancel, null);
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ public class Utils {
        update.setDownloadUrl(object.getString("url"));
        update.setVersion(object.getString("version"));
        update.setDisplayVersion(object.getString("display_version"));
        update.setAndroidVersion(object.getString("android_version"));
        return update;
    }

Loading