From aac722a9c0d199c79ae8ce2dd3cce113f01c30b7 Mon Sep 17 00:00:00 2001 From: Philip Milne Date: Mon, 26 Mar 2012 13:30:26 -0700 Subject: Fixes for bugs: 6104423, 6103563, 6103509, 6103807 & 6103253. Add properties to Java API so as to better mirror the framework's XML API. I'm not familiar with many of these areas so this CL is worth some scrutiny. Change-Id: Iff63c43521305efaad5a2189c1b5556d2353cbd4 --- core/java/android/widget/AdapterViewFlipper.java | 26 ++++- core/java/android/widget/ImageView.java | 133 ++++++++++++++++++++++- core/java/android/widget/RadioGroup.java | 2 + core/java/android/widget/RatingBar.java | 4 + 4 files changed, 154 insertions(+), 11 deletions(-) (limited to 'core/java') diff --git a/core/java/android/widget/AdapterViewFlipper.java b/core/java/android/widget/AdapterViewFlipper.java index 5096227..aea029b 100644 --- a/core/java/android/widget/AdapterViewFlipper.java +++ b/core/java/android/widget/AdapterViewFlipper.java @@ -127,13 +127,29 @@ public class AdapterViewFlipper extends AdapterViewAnimator { } /** - * How long to wait before flipping to the next view + * Returns the flip interval, in milliseconds. * - * @param milliseconds - * time in milliseconds + * @return the flip interval in milliseconds + * + * @see #setFlipInterval(int) + * + * @attr ref android.R.styleable#AdapterViewFlipper_flipInterval + */ + public int getFlipInterval() { + return mFlipInterval; + } + + /** + * How long to wait before flipping to the next view. + * + * @param flipInterval flip interval in milliseconds + * + * @see #getFlipInterval() + * + * @attr ref android.R.styleable#AdapterViewFlipper_flipInterval */ - public void setFlipInterval(int milliseconds) { - mFlipInterval = milliseconds; + public void setFlipInterval(int flipInterval) { + mFlipInterval = flipInterval; } /** diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 3001ea1..b1a75e1 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -223,11 +223,28 @@ public class ImageView extends View { } /** + * True when ImageView is adjusting its bounds + * to preserve the aspect ratio of its drawable + * + * @return whether to adjust the bounds of this view + * to presrve the original aspect ratio of the drawable + * + * @see #setAdjustViewBounds(boolean) + * + * @attr ref android.R.styleable#ImageView_adjustViewBounds + */ + public boolean getAdjustViewBounds() { + return mAdjustViewBounds; + } + + /** * Set this to true if you want the ImageView to adjust its bounds * to preserve the aspect ratio of its drawable. * @param adjustViewBounds Whether to adjust the bounds of this view * to presrve the original aspect ratio of the drawable * + * @see #getAdjustViewBounds() + * * @attr ref android.R.styleable#ImageView_adjustViewBounds */ @android.view.RemotableViewMethod @@ -237,7 +254,20 @@ public class ImageView extends View { setScaleType(ScaleType.FIT_CENTER); } } - + + /** + * The maximum width of this view. + * + * @return The maximum width of this view + * + * @see #setMaxWidth(int) + * + * @attr ref android.R.styleable#ImageView_maxWidth + */ + public int getMaxWidth() { + return mMaxWidth; + } + /** * An optional argument to supply a maximum width for this view. Only valid if * {@link #setAdjustViewBounds(boolean)} has been set to true. To set an image to be a maximum @@ -253,14 +283,29 @@ public class ImageView extends View { *

* * @param maxWidth maximum width for this view - * + * + * @see #getMaxWidth() + * * @attr ref android.R.styleable#ImageView_maxWidth */ @android.view.RemotableViewMethod public void setMaxWidth(int maxWidth) { mMaxWidth = maxWidth; } - + + /** + * The maximum height of this view. + * + * @return The maximum height of this view + * + * @see #setMaxHeight(int) + * + * @attr ref android.R.styleable#ImageView_maxHeight + */ + public int getMaxHeight() { + return mMaxHeight; + } + /** * An optional argument to supply a maximum height for this view. Only valid if * {@link #setAdjustViewBounds(boolean)} has been set to true. To set an image to be a @@ -276,7 +321,9 @@ public class ImageView extends View { *

* * @param maxHeight maximum height for this view - * + * + * @see #getMaxHeight() + * * @attr ref android.R.styleable#ImageView_maxHeight */ @android.view.RemotableViewMethod @@ -522,7 +569,37 @@ public class ImageView extends View { invalidate(); } } - + + /** + * Return whether this ImageView crops to padding. + * + * @return whether this ImageView crops to padding + * + * @see #setCropToPadding(boolean) + * + * @attr ref android.R.styleable#ImageView_cropToPadding + */ + public boolean getCropToPadding() { + return mCropToPadding; + } + + /** + * Sets whether this ImageView will crop to padding. + * + * @param cropToPadding whether this ImageView will crop to padding + * + * @see #getCropToPadding() + * + * @attr ref android.R.styleable#ImageView_cropToPadding + */ + public void setCropToPadding(boolean cropToPadding) { + if (mCropToPadding != cropToPadding) { + mCropToPadding = cropToPadding; + requestLayout(); + invalidate(); + } + } + private void resolveUri() { if (mDrawable != null) { return; @@ -997,11 +1074,24 @@ public class ImageView extends View { public final void clearColorFilter() { setColorFilter(null); } - + + /** + * Returns the active color filter for this ImageView. + * + * @return the active color filter for this ImageView + * + * @see #setColorFilter(android.graphics.ColorFilter) + */ + public ColorFilter getColorFilter() { + return mColorFilter; + } + /** * Apply an arbitrary colorfilter to the image. * * @param cf the colorfilter to apply (may be null) + * + * @see #getColorFilter() */ public void setColorFilter(ColorFilter cf) { if (mColorFilter != cf) { @@ -1012,6 +1102,37 @@ public class ImageView extends View { } } + /** + * Returns the alpha that will be applied to the drawable of this ImageView. + * + * @return the alpha that will be applied to the drawable of this ImageView + * + * @see #setImageAlpha(int) + */ + public int getImageAlpha() { + return mAlpha; + } + + /** + * Sets the alpha value that should be applied to the image. + * + * @param alpha the alpha value that should be applied to the image + * + * @see #getImageAlpha() + */ + @RemotableViewMethod + public void setImageAlpha(int alpha) { + setAlpha(alpha); + } + + /** + * Sets the alpha value that should be applied to the image. + * + * @param alpha the alpha value that should be applied to the image + * + * @deprecated use #setImageAlpha(int) instead + */ + @Deprecated @RemotableViewMethod public void setAlpha(int alpha) { alpha &= 0xFF; // keep it legal diff --git a/core/java/android/widget/RadioGroup.java b/core/java/android/widget/RadioGroup.java index 7f53ffd..f217c9c 100644 --- a/core/java/android/widget/RadioGroup.java +++ b/core/java/android/widget/RadioGroup.java @@ -190,6 +190,8 @@ public class RadioGroup extends LinearLayout { * * @see #check(int) * @see #clearCheck() + * + * @attr ref android.R.styleable#RadioGroup_checkedButton */ public int getCheckedRadioButtonId() { return mCheckedId; diff --git a/core/java/android/widget/RatingBar.java b/core/java/android/widget/RatingBar.java index e69577b..524d272 100644 --- a/core/java/android/widget/RatingBar.java +++ b/core/java/android/widget/RatingBar.java @@ -145,6 +145,8 @@ public class RatingBar extends AbsSeekBar { * by the user). * * @param isIndicator Whether it should be an indicator. + * + * @attr ref android.R.styleable#RatingBar_isIndicator */ public void setIsIndicator(boolean isIndicator) { mIsUserSeekable = !isIndicator; @@ -153,6 +155,8 @@ public class RatingBar extends AbsSeekBar { /** * @return Whether this rating bar is only an indicator. + * + * @attr ref android.R.styleable#RatingBar_isIndicator */ public boolean isIndicator() { return !mIsUserSeekable; -- cgit v1.1