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

Commit 64435af1 authored by Rohit Sekhar's avatar Rohit Sekhar
Browse files

Updater: Modify install AlertDialog strings if android_version changes

parent 762a8038
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -112,6 +112,10 @@
    <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="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>

    <string name="label_download_url">Download URL</string>
+27 −11
Original line number Diff line number Diff line
@@ -447,26 +447,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,
                               BuildInfoUtils.getBuildVersion(), buildDate);

            if(update.getAndroidVersion().equals(Build.VERSION.RELEASE)){
              title = R.string.apply_update_dialog_title;
              if (Utils.isABUpdate(update.getFile())) {
                message = mActivity.getString(R.string.apply_update_dialog_message_ab, buildInfoText,
                        mActivity.getString(android.R.string.ok));
              } else {
                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())) {
                resId = R.string.apply_update_dialog_message_ab;
                message = mActivity.getString(R.string.version_upgrade_dialog_message_ab, buildInfoText,
                        update.getAndroidVersion(), mActivity.getString(android.R.string.ok));
              } else {
                resId = R.string.apply_update_dialog_message;
                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,
                BuildInfoUtils.getBuildVersion(), 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);