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

Commit 26f072c3 authored by Adam Cohen's avatar Adam Cohen
Browse files

Making StackView res-out and click feedback colors stylable

Change-Id: Ia6241b1b66dc510b22bcf342d775f98eb7c86871
parent ad575f4d
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -102,11 +102,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
     */
@@ -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>();
    }

+29 −11
Original line number Diff line number Diff line
@@ -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);
            }

+9 −0
Original line number Diff line number Diff line
@@ -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" />
+5 −0
Original line number Diff line number Diff line
@@ -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>
+3 −1
Original line number Diff line number Diff line
@@ -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,6 +1256,7 @@
        <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>