Skip to content

UncleSunnyWen/permissions-ui

Repository files navigation

Permissions UI

A tiny Jetpack Compose UI library that provides two small components for improving Android permission UX:

  • RationaleBanner — a lightweight animated banner for showing permission rationale
  • DeniedGuideDialog — a Material 3 dialog for guiding users to system settings when a permission is permanently denied

Simple, UI-only, and no extra dependencies beyond Compose + Material3.


Setup

This library is not published online.
To use it:

  1. Copy the permissions-ui module into your project
  2. Add the module dependency:
implementation(project(":permissions-ui"))

RationaleBanner

A small popup banner displayed before requesting permission.

var showRationale by remember { mutableStateOf(false) }

RationaleBanner(
    visible = showRationale,
    title = "Camera Permission",
    message = "Used to take photos."
)

DeniedGuideDialog

A dialog shown when a permission has been permanently denied.
All texts are fully customizable.

var showDeniedGuide by remember { mutableStateOf(false) }

DeniedGuideDialog(
    visible = showDeniedGuide,
    title = "Camera Permission Denied",
    message = "Please enable camera permission in Settings.",
    dismissText = "Cancel",
    confirmText = "Open Settings",
    onDismiss = { showDeniedGuide = false },
    onConfirm = {
        context.openAppSettings()
    }
)

// Or use defaults:
DeniedGuideDialog(
    visible = showDeniedGuide,
    onDismiss = { showDeniedGuide = false },
    onConfirm = {
        context.openAppSettings()
    }
)

Helper function:

fun Context.openAppSettings() {  
    val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {  
        data = "package:$packageName".toUri()  
        if (this@openAppSettings !is Activity) {  
            addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)  
        }  
    }  
    startActivity(intent)  
}

Requirements

  • Jetpack Compose

  • Material 3


License

Apache License 2.0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages