StatusBarAlert

by fede87

Telegram X inspired android status bar alert view

196 Stars 22 Forks Last release: 3 months ago (v1.1.0) Apache License 2.0 41 Commits 3 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Android Arsenal

What is this?

This is a small library inspired by Telegram X status bar new alert written in Kotlin. It can show custom message with optional indeterminate progress in status bar area. Optional autohide feature can be tweaked with custom duration. When showing, status bar alert kindly hides status bar's icon with SYSTEMUIFLAGLOWPROFILE flag mode, if available from os.

Supported devices

This lib is supported by every device with a SDK level of at least 14 (Android 4+).

Android X required for v1.1.0, otherwise use old version v1.0.2.

Quick walkthrough

Gradle

Add this line to your app's dependencies:

implementation 'com.fede987:status-bar-alert:1.1.0'

Quick Sample

Show a new status bar alert:

val statusBarAlertview: StatusBarAlertView = StatusBarAlert.Builder([email protected])
                       .autoHide(true)
                       .withDuration(100)
                       .showProgress(true)
                       .withText("autohide!")
                       .withAlertColor(R.color.colorPrimaryDark)
                       .withTypeface(typeface)
                       .build()


//update status bar alert view text at any time: statusBarAlertView.updateText("UPDATED!!") //or: statusBarAlertView.updateText(R.string.updated)

// show indeterminate progress: statusBarAlertView.showIndeterminateProgress()

// hide indeterminate progress: statusBarAlertView.hideIndeterminateProgress()

Hide all status bar alerts for current activity with an optional "on hidden" callback:

StatusBarAlert.hide([email protected]) {
    // onHidden callback
    Toast.makeText([email protected], "Alert has been hidden.", Toast.LENGHT_SHORT).show()
}

// or just call:

StatusBarAlert.hide([email protected])

License

Copyright 2018 Federico Marin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.