Skip to content

Hassle free dealing with Android System UIs (Status bar, Navigation bar, Action bar) With Automated lifecycle managment for Fragments and Activies, and automated handling of configuration changes.

License

smooth-io/smooth-system-ui

Repository files navigation

Smooth system UI

Hassle free dealing with Android System UIs (Status bar, Navigation bar, Action bar) With Automated lifecycle managment for Fragments and Activies, and automated handling of configuration changes.

Getting Started

The library has two versions, with and without lifecycle management, use the lifecycle one to have an automated disabling/releasing of resources and changes when the fragment or activity is dead and you need to revert the changes

Installing

Without lifecycle (NOT RECOMMENED) :
implementation "io.getsmooth.kt.android:system_ui:1.0.0" 
With lifecycle (RECOMMENED) :
implementation "io.getsmooth.kt.android:system_ui:1.0.0" 
implementation "io.getsmooth.kt.android:system_ui.lifecycle:1.0.0" 

Usage

If you use the varient with auto then you don't have to do anything.

but using the varient without auto you will have to call disable in onStop.

Example without Auto:

private var fullScreen: FullScreen? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    fullScreen = fullScreen {}
}

override fun onStop() {
    super.onStop()
    fullScreen?.disable()
    fullScreen?.release()
}

Example with Auto: Requires lifecycle dependency

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    fullScreenAuto{} //Requires lifecycle dependency
}

Varients :

Normal mode

normalAuto(0//optional defaults to 0) {//This makes the status bar and navigation bar visible

            //Passing -1 to delay will not make any change
            //Passing 0 to delay will make the change immediate
            //Passing a value larger than 0 will make the change after the specified delay mills
            
            lightStatusBar() //Make status bar icons dark (use it if you have light status bar)
            
            darkStatusBar() //Make status bar icons light (use it if you have dark status bar)
            
            autoDelay(3000) //This is the delay applied when a configuration change happens and we need to restore the requested state
}

Full screen mode

fullScreenAuto{//This means lean mode
            //The default in fullscreen is hide the action bar
            showActionBar() //Show the action bar instead of hiding it
            
            //The default in full screen is hiding the navigation bars also
            showNavigationBar() //Show the navigation bar instead of hiding them
            
            //The default is that the layout reacts to system UIs visibility like going down/up 
            //based on system UIs visibility
            keepLayout() //Don't react to system UIs changes and keep your layout stable/not changing
}

Immersive mode

immersiveAuto{
            //The default is not_sticky 
            sticky()  //Makes the screen sticky with immersive mode
            
            //The default in immersive mode is hide the action bar
            showActionBar() //Show the action bar instead of hiding it
            
            //The default is that the layout reacts to system UIs visibility like going down/up
            //based on system UIs visibility
            keepLayout() //Don't react to system UIs changes and keep your layout stable/not changing
}

Common things Those available in all varients

You can always pass a delay to your varient :

Passing -1 to delay will not make any change Passing 0 to delay will make the change immediate Passing a value larger than 0 will make the change after the specified delay mills

Light/Dark status bar:

If you want Light Status bar : call lightStatusBar() If you want Dark status bar : call darkStatusBar()

Auto delay:

This determines when a configuration changed and the system ui in a state not the one you requested, this is the delay applied before the changes happen and the ui is back to the state you requested, defaults to 1 second (1000 mills).

Contributing

Feel free to submit pull requests, and we will review it and accept it if it's working well.

Versioning

We use [SemVer] (http://semver.org/) for versioning. For the versions available, see the [tags on this repository] (https://github.com/smooth-io/smooth-system-ui/tags).

Authors

License

This project is licensed under the Apache License - see the LICENSE.md file for details

About

Hassle free dealing with Android System UIs (Status bar, Navigation bar, Action bar) With Automated lifecycle managment for Fragments and Activies, and automated handling of configuration changes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages