Merge "Enable use of of CompoundButtons in RemoteViews" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ae11a1abcf
@@ -53349,7 +53349,7 @@ package android.widget {
|
||||
method public void onSelectedDayChange(@NonNull android.widget.CalendarView, int, int, int);
|
||||
}
|
||||
|
||||
public class CheckBox extends android.widget.CompoundButton {
|
||||
@android.widget.RemoteViews.RemoteView public class CheckBox extends android.widget.CompoundButton {
|
||||
ctor public CheckBox(android.content.Context);
|
||||
ctor public CheckBox(android.content.Context, android.util.AttributeSet);
|
||||
ctor public CheckBox(android.content.Context, android.util.AttributeSet, int);
|
||||
@@ -53415,6 +53415,7 @@ package android.widget {
|
||||
method public boolean isChecked();
|
||||
method public void setButtonDrawable(@DrawableRes int);
|
||||
method public void setButtonDrawable(@Nullable android.graphics.drawable.Drawable);
|
||||
method public void setButtonIcon(@Nullable android.graphics.drawable.Icon);
|
||||
method public void setButtonTintBlendMode(@Nullable android.graphics.BlendMode);
|
||||
method public void setButtonTintList(@Nullable android.content.res.ColorStateList);
|
||||
method public void setButtonTintMode(@Nullable android.graphics.PorterDuff.Mode);
|
||||
@@ -54455,14 +54456,14 @@ package android.widget {
|
||||
field protected String[] mExcludeMimes;
|
||||
}
|
||||
|
||||
public class RadioButton extends android.widget.CompoundButton {
|
||||
@android.widget.RemoteViews.RemoteView public class RadioButton extends android.widget.CompoundButton {
|
||||
ctor public RadioButton(android.content.Context);
|
||||
ctor public RadioButton(android.content.Context, android.util.AttributeSet);
|
||||
ctor public RadioButton(android.content.Context, android.util.AttributeSet, int);
|
||||
ctor public RadioButton(android.content.Context, android.util.AttributeSet, int, int);
|
||||
}
|
||||
|
||||
public class RadioGroup extends android.widget.LinearLayout {
|
||||
@android.widget.RemoteViews.RemoteView public class RadioGroup extends android.widget.LinearLayout {
|
||||
ctor public RadioGroup(android.content.Context);
|
||||
ctor public RadioGroup(android.content.Context, android.util.AttributeSet);
|
||||
method public void check(@IdRes int);
|
||||
@@ -54584,6 +54585,7 @@ package android.widget {
|
||||
method public void setChronometerCountDown(@IdRes int, boolean);
|
||||
method public void setColor(@IdRes int, @NonNull String, @ColorRes int);
|
||||
method public void setColorStateList(@IdRes int, @NonNull String, @ColorRes int);
|
||||
method public void setCompoundButtonChecked(@IdRes int, boolean);
|
||||
method public void setContentDescription(@IdRes int, CharSequence);
|
||||
method public void setDisplayedChild(@IdRes int, int);
|
||||
method public void setDouble(@IdRes int, String, double);
|
||||
@@ -54608,6 +54610,7 @@ package android.widget {
|
||||
method public void setOnClickResponse(@IdRes int, @NonNull android.widget.RemoteViews.RemoteResponse);
|
||||
method public void setPendingIntentTemplate(@IdRes int, android.app.PendingIntent);
|
||||
method public void setProgressBar(@IdRes int, int, int, boolean);
|
||||
method public void setRadioGroupChecked(@IdRes int, @IdRes int);
|
||||
method public void setRelativeScrollPosition(@IdRes int, int);
|
||||
method @Deprecated public void setRemoteAdapter(int, @IdRes int, android.content.Intent);
|
||||
method public void setRemoteAdapter(@IdRes int, android.content.Intent);
|
||||
@@ -54974,7 +54977,7 @@ package android.widget {
|
||||
ctor public StackView(android.content.Context, android.util.AttributeSet, int, int);
|
||||
}
|
||||
|
||||
public class Switch extends android.widget.CompoundButton {
|
||||
@android.widget.RemoteViews.RemoteView public class Switch extends android.widget.CompoundButton {
|
||||
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);
|
||||
@@ -55005,12 +55008,14 @@ package android.widget {
|
||||
method public void setTextOff(CharSequence);
|
||||
method public void setTextOn(CharSequence);
|
||||
method public void setThumbDrawable(android.graphics.drawable.Drawable);
|
||||
method public void setThumbIcon(@Nullable android.graphics.drawable.Icon);
|
||||
method public void setThumbResource(@DrawableRes int);
|
||||
method public void setThumbTextPadding(int);
|
||||
method public void setThumbTintBlendMode(@Nullable android.graphics.BlendMode);
|
||||
method public void setThumbTintList(@Nullable android.content.res.ColorStateList);
|
||||
method public void setThumbTintMode(@Nullable android.graphics.PorterDuff.Mode);
|
||||
method public void setTrackDrawable(android.graphics.drawable.Drawable);
|
||||
method public void setTrackIcon(@Nullable android.graphics.drawable.Icon);
|
||||
method public void setTrackResource(@DrawableRes int);
|
||||
method public void setTrackTintBlendMode(@Nullable android.graphics.BlendMode);
|
||||
method public void setTrackTintList(@Nullable android.content.res.ColorStateList);
|
||||
|
||||
@@ -18,6 +18,7 @@ package android.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RemoteViews.RemoteView;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -52,6 +53,7 @@ import android.util.AttributeSet;
|
||||
* {@link android.R.styleable#View View Attributes}
|
||||
* </p>
|
||||
*/
|
||||
@RemoteView
|
||||
public class CheckBox extends CompoundButton {
|
||||
public CheckBox(Context context) {
|
||||
this(context, null);
|
||||
|
||||
@@ -27,11 +27,13 @@ import android.graphics.BlendMode;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.RemotableViewMethod;
|
||||
import android.view.SoundEffectConstants;
|
||||
import android.view.ViewDebug;
|
||||
import android.view.ViewHierarchyEncoder;
|
||||
@@ -275,6 +277,7 @@ public abstract class CompoundButton extends Button implements Checkable {
|
||||
* @param resId the resource identifier of the drawable
|
||||
* @attr ref android.R.styleable#CompoundButton_button
|
||||
*/
|
||||
@RemotableViewMethod(asyncImpl = "setButtonDrawableAsync")
|
||||
public void setButtonDrawable(@DrawableRes int resId) {
|
||||
final Drawable d;
|
||||
if (resId != 0) {
|
||||
@@ -285,6 +288,12 @@ public abstract class CompoundButton extends Button implements Checkable {
|
||||
setButtonDrawable(d);
|
||||
}
|
||||
|
||||
/** @hide **/
|
||||
public Runnable setButtonDrawableAsync(@DrawableRes int resId) {
|
||||
Drawable drawable = resId == 0 ? null : getContext().getDrawable(resId);
|
||||
return () -> setButtonDrawable(drawable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a drawable as the compound button image.
|
||||
*
|
||||
@@ -335,6 +344,23 @@ public abstract class CompoundButton extends Button implements Checkable {
|
||||
return mButtonDrawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the button of this CompoundButton to the specified Icon.
|
||||
*
|
||||
* @param icon an Icon holding the desired button, or {@code null} to clear
|
||||
* the button
|
||||
*/
|
||||
@RemotableViewMethod(asyncImpl = "setButtonIconAsync")
|
||||
public void setButtonIcon(@Nullable Icon icon) {
|
||||
setButtonDrawable(icon == null ? null : icon.loadDrawable(getContext()));
|
||||
}
|
||||
|
||||
/** @hide **/
|
||||
public Runnable setButtonIconAsync(@Nullable Icon icon) {
|
||||
Drawable button = icon == null ? null : icon.loadDrawable(getContext());
|
||||
return () -> setButtonDrawable(button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a tint to the button drawable. Does not modify the current tint
|
||||
* mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
|
||||
@@ -350,6 +376,7 @@ public abstract class CompoundButton extends Button implements Checkable {
|
||||
* @see #setButtonTintList(ColorStateList)
|
||||
* @see Drawable#setTintList(ColorStateList)
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setButtonTintList(@Nullable ColorStateList tint) {
|
||||
mButtonTintList = tint;
|
||||
mHasButtonTint = true;
|
||||
@@ -394,6 +421,7 @@ public abstract class CompoundButton extends Button implements Checkable {
|
||||
* @see #getButtonTintMode()
|
||||
* @see Drawable#setTintBlendMode(BlendMode)
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setButtonTintBlendMode(@Nullable BlendMode tintMode) {
|
||||
mButtonBlendMode = tintMode;
|
||||
mHasButtonBlendMode = true;
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.RemoteViews.RemoteView;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
@@ -49,6 +50,7 @@ import com.android.internal.R;
|
||||
* {@link android.R.styleable#View View Attributes}
|
||||
* </p>
|
||||
*/
|
||||
@RemoteView
|
||||
public class RadioButton extends CompoundButton {
|
||||
|
||||
public RadioButton(Context context) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.view.ViewStructure;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.autofill.AutofillManager;
|
||||
import android.view.autofill.AutofillValue;
|
||||
import android.widget.RemoteViews.RemoteView;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
@@ -59,6 +60,7 @@ import com.android.internal.R;
|
||||
* @see RadioButton
|
||||
*
|
||||
*/
|
||||
@RemoteView
|
||||
public class RadioGroup extends LinearLayout {
|
||||
private static final String LOG_TAG = RadioGroup.class.getSimpleName();
|
||||
|
||||
|
||||
@@ -132,6 +132,13 @@ import java.util.function.Consumer;
|
||||
* <li>{@link android.widget.TextClock}</li>
|
||||
* <li>{@link android.widget.TextView}</li>
|
||||
* </ul>
|
||||
* <p>As of API 31, the following widgets and layouts may also be used:</p>
|
||||
* <ul>
|
||||
* <li>{@link android.widget.CheckBox}</li>
|
||||
* <li>{@link android.widget.RadioButton}</li>
|
||||
* <li>{@link android.widget.RadioGroup}</li>
|
||||
* <li>{@link android.widget.Switch}</li>
|
||||
* </ul>
|
||||
* <p>Descendants of these classes are not supported.</p>
|
||||
*/
|
||||
public class RemoteViews implements Parcelable, Filter {
|
||||
@@ -185,6 +192,8 @@ public class RemoteViews implements Parcelable, Filter {
|
||||
private static final int REMOVE_FROM_PARENT_ACTION_TAG = 23;
|
||||
private static final int RESOURCE_REFLECTION_ACTION_TAG = 24;
|
||||
private static final int COMPLEX_UNIT_DIMENSION_REFLECTION_ACTION_TAG = 25;
|
||||
private static final int SET_COMPOUND_BUTTON_CHECKED_TAG = 26;
|
||||
private static final int SET_RADIO_GROUP_CHECKED = 27;
|
||||
|
||||
/** @hide **/
|
||||
@IntDef(prefix = "MARGIN_", value = {
|
||||
@@ -2552,6 +2561,87 @@ public class RemoteViews implements Parcelable, Filter {
|
||||
}
|
||||
}
|
||||
|
||||
private static class SetCompoundButtonCheckedAction extends Action {
|
||||
|
||||
private final boolean mChecked;
|
||||
|
||||
SetCompoundButtonCheckedAction(@IdRes int viewId, boolean checked) {
|
||||
this.viewId = viewId;
|
||||
mChecked = checked;
|
||||
}
|
||||
|
||||
SetCompoundButtonCheckedAction(Parcel in) {
|
||||
viewId = in.readInt();
|
||||
mChecked = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(viewId);
|
||||
dest.writeBoolean(mChecked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(View root, ViewGroup rootParent, OnClickHandler handler)
|
||||
throws ActionException {
|
||||
final View target = root.findViewById(viewId);
|
||||
if (target == null) return;
|
||||
|
||||
if (!(target instanceof CompoundButton)) {
|
||||
Log.w(LOG_TAG, "Cannot set checked to view "
|
||||
+ viewId + " because it is not a CompoundButton");
|
||||
return;
|
||||
}
|
||||
|
||||
((CompoundButton) target).setChecked(mChecked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActionTag() {
|
||||
return SET_COMPOUND_BUTTON_CHECKED_TAG;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SetRadioGroupCheckedAction extends Action {
|
||||
|
||||
@IdRes private final int mCheckedId;
|
||||
|
||||
SetRadioGroupCheckedAction(@IdRes int viewId, @IdRes int checkedId) {
|
||||
this.viewId = viewId;
|
||||
mCheckedId = checkedId;
|
||||
}
|
||||
|
||||
SetRadioGroupCheckedAction(Parcel in) {
|
||||
viewId = in.readInt();
|
||||
mCheckedId = in.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(viewId);
|
||||
dest.writeInt(mCheckedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(View root, ViewGroup rootParent, OnClickHandler handler)
|
||||
throws ActionException {
|
||||
final View target = root.findViewById(viewId);
|
||||
if (target == null) return;
|
||||
|
||||
if (!(target instanceof RadioGroup)) {
|
||||
Log.w(LOG_TAG, "Cannot check " + viewId + " because it's not a RadioGroup");
|
||||
return;
|
||||
}
|
||||
|
||||
((RadioGroup) target).check(mCheckedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActionTag() {
|
||||
return SET_RADIO_GROUP_CHECKED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RemoteViews object that will display the views contained
|
||||
* in the specified layout file.
|
||||
@@ -2766,6 +2856,10 @@ public class RemoteViews implements Parcelable, Filter {
|
||||
return new ResourceReflectionAction(parcel);
|
||||
case COMPLEX_UNIT_DIMENSION_REFLECTION_ACTION_TAG:
|
||||
return new ComplexUnitDimensionReflectionAction(parcel);
|
||||
case SET_COMPOUND_BUTTON_CHECKED_TAG:
|
||||
return new SetCompoundButtonCheckedAction(parcel);
|
||||
case SET_RADIO_GROUP_CHECKED:
|
||||
return new SetRadioGroupCheckedAction(parcel);
|
||||
default:
|
||||
throw new ActionException("Tag " + tag + " not found");
|
||||
}
|
||||
@@ -3845,6 +3939,26 @@ public class RemoteViews implements Parcelable, Filter {
|
||||
setInt(viewId, "setLabelFor", labeledId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to calling {@link android.widget.CompoundButton#setChecked(boolean)}.
|
||||
*
|
||||
* @param viewId The id of the view whose property to set.
|
||||
* @param checked true to check the button, false to uncheck it.
|
||||
*/
|
||||
public void setCompoundButtonChecked(@IdRes int viewId, boolean checked) {
|
||||
addAction(new SetCompoundButtonCheckedAction(viewId, checked));
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to calling {@link android.widget.RadioGroup#check(int)}.
|
||||
*
|
||||
* @param viewId The id of the view whose property to set.
|
||||
* @param checkedId The unique id of the radio button to select in the group.
|
||||
*/
|
||||
public void setRadioGroupChecked(@IdRes int viewId, @IdRes int checkedId) {
|
||||
addAction(new SetRadioGroupCheckedAction(viewId, checkedId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an alternate layout ID, which can be used to inflate this view. This layout will be
|
||||
* used by the host when the widgets displayed on a light-background where foreground elements
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.graphics.Rect;
|
||||
import android.graphics.Region.Op;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Build;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.text.Layout;
|
||||
@@ -48,12 +49,14 @@ import android.util.FloatProperty;
|
||||
import android.util.MathUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.RemotableViewMethod;
|
||||
import android.view.SoundEffectConstants;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewStructure;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.inspector.InspectableProperty;
|
||||
import android.widget.RemoteViews.RemoteView;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
@@ -84,6 +87,7 @@ import com.android.internal.R;
|
||||
* @attr ref android.R.styleable#Switch_thumbTextPadding
|
||||
* @attr ref android.R.styleable#Switch_track
|
||||
*/
|
||||
@RemoteView
|
||||
public class Switch extends CompoundButton {
|
||||
private static final int THUMB_ANIMATION_DURATION = 250;
|
||||
|
||||
@@ -441,6 +445,7 @@ public class Switch extends CompoundButton {
|
||||
*
|
||||
* @attr ref android.R.styleable#Switch_switchPadding
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setSwitchPadding(int pixels) {
|
||||
mSwitchPadding = pixels;
|
||||
requestLayout();
|
||||
@@ -466,6 +471,7 @@ public class Switch extends CompoundButton {
|
||||
*
|
||||
* @attr ref android.R.styleable#Switch_switchMinWidth
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setSwitchMinWidth(int pixels) {
|
||||
mSwitchMinWidth = pixels;
|
||||
requestLayout();
|
||||
@@ -491,6 +497,7 @@ public class Switch extends CompoundButton {
|
||||
*
|
||||
* @attr ref android.R.styleable#Switch_thumbTextPadding
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setThumbTextPadding(int pixels) {
|
||||
mThumbTextPadding = pixels;
|
||||
requestLayout();
|
||||
@@ -533,10 +540,17 @@ public class Switch extends CompoundButton {
|
||||
*
|
||||
* @attr ref android.R.styleable#Switch_track
|
||||
*/
|
||||
@RemotableViewMethod(asyncImpl = "setTrackResourceAsync")
|
||||
public void setTrackResource(@DrawableRes int resId) {
|
||||
setTrackDrawable(getContext().getDrawable(resId));
|
||||
}
|
||||
|
||||
/** @hide **/
|
||||
public Runnable setTrackResourceAsync(@DrawableRes int resId) {
|
||||
Drawable drawable = resId == 0 ? null : getContext().getDrawable(resId);
|
||||
return () -> setTrackDrawable(drawable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the drawable used for the track that the switch slides within.
|
||||
*
|
||||
@@ -549,6 +563,23 @@ public class Switch extends CompoundButton {
|
||||
return mTrackDrawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the drawable used for the track that the switch slides within to the specified Icon.
|
||||
*
|
||||
* @param icon an Icon holding the desired track, or {@code null} to clear
|
||||
* the track
|
||||
*/
|
||||
@RemotableViewMethod(asyncImpl = "setTrackIconAsync")
|
||||
public void setTrackIcon(@Nullable Icon icon) {
|
||||
setTrackDrawable(icon == null ? null : icon.loadDrawable(getContext()));
|
||||
}
|
||||
|
||||
/** @hide **/
|
||||
public Runnable setTrackIconAsync(@Nullable Icon icon) {
|
||||
Drawable track = icon == null ? null : icon.loadDrawable(getContext());
|
||||
return () -> setTrackDrawable(track);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a tint to the track drawable. Does not modify the current
|
||||
* tint mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
|
||||
@@ -563,6 +594,7 @@ public class Switch extends CompoundButton {
|
||||
* @see #getTrackTintList()
|
||||
* @see Drawable#setTintList(ColorStateList)
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setTrackTintList(@Nullable ColorStateList tint) {
|
||||
mTrackTintList = tint;
|
||||
mHasTrackTint = true;
|
||||
@@ -607,6 +639,7 @@ public class Switch extends CompoundButton {
|
||||
* @see #getTrackTintMode()
|
||||
* @see Drawable#setTintBlendMode(BlendMode)
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setTrackTintBlendMode(@Nullable BlendMode blendMode) {
|
||||
mTrackBlendMode = blendMode;
|
||||
mHasTrackTintMode = true;
|
||||
@@ -686,10 +719,17 @@ public class Switch extends CompoundButton {
|
||||
*
|
||||
* @attr ref android.R.styleable#Switch_thumb
|
||||
*/
|
||||
@RemotableViewMethod(asyncImpl = "setThumbResourceAsync")
|
||||
public void setThumbResource(@DrawableRes int resId) {
|
||||
setThumbDrawable(getContext().getDrawable(resId));
|
||||
}
|
||||
|
||||
/** @hide **/
|
||||
public Runnable setThumbResourceAsync(@DrawableRes int resId) {
|
||||
Drawable drawable = resId == 0 ? null : getContext().getDrawable(resId);
|
||||
return () -> setThumbDrawable(drawable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the drawable used for the switch "thumb" - the piece that the user
|
||||
* can physically touch and drag along the track.
|
||||
@@ -703,6 +743,24 @@ public class Switch extends CompoundButton {
|
||||
return mThumbDrawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the drawable used for the switch "thumb" - the piece that the user
|
||||
* can physically touch and drag along the track - to the specified Icon.
|
||||
*
|
||||
* @param icon an Icon holding the desired thumb, or {@code null} to clear
|
||||
* the thumb
|
||||
*/
|
||||
@RemotableViewMethod(asyncImpl = "setThumbIconAsync")
|
||||
public void setThumbIcon(@Nullable Icon icon) {
|
||||
setThumbDrawable(icon == null ? null : icon.loadDrawable(getContext()));
|
||||
}
|
||||
|
||||
/** @hide **/
|
||||
public Runnable setThumbIconAsync(@Nullable Icon icon) {
|
||||
Drawable track = icon == null ? null : icon.loadDrawable(getContext());
|
||||
return () -> setThumbDrawable(track);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a tint to the thumb drawable. Does not modify the current
|
||||
* tint mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
|
||||
@@ -717,6 +775,7 @@ public class Switch extends CompoundButton {
|
||||
* @see #getThumbTintList()
|
||||
* @see Drawable#setTintList(ColorStateList)
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setThumbTintList(@Nullable ColorStateList tint) {
|
||||
mThumbTintList = tint;
|
||||
mHasThumbTint = true;
|
||||
@@ -761,6 +820,7 @@ public class Switch extends CompoundButton {
|
||||
* @see #getThumbTintMode()
|
||||
* @see Drawable#setTintBlendMode(BlendMode)
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setThumbTintBlendMode(@Nullable BlendMode blendMode) {
|
||||
mThumbBlendMode = blendMode;
|
||||
mHasThumbTintMode = true;
|
||||
@@ -822,6 +882,7 @@ public class Switch extends CompoundButton {
|
||||
*
|
||||
* @attr ref android.R.styleable#Switch_splitTrack
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setSplitTrack(boolean splitTrack) {
|
||||
mSplitTrack = splitTrack;
|
||||
invalidate();
|
||||
@@ -852,6 +913,7 @@ public class Switch extends CompoundButton {
|
||||
*
|
||||
* @attr ref android.R.styleable#Switch_textOn
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setTextOn(CharSequence textOn) {
|
||||
mTextOn = textOn;
|
||||
requestLayout();
|
||||
@@ -875,6 +937,7 @@ public class Switch extends CompoundButton {
|
||||
*
|
||||
* @attr ref android.R.styleable#Switch_textOff
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setTextOff(CharSequence textOff) {
|
||||
mTextOff = textOff;
|
||||
requestLayout();
|
||||
@@ -889,6 +952,7 @@ public class Switch extends CompoundButton {
|
||||
* @param showText {@code true} to display on/off text
|
||||
* @attr ref android.R.styleable#Switch_showText
|
||||
*/
|
||||
@RemotableViewMethod
|
||||
public void setShowText(boolean showText) {
|
||||
if (mShowText != showText) {
|
||||
mShowText = showText;
|
||||
|
||||
Reference in New Issue
Block a user