Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Permissions Flow

Download API

A simple library to make it easy requesting permissions in Android using Kotlin Coroutines.

Setup

Gradle:

Add following line of code to your module (app) level gradle file:

    implementation 'com.innfinity:PermissionsFlow:<LATEST-VERSION>'

Maven:

  <dependency>
    <groupId>com.innfinity</groupId>
    <artifactId>PermissionsFlow</artifactId>
    <version>1.0.1</version>
    <type>pom</type>
  </dependency>

Usage:

Permission flow offers 2 simple extension functions - both for for activities/fragments:

requestPermissions(vararg permissionsToRequest: String)
requestEachPermissions(vararg permissionsToRequest: String)

Both functions do request all permissions passed to them - the first one emits a list of Permissions, the second one flattens the permissions.

Here's a full code example like it would look like in an activity:

override fun onCreate(savedInstanceState: Bundle?) {
 
    CoroutineScope(Dispatchers.Main).launch {
        // just call requestPermission and pass in all required permissions
        requestPermissions(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE)
            .collect { permissions ->
                // here you get the result of the requests, permissions holds a list of Permission requests and you can check if all of them have been granted:
                val allGranted = permissions.find { !it.isGranted } == null
                // or iterate over the permissions and check them one by one
                permissions.forEach { 
                	val granted = it.isGranted
                	// ...
                }
            }
	}
}

That's it!

With only few simple steps you can request permissions without splitting your code or overriding functions.

Versions

1.0.0

First version of library

Contact

Licence

    Permissions Flow©
    Copyright 2020 Robert Levonyan
    Url: https://github.com/innfinity-am/PermissionsFlow

    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.

About

A simple library to make it easy requesting permissions in Android using Kotlin Coroutines.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages