Loading core/java/com/android/internal/widget/NotificationProgressBar.java +21 −14 Original line number Diff line number Diff line Loading @@ -78,6 +78,13 @@ public final class NotificationProgressBar extends ProgressBar implements @Nullable private List<DrawablePart> mProgressDrawableParts = null; /** @see R.styleable#NotificationProgressBar_segMinWidth */ private final float mSegMinWidth; /** @see R.styleable#NotificationProgressBar_segSegGap */ private final float mSegSegGap; /** @see R.styleable#NotificationProgressBar_segPointGap */ private final float mSegPointGap; @Nullable private Drawable mTracker = null; private boolean mHasTrackerIcon = false; Loading Loading @@ -128,6 +135,10 @@ public final class NotificationProgressBar extends ProgressBar implements Log.e(TAG, "Can't get NotificationProgressDrawable", ex); } mSegMinWidth = a.getDimension(R.styleable.NotificationProgressBar_segMinWidth, 0f); mSegSegGap = a.getDimension(R.styleable.NotificationProgressBar_segSegGap, 0f); mSegPointGap = a.getDimension(R.styleable.NotificationProgressBar_segPointGap, 0f); // Supports setting the tracker in xml, but ProgressStyle notifications set/override it // via {@code #setProgressTrackerIcon}. final Drawable tracker = a.getDrawable(R.styleable.NotificationProgressBar_tracker); Loading Loading @@ -444,30 +455,26 @@ public final class NotificationProgressBar extends ProgressBar implements return; } final float segSegGap = mNotificationProgressDrawable.getSegSegGap(); final float segPointGap = mNotificationProgressDrawable.getSegPointGap(); final float pointRadius = mNotificationProgressDrawable.getPointRadius(); mProgressDrawableParts = processPartsAndConvertToDrawableParts( mParts, width, segSegGap, segPointGap, mSegSegGap, mSegPointGap, pointRadius, mHasTrackerIcon, mTrackerDrawWidth ); final float segmentMinWidth = mNotificationProgressDrawable.getSegmentMinWidth(); final float progressFraction = getProgressFraction(); final boolean isStyledByProgress = mProgressModel.isStyledByProgress(); final float progressGap = mHasTrackerIcon ? 0F : mNotificationProgressDrawable.getSegSegGap(); final float progressGap = mHasTrackerIcon ? 0F : mSegSegGap; Pair<List<DrawablePart>, Float> p = null; try { p = maybeStretchAndRescaleSegments( mParts, mProgressDrawableParts, segmentMinWidth, mSegMinWidth, pointRadius, progressFraction, isStyledByProgress, Loading @@ -492,11 +499,11 @@ public final class NotificationProgressBar extends ProgressBar implements mProgressModel.getProgress(), getMax(), width, segSegGap, segPointGap, mSegSegGap, mSegPointGap, pointRadius, mHasTrackerIcon, segmentMinWidth, mSegMinWidth, isStyledByProgress, mTrackerDrawWidth); } catch (NotEnoughWidthToFitAllPartsException ex) { Loading @@ -521,11 +528,11 @@ public final class NotificationProgressBar extends ProgressBar implements mProgressModel.getProgress(), getMax(), width, segSegGap, segPointGap, mSegSegGap, mSegPointGap, pointRadius, mHasTrackerIcon, segmentMinWidth, mSegMinWidth, isStyledByProgress, mTrackerDrawWidth); } catch (NotEnoughWidthToFitAllPartsException ex) { Loading core/java/com/android/internal/widget/NotificationProgressDrawable.java +0 −68 Original line number Diff line number Diff line Loading @@ -83,27 +83,6 @@ public final class NotificationProgressDrawable extends Drawable { this(new State(), null); } /** * Returns the gap between two segments. */ public float getSegSegGap() { return mState.mSegSegGap; } /** * Returns the gap between a segment and a point. */ public float getSegPointGap() { return mState.mSegPointGap; } /** * Returns the gap between a segment and a point. */ public float getSegmentMinWidth() { return mState.mSegmentMinWidth; } /** * Returns the radius for the points. */ Loading Loading @@ -241,11 +220,6 @@ public final class NotificationProgressDrawable extends Drawable { mState.setDensity(resolveDensity(r, 0)); final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.NotificationProgressDrawable); updateStateFromTypedArray(a); a.recycle(); inflateChildElements(r, parser, attrs, theme); updateLocalState(); Loading @@ -262,13 +236,6 @@ public final class NotificationProgressDrawable extends Drawable { state.setDensity(resolveDensity(t.getResources(), 0)); if (state.mThemeAttrs != null) { final TypedArray a = t.resolveAttributes( state.mThemeAttrs, R.styleable.NotificationProgressDrawable); updateStateFromTypedArray(a); a.recycle(); } applyThemeChildElements(t); updateLocalState(); Loading @@ -279,21 +246,6 @@ public final class NotificationProgressDrawable extends Drawable { return (mState.canApplyTheme()) || super.canApplyTheme(); } private void updateStateFromTypedArray(TypedArray a) { final State state = mState; // Account for any configuration changes. state.mChangingConfigurations |= a.getChangingConfigurations(); // Extract the theme attributes, if any. state.mThemeAttrs = a.extractThemeAttrs(); state.mSegSegGap = a.getDimension(R.styleable.NotificationProgressDrawable_segSegGap, state.mSegSegGap); state.mSegPointGap = a.getDimension(R.styleable.NotificationProgressDrawable_segPointGap, state.mSegPointGap); } private void inflateChildElements(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException { TypedArray a; Loading Loading @@ -357,8 +309,6 @@ public final class NotificationProgressDrawable extends Drawable { // Extract the theme attributes, if any. state.mThemeAttrsSegments = a.extractThemeAttrs(); state.mSegmentMinWidth = a.getDimension( R.styleable.NotificationProgressDrawableSegments_minWidth, state.mSegmentMinWidth); state.mSegmentHeight = a.getDimension( R.styleable.NotificationProgressDrawableSegments_height, state.mSegmentHeight); state.mFadedSegmentHeight = a.getDimension( Loading Loading @@ -588,9 +538,6 @@ public final class NotificationProgressDrawable extends Drawable { static final class State extends ConstantState { @Config int mChangingConfigurations; float mSegSegGap = 0.0f; float mSegPointGap = 0.0f; float mSegmentMinWidth = 0.0f; float mSegmentHeight; float mFadedSegmentHeight; float mSegmentCornerRadius; Loading @@ -610,9 +557,6 @@ public final class NotificationProgressDrawable extends Drawable { State(@NonNull State orig, @Nullable Resources res) { mChangingConfigurations = orig.mChangingConfigurations; mSegSegGap = orig.mSegSegGap; mSegPointGap = orig.mSegPointGap; mSegmentMinWidth = orig.mSegmentMinWidth; mSegmentHeight = orig.mSegmentHeight; mFadedSegmentHeight = orig.mFadedSegmentHeight; mSegmentCornerRadius = orig.mSegmentCornerRadius; Loading @@ -631,18 +575,6 @@ public final class NotificationProgressDrawable extends Drawable { } private void applyDensityScaling(int sourceDensity, int targetDensity) { if (mSegSegGap > 0) { mSegSegGap = scaleFromDensity( mSegSegGap, sourceDensity, targetDensity); } if (mSegPointGap > 0) { mSegPointGap = scaleFromDensity( mSegPointGap, sourceDensity, targetDensity); } if (mSegmentMinWidth > 0) { mSegmentMinWidth = scaleFromDensity( mSegmentMinWidth, sourceDensity, targetDensity); } if (mSegmentHeight > 0) { mSegmentHeight = scaleFromDensity( mSegmentHeight, sourceDensity, targetDensity); Loading core/res/res/drawable/notification_progress.xml +1 −4 Original line number Diff line number Diff line Loading @@ -19,12 +19,9 @@ android:gravity="center_vertical|fill_horizontal"> <com.android.internal.widget.NotificationProgressDrawable android:layout_width="wrap_content" android:layout_height="wrap_content" android:segSegGap="@dimen/notification_progress_segSeg_gap" android:segPointGap="@dimen/notification_progress_segPoint_gap"> android:layout_height="wrap_content"> <segments android:color="?attr/colorProgressBackgroundNormal" android:minWidth="@dimen/notification_progress_segments_min_width" android:height="@dimen/notification_progress_segments_height" android:fadedHeight="@dimen/notification_progress_segments_faded_height" android:cornerRadius="@dimen/notification_progress_segments_corner_radius"/> Loading core/res/res/values/attrs.xml +8 −16 Original line number Diff line number Diff line Loading @@ -5573,6 +5573,14 @@ <!-- @hide internal use only --> <declare-styleable name="NotificationProgressBar"> <!-- Minimum required drawing width for segments. The drawing width refers to the width after the original segments have been adjusted for the neighboring Points and gaps. This is enforced by stretching the segments that are too short. --> <attr name="segMinWidth" format="dimension" /> <!-- The gap between two segments. --> <attr name="segSegGap" format="dimension" /> <!-- The gap between a segment and a point. --> <attr name="segPointGap" format="dimension" /> <!-- Draws the tracker on a NotificationProgressBar. --> <attr name="tracker" format="reference" /> <!-- Height of the tracker. --> Loading Loading @@ -7580,25 +7588,9 @@ <!-- NotificationProgressDrawable class --> <!-- ================================== --> <!-- Drawable used to render a notification progress bar, with segments and points. --> <!-- @hide internal use only --> <declare-styleable name="NotificationProgressDrawable"> <!-- The gap between two segments. --> <attr name="segSegGap" format="dimension" /> <!-- The gap between a segment and a point. --> <attr name="segPointGap" format="dimension" /> </declare-styleable> <!-- Used to config the segments of a NotificationProgressDrawable. --> <!-- @hide internal use only --> <declare-styleable name="NotificationProgressDrawableSegments"> <!-- TODO: b/390196782 - maybe move this to NotificationProgressBar, because that's the only place this is used actually. Same for NotificationProgressDrawable.segSegGap/segPointGap above. --> <!-- Minimum required drawing width. The drawing width refers to the width after the original segments have been adjusted for the neighboring Points and gaps. This is enforced by stretching the segments that are too short. --> <attr name="minWidth" /> <!-- Height of the solid segments. --> <attr name="height" /> <!-- Height of the faded segments. --> Loading core/res/res/values/styles_material.xml +3 −0 Original line number Diff line number Diff line Loading @@ -503,6 +503,9 @@ please see styles_device_defaults.xml. <style name="Widget.Material.Notification.ProgressBar" parent="Widget.Material.Light.ProgressBar.Horizontal" /> <style name="Widget.Material.Notification.NotificationProgressBar" parent="Widget.Material.Light.ProgressBar.Horizontal"> <item name="segMinWidth">@dimen/notification_progress_segments_min_width</item> <item name="segSegGap">@dimen/notification_progress_segSeg_gap</item> <item name="segPointGap">@dimen/notification_progress_segPoint_gap</item> <item name="progressDrawable">@drawable/notification_progress</item> <item name="trackerHeight">@dimen/notification_progress_tracker_height</item> </style> Loading Loading
core/java/com/android/internal/widget/NotificationProgressBar.java +21 −14 Original line number Diff line number Diff line Loading @@ -78,6 +78,13 @@ public final class NotificationProgressBar extends ProgressBar implements @Nullable private List<DrawablePart> mProgressDrawableParts = null; /** @see R.styleable#NotificationProgressBar_segMinWidth */ private final float mSegMinWidth; /** @see R.styleable#NotificationProgressBar_segSegGap */ private final float mSegSegGap; /** @see R.styleable#NotificationProgressBar_segPointGap */ private final float mSegPointGap; @Nullable private Drawable mTracker = null; private boolean mHasTrackerIcon = false; Loading Loading @@ -128,6 +135,10 @@ public final class NotificationProgressBar extends ProgressBar implements Log.e(TAG, "Can't get NotificationProgressDrawable", ex); } mSegMinWidth = a.getDimension(R.styleable.NotificationProgressBar_segMinWidth, 0f); mSegSegGap = a.getDimension(R.styleable.NotificationProgressBar_segSegGap, 0f); mSegPointGap = a.getDimension(R.styleable.NotificationProgressBar_segPointGap, 0f); // Supports setting the tracker in xml, but ProgressStyle notifications set/override it // via {@code #setProgressTrackerIcon}. final Drawable tracker = a.getDrawable(R.styleable.NotificationProgressBar_tracker); Loading Loading @@ -444,30 +455,26 @@ public final class NotificationProgressBar extends ProgressBar implements return; } final float segSegGap = mNotificationProgressDrawable.getSegSegGap(); final float segPointGap = mNotificationProgressDrawable.getSegPointGap(); final float pointRadius = mNotificationProgressDrawable.getPointRadius(); mProgressDrawableParts = processPartsAndConvertToDrawableParts( mParts, width, segSegGap, segPointGap, mSegSegGap, mSegPointGap, pointRadius, mHasTrackerIcon, mTrackerDrawWidth ); final float segmentMinWidth = mNotificationProgressDrawable.getSegmentMinWidth(); final float progressFraction = getProgressFraction(); final boolean isStyledByProgress = mProgressModel.isStyledByProgress(); final float progressGap = mHasTrackerIcon ? 0F : mNotificationProgressDrawable.getSegSegGap(); final float progressGap = mHasTrackerIcon ? 0F : mSegSegGap; Pair<List<DrawablePart>, Float> p = null; try { p = maybeStretchAndRescaleSegments( mParts, mProgressDrawableParts, segmentMinWidth, mSegMinWidth, pointRadius, progressFraction, isStyledByProgress, Loading @@ -492,11 +499,11 @@ public final class NotificationProgressBar extends ProgressBar implements mProgressModel.getProgress(), getMax(), width, segSegGap, segPointGap, mSegSegGap, mSegPointGap, pointRadius, mHasTrackerIcon, segmentMinWidth, mSegMinWidth, isStyledByProgress, mTrackerDrawWidth); } catch (NotEnoughWidthToFitAllPartsException ex) { Loading @@ -521,11 +528,11 @@ public final class NotificationProgressBar extends ProgressBar implements mProgressModel.getProgress(), getMax(), width, segSegGap, segPointGap, mSegSegGap, mSegPointGap, pointRadius, mHasTrackerIcon, segmentMinWidth, mSegMinWidth, isStyledByProgress, mTrackerDrawWidth); } catch (NotEnoughWidthToFitAllPartsException ex) { Loading
core/java/com/android/internal/widget/NotificationProgressDrawable.java +0 −68 Original line number Diff line number Diff line Loading @@ -83,27 +83,6 @@ public final class NotificationProgressDrawable extends Drawable { this(new State(), null); } /** * Returns the gap between two segments. */ public float getSegSegGap() { return mState.mSegSegGap; } /** * Returns the gap between a segment and a point. */ public float getSegPointGap() { return mState.mSegPointGap; } /** * Returns the gap between a segment and a point. */ public float getSegmentMinWidth() { return mState.mSegmentMinWidth; } /** * Returns the radius for the points. */ Loading Loading @@ -241,11 +220,6 @@ public final class NotificationProgressDrawable extends Drawable { mState.setDensity(resolveDensity(r, 0)); final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.NotificationProgressDrawable); updateStateFromTypedArray(a); a.recycle(); inflateChildElements(r, parser, attrs, theme); updateLocalState(); Loading @@ -262,13 +236,6 @@ public final class NotificationProgressDrawable extends Drawable { state.setDensity(resolveDensity(t.getResources(), 0)); if (state.mThemeAttrs != null) { final TypedArray a = t.resolveAttributes( state.mThemeAttrs, R.styleable.NotificationProgressDrawable); updateStateFromTypedArray(a); a.recycle(); } applyThemeChildElements(t); updateLocalState(); Loading @@ -279,21 +246,6 @@ public final class NotificationProgressDrawable extends Drawable { return (mState.canApplyTheme()) || super.canApplyTheme(); } private void updateStateFromTypedArray(TypedArray a) { final State state = mState; // Account for any configuration changes. state.mChangingConfigurations |= a.getChangingConfigurations(); // Extract the theme attributes, if any. state.mThemeAttrs = a.extractThemeAttrs(); state.mSegSegGap = a.getDimension(R.styleable.NotificationProgressDrawable_segSegGap, state.mSegSegGap); state.mSegPointGap = a.getDimension(R.styleable.NotificationProgressDrawable_segPointGap, state.mSegPointGap); } private void inflateChildElements(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException { TypedArray a; Loading Loading @@ -357,8 +309,6 @@ public final class NotificationProgressDrawable extends Drawable { // Extract the theme attributes, if any. state.mThemeAttrsSegments = a.extractThemeAttrs(); state.mSegmentMinWidth = a.getDimension( R.styleable.NotificationProgressDrawableSegments_minWidth, state.mSegmentMinWidth); state.mSegmentHeight = a.getDimension( R.styleable.NotificationProgressDrawableSegments_height, state.mSegmentHeight); state.mFadedSegmentHeight = a.getDimension( Loading Loading @@ -588,9 +538,6 @@ public final class NotificationProgressDrawable extends Drawable { static final class State extends ConstantState { @Config int mChangingConfigurations; float mSegSegGap = 0.0f; float mSegPointGap = 0.0f; float mSegmentMinWidth = 0.0f; float mSegmentHeight; float mFadedSegmentHeight; float mSegmentCornerRadius; Loading @@ -610,9 +557,6 @@ public final class NotificationProgressDrawable extends Drawable { State(@NonNull State orig, @Nullable Resources res) { mChangingConfigurations = orig.mChangingConfigurations; mSegSegGap = orig.mSegSegGap; mSegPointGap = orig.mSegPointGap; mSegmentMinWidth = orig.mSegmentMinWidth; mSegmentHeight = orig.mSegmentHeight; mFadedSegmentHeight = orig.mFadedSegmentHeight; mSegmentCornerRadius = orig.mSegmentCornerRadius; Loading @@ -631,18 +575,6 @@ public final class NotificationProgressDrawable extends Drawable { } private void applyDensityScaling(int sourceDensity, int targetDensity) { if (mSegSegGap > 0) { mSegSegGap = scaleFromDensity( mSegSegGap, sourceDensity, targetDensity); } if (mSegPointGap > 0) { mSegPointGap = scaleFromDensity( mSegPointGap, sourceDensity, targetDensity); } if (mSegmentMinWidth > 0) { mSegmentMinWidth = scaleFromDensity( mSegmentMinWidth, sourceDensity, targetDensity); } if (mSegmentHeight > 0) { mSegmentHeight = scaleFromDensity( mSegmentHeight, sourceDensity, targetDensity); Loading
core/res/res/drawable/notification_progress.xml +1 −4 Original line number Diff line number Diff line Loading @@ -19,12 +19,9 @@ android:gravity="center_vertical|fill_horizontal"> <com.android.internal.widget.NotificationProgressDrawable android:layout_width="wrap_content" android:layout_height="wrap_content" android:segSegGap="@dimen/notification_progress_segSeg_gap" android:segPointGap="@dimen/notification_progress_segPoint_gap"> android:layout_height="wrap_content"> <segments android:color="?attr/colorProgressBackgroundNormal" android:minWidth="@dimen/notification_progress_segments_min_width" android:height="@dimen/notification_progress_segments_height" android:fadedHeight="@dimen/notification_progress_segments_faded_height" android:cornerRadius="@dimen/notification_progress_segments_corner_radius"/> Loading
core/res/res/values/attrs.xml +8 −16 Original line number Diff line number Diff line Loading @@ -5573,6 +5573,14 @@ <!-- @hide internal use only --> <declare-styleable name="NotificationProgressBar"> <!-- Minimum required drawing width for segments. The drawing width refers to the width after the original segments have been adjusted for the neighboring Points and gaps. This is enforced by stretching the segments that are too short. --> <attr name="segMinWidth" format="dimension" /> <!-- The gap between two segments. --> <attr name="segSegGap" format="dimension" /> <!-- The gap between a segment and a point. --> <attr name="segPointGap" format="dimension" /> <!-- Draws the tracker on a NotificationProgressBar. --> <attr name="tracker" format="reference" /> <!-- Height of the tracker. --> Loading Loading @@ -7580,25 +7588,9 @@ <!-- NotificationProgressDrawable class --> <!-- ================================== --> <!-- Drawable used to render a notification progress bar, with segments and points. --> <!-- @hide internal use only --> <declare-styleable name="NotificationProgressDrawable"> <!-- The gap between two segments. --> <attr name="segSegGap" format="dimension" /> <!-- The gap between a segment and a point. --> <attr name="segPointGap" format="dimension" /> </declare-styleable> <!-- Used to config the segments of a NotificationProgressDrawable. --> <!-- @hide internal use only --> <declare-styleable name="NotificationProgressDrawableSegments"> <!-- TODO: b/390196782 - maybe move this to NotificationProgressBar, because that's the only place this is used actually. Same for NotificationProgressDrawable.segSegGap/segPointGap above. --> <!-- Minimum required drawing width. The drawing width refers to the width after the original segments have been adjusted for the neighboring Points and gaps. This is enforced by stretching the segments that are too short. --> <attr name="minWidth" /> <!-- Height of the solid segments. --> <attr name="height" /> <!-- Height of the faded segments. --> Loading
core/res/res/values/styles_material.xml +3 −0 Original line number Diff line number Diff line Loading @@ -503,6 +503,9 @@ please see styles_device_defaults.xml. <style name="Widget.Material.Notification.ProgressBar" parent="Widget.Material.Light.ProgressBar.Horizontal" /> <style name="Widget.Material.Notification.NotificationProgressBar" parent="Widget.Material.Light.ProgressBar.Horizontal"> <item name="segMinWidth">@dimen/notification_progress_segments_min_width</item> <item name="segSegGap">@dimen/notification_progress_segSeg_gap</item> <item name="segPointGap">@dimen/notification_progress_segPoint_gap</item> <item name="progressDrawable">@drawable/notification_progress</item> <item name="trackerHeight">@dimen/notification_progress_tracker_height</item> </style> Loading