diff options
-rw-r--r-- | core/java/android/view/View.java | 13 | ||||
-rw-r--r-- | core/java/android/view/animation/Transformation.java | 3 | ||||
-rw-r--r-- | graphics/java/android/graphics/Canvas.java | 16 | ||||
-rw-r--r-- | graphics/java/android/graphics/Color.java | 13 | ||||
-rw-r--r-- | graphics/java/android/graphics/Outline.java | 3 |
5 files changed, 29 insertions, 19 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 6f8d822..7d49969 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -21,10 +21,12 @@ import android.animation.StateListAnimator; import android.annotation.CallSuper; import android.annotation.ColorInt; import android.annotation.DrawableRes; +import android.annotation.FloatRange; import android.annotation.IdRes; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.Size; import android.content.ClipData; import android.content.Context; import android.content.res.ColorStateList; @@ -10580,7 +10582,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @attr ref android.R.styleable#View_alpha */ - public void setAlpha(float alpha) { + public void setAlpha(@FloatRange(from=0.0, to=1.0) float alpha) { ensureTransformationInfo(); if (mTransformationInfo.mAlpha != alpha) { mTransformationInfo.mAlpha = alpha; @@ -17028,7 +17030,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @param location an array of two integers in which to hold the coordinates */ - public void getLocationOnScreen(int[] location) { + public void getLocationOnScreen(@Size(2) int[] location) { getLocationInWindow(location); final AttachInfo info = mAttachInfo; @@ -17045,7 +17047,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @param location an array of two integers in which to hold the coordinates */ - public void getLocationInWindow(int[] location) { + public void getLocationInWindow(@Size(2) int[] location) { if (location == null || location.length < 2) { throw new IllegalArgumentException("location must be an array of two integers"); } @@ -18889,7 +18891,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @see #dispatchNestedPreScroll(int, int, int[], int[]) */ public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, - int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow) { + int dxUnconsumed, int dyUnconsumed, @Nullable @Size(2) int[] offsetInWindow) { if (isNestedScrollingEnabled() && mNestedScrollingParent != null) { if (dxConsumed != 0 || dyConsumed != 0 || dxUnconsumed != 0 || dyUnconsumed != 0) { int startX = 0; @@ -18937,7 +18939,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @return true if the parent consumed some or all of the scroll delta * @see #dispatchNestedScroll(int, int, int, int, int[]) */ - public boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow) { + public boolean dispatchNestedPreScroll(int dx, int dy, + @Nullable @Size(2) int[] consumed, @Nullable @Size(2) int[] offsetInWindow) { if (isNestedScrollingEnabled() && mNestedScrollingParent != null) { if (dx != 0 || dy != 0) { int startX = 0; diff --git a/core/java/android/view/animation/Transformation.java b/core/java/android/view/animation/Transformation.java index 30c12ed..8eb5b5c 100644 --- a/core/java/android/view/animation/Transformation.java +++ b/core/java/android/view/animation/Transformation.java @@ -16,6 +16,7 @@ package android.view.animation; +import android.annotation.FloatRange; import android.graphics.Matrix; import android.graphics.Rect; @@ -163,7 +164,7 @@ public class Transformation { * Sets the degree of transparency * @param alpha 1.0 means fully opaqe and 0.0 means fully transparent */ - public void setAlpha(float alpha) { + public void setAlpha(@FloatRange(from=0.0, to=1.0) float alpha) { mAlpha = alpha; } diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index 55b7277..150f195 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -20,6 +20,7 @@ import android.annotation.ColorInt; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.Size; import android.text.GraphicsOperations; import android.text.SpannableString; import android.text.SpannedString; @@ -1055,14 +1056,15 @@ public class Canvas { * "points" that are drawn is really (count >> 1). * @param paint The paint used to draw the points */ - public void drawPoints(float[] pts, int offset, int count, @NonNull Paint paint) { + public void drawPoints(@Size(multiple=2) float[] pts, int offset, int count, + @NonNull Paint paint) { native_drawPoints(mNativeCanvasWrapper, pts, offset, count, paint.getNativeInstance()); } /** * Helper for drawPoints() that assumes you want to draw the entire array */ - public void drawPoints(@NonNull float[] pts, @NonNull Paint paint) { + public void drawPoints(@Size(multiple=2) @NonNull float[] pts, @NonNull Paint paint) { drawPoints(pts, 0, pts.length, paint); } @@ -1105,11 +1107,11 @@ public class Canvas { * (count >> 2). * @param paint The paint used to draw the points */ - public void drawLines(float[] pts, int offset, int count, Paint paint) { + public void drawLines(@Size(min=4,multiple=2) float[] pts, int offset, int count, Paint paint) { native_drawLines(mNativeCanvasWrapper, pts, offset, count, paint.getNativeInstance()); } - public void drawLines(@NonNull float[] pts, @NonNull Paint paint) { + public void drawLines(@Size(min=4,multiple=2) @NonNull float[] pts, @NonNull Paint paint) { drawLines(pts, 0, pts.length, paint); } @@ -1829,7 +1831,8 @@ public class Canvas { * @param paint The paint used for the text (e.g. color, size, style) */ @Deprecated - public void drawPosText(@NonNull char[] text, int index, int count, @NonNull float[] pos, + public void drawPosText(@NonNull char[] text, int index, int count, + @NonNull @Size(multiple=2) float[] pos, @NonNull Paint paint) { if (index < 0 || index + count > text.length || count*2 > pos.length) { throw new IndexOutOfBoundsException(); @@ -1852,7 +1855,8 @@ public class Canvas { * @param paint The paint used for the text (e.g. color, size, style) */ @Deprecated - public void drawPosText(@NonNull String text, @NonNull float[] pos, @NonNull Paint paint) { + public void drawPosText(@NonNull String text, @NonNull @Size(multiple=2) float[] pos, + @NonNull Paint paint) { drawPosText(text.toCharArray(), 0, text.length(), pos, paint); } diff --git a/graphics/java/android/graphics/Color.java b/graphics/java/android/graphics/Color.java index df0ebee..666dbd8 100644 --- a/graphics/java/android/graphics/Color.java +++ b/graphics/java/android/graphics/Color.java @@ -17,6 +17,7 @@ package android.graphics; import android.annotation.ColorInt; +import android.annotation.Size; import android.util.MathUtils; import com.android.internal.util.XmlUtils; @@ -214,7 +215,7 @@ public class Color { * 'silver', 'teal'. */ @ColorInt - public static int parseColor(String colorString) { + public static int parseColor(@Size(min=1) String colorString) { if (colorString.charAt(0) == '#') { // Use a long to avoid rollovers on #ffXXXXXX long color = Long.parseLong(colorString.substring(1), 16); @@ -246,7 +247,7 @@ public class Color { * @hide Pending API council */ @ColorInt - public static int HSBtoColor(float[] hsb) { + public static int HSBtoColor(@Size(3) float[] hsb) { return HSBtoColor(hsb[0], hsb[1], hsb[2]); } @@ -327,7 +328,7 @@ public class Color { * @param blue blue component value [0..255] * @param hsv 3 element array which holds the resulting HSV components. */ - public static void RGBToHSV(int red, int green, int blue, float hsv[]) { + public static void RGBToHSV(int red, int green, int blue, @Size(3) float hsv[]) { if (hsv.length < 3) { throw new RuntimeException("3 components required for hsv"); } @@ -342,7 +343,7 @@ public class Color { * @param color the argb color to convert. The alpha component is ignored. * @param hsv 3 element array which holds the resulting HSV components. */ - public static void colorToHSV(@ColorInt int color, float hsv[]) { + public static void colorToHSV(@ColorInt int color, @Size(3) float hsv[]) { RGBToHSV((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF, hsv); } @@ -355,7 +356,7 @@ public class Color { * @param hsv 3 element array which holds the input HSV components. * @return the resulting argb color */ - public static int HSVToColor(float hsv[]) { + public static int HSVToColor(@Size(3) float hsv[]) { return HSVToColor(0xFF, hsv); } @@ -370,7 +371,7 @@ public class Color { * @param hsv 3 element array which holds the input HSV components. * @return the resulting argb color */ - public static int HSVToColor(int alpha, float hsv[]) { + public static int HSVToColor(int alpha, @Size(3) float hsv[]) { if (hsv.length < 3) { throw new RuntimeException("3 components required for hsv"); } diff --git a/graphics/java/android/graphics/Outline.java b/graphics/java/android/graphics/Outline.java index f76184f..aa40408 100644 --- a/graphics/java/android/graphics/Outline.java +++ b/graphics/java/android/graphics/Outline.java @@ -16,6 +16,7 @@ package android.graphics; +import android.annotation.FloatRange; import android.annotation.NonNull; import android.graphics.drawable.Drawable; @@ -101,7 +102,7 @@ public final class Outline { * assumed by the drawing system to fully cover content beneath it, * meaning content beneath may be optimized away. */ - public void setAlpha(float alpha) { + public void setAlpha(@FloatRange(from=0.0, to=1.0) float alpha) { mAlpha = alpha; } |