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

Commit c42edd69 authored by Steven Kideckel's avatar Steven Kideckel
Browse files

Enable use of of CompoundButtons in RemoteViews

This change adds @RemoteView and @RemotableViewMethod to the relevant
views we'd like to enable. New APIs have been added to set Icons in
CompooundButton and Switch.

onCheckedChange support will be added in a follow-up CL.

CompoundButton.setChecked and RadioGroup.check aren't directly remotable
since RemoteViews will need to control those calls directly to ensure
that any onCheckedChange listeners aren't triggered by RemoteViews
actions.

Bug: 179245670
Test: manual, atest
Change-Id: I85e2aee62cf39ed008d9c9c1fece813293841fbd
parent 09462b68
Loading
Loading
Loading
Loading
+9 −4
Original line number Original line Diff line number Diff line
@@ -53287,7 +53287,7 @@ package android.widget {
    method public void onSelectedDayChange(@NonNull android.widget.CalendarView, int, int, int);
    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);
    ctor public CheckBox(android.content.Context, android.util.AttributeSet);
    ctor public CheckBox(android.content.Context, android.util.AttributeSet);
    ctor public CheckBox(android.content.Context, android.util.AttributeSet, int);
    ctor public CheckBox(android.content.Context, android.util.AttributeSet, int);
@@ -53353,6 +53353,7 @@ package android.widget {
    method public boolean isChecked();
    method public boolean isChecked();
    method public void setButtonDrawable(@DrawableRes int);
    method public void setButtonDrawable(@DrawableRes int);
    method public void setButtonDrawable(@Nullable android.graphics.drawable.Drawable);
    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 setButtonTintBlendMode(@Nullable android.graphics.BlendMode);
    method public void setButtonTintList(@Nullable android.content.res.ColorStateList);
    method public void setButtonTintList(@Nullable android.content.res.ColorStateList);
    method public void setButtonTintMode(@Nullable android.graphics.PorterDuff.Mode);
    method public void setButtonTintMode(@Nullable android.graphics.PorterDuff.Mode);
@@ -54393,14 +54394,14 @@ package android.widget {
    field protected String[] mExcludeMimes;
    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);
    ctor public RadioButton(android.content.Context, android.util.AttributeSet);
    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);
    ctor public RadioButton(android.content.Context, android.util.AttributeSet, int, 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);
    ctor public RadioGroup(android.content.Context, android.util.AttributeSet);
    ctor public RadioGroup(android.content.Context, android.util.AttributeSet);
    method public void check(@IdRes int);
    method public void check(@IdRes int);
@@ -54522,6 +54523,7 @@ package android.widget {
    method public void setChronometerCountDown(@IdRes int, boolean);
    method public void setChronometerCountDown(@IdRes int, boolean);
    method public void setColor(@IdRes int, @NonNull String, @ColorRes int);
    method public void setColor(@IdRes int, @NonNull String, @ColorRes int);
    method public void setColorStateList(@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 setContentDescription(@IdRes int, CharSequence);
    method public void setDisplayedChild(@IdRes int, int);
    method public void setDisplayedChild(@IdRes int, int);
    method public void setDouble(@IdRes int, String, double);
    method public void setDouble(@IdRes int, String, double);
@@ -54546,6 +54548,7 @@ package android.widget {
    method public void setOnClickResponse(@IdRes int, @NonNull android.widget.RemoteViews.RemoteResponse);
    method public void setOnClickResponse(@IdRes int, @NonNull android.widget.RemoteViews.RemoteResponse);
    method public void setPendingIntentTemplate(@IdRes int, android.app.PendingIntent);
    method public void setPendingIntentTemplate(@IdRes int, android.app.PendingIntent);
    method public void setProgressBar(@IdRes int, int, int, boolean);
    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 public void setRelativeScrollPosition(@IdRes int, int);
    method @Deprecated public void setRemoteAdapter(int, @IdRes int, android.content.Intent);
    method @Deprecated public void setRemoteAdapter(int, @IdRes int, android.content.Intent);
    method public void setRemoteAdapter(@IdRes int, android.content.Intent);
    method public void setRemoteAdapter(@IdRes int, android.content.Intent);
@@ -54912,7 +54915,7 @@ package android.widget {
    ctor public StackView(android.content.Context, android.util.AttributeSet, int, int);
    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);
    ctor public Switch(android.content.Context, android.util.AttributeSet);
    ctor public Switch(android.content.Context, android.util.AttributeSet);
    ctor public Switch(android.content.Context, android.util.AttributeSet, int);
    ctor public Switch(android.content.Context, android.util.AttributeSet, int);
@@ -54943,12 +54946,14 @@ package android.widget {
    method public void setTextOff(CharSequence);
    method public void setTextOff(CharSequence);
    method public void setTextOn(CharSequence);
    method public void setTextOn(CharSequence);
    method public void setThumbDrawable(android.graphics.drawable.Drawable);
    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 setThumbResource(@DrawableRes int);
    method public void setThumbTextPadding(int);
    method public void setThumbTextPadding(int);
    method public void setThumbTintBlendMode(@Nullable android.graphics.BlendMode);
    method public void setThumbTintBlendMode(@Nullable android.graphics.BlendMode);
    method public void setThumbTintList(@Nullable android.content.res.ColorStateList);
    method public void setThumbTintList(@Nullable android.content.res.ColorStateList);
    method public void setThumbTintMode(@Nullable android.graphics.PorterDuff.Mode);
    method public void setThumbTintMode(@Nullable android.graphics.PorterDuff.Mode);
    method public void setTrackDrawable(android.graphics.drawable.Drawable);
    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 setTrackResource(@DrawableRes int);
    method public void setTrackTintBlendMode(@Nullable android.graphics.BlendMode);
    method public void setTrackTintBlendMode(@Nullable android.graphics.BlendMode);
    method public void setTrackTintList(@Nullable android.content.res.ColorStateList);
    method public void setTrackTintList(@Nullable android.content.res.ColorStateList);
+2 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package android.widget;


import android.content.Context;
import android.content.Context;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.widget.RemoteViews.RemoteView;


/**
/**
 * <p>
 * <p>
@@ -52,6 +53,7 @@ import android.util.AttributeSet;
 * {@link android.R.styleable#View View Attributes}
 * {@link android.R.styleable#View View Attributes}
 * </p>
 * </p>
 */
 */
@RemoteView
public class CheckBox extends CompoundButton {
public class CheckBox extends CompoundButton {
    public CheckBox(Context context) {
    public CheckBox(Context context) {
        this(context, null);
        this(context, null);
+28 −0
Original line number Original line Diff line number Diff line
@@ -27,11 +27,13 @@ import android.graphics.BlendMode;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Log;
import android.view.Gravity;
import android.view.Gravity;
import android.view.RemotableViewMethod;
import android.view.SoundEffectConstants;
import android.view.SoundEffectConstants;
import android.view.ViewDebug;
import android.view.ViewDebug;
import android.view.ViewHierarchyEncoder;
import android.view.ViewHierarchyEncoder;
@@ -275,6 +277,7 @@ public abstract class CompoundButton extends Button implements Checkable {
     * @param resId the resource identifier of the drawable
     * @param resId the resource identifier of the drawable
     * @attr ref android.R.styleable#CompoundButton_button
     * @attr ref android.R.styleable#CompoundButton_button
     */
     */
    @RemotableViewMethod(asyncImpl = "setButtonDrawableAsync")
    public void setButtonDrawable(@DrawableRes int resId) {
    public void setButtonDrawable(@DrawableRes int resId) {
        final Drawable d;
        final Drawable d;
        if (resId != 0) {
        if (resId != 0) {
@@ -285,6 +288,12 @@ public abstract class CompoundButton extends Button implements Checkable {
        setButtonDrawable(d);
        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.
     * Sets a drawable as the compound button image.
     *
     *
@@ -335,6 +344,23 @@ public abstract class CompoundButton extends Button implements Checkable {
        return mButtonDrawable;
        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
     * Applies a tint to the button drawable. Does not modify the current tint
     * mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
     * 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 #setButtonTintList(ColorStateList)
     * @see Drawable#setTintList(ColorStateList)
     * @see Drawable#setTintList(ColorStateList)
     */
     */
    @RemotableViewMethod
    public void setButtonTintList(@Nullable ColorStateList tint) {
    public void setButtonTintList(@Nullable ColorStateList tint) {
        mButtonTintList = tint;
        mButtonTintList = tint;
        mHasButtonTint = true;
        mHasButtonTint = true;
@@ -394,6 +421,7 @@ public abstract class CompoundButton extends Button implements Checkable {
     * @see #getButtonTintMode()
     * @see #getButtonTintMode()
     * @see Drawable#setTintBlendMode(BlendMode)
     * @see Drawable#setTintBlendMode(BlendMode)
     */
     */
    @RemotableViewMethod
    public void setButtonTintBlendMode(@Nullable BlendMode tintMode) {
    public void setButtonTintBlendMode(@Nullable BlendMode tintMode) {
        mButtonBlendMode = tintMode;
        mButtonBlendMode = tintMode;
        mHasButtonBlendMode = true;
        mHasButtonBlendMode = true;
+2 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.content.Context;
import android.content.Context;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.RemoteViews.RemoteView;


import com.android.internal.R;
import com.android.internal.R;


@@ -49,6 +50,7 @@ import com.android.internal.R;
 * {@link android.R.styleable#View View Attributes}
 * {@link android.R.styleable#View View Attributes}
 * </p>
 * </p>
 */
 */
@RemoteView
public class RadioButton extends CompoundButton {
public class RadioButton extends CompoundButton {


    public RadioButton(Context context) {
    public RadioButton(Context context) {
+2 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import android.view.ViewStructure;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.autofill.AutofillManager;
import android.view.autofill.AutofillManager;
import android.view.autofill.AutofillValue;
import android.view.autofill.AutofillValue;
import android.widget.RemoteViews.RemoteView;


import com.android.internal.R;
import com.android.internal.R;


@@ -59,6 +60,7 @@ import com.android.internal.R;
 * @see RadioButton
 * @see RadioButton
 *
 *
 */
 */
@RemoteView
public class RadioGroup extends LinearLayout {
public class RadioGroup extends LinearLayout {
    private static final String LOG_TAG = RadioGroup.class.getSimpleName();
    private static final String LOG_TAG = RadioGroup.class.getSimpleName();


Loading