Merge "Enable changing ProgressBar min/max width/height"

This commit is contained in:
TreeHugger Robot
2019-02-06 17:54:23 +00:00
committed by Android (Google) Code Review
2 changed files with 92 additions and 3 deletions

View File

@@ -56372,7 +56372,11 @@ package android.widget {
method @Nullable public android.graphics.PorterDuff.Mode getIndeterminateTintMode();
method public android.view.animation.Interpolator getInterpolator();
method @android.view.ViewDebug.ExportedProperty(category="progress") public int getMax();
method @Px public int getMaxHeight();
method @Px public int getMaxWidth();
method @android.view.ViewDebug.ExportedProperty(category="progress") public int getMin();
method @Px public int getMinHeight();
method @Px public int getMinWidth();
method @android.view.ViewDebug.ExportedProperty(category="progress") public int getProgress();
method @Nullable public android.content.res.ColorStateList getProgressBackgroundTintList();
method @Nullable public android.graphics.PorterDuff.Mode getProgressBackgroundTintMode();
@@ -56396,7 +56400,11 @@ package android.widget {
method public void setInterpolator(android.content.Context, @InterpolatorRes int);
method public void setInterpolator(android.view.animation.Interpolator);
method public void setMax(int);
method public void setMaxHeight(@Px int);
method public void setMaxWidth(@Px int);
method public void setMin(int);
method public void setMinHeight(@Px int);
method public void setMinWidth(@Px int);
method public void setProgress(int);
method public void setProgress(int, boolean);
method public void setProgressBackgroundTintList(@Nullable android.content.res.ColorStateList);

View File

@@ -20,6 +20,7 @@ import android.animation.ObjectAnimator;
import android.annotation.InterpolatorRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Px;
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.ColorStateList;
@@ -170,12 +171,24 @@ public class ProgressBar extends View {
/** Duration of smooth progress animations. */
private static final int PROGRESS_ANIM_DURATION = 80;
@UnsupportedAppUsage
/**
* Outside the framework, please use {@link ProgressBar#getMinWidth()} and
* {@link ProgressBar#setMinWidth(int)} instead of accessing these directly.
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
int mMinWidth;
int mMaxWidth;
@UnsupportedAppUsage
/**
* Outside the framework, please use {@link ProgressBar#getMinHeight()} and
* {@link ProgressBar#setMinHeight(int)} instead of accessing these directly.
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
int mMinHeight;
@UnsupportedAppUsage
/**
* Outside the framework, please use {@link ProgressBar#getMaxHeight()} ()} and
* {@link ProgressBar#setMaxHeight(int)} (int)} instead of accessing these directly.
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
int mMaxHeight;
private int mProgress;
@@ -392,6 +405,74 @@ public class ProgressBar extends View {
}
}
/**
* Sets the minimum width the progress bar can have.
* @param minWidth the minimum width to be set, in pixels
* @attr ref android.R.styleable#ProgressBar_minWidth
*/
public void setMinWidth(@Px int minWidth) {
mMinWidth = minWidth;
requestLayout();
}
/**
* @return the minimum width the progress bar can have, in pixels
*/
@Px public int getMinWidth() {
return mMinWidth;
}
/**
* Sets the maximum width the progress bar can have.
* @param maxWidth the maximum width to be set, in pixels
* @attr ref android.R.styleable#ProgressBar_maxWidth
*/
public void setMaxWidth(@Px int maxWidth) {
mMaxWidth = maxWidth;
requestLayout();
}
/**
* @return the maximum width the progress bar can have, in pixels
*/
@Px public int getMaxWidth() {
return mMaxWidth;
}
/**
* Sets the minimum height the progress bar can have.
* @param minHeight the minimum height to be set, in pixels
* @attr ref android.R.styleable#ProgressBar_minHeight
*/
public void setMinHeight(@Px int minHeight) {
mMinHeight = minHeight;
requestLayout();
}
/**
* @return the minimum height the progress bar can have, in pixels
*/
@Px public int getMinHeight() {
return mMinHeight;
}
/**
* Sets the maximum height the progress bar can have.
* @param maxHeight the maximum height to be set, in pixels
* @attr ref android.R.styleable#ProgressBar_maxHeight
*/
public void setMaxHeight(@Px int maxHeight) {
mMaxHeight = maxHeight;
requestLayout();
}
/**
* @return the maximum height the progress bar can have, in pixels
*/
@Px public int getMaxHeight() {
return mMaxHeight;
}
/**
* Returns {@code true} if the target drawable needs to be tileified.
*