{"id":18725809,"url":"https://github.com/cryptix720/kotlin-permissions","last_synced_at":"2025-06-13T22:41:07.591Z","repository":{"id":71599824,"uuid":"137261988","full_name":"Cryptix720/kotlin-permissions","owner":"Cryptix720","description":"Basic annotation API to handle runtime permissions, 100% Kotlin friendly.","archived":false,"fork":false,"pushed_at":"2018-06-13T20:03:38.000Z","size":243,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-28T13:19:33.354Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cryptix720.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-06-13T19:34:59.000Z","updated_at":"2018-09-14T09:56:25.000Z","dependencies_parsed_at":"2023-04-08T19:47:52.160Z","dependency_job_id":null,"html_url":"https://github.com/Cryptix720/kotlin-permissions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptix720%2Fkotlin-permissions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptix720%2Fkotlin-permissions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptix720%2Fkotlin-permissions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptix720%2Fkotlin-permissions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cryptix720","download_url":"https://codeload.github.com/Cryptix720/kotlin-permissions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239592976,"owners_count":19664855,"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-11-07T14:12:04.868Z","updated_at":"2025-02-19T03:43:06.364Z","avatar_url":"https://github.com/Cryptix720.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Pure Kotlin \r\n\r\nFrom 3.1.1 we started support `.kt` file generation.\r\n\r\n\r\n\r\n### 0. Preparation\r\n\r\nAdd the following line to `AndroidManifest.xml`:\r\n \r\n`\u003cuses-permission android:name=\"android.permission.READ_CONTACTS\" /\u003e`\r\n\r\nInclude the following in your **app module** `build.gradle` file:\r\n\r\n`${latest.version}` \r\n\r\n```groovy\r\napply plugin: 'kotlin-kapt'\r\n\r\ndependencies {\r\n  compile(\"com.YOUR_OWN_DISPATCH:permissionsdispatcher:${latest.version}\") {\r\n      // if you don't use android.app.Fragment you can exclude support for them\r\n      exclude module: \"support-v13\"\r\n  }\r\n  kapt \"com.YOUR_OWN_DISPATCH:permissionsdispatcher-processor:${latest.version}\"\r\n}\r\n```\r\n\r\n### 1. Attach annotations\r\n\r\nPermissionsDispatcher introduces only a few annotations, keeping its general API concise:\r\n\r\n\u003e NOTE: Annotated methods must not be `private`.\r\n\r\n|Annotation|Required|Description|\r\n|---|---|---|\r\n|`@RuntimePermissions`|**✓**|Register an `Activity` or `Fragment`(we support both) to handle permissions|\r\n|`@NeedsPermission`|**✓**|Annotate a method which performs the action that requires one or more permissions|\r\n|`@OnShowRationale`||Annotate a method which explains why the permission/s is/are needed. It passes in a `PermissionRequest` object which can be used to continue or abort the current permission request upon user input|\r\n|`@OnPermissionDenied`||Annotate a method which is invoked if the user doesn't grant the permissions|\r\n|`@OnNeverAskAgain`||Annotate a method which is invoked if the user chose to have the device \"never ask again\" about a permission|\r\n\r\n```kotlin\r\n@RuntimePermissions\r\nclass MainActivity : AppCompatActivity(), View.OnClickListener {\r\n\r\n    @NeedsPermission(Manifest.permission.CAMERA)\r\n    fun showCamera() {\r\n        supportFragmentManager.beginTransaction()\r\n                .replace(R.id.sample_content_fragment, CameraPreviewFragment.newInstance())\r\n                .addToBackStack(\"camera\")\r\n                .commitAllowingStateLoss()\r\n    }\r\n\r\n    @OnShowRationale(Manifest.permission.CAMERA)\r\n    fun showRationaleForCamera(request: PermissionRequest) {\r\n        showRationaleDialog(R.string.permission_camera_rationale, request)\r\n    }\r\n\r\n    @OnPermissionDenied(Manifest.permission.CAMERA)\r\n    fun onCameraDenied() {\r\n        Toast.makeText(this, R.string.permission_camera_denied, Toast.LENGTH_SHORT).show()\r\n    }\r\n\r\n    @OnNeverAskAgain(Manifest.permission.CAMERA)\r\n    fun onCameraNeverAskAgain() {\r\n        Toast.makeText(this, R.string.permission_camera_never_askagain, Toast.LENGTH_SHORT).show()\r\n    }\r\n}\r\n```\r\n\r\n### 2. Delegate to generated functions\r\n\r\nNow generated functions become much more concise and intuitive than Java version!\r\n\r\n```kotlin\r\n    override fun onCreate(savedInstanceState: Bundle?) {\r\n        super.onCreate(savedInstanceState)\r\n        setContentView(R.layout.activity_main)\r\n        findViewById(R.id.button_camera).setOnClickListener {\r\n            // NOTE: delegate the permission handling to generated function\r\n            showCameraWithPermissionCheck()\r\n        }\r\n    }\r\n\r\n    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array\u003cString\u003e, grantResults: IntArray) {\r\n        super.onRequestPermissionsResult(requestCode, permissions, grantResults)\r\n        // NOTE: delegate the permission handling to generated function\r\n        onRequestPermissionsResult(requestCode, grantResults)\r\n    }\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptix720%2Fkotlin-permissions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptix720%2Fkotlin-permissions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptix720%2Fkotlin-permissions/lists"}