Giter Site home page Giter Site logo

msoftware / startask-permissions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from illiashenkoo/startask-permissions

0.0 1.0 0.0 240 KB

Is a library that helps to handle runtime permissions on Android, entirely written using Kotlin language.

License: Apache License 2.0

Kotlin 100.00%

startask-permissions's Introduction

StartaskPermissions

JitPack Android Arsenal

StartaskPermissions is a library that helps to handle runtime permissions on Android, entirely written using Kotlin language.

Using in your projects

Gradle Gradle

The library is published to JitPack repository.

  1. Add the JitPack repository to your root build.gradle at the end of repositories.
allprojects {
    repositories {
        //...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency

${latest.version} is

dependencies {
    implementation "com.github.illiashenkoo:startask-permissions:${latest.version}"
}

Kotlin Usage with Kotlin

  1. Add the following line to AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
  1. Create a Permission object
private val permission: Permission by lazy {
    Permission.Builder(Manifest.permission.CAMERA)
            .setRequestCode(MY_PERMISSIONS_REQUEST_CODE)
            .build()
}
  1. Check and request permission if needed
permission.check(this)
        .onGranted {
            // All requested permissions are granted
        }.onShowRationale {
            // Provide an explanation if the user has already denied that permission request
        }
  1. Delegate the permission handling to library
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    permission.onRequestPermissionsResult(this, requestCode, grantResults)
            .onGranted {
                // All requested permissions are granted
            }.onDenied {
                // Oops, some of the permissions are denied
            }.onNeverAskAgain {
                // Oops, some of the permissions are denied
                // User chose "never ask again" about a permission
            }
}

Look at the examples of using the library

License

Apache License 2.0

Contacts

Oleg Illiashenko

Contributions and releases

All development (both new features and bug fixes) is performed in develop branch. This way master sources always contain sources of the most recently released version. Please send PRs with bug fixes to develop branch. Fixes to documentation in markdown files are an exception to this rule. They are updated directly in master.

The develop branch is pushed to master during release.

startask-permissions's People

Contributors

illiashenkoo 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.