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

Commit 778ce666 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

DO NOT MERGE Make "Want to start battery saver?" dialog better.

- Don't line-break in "Battery" (only in English)
- Add "Learn more" link.

Bug: 78261259

Test: Manual test with:
- adb shell dumpsys battery unplug
- adb shell settings delete secure low_power_warning_acknowledged
- Enable battery saver
- Make sure the link is clickable if a link is set.
- Make sure there's no "learn more" link if the link is not set in strings.xml

Change-Id: I83364f628dd596a4d50bf2aca4db7cbfe7cf4909
parent c4c7c19b
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.app;

import com.android.internal.app.AlertController;

import android.annotation.ArrayRes;
import android.annotation.AttrRes;
import android.annotation.DrawableRes;
@@ -30,17 +28,19 @@ import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Message;
import android.text.Layout;
import android.text.method.MovementMethod;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;

import com.android.internal.R;
import com.android.internal.app.AlertController;

/**
 * A subclass of Dialog that can display one, two or three buttons. If you only want to
@@ -54,7 +54,7 @@ import com.android.internal.R;
 * </pre>
 *
 * <p>The AlertDialog class takes care of automatically setting
 * {@link WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM
 * {@link android.view.WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM
 * WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM} for you based on whether
 * any views in the dialog return true from {@link View#onCheckIsTextEditor()
 * View.onCheckIsTextEditor()}.  Generally you want this set for a Dialog
@@ -266,6 +266,17 @@ public class AlertDialog extends Dialog implements DialogInterface {
        mAlert.setMessage(message);
    }

    /** @hide */
    public void setMessageMovementMethod(MovementMethod movementMethod) {
        mAlert.setMessageMovementMethod(movementMethod);
    }

    /** @hide */
    public void setMessageHyphenationFrequency(
            @Layout.HyphenationFrequency int hyphenationFrequency) {
        mAlert.setMessageHyphenationFrequency(hyphenationFrequency);
    }

    /**
     * Set the view to display in that dialog.
     */
+27 −0
Original line number Diff line number Diff line
@@ -30,7 +30,10 @@ import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.text.Layout;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.method.MovementMethod;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
@@ -101,6 +104,9 @@ public class AlertController {
    private ImageView mIconView;
    private TextView mTitleView;
    protected TextView mMessageView;
    private MovementMethod mMessageMovementMethod;
    @Layout.HyphenationFrequency
    private Integer mMessageHyphenationFrequency;
    private View mCustomTitleView;

    private boolean mForceInverseBackground;
@@ -290,6 +296,21 @@ public class AlertController {
        }
    }

    public void setMessageMovementMethod(MovementMethod movementMethod) {
        mMessageMovementMethod = movementMethod;
        if (mMessageView != null) {
            mMessageView.setMovementMethod(movementMethod);
        }
    }

    public void setMessageHyphenationFrequency(
            @Layout.HyphenationFrequency int hyphenationFrequency) {
        mMessageHyphenationFrequency = hyphenationFrequency;
        if (mMessageView != null) {
            mMessageView.setHyphenationFrequency(hyphenationFrequency);
        }
    }

    /**
     * Set the view resource to display in the dialog.
     */
@@ -676,6 +697,12 @@ public class AlertController {

        if (mMessage != null) {
            mMessageView.setText(mMessage);
            if (mMessageMovementMethod != null) {
                mMessageView.setMovementMethod(mMessageMovementMethod);
            }
            if (mMessageHyphenationFrequency != null) {
                mMessageView.setHyphenationFrequency(mMessageHyphenationFrequency);
            }
        } else {
            mMessageView.setVisibility(View.GONE);
            mScrollView.removeView(mMessageView);
+4 −1
Original line number Diff line number Diff line
@@ -4514,7 +4514,10 @@
    <!-- Notification shown when device owner silently deletes a package [CHAR LIMIT=NONE] -->
    <string name="package_deleted_device_owner">Deleted by your admin</string>

    <!-- [CHAR_LIMIT=NONE] Battery saver: Feature description -->
    <!-- [CHAR_LIMIT=NONE] Battery saver: Feature description, with a "learn more" link. -->
    <string name="battery_saver_description_with_learn_more">To extend your battery life, Battery Saver turns off some device features and restricts apps. <annotation id="url">Learn More</annotation></string>

    <!-- [CHAR_LIMIT=NONE] Battery saver: Feature description, without a "learn more" link. -->
    <string name="battery_saver_description">To extend your battery life, Battery Saver turns off some device features and restricts apps.</string>

    <!-- [CHAR_LIMIT=NONE] Data saver: Feature description -->
+1 −0
Original line number Diff line number Diff line
@@ -3369,4 +3369,5 @@
  <java-symbol type="id" name="user_loading_avatar" />
  <java-symbol type="id" name="user_loading" />

  <java-symbol type="string" name="battery_saver_description_with_learn_more" />
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -2223,4 +2223,6 @@
    <!-- An action on the dialog that tells that scheduled (i.e. automatic) battery saver: user acknowledges and closes the dialog.  [CHAR LIMIT=NONE]-->
    <string name="auto_saver_okay_action">Got it</string>

    <!-- URl of the webpage that explains battery saver. -->
    <string name="help_uri_battery_saver_learn_more_link_target" translatable="false"></string>
</resources>
Loading