PermissionEdge is a lightweight Android library that simplifies runtime permission handling with a clean and intuitive API. It handles all the complexity of permission requests, rationale dialogs, and permanent denial cases.
- Simple and fluent API for requesting multiple permissions
- Built-in handling of permission rationale dialogs
- Automatic management of "Don't ask again" cases
- Customizable messages for different permission states
- Proper lifecycle management to prevent memory leaks
Add JitPack repository to your root build.gradle or settings.gradle:
repositories {
maven { url 'https://jitpack.io' }
}dependencies {
implementation 'com.github.Nishikanto:PermissionEdge:v1.0.4'
}class MainActivity : AppCompatActivity() {
private lateinit var permissionManager: PermissionManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
permissionManager = PermissionManager(this)
}
}val cameraPermissionConfig = PermissionConfig(
permission = Manifest.permission.CAMERA,
rationaleMessage = "Camera access is needed to take pictures",
deniedMessage = "Camera permission was denied. Some features may not work.",
permanentlyDeniedMessage = "Camera permission was permanently denied. Please enable it in app settings."
)permissionManager.requestPermissions(
permissionsToRequest = listOf(cameraPermissionConfig)
) {
// This callback is called when all permissions are granted
startCamera()
}val permissionConfigs = listOf(
PermissionConfig(
permission = Manifest.permission.CAMERA,
rationaleMessage = "Camera access is needed to take pictures",
deniedMessage = "Camera permission was denied",
permanentlyDeniedMessage = "Please enable camera permission in settings"
),
PermissionConfig(
permission = Manifest.permission.RECORD_AUDIO,
rationaleMessage = "Microphone access is needed to record audio",
deniedMessage = "Microphone permission was denied",
permanentlyDeniedMessage = "Please enable microphone permission in settings"
)
)
permissionManager.requestPermissions(permissionConfigs) {
// All permissions granted
startFeature()
}- Initialize
PermissionManagerinonCreate()before any permission requests. - The library automatically handles:
- Permission rationale dialogs
- Permanent denial cases with settings redirect
- Permission request callbacks
- Lifecycle-aware implementation
MIT License
Copyright (c) 2024 YourName
Permission 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:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE 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.
Contributions are welcome! Please feel free to submit a Pull Request.
If you find any bugs or have feature requests, please create an issue in the GitHub repository.