ProgressStyle


open class ProgressStyle : Notification.Style
kotlin.Any
   ↳ android.app.Notification.Style
   ↳ android.app.Notification.ProgressStyle

A Notification Style used to define a notification whose expanded state includes a highly customizable progress bar with segments, points, a custom tracker icon, and custom icons at the start and end of the progress bar. This style is suggested for use cases where the app is showing a tracker to the user of a thing they are interested in: the location of a car on its way to pick them up, food being delivered, or their own progress in a navigation journey. To use this style with your Notification, feed it to Notification.Builder.setStyle(android.app.Notification.Style) like so:

new Notification.Builder(context)
    .setSmallIcon(R.drawable.ic_notification)
    .setColor(Color.GREEN)
    .setColorized(true)
    .setContentTitle("Arrive 10:08 AM").
    .setContentText("Dominique Ansel Bakery Soho")
    .addAction(new Notification.Action("Exit navigation",...))
    .setStyle(new Notification.ProgressStyle()
        .setStyledByProgress(false)
        .setProgress(456)
        .setProgressTrackerIcon(Icon.createWithResource(R.drawable.ic_driving_tracker))
        .addProgressSegment(new Segment(41).setColor(Color.BLACK))
        .addProgressSegment(new Segment(552).setColor(Color.YELLOW))
        .addProgressSegment(new Segment(253).setColor(Color.YELLOW))
        .addProgressSegment(new Segment(94).setColor(Color.BLUE))
        .addProgressPoint(new Point(60).setColor(Color.RED))
        .addProgressPoint(new Point(560).setColor(Color.YELLOW))
    )
  
NOTE: The progress bar layout will be mirrored for RTL layout. NOTE: The extras set by Notification.Builder.setProgress will be overridden by the values set on this style object when the notification is built.

Summary

Nested classes

A point within the progress bar, defining its position and color.

A segment of the progress bar, which defines its length and color.

Public constructors

Public methods
open Notification.ProgressStyle

Adds another point.

open Notification.ProgressStyle

Appends a segment to the end of the progress bar.

open Int

Gets the progress value of the progress bar.

open Icon?

Gets the progress bar end icon.

open Int

Gets the sum of the lengths of all Segments in the style, which defines the maximum progress.

open MutableList<Notification.ProgressStyle.Point!>

Gets the points that are displayed on the progress bar.

open MutableList<Notification.ProgressStyle.Segment!>

Gets the segments that define the background layer of the progress bar.

open Icon?

Gets the progress bar start icon.

open Icon?

Gets the progress tracker icon for the progress bar.

open Boolean

Get indeterminate value of the progress bar.

open Boolean

Gets whether the progress bar's style is based on its progress.

open Notification.ProgressStyle
setProgress(progress: Int)

Specifies the progress (in the same units as Segment.getLength()) of the tracker along the length of the bar.

open Notification.ProgressStyle

An optional square icon that appears at the end of the progress bar.

open Notification.ProgressStyle

Used to indicate an initialization state without a known progress amount.

open Notification.ProgressStyle

Replaces all the progress points.

open Notification.ProgressStyle

Sets or replaces the segments of the progress bar.

open Notification.ProgressStyle

An optional square icon that appears at the start of the progress bar.

open Notification.ProgressStyle

An optional icon that can appear as an overlay on the bar at the point of current progress.

open Notification.ProgressStyle

Indicates whether the segments and points will be styled differently based on whether they are behind or ahead of the current progress.

Inherited functions
Inherited properties

Public constructors

ProgressStyle

ProgressStyle()

Public methods

addProgressPoint

open fun addProgressPoint(point: Notification.ProgressStyle.Point): Notification.ProgressStyle

Adds another point. Points within a progress bar are used to visualize distinct stages or milestones. For example, you might use points to mark stops in a multi-stop navigation journey, where each point represents a destination. Points can be added in any order, as their position within the progress bar is determined by their individual Point.getPosition().

Parameters
point Notification.ProgressStyle.Point: This value cannot be null.
Return
Notification.ProgressStyle This value cannot be null.

addProgressSegment

open fun addProgressSegment(segment: Notification.ProgressStyle.Segment): Notification.ProgressStyle

Appends a segment to the end of the progress bar. Segments allow for creating progress bars with multiple colors or sections to represent different stages or categories of progress. For example, Traffic conditions along a navigation journey.

Parameters
segment Notification.ProgressStyle.Segment: This value cannot be null.
Return
Notification.ProgressStyle This value cannot be null.

getProgress

open fun getProgress(): Int

Gets the progress value of the progress bar.

See Also

getProgressEndIcon

open fun getProgressEndIcon(): Icon?

Gets the progress bar end icon.

Return
Icon? This value may be null.

getProgressMax

open fun getProgressMax(): Int

Gets the sum of the lengths of all Segments in the style, which defines the maximum progress. Defaults to 100 when segments are omitted.

getProgressPoints

open fun getProgressPoints(): MutableList<Notification.ProgressStyle.Point!>

Gets the points that are displayed on the progress bar. .

Return
MutableList<Notification.ProgressStyle.Point!> This value cannot be null.

getProgressSegments

open fun getProgressSegments(): MutableList<Notification.ProgressStyle.Segment!>

Gets the segments that define the background layer of the progress bar. If no segments are provided, the progress bar will be rendered with a single segment with length 100 and default color.

Return
MutableList<Notification.ProgressStyle.Segment!> This value cannot be null.

getProgressStartIcon

open fun getProgressStartIcon(): Icon?

Gets the progress bar start icon.

Return
Icon? This value may be null.

getProgressTrackerIcon

open fun getProgressTrackerIcon(): Icon?

Gets the progress tracker icon for the progress bar.

Return
Icon? This value may be null.

isProgressIndeterminate

open fun isProgressIndeterminate(): Boolean

Get indeterminate value of the progress bar.

isStyledByProgress

open fun isStyledByProgress(): Boolean

Gets whether the progress bar's style is based on its progress.

setProgress

open fun setProgress(progress: Int): Notification.ProgressStyle

Specifies the progress (in the same units as Segment.getLength()) of the tracker along the length of the bar. The max progress value is the sum of all Segment lengths. The default value is 0.

Return
Notification.ProgressStyle This value cannot be null.

setProgressEndIcon

open fun setProgressEndIcon(endIcon: Icon?): Notification.ProgressStyle

An optional square icon that appears at the end of the progress bar. This icon will be cropped to its central square. This icon will NOT be mirrored in RTL layouts.

Parameters
endIcon Icon?: This value may be null.
Return
Notification.ProgressStyle This value cannot be null.

setProgressIndeterminate

open fun setProgressIndeterminate(indeterminate: Boolean): Notification.ProgressStyle

Used to indicate an initialization state without a known progress amount. When specified, the following fields are ignored:

Return
Notification.ProgressStyle This value cannot be null.

setProgressPoints

open fun setProgressPoints(points: MutableList<Notification.ProgressStyle.Point!>): Notification.ProgressStyle

Replaces all the progress points. Points within a progress bar are used to visualize distinct stages or milestones. For example, you might use points to mark stops in a multi-stop navigation journey, where each point represents a destination.

Parameters
points MutableList<Notification.ProgressStyle.Point!>: This value cannot be null.
Return
Notification.ProgressStyle This value cannot be null.

setProgressSegments

open fun setProgressSegments(progressSegments: MutableList<Notification.ProgressStyle.Segment!>): Notification.ProgressStyle

Sets or replaces the segments of the progress bar. Segments allow for creating progress bars with multiple colors or sections to represent different stages or categories of progress. For example, Traffic conditions along a navigation journey.

Parameters
progressSegments MutableList<Notification.ProgressStyle.Segment!>: This value cannot be null.
Return
Notification.ProgressStyle This value cannot be null.

setProgressStartIcon

open fun setProgressStartIcon(startIcon: Icon?): Notification.ProgressStyle

An optional square icon that appears at the start of the progress bar. This icon will be cropped to its central square. This icon will NOT be mirrored in RTL layouts.

Parameters
startIcon Icon?: This value may be null.
Return
Notification.ProgressStyle This value cannot be null.

setProgressTrackerIcon

open fun setProgressTrackerIcon(trackerIcon: Icon?): Notification.ProgressStyle

An optional icon that can appear as an overlay on the bar at the point of current progress. Aspect ratio may be anywhere from 2:1 to 1:2; content outside that aspect ratio range will be cropped. This icon will be mirrored in RTL.

Parameters
trackerIcon Icon?: This value may be null.
Return
Notification.ProgressStyle This value cannot be null.

setStyledByProgress

open fun setStyledByProgress(enabled: Boolean): Notification.ProgressStyle

Indicates whether the segments and points will be styled differently based on whether they are behind or ahead of the current progress. When true, segments appearing ahead of the current progress will be given a slightly different appearance to indicate that it is part of the progress bar that is not "filled". When false, all segments will be given the filled appearance, and it will be the app's responsibility to use #setProgressTrackerIcon or segment colors to make the current progress clear to the user. the default value is true.

Return
Notification.ProgressStyle This value cannot be null.