{"id":17596533,"url":"https://github.com/birjuvachhani/freedom","last_synced_at":"2025-07-11T11:36:32.216Z","repository":{"id":101312462,"uuid":"188523932","full_name":"BirjuVachhani/freedom","owner":"BirjuVachhani","description":"Freedom is an Android library to handle runtime permissions in easiest way.","archived":false,"fork":false,"pushed_at":"2019-09-24T10:52:47.000Z","size":179,"stargazers_count":15,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T20:46:35.888Z","etag":null,"topics":["android","android-library","androidpermission","kotlin-android","permission-android","permission-requests","runtime-permissions"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BirjuVachhani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-05-25T05:18:12.000Z","updated_at":"2024-02-22T05:51:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"20454d94-c506-40da-b5d2-a65df7c1b421","html_url":"https://github.com/BirjuVachhani/freedom","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/BirjuVachhani/freedom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirjuVachhani%2Ffreedom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirjuVachhani%2Ffreedom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirjuVachhani%2Ffreedom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirjuVachhani%2Ffreedom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BirjuVachhani","download_url":"https://codeload.github.com/BirjuVachhani/freedom/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirjuVachhani%2Ffreedom/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264796042,"owners_count":23665273,"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":["android","android-library","androidpermission","kotlin-android","permission-android","permission-requests","runtime-permissions"],"created_at":"2024-10-22T08:43:30.499Z","updated_at":"2025-07-11T11:36:32.194Z","avatar_url":"https://github.com/BirjuVachhani.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"![banner](https://github.com/BirjuVachhani/freedom/blob/master/freedom.svg)\n\n# Freedom\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-2196F3.svg?style=for-the-badge)](https://opensource.org/licenses/Apache-2.0)\n[![language](https://img.shields.io/github/languages/top/BirjuVachhani/location-extension-android.svg?style=for-the-badge\u0026colorB=f18e33)](https://kotlinlang.org/)\n[![Platform](https://img.shields.io/badge/Platform-Android-green.svg?style=for-the-badge)](https://www.android.com/)\n[![API](https://img.shields.io/badge/API-16%2B-F44336.svg?style=for-the-badge)](https://android-arsenal.com/api?level=16)\n\nFreedom is an Android library to handle runtime permissions in easiest way. Freedom is fully written in Kotlin so it uses Kotlin features and dsl syntax extensively.\n\nPlease note that this library is still under development. Stable version of the library will be released soon. Stay tuned!\n\nAt this time, this library does not have support for multiple permission requests. We are planning to add it soon!\n\n## Gradle Dependency\n\n* Add the JitPack repository to your project's build.gradle file\n\n```\nallprojects {\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n\n* Add the dependency in your app's build.gradle file\n\n```\ndependencies {\n    implementation 'com.github.BirjuVachhani:freedom:0.9.1'\n}\n```\n\n## Usage\n\n#### Set Permissions Event Listener\n\n```kotlin\nFreedom.setListener(this) whenGranted {\n    // permission granted\n    showToast(\"Granted\")\n} whenDenied {\n    // permission denied\n    showToast(\"Denied\")\n} whenPermanentlyDenied {\n    // permission permanently denied, show open settings dialog\n    showPermissionBlockedDialog()\n} whenShouldShowRationale {listener-\u003e\n    // show rationale dialog\n    showRationaleDialog(listener)\n}\n```\n\n#### Requesting Permission\n\n```kotlin\nFreedom.request(this, android.Manifest.permission.ACCESS_COARSE_LOCATION)\n```\n\n#### Handling Rationale Dialog\n\n```kotlin\nprivate fun showRationaleDialog(listener: RationaleInterface) {\n    AlertDialog.Builder(this)\n        .setTitle(getString(R.string.rationale_title))\n        .setMessage(getString(R.string.rationale_msg)\n        .setPositiveButton(\"Grant\") { dialog, _ -\u003e\n            listener.request()\n            dialog.dismiss()\n        }\n        .setNegativeButton(\"CANCEL\") { dialog, _ -\u003e\n            dialog.dismiss()\n        }.show()\n}\n```\n\n### Example\n\n```kotlin\nclass MainActivity : AppCompatActivity() {\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n\n        Freedom.setListener(this) whenGranted {\n            // permission granted\n            showToast(\"Granted\")\n        } whenDenied {\n            // permission denied\n            showToast(\"Denied\")\n        } whenPermanentlyDenied {\n            // permission permanently denied, show open settings dialog\n            showPermissionBlockedDialog()\n        } whenShouldShowRationale {listener-\u003e\n            // show rationale dialog\n            showRationaleDialog(listener)\n        }\n    }\n\n    private fun showPermissionBlockedDialog() {\n        AlertDialog.Builder(this)\n            .setTitle(\"Permission Blocked\")\n            .setMessage(\"This feature requires location permission to function. Please grant location permission for settings.\")\n            .setPositiveButton(\"OPEN SETTINGS\") { dialog, _ -\u003e\n                openSettings()\n                dialog.dismiss()\n            }\n            .setNegativeButton(\"CANCEL\") { dialog, _ -\u003e\n                dialog.dismiss()\n            }.show()\n    }\n\n    private fun showRationaleDialog(listener: RationaleInterface) {\n        AlertDialog.Builder(this)\n            .setTitle(\"Permission Required\")\n            .setMessage(\"This feature requires location permission to function. Please grant location permission.\")\n            .setPositiveButton(\"Grant\") { dialog, _ -\u003e\n                listener.request()\n                dialog.dismiss()\n            }\n            .setNegativeButton(\"CANCEL\") { dialog, _ -\u003e\n                dialog.dismiss()\n            }.show()\n    }\n\n    /**\n     * Opens app settings screen\n     * */\n    private fun openSettings() {\n        val intent = Intent()\n        intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS\n        val uri = Uri.fromParts(\"package\", packageName, null)\n        intent.data = uri\n        startActivity(intent)\n    }\n\n    /**\n     * method is invoked on button click which initiates permission request.\n     */\n    fun requestPermission(view: View) {\n        Freedom.request(this, android.Manifest.permission.ACCESS_COARSE_LOCATION)\n    }\n\n    private fun showToast(msg: String) {\n        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()\n    }\n}\n```\n\n### Pull Request\nTo generate a pull request, please consider following [Pull Request Template](https://github.com/BirjuVachhani/freedom/blob/master/PULL_REQUEST_TEMPLATE.md).\n\n### Issues\nTo submit an issue, please check the [Issue Template](https://github.com/BirjuVachhani/freedom/blob/master/ISSUE_TEMPLATE.md).\n\nCode of Conduct\n---\n[Code of Conduct](https://github.com/BirjuVachhani/freedom/blob/master/CODE_OF_CONDUCT.md)\n\n## Contribution\n\nYou are most welcome to contribute to this project!\n\nPlease have a look at [Contributing Guidelines](https://github.com/BirjuVachhani/freedom/blob/master/CONTRIBUTING.md), before contributing and proposing a change.\n\n# License\n\n```\n   Copyright © 2019 BirjuVachhani\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirjuvachhani%2Ffreedom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbirjuvachhani%2Ffreedom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirjuvachhani%2Ffreedom/lists"}