summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adam Cohen <adamcohen@google.com> 2011-04-01 16:23:18 -0700
committer Adam Cohen <adamcohen@google.com> 2011-04-01 16:28:51 -0700
commit26f072c3ee4f2baecf4fd3f8ed829ed709055cf4 (patch)
tree0e50340d7cae67f96d1e0ceae562bec37c22901c
parentad575f4dda3391baf9fcab927e65afbee32e7b95 (diff)
Making StackView res-out and click feedback colors stylable
Change-Id: Ia6241b1b66dc510b22bcf342d775f98eb7c86871
-rw-r--r--core/java/android/widget/AdapterViewAnimator.java17
-rw-r--r--core/java/android/widget/StackView.java40
-rwxr-xr-xcore/res/res/values/attrs.xml9
-rw-r--r--core/res/res/values/styles.xml5
-rw-r--r--core/res/res/values/themes.xml4
5 files changed, 53 insertions, 22 deletions
diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java
index 072992efef2b..ca1effb25846 100644
--- a/core/java/android/widget/AdapterViewAnimator.java
+++ b/core/java/android/widget/AdapterViewAnimator.java
@@ -103,11 +103,6 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
int mCurrentWindowStartUnbounded = 0;
/**
- * Handler to post events to the main thread
- */
- Handler mMainQueue;
-
- /**
* Listens for data changes from the adapter
*/
AdapterDataSetObserver mDataSetObserver;
@@ -163,15 +158,18 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
private static final int DEFAULT_ANIMATION_DURATION = 200;
public AdapterViewAnimator(Context context) {
- super(context);
- initViewAnimator();
+ this(context, null);
}
public AdapterViewAnimator(Context context, AttributeSet attrs) {
- super(context, attrs);
+ this(context, attrs, 0);
+ }
+
+ public AdapterViewAnimator(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
TypedArray a = context.obtainStyledAttributes(attrs,
- com.android.internal.R.styleable.AdapterViewAnimator);
+ com.android.internal.R.styleable.AdapterViewAnimator, defStyleAttr, 0);
int resource = a.getResourceId(
com.android.internal.R.styleable.AdapterViewAnimator_inAnimation, 0);
if (resource > 0) {
@@ -203,7 +201,6 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
* Initialize this {@link AdapterViewAnimator}
*/
private void initViewAnimator() {
- mMainQueue = new Handler(Looper.myLooper());
mPreviousViews = new ArrayList<Integer>();
}
diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java
index 21c61bdf67ab..ec4ef4b184b2 100644
--- a/core/java/android/widget/StackView.java
+++ b/core/java/android/widget/StackView.java
@@ -20,6 +20,7 @@ import java.lang.ref.WeakReference;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.content.Context;
+import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
@@ -132,6 +133,8 @@ public class StackView extends AdapterViewAnimator {
private int mMaximumVelocity;
private VelocityTracker mVelocityTracker;
private boolean mTransitionIsSetup = false;
+ private int mResOutColor;
+ private int mClickColor;
private static HolographicHelper sHolographicHelper;
private ImageView mHighlight;
@@ -146,12 +149,24 @@ public class StackView extends AdapterViewAnimator {
private final Rect stackInvalidateRect = new Rect();
public StackView(Context context) {
- super(context);
- initStackView();
+ this(context, null);
}
public StackView(Context context, AttributeSet attrs) {
- super(context, attrs);
+ this(context, attrs, com.android.internal.R.attr.stackViewStyle);
+ }
+
+ public StackView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ TypedArray a = context.obtainStyledAttributes(attrs,
+ com.android.internal.R.styleable.StackView, defStyleAttr, 0);
+
+ mResOutColor = a.getColor(
+ com.android.internal.R.styleable.StackView_resOutColor, 0);
+ mClickColor = a.getColor(
+ com.android.internal.R.styleable.StackView_clickColor, 0);
+
+ a.recycle();
initStackView();
}
@@ -357,7 +372,7 @@ public class StackView extends AdapterViewAnimator {
private void setupStackSlider(View v, int mode) {
mStackSlider.setMode(mode);
if (v != null) {
- mHighlight.setImageBitmap(sHolographicHelper.createOutline(v));
+ mHighlight.setImageBitmap(sHolographicHelper.createResOutline(v, mResOutColor));
mHighlight.setRotation(v.getRotation());
mHighlight.setTranslationY(v.getTranslationY());
mHighlight.setTranslationX(v.getTranslationX());
@@ -429,8 +444,8 @@ public class StackView extends AdapterViewAnimator {
if (!mClickFeedbackIsValid) {
View v = getViewAtRelativeIndex(1);
if (v != null) {
- mClickFeedback.setImageBitmap(sHolographicHelper.createOutline(v,
- HolographicHelper.CLICK_FEEDBACK));
+ mClickFeedback.setImageBitmap(
+ sHolographicHelper.createClickOutline(v, mClickColor));
mClickFeedback.setTranslationX(v.getTranslationX());
mClickFeedback.setTranslationY(v.getTranslationY());
}
@@ -1355,16 +1370,19 @@ public class StackView extends AdapterViewAnimator {
mLargeBlurMaskFilter = new BlurMaskFilter(4 * mDensity, BlurMaskFilter.Blur.NORMAL);
}
- Bitmap createOutline(View v) {
- return createOutline(v, RES_OUT);
+ Bitmap createClickOutline(View v, int color) {
+ return createOutline(v, CLICK_FEEDBACK, color);
+ }
+
+ Bitmap createResOutline(View v, int color) {
+ return createOutline(v, RES_OUT, color);
}
- Bitmap createOutline(View v, int type) {
+ Bitmap createOutline(View v, int type, int color) {
+ mHolographicPaint.setColor(color);
if (type == RES_OUT) {
- mHolographicPaint.setColor(0xff6699ff);
mBlurPaint.setMaskFilter(mSmallBlurMaskFilter);
} else if (type == CLICK_FEEDBACK) {
- mHolographicPaint.setColor(0x886699ff);
mBlurPaint.setMaskFilter(mLargeBlurMaskFilter);
}
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index c81f8c0e7e36..77e42f6ff826 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -529,6 +529,8 @@
<attr name="listPopupWindowStyle" format="reference" />
<!-- Default PopupMenu style. -->
<attr name="popupMenuStyle" format="reference" />
+ <!-- Default StackView style. -->
+ <attr name="stackViewStyle" format="reference" />
<!-- NumberPicker style. -->
<attr name="numberPickerStyle" format="reference" />
@@ -2489,6 +2491,13 @@
<attr name="thumbOffset" format="dimension" />
</declare-styleable>
+ <declare-styleable name="StackView">
+ <!-- Color of the res-out outline. -->
+ <attr name="resOutColor" format="color" />
+ <!-- Color of the outline of click feedback. -->
+ <attr name="clickColor" format="color" />
+ </declare-styleable>
+
<declare-styleable name="RatingBar">
<!-- The number of stars (or rating items) to show. -->
<attr name="numStars" format="integer" />
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index f7d3c3f9f1c5..f6a3979943f8 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1410,6 +1410,11 @@
<item name="android:minWidth">64dip</item>
</style>
+ <style name="Widget.Holo.StackView">
+ <item name="android:resOutColor">#ff6699ff</item>
+ <item name="android:clickColor">#886699ff</item>
+ </style>
+
<style name="Widget.Holo.Button.Borderless">
<item name="android:background">?android:attr/selectableItemBackground</item>
</style>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index b12774783287..fdeb229a7f16 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -972,6 +972,7 @@
<item name="quickContactBadgeStyleSmallWindowLarge">@android:style/Widget.Holo.QuickContactBadgeSmall.WindowLarge</item>
<item name="listPopupWindowStyle">@android:style/Widget.Holo.ListPopupWindow</item>
<item name="popupMenuStyle">@android:style/Widget.Holo.PopupMenu</item>
+ <item name="stackViewStyle">@android:style/Widget.Holo.StackView</item>
<!-- Preference styles -->
<item name="preferenceScreenStyle">@android:style/Preference.Holo.PreferenceScreen</item>
@@ -1255,7 +1256,8 @@
<item name="quickContactBadgeStyleSmallWindowLarge">@android:style/Widget.Holo.QuickContactBadgeSmall.WindowLarge</item>
<item name="listPopupWindowStyle">@android:style/Widget.Holo.Light.ListPopupWindow</item>
<item name="popupMenuStyle">@android:style/Widget.Holo.Light.PopupMenu</item>
-
+ <item name="stackViewStyle">@android:style/Widget.Holo.StackView</item>
+
<!-- Preference styles -->
<item name="preferenceScreenStyle">@android:style/Preference.Holo.PreferenceScreen</item>
<item name="preferenceCategoryStyle">@android:style/Preference.Holo.Category</item>