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

Commit 2356c5e6 authored by Alan Viverette's avatar Alan Viverette
Browse files

Update switch, checkbox, radio button, button, and toggle button

Add optical inset support to BitmapDrawable with gravity. Fix optical
inset support in DrawableContainer. Fix visibility change support in
AnimatedStateListDrawable. Adds a whole bunch of missing drawable
support to CheckedTextView.

BUG: 15127013
BUG: 15126976
BUG: 15125529
BUG: 15025806
BUG: 14597955
BUG: 14594498
BUG: 15152746
Change-Id: Id2d99e10838d25b6f927ca1e49996c8da8e78ab1
parent 42b30e1b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -255,6 +255,16 @@ public abstract class AbsSeekBar extends ProgressBar {
        }
    }

    @Override
    public void invalidateDrawable(Drawable dr) {
        super.invalidateDrawable(dr);

        if (dr == mThumb) {
            // Handle changes to thumb width and height.
            requestLayout();
        }
    }

    @Override
    void onProgressRefresh(float scale, boolean fromUser) {
        super.onProgressRefresh(scale, fromUser);
+33 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.RemotableViewMethod;
import android.view.ViewDebug;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -156,10 +157,36 @@ public class CheckedTextView extends TextView implements Checkable {
            mCheckMarkWidth = 0;
        }
        mCheckMarkDrawable = d;
        // Do padding resolution. This will call internalSetPadding() and do a requestLayout() if needed.

        // Do padding resolution. This will call internalSetPadding() and do a
        // requestLayout() if needed.
        resolvePadding();
    }

    @RemotableViewMethod
    @Override
    public void setVisibility(int visibility) {
        super.setVisibility(visibility);

        if (mCheckMarkDrawable != null) {
            mCheckMarkDrawable.setVisible(visibility == VISIBLE, false);
        }
    }

    @Override
    public void jumpDrawablesToCurrentState() {
        super.jumpDrawablesToCurrentState();

        if (mCheckMarkDrawable != null) {
            mCheckMarkDrawable.jumpToCurrentState();
        }
    }

    @Override
    protected boolean verifyDrawable(Drawable who) {
        return who == mCheckMarkDrawable || super.verifyDrawable(who);
    }

    /**
     * Gets the checkmark drawable
     *
@@ -249,6 +276,11 @@ public class CheckedTextView extends TextView implements Checkable {
            }
            checkMarkDrawable.setBounds(mScrollX + left, top, mScrollX + right, bottom);
            checkMarkDrawable.draw(canvas);

            final Drawable background = getBackground();
            if (background != null) {
                background.setHotspotBounds(mScrollX + left, top, mScrollX + right, bottom);
            }
        }
    }
    
+12 −3
Original line number Diff line number Diff line
@@ -951,9 +951,8 @@ public class Switch extends CompoundButton {

        final int[] myDrawableState = getDrawableState();

        if (mThumbDrawable != null && mThumbDrawable.setState(myDrawableState)) {
            // Handle changes to thumb width and height.
            requestLayout();
        if (mThumbDrawable != null) {
            mThumbDrawable.setState(myDrawableState);
        }

        if (mTrackDrawable != null) {
@@ -963,6 +962,16 @@ public class Switch extends CompoundButton {
        invalidate();
    }

    @Override
    public void invalidateDrawable(Drawable drawable) {
        super.invalidateDrawable(drawable);

        if (drawable == mThumbDrawable) {
            // Handle changes to thumb width and height.
            requestLayout();
        }
    }

    @Override
    protected boolean verifyDrawable(Drawable who) {
        return super.verifyDrawable(who) || who == mThumbDrawable || who == mTrackDrawable;
+17 −1
Original line number Diff line number Diff line
@@ -1026,7 +1026,7 @@ public class AlertController {
                        ? dialog.mSingleChoiceItemLayout : dialog.mListItemLayout;
                if (mCursor == null) {
                    adapter = (mAdapter != null) ? mAdapter
                            : new ArrayAdapter<CharSequence>(mContext, layout, R.id.text1, mItems);
                            : new CheckedItemAdapter(mContext, layout, R.id.text1, mItems);
                } else {
                    adapter = new SimpleCursorAdapter(mContext, layout, 
                            mCursor, new String[]{mLabelColumn}, new int[]{R.id.text1});
@@ -1081,4 +1081,20 @@ public class AlertController {
        }
    }

    private static class CheckedItemAdapter extends ArrayAdapter<CharSequence> {
        public CheckedItemAdapter(Context context, int resource, int textViewResourceId,
                CharSequence[] objects) {
            super(context, resource, textViewResourceId, objects);
        }

        @Override
        public boolean hasStableIds() {
            return true;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }
    }
}
−211 B
Loading image diff...
Loading