Giter VIP home page Giter VIP logo

statusbaralert's Introduction

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 SYSTEM_UI_FLAG_LOW_PROFILE 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+. On Android 4.x the alert will be drawn below the status).

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

Quick walkthrough

Gradle

#####Step 1. Add the JitPack repository to your build file

gradle: add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Add this line to your app's dependencies:


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


Quick Sample

Show a new status bar alert:

val statusBarAlertview: StatusBarAlertView = StatusBarAlert.Builder(this@MainActivity)
                       .autoHide(true)
                       .withDuration(100)
                       .showProgress(true)
                       .withText("autohide!")
                       .withAlertColor(R.color.colorPrimaryDark)
                       .withTextColor(R.color.colorAccent)
                       .withIndeterminateProgressBarColor(R.color.colorAccent)
                       .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(this@MainActivity) {
    // onHidden callback
    Toast.makeText([email protected], "Alert has been hidden.", Toast.LENGHT_SHORT).show()
}

// or just call:

StatusBarAlert.hide(this@MainActivity)

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.

statusbaralert's People

Contributors

fede87 avatar nestoleh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.