summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Stevie Kideckel <kideckel@google.com> 2021-02-11 17:13:40 +0000
committer Stevie Kideckel <kideckel@google.com> 2021-02-22 15:09:18 +0000
commit41c60e0ccb0a5b952df3325c85b47cf2d7e74f39 (patch)
tree68042a234bfe00bcf04863cdb545debc2529c02e
parentce4baef6ea2becc005c7387a4036ec57237038ec (diff)
Expose tint lists and other runtime functionality to RemoteViews
Bug: 180086170 Test: sample app using new methods, atest Change-Id: I5aa5476d95d6c9fb992c4548d97f577234d747a7
-rw-r--r--core/api/current.txt13
-rw-r--r--core/java/android/view/View.java19
-rw-r--r--core/java/android/widget/ImageView.java1
-rw-r--r--core/java/android/widget/ProgressBar.java2
-rw-r--r--core/java/android/widget/RemoteViews.java41
-rw-r--r--core/java/android/widget/TextView.java4
6 files changed, 47 insertions, 33 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 4382b3207e1e..253f1d86f621 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -55074,6 +55074,7 @@ package android.widget {
method public void setChronometerCountDown(@IdRes int, boolean);
method public void setColor(@IdRes int, @NonNull String, @ColorRes int);
method public void setColorInt(@IdRes int, @NonNull String, @ColorInt int, @ColorInt int);
+ method public void setColorStateList(@IdRes int, @NonNull String, @Nullable android.content.res.ColorStateList);
method public void setColorStateList(@IdRes int, @NonNull String, @Nullable android.content.res.ColorStateList, @Nullable android.content.res.ColorStateList);
method public void setColorStateList(@IdRes int, @NonNull String, @ColorRes int);
method public void setCompoundButtonChecked(@IdRes int, boolean);
@@ -55116,6 +55117,12 @@ package android.widget {
method public void setTextViewText(@IdRes int, CharSequence);
method public void setTextViewTextSize(@IdRes int, int, float);
method public void setUri(@IdRes int, String, android.net.Uri);
+ method public void setViewLayoutHeight(@IdRes int, float, int);
+ method public void setViewLayoutHeightDimen(@IdRes int, @DimenRes int);
+ method public void setViewLayoutMargin(@IdRes int, int, float, int);
+ method public void setViewLayoutMarginDimen(@IdRes int, int, @DimenRes int);
+ method public void setViewLayoutWidth(@IdRes int, float, int);
+ method public void setViewLayoutWidthDimen(@IdRes int, @DimenRes int);
method public void setViewOutlinePreferredRadius(@IdRes int, float, int);
method public void setViewOutlinePreferredRadiusDimen(@IdRes int, @DimenRes int);
method public void setViewPadding(@IdRes int, @Px int, @Px int, @Px int, @Px int);
@@ -55126,6 +55133,12 @@ package android.widget {
field @NonNull public static final android.os.Parcelable.Creator<android.widget.RemoteViews> CREATOR;
field public static final String EXTRA_CHECKED = "android.widget.extra.CHECKED";
field public static final String EXTRA_SHARED_ELEMENT_BOUNDS = "android.widget.extra.SHARED_ELEMENT_BOUNDS";
+ field public static final int MARGIN_BOTTOM = 3; // 0x3
+ field public static final int MARGIN_END = 5; // 0x5
+ field public static final int MARGIN_LEFT = 0; // 0x0
+ field public static final int MARGIN_RIGHT = 2; // 0x2
+ field public static final int MARGIN_START = 4; // 0x4
+ field public static final int MARGIN_TOP = 1; // 0x1
}
public static class RemoteViews.ActionException extends java.lang.RuntimeException {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index c46fbc7fb4c4..3789324a038c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6996,6 +6996,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @see #getScrollIndicators()
* @attr ref android.R.styleable#View_scrollIndicators
*/
+ @RemotableViewMethod
public void setScrollIndicators(@ScrollIndicators int indicators) {
setScrollIndicators(indicators,
SCROLL_INDICATORS_PFLAG3_MASK >>> SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT);
@@ -11881,6 +11882,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @see #setFocusable(int)
* @attr ref android.R.styleable#View_focusable
*/
+ @RemotableViewMethod
public void setFocusable(boolean focusable) {
setFocusable(focusable ? FOCUSABLE : NOT_FOCUSABLE);
}
@@ -11899,6 +11901,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @see #setFocusableInTouchMode(boolean)
* @attr ref android.R.styleable#View_focusable
*/
+ @RemotableViewMethod
public void setFocusable(@Focusable int focusable) {
if ((focusable & (FOCUSABLE_AUTO | FOCUSABLE)) == 0) {
setFlags(0, FOCUSABLE_IN_TOUCH_MODE);
@@ -11917,6 +11920,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @see #setFocusable(boolean)
* @attr ref android.R.styleable#View_focusableInTouchMode
*/
+ @RemotableViewMethod
public void setFocusableInTouchMode(boolean focusableInTouchMode) {
// Focusable in touch mode should always be set before the focusable flag
// otherwise, setting the focusable flag will trigger a focusableViewAvailable()
@@ -12871,6 +12875,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_focusedByDefault
*/
+ @RemotableViewMethod
public void setFocusedByDefault(boolean isFocusedByDefault) {
if (isFocusedByDefault == ((mPrivateFlags3 & PFLAG3_FOCUSED_BY_DEFAULT) != 0)) {
return;
@@ -16850,6 +16855,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_rotation
*/
+ @RemotableViewMethod
public void setRotation(float rotation) {
if (rotation != getRotation()) {
// Double-invalidation is necessary to capture view's old and new areas
@@ -16896,6 +16902,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_rotationY
*/
+ @RemotableViewMethod
public void setRotationY(float rotationY) {
if (rotationY != getRotationY()) {
invalidateViewProperty(true, false);
@@ -16941,6 +16948,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_rotationX
*/
+ @RemotableViewMethod
public void setRotationX(float rotationX) {
if (rotationX != getRotationX()) {
invalidateViewProperty(true, false);
@@ -16978,6 +16986,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_scaleX
*/
+ @RemotableViewMethod
public void setScaleX(float scaleX) {
if (scaleX != getScaleX()) {
scaleX = sanitizeFloatPropertyValue(scaleX, "scaleX");
@@ -17016,6 +17025,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_scaleY
*/
+ @RemotableViewMethod
public void setScaleY(float scaleY) {
if (scaleY != getScaleY()) {
scaleY = sanitizeFloatPropertyValue(scaleY, "scaleY");
@@ -17061,6 +17071,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_transformPivotX
*/
+ @RemotableViewMethod
public void setPivotX(float pivotX) {
if (!mRenderNode.isPivotExplicitlySet() || pivotX != getPivotX()) {
invalidateViewProperty(true, false);
@@ -17103,6 +17114,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_transformPivotY
*/
+ @RemotableViewMethod
public void setPivotY(float pivotY) {
if (!mRenderNode.isPivotExplicitlySet() || pivotY != getPivotY()) {
invalidateViewProperty(true, false);
@@ -17243,6 +17255,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_alpha
*/
+ @RemotableViewMethod
public void setAlpha(@FloatRange(from=0.0, to=1.0) float alpha) {
ensureTransformationInfo();
if (mTransformationInfo.mAlpha != alpha) {
@@ -17732,6 +17745,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_elevation
*/
+ @RemotableViewMethod
public void setElevation(float elevation) {
if (elevation != getElevation()) {
elevation = sanitizeFloatPropertyValue(elevation, "elevation");
@@ -17766,6 +17780,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_translationX
*/
+ @RemotableViewMethod
public void setTranslationX(float translationX) {
if (translationX != getTranslationX()) {
invalidateViewProperty(true, false);
@@ -17801,6 +17816,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_translationY
*/
+ @RemotableViewMethod
public void setTranslationY(float translationY) {
if (translationY != getTranslationY()) {
invalidateViewProperty(true, false);
@@ -17828,6 +17844,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*
* @attr ref android.R.styleable#View_translationZ
*/
+ @RemotableViewMethod
public void setTranslationZ(float translationZ) {
if (translationZ != getTranslationZ()) {
translationZ = sanitizeFloatPropertyValue(translationZ, "translationZ");
@@ -23989,6 +24006,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @see #getBackgroundTintList()
* @see Drawable#setTintList(ColorStateList)
*/
+ @RemotableViewMethod
public void setBackgroundTintList(@Nullable ColorStateList tint) {
if (mBackgroundTint == null) {
mBackgroundTint = new TintInfo();
@@ -24248,6 +24266,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @see #getForegroundTintList()
* @see Drawable#setTintList(ColorStateList)
*/
+ @RemotableViewMethod
public void setForegroundTintList(@Nullable ColorStateList tint) {
if (mForegroundInfo == null) {
mForegroundInfo = new ForegroundInfo();
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index 0a08ccd34f02..8aa557bab4e3 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -648,6 +648,7 @@ public class ImageView extends View {
* @see #getImageTintList()
* @see Drawable#setTintList(ColorStateList)
*/
+ @android.view.RemotableViewMethod
public void setImageTintList(@Nullable ColorStateList tint) {
mDrawableTintList = tint;
mHasDrawableTint = true;
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java
index a44808eb3120..1b76ebf7c8c6 100644
--- a/core/java/android/widget/ProgressBar.java
+++ b/core/java/android/widget/ProgressBar.java
@@ -1308,6 +1308,7 @@ public class ProgressBar extends View {
* @see #getSecondaryProgressTintList()
* @see Drawable#setTintList(ColorStateList)
*/
+ @RemotableViewMethod
public void setSecondaryProgressTintList(@Nullable ColorStateList tint) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
@@ -1619,6 +1620,7 @@ public class ProgressBar extends View {
* @param stateDescription The state description.
*/
@Override
+ @RemotableViewMethod
public void setStateDescription(@Nullable CharSequence stateDescription) {
mCustomStateDescription = stateDescription;
if (stateDescription == null) {
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 30bf546eb83e..514471783c6a 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -224,35 +224,17 @@ public class RemoteViews implements Parcelable, Filter {
})
@Retention(RetentionPolicy.SOURCE)
public @interface MarginType {}
- /**
- * The value will apply to the marginLeft.
- * @hide
- */
+ /** The value will apply to the marginLeft. */
public static final int MARGIN_LEFT = 0;
- /**
- * The value will apply to the marginTop.
- * @hide
- */
+ /** The value will apply to the marginTop. */
public static final int MARGIN_TOP = 1;
- /**
- * The value will apply to the marginRight.
- * @hide
- */
+ /** The value will apply to the marginRight. */
public static final int MARGIN_RIGHT = 2;
- /**
- * The value will apply to the marginBottom.
- * @hide
- */
+ /** The value will apply to the marginBottom. */
public static final int MARGIN_BOTTOM = 3;
- /**
- * The value will apply to the marginStart.
- * @hide
- */
+ /** The value will apply to the marginStart. */
public static final int MARGIN_START = 4;
- /**
- * The value will apply to the marginEnd.
- * @hide
- */
+ /** The value will apply to the marginEnd. */
public static final int MARGIN_END = 5;
/** @hide **/
@@ -4002,7 +3984,6 @@ public class RemoteViews implements Parcelable, Filter {
* @param viewId The id of the view to change
* @param type The margin being set e.g. {@link #MARGIN_END}
* @param dimen a dimension resource to apply to the margin, or 0 to clear the margin.
- * @hide
*/
public void setViewLayoutMarginDimen(@IdRes int viewId, @MarginType int type,
@DimenRes int dimen) {
@@ -4021,7 +4002,6 @@ public class RemoteViews implements Parcelable, Filter {
* @param type The margin being set e.g. {@link #MARGIN_END}
* @param value a value for the margin the given units.
* @param units The unit type of the value e.g. {@link TypedValue#COMPLEX_UNIT_DIP}
- * @hide
*/
public void setViewLayoutMargin(@IdRes int viewId, @MarginType int type, float value,
@ComplexDimensionUnit int units) {
@@ -4039,7 +4019,6 @@ public class RemoteViews implements Parcelable, Filter {
*
* @param width Width of the view in the given units
* @param units The unit type of the value e.g. {@link TypedValue#COMPLEX_UNIT_DIP}
- * @hide
*/
public void setViewLayoutWidth(@IdRes int viewId, float width,
@ComplexDimensionUnit int units) {
@@ -4051,7 +4030,6 @@ public class RemoteViews implements Parcelable, Filter {
* the result of {@link Resources#getDimensionPixelSize(int)}.
*
* @param widthDimen the dimension resource for the view's width
- * @hide
*/
public void setViewLayoutWidthDimen(@IdRes int viewId, @DimenRes int widthDimen) {
addAction(new LayoutParamAction(viewId, LayoutParamAction.LAYOUT_WIDTH, widthDimen));
@@ -4068,7 +4046,6 @@ public class RemoteViews implements Parcelable, Filter {
*
* @param height height of the view in the given units
* @param units The unit type of the value e.g. {@link TypedValue#COMPLEX_UNIT_DIP}
- * @hide
*/
public void setViewLayoutHeight(@IdRes int viewId, float height,
@ComplexDimensionUnit int units) {
@@ -4080,7 +4057,6 @@ public class RemoteViews implements Parcelable, Filter {
* the result of {@link Resources#getDimensionPixelSize(int)}.
*
* @param heightDimen a dimen resource to read the height from.
- * @hide
*/
public void setViewLayoutHeightDimen(@IdRes int viewId, @DimenRes int heightDimen) {
addAction(new LayoutParamAction(viewId, LayoutParamAction.LAYOUT_HEIGHT, heightDimen));
@@ -4231,10 +4207,9 @@ public class RemoteViews implements Parcelable, Filter {
* @param viewId The id of the view on which to call the method.
* @param methodName The name of the method to call.
* @param value The value to pass to the method.
- *
- * @hide
*/
- public void setColorStateList(@IdRes int viewId, String methodName, ColorStateList value) {
+ public void setColorStateList(@IdRes int viewId, @NonNull String methodName,
+ @Nullable ColorStateList value) {
addAction(new ReflectionAction(viewId, methodName, BaseReflectionAction.COLOR_STATE_LIST,
value));
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 0f2089a5463f..ca0747fadf14 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4756,6 +4756,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* @see #getJustificationMode()
*/
@Layout.JustificationMode
+ @android.view.RemotableViewMethod
public void setJustificationMode(@Layout.JustificationMode int justificationMode) {
mJustificationMode = justificationMode;
if (mLayout != null) {
@@ -5232,6 +5233,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* @see android.view.Gravity
* @attr ref android.R.styleable#TextView_gravity
*/
+ @android.view.RemotableViewMethod
public void setGravity(int gravity) {
if ((gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
gravity |= Gravity.START;
@@ -5826,6 +5828,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
*
* @attr ref android.R.styleable#TextView_lineHeight
*/
+ @android.view.RemotableViewMethod
public void setLineHeight(@Px @IntRange(from = 0) int lineHeight) {
Preconditions.checkArgumentNonnegative(lineHeight);
@@ -10277,6 +10280,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* @see #setTransformationMethod(TransformationMethod)
* @attr ref android.R.styleable#TextView_textAllCaps
*/
+ @android.view.RemotableViewMethod
public void setAllCaps(boolean allCaps) {
if (allCaps) {
setTransformationMethod(new AllCapsTransformationMethod(getContext()));