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

Commit 822c76b6 authored by Alan Viverette's avatar Alan Viverette Committed by Android Git Automerger
Browse files

am a3891440: am 143631f0: am d3957f25: am a6958574: am 63756956: Merge "Add...

am a3891440: am 143631f0: am d3957f25: am a6958574: am 63756956: Merge "Add callback to track and thumb drawables, propagate state in ASLD" into lmp-dev

* commit 'a3891440':
  Add callback to track and thumb drawables, propagate state in ASLD
parents c439d093 a3891440
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -208,7 +208,13 @@ public class Switch extends CompoundButton {
        final TypedArray a = context.obtainStyledAttributes(
                attrs, com.android.internal.R.styleable.Switch, defStyleAttr, defStyleRes);
        mThumbDrawable = a.getDrawable(com.android.internal.R.styleable.Switch_thumb);
        if (mThumbDrawable != null) {
            mThumbDrawable.setCallback(this);
        }
        mTrackDrawable = a.getDrawable(com.android.internal.R.styleable.Switch_track);
        if (mTrackDrawable != null) {
            mTrackDrawable.setCallback(this);
        }
        mTextOn = a.getText(com.android.internal.R.styleable.Switch_textOn);
        mTextOff = a.getText(com.android.internal.R.styleable.Switch_textOff);
        mShowText = a.getBoolean(com.android.internal.R.styleable.Switch_showText, true);
@@ -433,7 +439,13 @@ public class Switch extends CompoundButton {
     * @attr ref android.R.styleable#Switch_track
     */
    public void setTrackDrawable(Drawable track) {
        if (mTrackDrawable != null) {
            mTrackDrawable.setCallback(null);
        }
        mTrackDrawable = track;
        if (track != null) {
            track.setCallback(this);
        }
        requestLayout();
    }

@@ -468,7 +480,13 @@ public class Switch extends CompoundButton {
     * @attr ref android.R.styleable#Switch_thumb
     */
    public void setThumbDrawable(Drawable thumb) {
        if (mThumbDrawable != null) {
            mThumbDrawable.setCallback(null);
        }
        mThumbDrawable = thumb;
        if (thumb != null) {
            thumb.setCallback(this);
        }
        requestLayout();
    }

+7 −2
Original line number Diff line number Diff line
@@ -91,7 +91,8 @@ public class AnimatedStateListDrawable extends StateListDrawable {
            if (visible) {
                mTransition.start();
            } else {
                mTransition.stop();
                // Ensure we're showing the correct state when visible.
                jumpToCurrentState();
            }
        }

@@ -140,7 +141,11 @@ public class AnimatedStateListDrawable extends StateListDrawable {
    protected boolean onStateChange(int[] stateSet) {
        final int keyframeIndex = mState.indexOfKeyframe(stateSet);
        if (keyframeIndex == getCurrentIndex()) {
            // No transition needed.
            // Propagate state change to current keyframe.
            final Drawable current = getCurrent();
            if (current != null) {
                return current.setState(stateSet);
            }
            return false;
        }