{"id":22798673,"url":"https://github.com/ralphpina/android-permissions-manager","last_synced_at":"2025-04-19T15:23:20.328Z","repository":{"id":147150000,"uuid":"45413861","full_name":"ralphpina/Android-Permissions-Manager","owner":"ralphpina","description":"Easily manage Android Marshmallow and up runtime permissions.","archived":false,"fork":false,"pushed_at":"2019-03-15T22:02:45.000Z","size":223,"stargazers_count":50,"open_issues_count":2,"forks_count":22,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T09:22:12.642Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ralphpina.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-02T18:34:32.000Z","updated_at":"2023-09-08T17:03:14.000Z","dependencies_parsed_at":"2023-06-10T02:30:31.020Z","dependency_job_id":null,"html_url":"https://github.com/ralphpina/Android-Permissions-Manager","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphpina%2FAndroid-Permissions-Manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphpina%2FAndroid-Permissions-Manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphpina%2FAndroid-Permissions-Manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphpina%2FAndroid-Permissions-Manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ralphpina","download_url":"https://codeload.github.com/ralphpina/Android-Permissions-Manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249725467,"owners_count":21316204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-12T06:10:43.467Z","updated_at":"2025-04-19T15:23:20.316Z","avatar_url":"https://github.com/ralphpina.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Android Permissions Manager\nEasily manage Android runtime permissions in API 23 `Marshmallow` and up. This library uses RXJava to skip all the painful parts of the `Activity`/`Fragment` lifecycle management.\n\n# Features\n- Reactive API\n- Usage in non-Android modules\n- Kotlin implementation\n- Support for \"Don't ask again\"\n- Catch missing `AndroidManifest.xml` permissions\n\n# Install\nAPM is split into two modules. `permissions-manager` and `permissions-manager-android`. They can be used independently. \n\n`permissions-manager` provides the API to consume the library.\n\n`permissions-manager-android` provides `PermissionsComponent` to init the Android specific implementation of `PermissionsManager`.\n\nIf your app is a monolith with a single `app` module, then you want to include both modules in your `app/build.gradle` like so:\n\n```groovy\ndependencies {\n    implemetation 'net.ralphpina.permissionsmanager:permissions-manager:3.0.1'\n    implemetation 'net.ralphpina.permissionsmanager:permissions-manager-android:3.0.1'\n}\n```\n\nHowever, if your app is a multi-module project, you only need to include `permissions-manager` in the modules where you will consume the library. These modules could be Android or pure Kotlin/Java modules.\n\nLet's say you have an app with the following `settings.gradle`:\n```groovy\ninclude ':app', \n        ':feature1', // pure Kotlin module, no com.android.library plugin \n        ':feature2'  // Android module with com.android.library plugin\n```\n\nLet's say that you use Dagger to build and inject dependencies in your `app` module. In `feature1/build.gradle` and `feature2/build.gradle` you would use the library by including the `permissions-manager` package:\n```groovy\ndependencies {\n    implemetation 'net.ralphpina.permissionsmanager:permissions-manager-android:3.0.1'\n}\n```\n\nThen, in your `app/build.gradle` module you would include both packages to inject `PermissionsManager` using `PermissionsComponent`:\n```groovy\ndependencies {\n    implemetation 'net.ralphpina.permissionsmanager:permissions-manager:3.0.1'\n    implemetation 'net.ralphpina.permissionsmanager:permissions-manager-android:3.0.1'\n}\n```\n\n# Initing\nSetting up the library the should be done once. If you are using Dagger you will want to provide it in one of your app scoped modules. Most likely in your `app` module. \n\n```kotlin\n@Module\nclass AppModule {\n    @AppScope\n    @Provides\n    fun providePermissionsManager(context: Context): PermissionsManager =\n        PermissionsComponent.Initializer()\n                            .context(context)\n                            .prepare()\n}\n```\n\n# Usage\n1. Observe one of more permissions:\n```kotlin\npermissionsManager.observe(Permission.Location.Fine)\n                .doOnNext {\n                    println(\"Fine location granted: ${it[0].isGranted()}\")\n                }\n                .subscribe()\n```\n\nFor multiple permissions:\n```kotlin\npermissionsManager.observe(Permission.Location.Fine, Permission.Location.Coarse)\n                .doOnNext {\n                    println(\"${it[0].permission.value} granted: ${it[0].isGranted()}\")\n                    println(\"${it[1].permission.value} granted: ${it[1].isGranted()}\")\n                }\n                .subscribe()\n```\n\n2. Request one of more permissions:\n```kotlin\npermissionsManager.request(Permission.Location.Fine)\n                .doOnSuccess {\n                    Toast.makeText(\n                        dataBinding.root.context,\n                        \"Permission result for ${it[0].permission.value}, given: ${it[0].isGranted()}\",\n                        Toast.LENGTH_SHORT\n                    ).show()\n                }\n                .subscribe()\n```\n\nFor multiple permissions:\n```kotlin\npermissionsManager.request(Permission.Location.Fine, Permission.Location.Coarse)\n                .doOnSuccess {\n                    Toast.makeText(\n                        context,\n                        \"Permission result for ${it[0].permission.value}, given: ${it[0].isGranted()} and ${it[1].permission.value}, given: ${it[1].isGranted()}\",\n                        Toast.LENGTH_SHORT\n                    ).show()\n                }\n                .subscribe()\n```\n\n3. Navigate to settings:\n```kotlin\npermissionsManager.navigateToOsAppSettings()\n```\n\nThat is the entirety of the API:\n```kotlin\ninterface PermissionsManager {\n    fun observe(vararg permissions: Permission): Observable\u003cList\u003cPermissionResult\u003e\u003e\n    fun request(vararg permissions: Permission): Single\u003cList\u003cPermissionResult\u003e\u003e\n    fun navigateToOsAppSettings()\n}\n```\n\n`PermissionResult` provides the permission this result applies to, the result from the OS, and two flags, whether we've requested the permission before, and whether the user has selected \"Don't ask again\" for that or another permission in it's group.\n```kotlin\ndata class PermissionResult(\n    val permission: Permission,\n    val result: Result,\n    val hasAskedForPermissions: Boolean,\n    val isMarkedAsDontAsk: Boolean = false\n)\n\nenum class Result {\n    GRANTED, // PermissionChecker.PERMISSION_GRANTED\n    DENIED, // PermissionChecker.PERMISSION_DENIED\n    DENIED_APP_OP // PermissionChecker.PERMISSION_DENIED_APP_OP\n}\n```\n\n\n# License\n```\nCopyright 2019 Ralph Pina.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralphpina%2Fandroid-permissions-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fralphpina%2Fandroid-permissions-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralphpina%2Fandroid-permissions-manager/lists"}