diff options
| author | 2011-01-12 17:49:12 -0800 | |
|---|---|---|
| committer | 2011-01-26 12:08:45 -0800 | |
| commit | 5f059e4663d94c4569b4757ea8406793fc217dfb (patch) | |
| tree | 2654575d221918a555d202c10f3e9862f891be79 | |
| parent | 6df89fde0db446bb530ab872b373b1faa3ccb06c (diff) | |
Holo theme for error popups in TextViews.
Bug 3277308
Change-Id: I9711adb848df975b95ad09fc84bba4b970e44670
| -rw-r--r-- | core/java/android/widget/TextView.java | 19 | ||||
| -rw-r--r-- | core/res/res/drawable-mdpi/popup_inline_error_above_holo_dark.9.png | bin | 0 -> 1462 bytes | |||
| -rw-r--r-- | core/res/res/drawable-mdpi/popup_inline_error_above_holo_light.9.png | bin | 0 -> 1446 bytes | |||
| -rwxr-xr-x | core/res/res/drawable-mdpi/popup_inline_error_holo_dark.9.png | bin | 0 -> 1418 bytes | |||
| -rwxr-xr-x | core/res/res/drawable-mdpi/popup_inline_error_holo_light.9.png | bin | 0 -> 1410 bytes | |||
| -rw-r--r-- | core/res/res/layout/textview_hint.xml | 1 | ||||
| -rwxr-xr-x | core/res/res/values/attrs.xml | 5 | ||||
| -rw-r--r-- | core/res/res/values/themes.xml | 6 |
8 files changed, 28 insertions, 3 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index fedda686b712..54d7021f81d7 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -3508,6 +3508,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private static class ErrorPopup extends PopupWindow { private boolean mAbove = false; private final TextView mView; + private int mPopupInlineErrorBackgroundId = 0; + private int mPopupInlineErrorAboveBackgroundId = 0; ErrorPopup(TextView v, int width, int height) { super(v, width, height); @@ -3518,10 +3520,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mAbove = above; if (above) { - mView.setBackgroundResource(com.android.internal.R.drawable.popup_inline_error_above); + mPopupInlineErrorAboveBackgroundId = + getResourceId(mPopupInlineErrorAboveBackgroundId, com.android.internal.R.styleable.Theme_errorMessageAboveBackground); } else { - mView.setBackgroundResource(com.android.internal.R.drawable.popup_inline_error); + mPopupInlineErrorBackgroundId = + getResourceId(mPopupInlineErrorBackgroundId, com.android.internal.R.styleable.Theme_errorMessageBackground); } + + mView.setBackgroundResource(above ? mPopupInlineErrorAboveBackgroundId : mPopupInlineErrorBackgroundId); + } + + private int getResourceId(int currentId, int index) { + if (currentId == 0) { + TypedArray styledAttributes = mView.getContext().obtainStyledAttributes(R.styleable.Theme); + currentId = styledAttributes.getResourceId(index, 0); + styledAttributes.recycle(); + } + return currentId; } @Override diff --git a/core/res/res/drawable-mdpi/popup_inline_error_above_holo_dark.9.png b/core/res/res/drawable-mdpi/popup_inline_error_above_holo_dark.9.png Binary files differnew file mode 100644 index 000000000000..dd4af6d04d67 --- /dev/null +++ b/core/res/res/drawable-mdpi/popup_inline_error_above_holo_dark.9.png diff --git a/core/res/res/drawable-mdpi/popup_inline_error_above_holo_light.9.png b/core/res/res/drawable-mdpi/popup_inline_error_above_holo_light.9.png Binary files differnew file mode 100644 index 000000000000..892511270d3a --- /dev/null +++ b/core/res/res/drawable-mdpi/popup_inline_error_above_holo_light.9.png diff --git a/core/res/res/drawable-mdpi/popup_inline_error_holo_dark.9.png b/core/res/res/drawable-mdpi/popup_inline_error_holo_dark.9.png Binary files differnew file mode 100755 index 000000000000..66c2c09b52a4 --- /dev/null +++ b/core/res/res/drawable-mdpi/popup_inline_error_holo_dark.9.png diff --git a/core/res/res/drawable-mdpi/popup_inline_error_holo_light.9.png b/core/res/res/drawable-mdpi/popup_inline_error_holo_light.9.png Binary files differnew file mode 100755 index 000000000000..c5113f2919e3 --- /dev/null +++ b/core/res/res/drawable-mdpi/popup_inline_error_holo_light.9.png diff --git a/core/res/res/layout/textview_hint.xml b/core/res/res/layout/textview_hint.xml index 20b08bf9b7b6..f9c4406a0925 100644 --- a/core/res/res/layout/textview_hint.xml +++ b/core/res/res/layout/textview_hint.xml @@ -17,7 +17,6 @@ <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@drawable/popup_inline_error" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="@color/primary_text_light" /> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 260c7c6d41ec..4a5653212ce1 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -142,6 +142,11 @@ <!-- EditText background drawable. --> <attr name="editTextBackground" format="reference" /> + <!-- Popup text displayed in TextView when setError is used. --> + <attr name="errorMessageBackground" format="reference" /> + <!-- Background used instead of errorMessageBackground when the popup has to be above. --> + <attr name="errorMessageAboveBackground" format="reference" /> + <!-- A styled string, specifying the style to be used for showing inline candidate text when composing with an input method. The text itself will be ignored, but the style spans will be applied diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml index ddaeb8210bc6..c5ae77fbd5cf 100644 --- a/core/res/res/values/themes.xml +++ b/core/res/res/values/themes.xml @@ -217,6 +217,8 @@ <item name="starStyle">@android:style/Widget.CompoundButton.Star</item> <item name="tabWidgetStyle">@android:style/Widget.TabWidget</item> <item name="textViewStyle">@android:style/Widget.TextView</item> + <item name="errorMessageBackground">@android:drawable/popup_inline_error</item> + <item name="errorMessageAboveBackground">@android:drawable/popup_inline_error_above</item> <item name="webTextViewStyle">@android:style/Widget.WebTextView</item> <item name="webViewStyle">@android:style/Widget.WebView</item> <item name="dropDownItemStyle">@android:style/Widget.DropDownItem</item> @@ -934,6 +936,8 @@ <item name="starStyle">@android:style/Widget.Holo.CompoundButton.Star</item> <item name="tabWidgetStyle">@android:style/Widget.Holo.TabWidget</item> <item name="textViewStyle">@android:style/Widget.Holo.TextView</item> + <item name="errorMessageBackground">@android:drawable/popup_inline_error_holo_dark</item> + <item name="errorMessageAboveBackground">@android:drawable/popup_inline_error_above_holo_dark</item> <item name="webTextViewStyle">@android:style/Widget.Holo.WebTextView</item> <item name="webViewStyle">@android:style/Widget.Holo.WebView</item> <item name="dropDownItemStyle">@android:style/Widget.Holo.DropDownItem</item> @@ -1207,6 +1211,8 @@ <item name="starStyle">@android:style/Widget.Holo.Light.CompoundButton.Star</item> <item name="tabWidgetStyle">@android:style/Widget.Holo.Light.TabWidget</item> <item name="textViewStyle">@android:style/Widget.Holo.Light.TextView</item> + <item name="errorMessageBackground">@android:drawable/popup_inline_error_holo_light</item> + <item name="errorMessageAboveBackground">@android:drawable/popup_inline_error_above_holo_light</item> <item name="webTextViewStyle">@android:style/Widget.Holo.Light.WebTextView</item> <item name="webViewStyle">@android:style/Widget.Holo.Light.WebView</item> <item name="dropDownItemStyle">@android:style/Widget.Holo.Light.DropDownItem</item> |