PermissionHelper Android Library

repository·master·Indexed 22 days ago

https://github.com/k0shk0sh/permissionhelper

An Android library for simplifying runtime permission handling with a focus on educational UIs to increase user acceptance. It provides BasePermissionActivity for custom explanation screens, OnPermissionCallback for result handling, and helper classes for Activities and Fragments to trigger permission flows.

Tokens
522
Snippets
1
Records
5
Agent score
29%

What's inside PermissionHelper

  1. Use BasePermissionActivity for custom educational UI

    master

    If you want to provide a highly customized educational UI (explaining why permissions are needed) before the system dialog appears, extend BasePermissionActivity.

    This approach allows you to control:

    • Permissions being asked and their specific explanations.
    • Screen background colors (automatically generates DarkPrimaryColor).
    • Screen images, titles, and messages.
    • Text colors, sizes, and FontType per screen.
    • Button icon resources (Next, Previous, Request).
    • Custom ViewPager.PageTransformer implementations.
    • Behavior such as preventing users from skipping the explanation dialog.

    Note: On Android versions older than Marshmallow (M), the library acts as a standard intro library and will not attempt to trigger the system permission request dialog.

  2. Install PermissionHelper via Gradle or Maven

    master

    To use PermissionHelper in your Android project, add the dependency to your build configuration files.

    #### Gradle
    ```groovy
        compile 'com.github.k0shk0sh:PermissionHelper:1.1.0'

    Maven

    <dependency>
      <groupId>com.github.k0shk0sh</groupId>
      <artifactId>PermissionHelper</artifactId>
      <version>1.1.0</version>
      <type>aar</type>
    </dependency>
  3. Implement OnPermissionCallback to handle permission results

    master
    To manually manage permission requests in your Activity, Fragment, or Presenter, implement the OnPermissionCallback interface. This provides granular feedback on the user's interaction with permission requests.
  4. Request permissions using PermissionHelper

    master
    Use the request method on a PermissionHelper (for Activities) or PermissionFragmentHelper (for Fragments) instance to trigger the permission flow. You can configure whether to skip explanations or force the dialog to reappear.