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

Commit 6c86e1ba authored by Adam Powell's avatar Adam Powell
Browse files

Public API for android.widget.Switch properties

Bug 6104562

Add properties that can be set/retrieved programmatically to match the
XML attributes available.

Change-Id: Ief28e5cad9ec3e6c2d12dd11ff9fa24f22eecec3
parent 7ec22d33
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -10782,8 +10782,8 @@ package android.media {
  public class MediaActionSound {
    ctor public MediaActionSound();
    method public void load(int);
    method public void play(int);
    method public synchronized void load(int);
    method public synchronized void play(int);
    method public void release();
    field public static final int FOCUS_COMPLETE = 1; // 0x1
    field public static final int SHUTTER_CLICK = 0; // 0x0
@@ -27511,14 +27511,24 @@ package android.widget {
    ctor public Switch(android.content.Context);
    ctor public Switch(android.content.Context, android.util.AttributeSet);
    ctor public Switch(android.content.Context, android.util.AttributeSet, int);
    method public int getSwitchMinWidth();
    method public int getSwitchPadding();
    method public java.lang.CharSequence getTextOff();
    method public java.lang.CharSequence getTextOn();
    method public android.graphics.drawable.Drawable getThumbDrawable();
    method public int getThumbTextPadding();
    method public android.graphics.drawable.Drawable getTrackDrawable();
    method public void onMeasure(int, int);
    method public void setSwitchMinWidth(int);
    method public void setSwitchPadding(int);
    method public void setSwitchTextAppearance(android.content.Context, int);
    method public void setSwitchTypeface(android.graphics.Typeface, int);
    method public void setSwitchTypeface(android.graphics.Typeface);
    method public void setTextOff(java.lang.CharSequence);
    method public void setTextOn(java.lang.CharSequence);
    method public void setThumbDrawable(android.graphics.drawable.Drawable);
    method public void setThumbTextPadding(int);
    method public void setTrackDrawable(android.graphics.drawable.Drawable);
  }
  public class TabHost extends android.widget.FrameLayout implements android.view.ViewTreeObserver.OnTouchModeChangeListener {
+129 −0
Original line number Diff line number Diff line
@@ -169,6 +169,8 @@ public class Switch extends CompoundButton {
    /**
     * Sets the switch text color, size, style, hint color, and highlight color
     * from the specified TextAppearance resource.
     *
     * @attr ref android.R.styleable#Switch_switchTextAppearance
     */
    public void setSwitchTextAppearance(Context context, int resid) {
        TypedArray appearance =
@@ -273,8 +275,129 @@ public class Switch extends CompoundButton {
        }
    }

    /**
     * Set the amount of horizontal padding between the switch and the associated text.
     *
     * @param pixels Amount of padding in pixels
     *
     * @attr ref android.R.styleable#Switch_switchPadding
     */
    public void setSwitchPadding(int pixels) {
        mSwitchPadding = pixels;
        requestLayout();
    }

    /**
     * Get the amount of horizontal padding between the switch and the associated text.
     *
     * @return Amount of padding in pixels
     *
     * @attr ref android.R.styleable#Switch_switchPadding
     */
    public int getSwitchPadding() {
        return mSwitchPadding;
    }

    /**
     * Set the minimum width of the switch in pixels. The switch's width will be the maximum
     * of this value and its measured width as determined by the switch drawables and text used.
     *
     * @param pixels Minimum width of the switch in pixels
     *
     * @attr ref android.R.styleable#Switch_switchMinWidth
     */
    public void setSwitchMinWidth(int pixels) {
        mSwitchMinWidth = pixels;
        requestLayout();
    }

    /**
     * Get the minimum width of the switch in pixels. The switch's width will be the maximum
     * of this value and its measured width as determined by the switch drawables and text used.
     *
     * @return Minimum width of the switch in pixels
     *
     * @attr ref android.R.styleable#Switch_switchMinWidth
     */
    public int getSwitchMinWidth() {
        return mSwitchMinWidth;
    }

    /**
     * Set the horizontal padding around the text drawn on the switch itself.
     *
     * @param pixels Horizontal padding for switch thumb text in pixels
     *
     * @attr ref android.R.styleable#Switch_thumbTextPadding
     */
    public void setThumbTextPadding(int pixels) {
        mThumbTextPadding = pixels;
        requestLayout();
    }

    /**
     * Get the horizontal padding around the text drawn on the switch itself.
     *
     * @return Horizontal padding for switch thumb text in pixels
     *
     * @attr ref android.R.styleable#Switch_thumbTextPadding
     */
    public int getThumbTextPadding() {
        return mThumbTextPadding;
    }

    /**
     * Set the drawable used for the track that the switch slides within.
     *
     * @param track Track drawable
     *
     * @attr ref android.R.styleable#Switch_track
     */
    public void setTrackDrawable(Drawable track) {
        mTrackDrawable = track;
        requestLayout();
    }

    /**
     * Get the drawable used for the track that the switch slides within.
     *
     * @return Track drawable
     *
     * @attr ref android.R.styleable#Switch_track
     */
    public Drawable getTrackDrawable() {
        return mTrackDrawable;
    }

    /**
     * Set the drawable used for the switch "thumb" - the piece that the user
     * can physically touch and drag along the track.
     *
     * @param thumb Thumb drawable
     *
     * @attr ref android.R.styleable#Switch_thumb
     */
    public void setThumbDrawable(Drawable thumb) {
        mThumbDrawable = thumb;
        requestLayout();
    }

    /**
     * Get the drawable used for the switch "thumb" - the piece that the user
     * can physically touch and drag along the track.
     *
     * @return Thumb drawable
     *
     * @attr ref android.R.styleable#Switch_thumb
     */
    public Drawable getThumbDrawable() {
        return mThumbDrawable;
    }

    /**
     * Returns the text displayed when the button is in the checked state.
     *
     * @attr ref android.R.styleable#Switch_textOn
     */
    public CharSequence getTextOn() {
        return mTextOn;
@@ -282,6 +405,8 @@ public class Switch extends CompoundButton {

    /**
     * Sets the text displayed when the button is in the checked state.
     *
     * @attr ref android.R.styleable#Switch_textOn
     */
    public void setTextOn(CharSequence textOn) {
        mTextOn = textOn;
@@ -290,6 +415,8 @@ public class Switch extends CompoundButton {

    /**
     * Returns the text displayed when the button is not in the checked state.
     *
     * @attr ref android.R.styleable#Switch_textOff
     */
    public CharSequence getTextOff() {
        return mTextOff;
@@ -297,6 +424,8 @@ public class Switch extends CompoundButton {

    /**
     * Sets the text displayed when the button is not in the checked state.
     *
     * @attr ref android.R.styleable#Switch_textOff
     */
    public void setTextOff(CharSequence textOff) {
        mTextOff = textOff;