diff options
| author | Makoto Onuki <omakoto@google.com> | 2018-04-20 14:04:50 -0700 |
|---|---|---|
| committer | Makoto Onuki <omakoto@google.com> | 2018-04-25 15:27:47 +0000 |
| commit | 778ce66697b61aa43bf4078c10c097b2fb2384f8 (patch) | |
| tree | 552de12ac7094f57202f16bdadb0da191143bf1c /core/java | |
| parent | c4c7c19b6723680dd0b3322fd667a757e259d178 (diff) | |
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
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/AlertDialog.java | 19 | ||||
| -rw-r--r-- | core/java/com/android/internal/app/AlertController.java | 27 |
2 files changed, 42 insertions, 4 deletions
diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java index a44bd0305875..07b4b9c39e1e 100644 --- a/core/java/android/app/AlertDialog.java +++ b/core/java/android/app/AlertDialog.java @@ -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. */ diff --git a/core/java/com/android/internal/app/AlertController.java b/core/java/com/android/internal/app/AlertController.java index 46cb5461b682..732172111b80 100644 --- a/core/java/com/android/internal/app/AlertController.java +++ b/core/java/com/android/internal/app/AlertController.java @@ -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); |
