diff options
author | Alan Viverette <alanv@google.com> | 2014-02-03 18:40:20 -0800 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2014-02-03 18:42:24 -0800 |
commit | 8eea3ea5591e59f55cbb4f6b2b7e9363a285ced3 (patch) | |
tree | a067807fe9c905fda3568db98cb654a520e694f8 /core/java/android/widget | |
parent | 8cff1a370e8d89c0a977b82cd8730ab791866808 (diff) | |
download | frameworks_base-8eea3ea5591e59f55cbb4f6b2b7e9363a285ced3.zip frameworks_base-8eea3ea5591e59f55cbb4f6b2b7e9363a285ced3.tar.gz frameworks_base-8eea3ea5591e59f55cbb4f6b2b7e9363a285ced3.tar.bz2 |
Add APIs for obtaining themed Drawable from Theme, Context
BUG: 12611005
Change-Id: Ic0057be4e4c2d0c61ce02a019b3f7d0625e3a016
Diffstat (limited to 'core/java/android/widget')
-rw-r--r-- | core/java/android/widget/AbsListView.java | 4 | ||||
-rw-r--r-- | core/java/android/widget/AnalogClock.java | 6 | ||||
-rw-r--r-- | core/java/android/widget/AppSecurityPermissions.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/AutoCompleteTextView.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/CalendarView.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/CheckedTextView.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/CompoundButton.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/EdgeEffect.java | 4 | ||||
-rw-r--r-- | core/java/android/widget/Editor.java | 10 | ||||
-rw-r--r-- | core/java/android/widget/ImageView.java | 4 | ||||
-rw-r--r-- | core/java/android/widget/QuickContactBadge.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/SearchView.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/ShareActionProvider.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/Spinner.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/SuggestionsAdapter.java | 4 | ||||
-rw-r--r-- | core/java/android/widget/Switch.java | 4 | ||||
-rw-r--r-- | core/java/android/widget/TabWidget.java | 15 | ||||
-rw-r--r-- | core/java/android/widget/TextView.java | 24 |
18 files changed, 46 insertions, 47 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 4d8975c..13febe9 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -1604,7 +1604,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } private void useDefaultSelector() { - setSelector(getResources().getDrawable( + setSelector(getContext().getDrawable( com.android.internal.R.drawable.list_selector_background)); } @@ -2616,7 +2616,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te * @attr ref android.R.styleable#AbsListView_listSelector */ public void setSelector(int resID) { - setSelector(getResources().getDrawable(resID)); + setSelector(getContext().getDrawable(resID)); } public void setSelector(Drawable sel) { diff --git a/core/java/android/widget/AnalogClock.java b/core/java/android/widget/AnalogClock.java index 3c88e94..5b80648 100644 --- a/core/java/android/widget/AnalogClock.java +++ b/core/java/android/widget/AnalogClock.java @@ -80,17 +80,17 @@ public class AnalogClock extends View { mDial = a.getDrawable(com.android.internal.R.styleable.AnalogClock_dial); if (mDial == null) { - mDial = r.getDrawable(com.android.internal.R.drawable.clock_dial); + mDial = context.getDrawable(com.android.internal.R.drawable.clock_dial); } mHourHand = a.getDrawable(com.android.internal.R.styleable.AnalogClock_hand_hour); if (mHourHand == null) { - mHourHand = r.getDrawable(com.android.internal.R.drawable.clock_hand_hour); + mHourHand = context.getDrawable(com.android.internal.R.drawable.clock_hand_hour); } mMinuteHand = a.getDrawable(com.android.internal.R.styleable.AnalogClock_hand_minute); if (mMinuteHand == null) { - mMinuteHand = r.getDrawable(com.android.internal.R.drawable.clock_hand_minute); + mMinuteHand = context.getDrawable(com.android.internal.R.drawable.clock_hand_minute); } mCalendar = new Time(); diff --git a/core/java/android/widget/AppSecurityPermissions.java b/core/java/android/widget/AppSecurityPermissions.java index 34cfea5..10e56c7 100644 --- a/core/java/android/widget/AppSecurityPermissions.java +++ b/core/java/android/widget/AppSecurityPermissions.java @@ -322,7 +322,7 @@ public class AppSecurityPermissions { CharSequence grpName, CharSequence description, boolean dangerous) { LayoutInflater inflater = (LayoutInflater)context.getSystemService( Context.LAYOUT_INFLATER_SERVICE); - Drawable icon = context.getResources().getDrawable(dangerous + Drawable icon = context.getDrawable(dangerous ? R.drawable.ic_bullet_key_permission : R.drawable.ic_text_dot); return getPermissionItemViewOld(context, inflater, grpName, description, dangerous, icon); diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index 259c66b..eb232fd 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -366,7 +366,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe * @attr ref android.R.styleable#PopupWindow_popupBackground */ public void setDropDownBackgroundResource(int id) { - mPopup.setBackgroundDrawable(getResources().getDrawable(id)); + mPopup.setBackgroundDrawable(getContext().getDrawable(id)); } /** diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java index c6be6dd..ea60abb 100644 --- a/core/java/android/widget/CalendarView.java +++ b/core/java/android/widget/CalendarView.java @@ -1029,7 +1029,7 @@ public class CalendarView extends FrameLayout { @Override public void setSelectedDateVerticalBar(int resourceId) { - Drawable drawable = mDelegator.getResources().getDrawable(resourceId); + Drawable drawable = mDelegator.getContext().getDrawable(resourceId); setSelectedDateVerticalBar(drawable); } diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java index 78b1b75..1533510 100644 --- a/core/java/android/widget/CheckedTextView.java +++ b/core/java/android/widget/CheckedTextView.java @@ -123,7 +123,7 @@ public class CheckedTextView extends TextView implements Checkable { Drawable d = null; if (mCheckMarkResource != 0) { - d = getResources().getDrawable(mCheckMarkResource); + d = getContext().getDrawable(mCheckMarkResource); } setCheckMarkDrawable(d); } diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index b22088c..4298545 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -186,7 +186,7 @@ public abstract class CompoundButton extends Button implements Checkable { Drawable d = null; if (mButtonResource != 0) { - d = getResources().getDrawable(mButtonResource); + d = getContext().getDrawable(mButtonResource); } setButtonDrawable(d); } diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java index 30752e0..fa37443 100644 --- a/core/java/android/widget/EdgeEffect.java +++ b/core/java/android/widget/EdgeEffect.java @@ -136,8 +136,8 @@ public class EdgeEffect { */ public EdgeEffect(Context context) { final Resources res = context.getResources(); - mEdge = res.getDrawable(R.drawable.overscroll_edge); - mGlow = res.getDrawable(R.drawable.overscroll_glow); + mEdge = context.getDrawable(R.drawable.overscroll_edge); + mGlow = context.getDrawable(R.drawable.overscroll_glow); mEdgeHeight = mEdge.getIntrinsicHeight(); mGlowHeight = mGlow.getIntrinsicHeight(); diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 11dbce8..ea62bbe 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -1679,7 +1679,7 @@ public class Editor { private void updateCursorPosition(int cursorIndex, int top, int bottom, float horizontal) { if (mCursorDrawable[cursorIndex] == null) - mCursorDrawable[cursorIndex] = mTextView.getResources().getDrawable( + mCursorDrawable[cursorIndex] = mTextView.getContext().getDrawable( mTextView.mCursorDrawableRes); if (mTempRect == null) mTempRect = new Rect(); @@ -2969,7 +2969,7 @@ public class Editor { positionY += mContentView.getMeasuredHeight(); // Assumes insertion and selection handles share the same height - final Drawable handle = mTextView.getResources().getDrawable( + final Drawable handle = mTextView.getContext().getDrawable( mTextView.mTextSelectHandleRes); positionY += handle.getIntrinsicHeight(); } @@ -3546,7 +3546,7 @@ public class Editor { private InsertionHandleView getHandle() { if (mSelectHandleCenter == null) { - mSelectHandleCenter = mTextView.getResources().getDrawable( + mSelectHandleCenter = mTextView.getContext().getDrawable( mTextView.mTextSelectHandleRes); } if (mHandle == null) { @@ -3592,11 +3592,11 @@ public class Editor { private void initDrawables() { if (mSelectHandleLeft == null) { - mSelectHandleLeft = mTextView.getContext().getResources().getDrawable( + mSelectHandleLeft = mTextView.getContext().getDrawable( mTextView.mTextSelectHandleLeftRes); } if (mSelectHandleRight == null) { - mSelectHandleRight = mTextView.getContext().getResources().getDrawable( + mSelectHandleRight = mTextView.getContext().getDrawable( mTextView.mTextSelectHandleRightRes); } } diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 58e4e86..572302a 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -642,7 +642,7 @@ public class ImageView extends View { if (mResource != 0) { try { - d = rsrc.getDrawable(mResource); + d = mContext.getDrawable(mResource); } catch (Exception e) { Log.w("ImageView", "Unable to find resource: " + mResource, e); // Don't try again. @@ -655,7 +655,7 @@ public class ImageView extends View { // Load drawable through Resources, to get the source density information ContentResolver.OpenResourceIdResult r = mContext.getContentResolver().getResourceId(mUri); - d = r.r.getDrawable(r.id); + d = r.r.getDrawable(r.id, mContext.getTheme()); } catch (Exception e) { Log.w("ImageView", "Unable to open content: " + mUri, e); } diff --git a/core/java/android/widget/QuickContactBadge.java b/core/java/android/widget/QuickContactBadge.java index a4f758c..74b41c9 100644 --- a/core/java/android/widget/QuickContactBadge.java +++ b/core/java/android/widget/QuickContactBadge.java @@ -155,7 +155,7 @@ public class QuickContactBadge extends ImageView implements OnClickListener { */ public void setImageToDefault() { if (mDefaultAvatar == null) { - mDefaultAvatar = getResources().getDrawable(R.drawable.ic_contact_picture); + mDefaultAvatar = mContext.getDrawable(R.drawable.ic_contact_picture); } setImageDrawable(mDefaultAvatar); } diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index 3791258..1eedc5d 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -1059,7 +1059,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { SpannableStringBuilder ssb = new SpannableStringBuilder(" "); // for the icon ssb.append(hintText); - Drawable searchIcon = getContext().getResources().getDrawable(getSearchIconId()); + Drawable searchIcon = getContext().getDrawable(getSearchIconId()); int textSize = (int) (mQueryTextView.getTextSize() * 1.25); searchIcon.setBounds(0, 0, textSize, textSize); ssb.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); diff --git a/core/java/android/widget/ShareActionProvider.java b/core/java/android/widget/ShareActionProvider.java index bdaaa01..64a1574 100644 --- a/core/java/android/widget/ShareActionProvider.java +++ b/core/java/android/widget/ShareActionProvider.java @@ -168,7 +168,7 @@ public class ShareActionProvider extends ActionProvider { // Lookup and set the expand action icon. TypedValue outTypedValue = new TypedValue(); mContext.getTheme().resolveAttribute(R.attr.actionModeShareDrawable, outTypedValue, true); - Drawable drawable = mContext.getResources().getDrawable(outTypedValue.resourceId); + Drawable drawable = mContext.getDrawable(outTypedValue.resourceId); activityChooserView.setExpandActivityOverflowButtonDrawable(drawable); activityChooserView.setProvider(this); diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java index eabe1a3..9601d4a 100644 --- a/core/java/android/widget/Spinner.java +++ b/core/java/android/widget/Spinner.java @@ -281,7 +281,7 @@ public class Spinner extends AbsSpinner implements OnClickListener { * @attr ref android.R.styleable#Spinner_popupBackground */ public void setPopupBackgroundResource(int resId) { - setPopupBackgroundDrawable(getContext().getResources().getDrawable(resId)); + setPopupBackgroundDrawable(getContext().getDrawable(resId)); } /** diff --git a/core/java/android/widget/SuggestionsAdapter.java b/core/java/android/widget/SuggestionsAdapter.java index c44d431..c8917e0 100644 --- a/core/java/android/widget/SuggestionsAdapter.java +++ b/core/java/android/widget/SuggestionsAdapter.java @@ -529,7 +529,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene return drawable; } // Not cached, find it by resource ID - drawable = mProviderContext.getResources().getDrawable(resourceId); + drawable = mProviderContext.getDrawable(resourceId); // Stick it in the cache, using the URI as key storeInIconCache(drawableUri, drawable); return drawable; @@ -563,7 +563,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter implements OnClickListene OpenResourceIdResult r = mProviderContext.getContentResolver().getResourceId(uri); try { - return r.r.getDrawable(r.id); + return r.r.getDrawable(r.id, mContext.getTheme()); } catch (Resources.NotFoundException ex) { throw new FileNotFoundException("Resource does not exist: " + uri); } diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index c9a1ca4..2a5fb15 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -417,7 +417,7 @@ public class Switch extends CompoundButton { * @attr ref android.R.styleable#Switch_track */ public void setTrackResource(int resId) { - setTrackDrawable(getContext().getResources().getDrawable(resId)); + setTrackDrawable(getContext().getDrawable(resId)); } /** @@ -453,7 +453,7 @@ public class Switch extends CompoundButton { * @attr ref android.R.styleable#Switch_thumb */ public void setThumbResource(int resId) { - setThumbDrawable(getContext().getResources().getDrawable(resId)); + setThumbDrawable(getContext().getDrawable(resId)); } /** diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java index 568b3e6..47a5449 100644 --- a/core/java/android/widget/TabWidget.java +++ b/core/java/android/widget/TabWidget.java @@ -120,28 +120,27 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { setChildrenDrawingOrderEnabled(true); final Context context = mContext; - final Resources resources = context.getResources(); // Tests the target Sdk version, as set in the Manifest. Could not be set using styles.xml // in a values-v? directory which targets the current platform Sdk version instead. if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) { // Donut apps get old color scheme if (mLeftStrip == null) { - mLeftStrip = resources.getDrawable( + mLeftStrip = context.getDrawable( com.android.internal.R.drawable.tab_bottom_left_v4); } if (mRightStrip == null) { - mRightStrip = resources.getDrawable( + mRightStrip = context.getDrawable( com.android.internal.R.drawable.tab_bottom_right_v4); } } else { // Use modern color scheme for Eclair and beyond if (mLeftStrip == null) { - mLeftStrip = resources.getDrawable( + mLeftStrip = context.getDrawable( com.android.internal.R.drawable.tab_bottom_left); } if (mRightStrip == null) { - mRightStrip = resources.getDrawable( + mRightStrip = context.getDrawable( com.android.internal.R.drawable.tab_bottom_right); } } @@ -246,7 +245,7 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { * divider. */ public void setDividerDrawable(int resId) { - setDividerDrawable(getResources().getDrawable(resId)); + setDividerDrawable(mContext.getDrawable(resId)); } /** @@ -267,7 +266,7 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { * left strip drawable */ public void setLeftStripDrawable(int resId) { - setLeftStripDrawable(getResources().getDrawable(resId)); + setLeftStripDrawable(mContext.getDrawable(resId)); } /** @@ -288,7 +287,7 @@ public class TabWidget extends LinearLayout implements OnFocusChangeListener { * right strip drawable */ public void setRightStripDrawable(int resId) { - setRightStripDrawable(getResources().getDrawable(resId)); + setRightStripDrawable(mContext.getDrawable(resId)); } /** diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 15606a4..3be23b7 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -2073,11 +2073,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ @android.view.RemotableViewMethod public void setCompoundDrawablesWithIntrinsicBounds(int left, int top, int right, int bottom) { - final Resources resources = getContext().getResources(); - setCompoundDrawablesWithIntrinsicBounds(left != 0 ? resources.getDrawable(left) : null, - top != 0 ? resources.getDrawable(top) : null, - right != 0 ? resources.getDrawable(right) : null, - bottom != 0 ? resources.getDrawable(bottom) : null); + final Context context = getContext(); + setCompoundDrawablesWithIntrinsicBounds(left != 0 ? context.getDrawable(left) : null, + top != 0 ? context.getDrawable(top) : null, + right != 0 ? context.getDrawable(right) : null, + bottom != 0 ? context.getDrawable(bottom) : null); } /** @@ -2247,12 +2247,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @android.view.RemotableViewMethod public void setCompoundDrawablesRelativeWithIntrinsicBounds(int start, int top, int end, int bottom) { - final Resources resources = getContext().getResources(); + final Context context = getContext(); setCompoundDrawablesRelativeWithIntrinsicBounds( - start != 0 ? resources.getDrawable(start) : null, - top != 0 ? resources.getDrawable(top) : null, - end != 0 ? resources.getDrawable(end) : null, - bottom != 0 ? resources.getDrawable(bottom) : null); + start != 0 ? context.getDrawable(start) : null, + top != 0 ? context.getDrawable(top) : null, + end != 0 ? context.getDrawable(end) : null, + bottom != 0 ? context.getDrawable(bottom) : null); } /** @@ -4385,8 +4385,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (error == null) { setError(null, null); } else { - Drawable dr = getContext().getResources(). - getDrawable(com.android.internal.R.drawable.indicator_input_error); + Drawable dr = getContext().getDrawable( + com.android.internal.R.drawable.indicator_input_error); dr.setBounds(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight()); setError(error, dr); |