Description
Know about real-time state of a Android app Permissions with Kotlin Flow APIs
Permission Flow for Android alternatives and similar packages
Based on the "Kotlin" category.
Alternatively, view permission-flow-android alternatives based on common mentions on social networks and blogs.
-
android-youtube-player
YouTube Player library for Android and Chromecast, stable and customizable. -
CalendarView
A highly customizable calendar view and compose library for Android. -
Balloon
:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android. -
Kotterknife
Android view injection writen in Kotlin based on ButterKnife -
Shortbread
Android library that creates app shortcuts from annotations -
kotlin-android-template
Android + Kotlin + Github Actions + ktlint + Detekt + Gradle Kotlin DSL + buildSrc = โค๏ธ -
NotyKT ๐๏ธ
๐ NotyKT is a complete ๐Kotlin-stack (Backend + Android) ๐ฑ application built to demonstrate the use of Modern development tools with best practices implementation๐ฆธ. -
Material Chip View
Material Chip view. Can be used as tags for categories, contacts or creating text clouds -
DrawableToolbox
๐ ๏ธ The missing drawable toolbox for Android. Create drawables programmatically and get rid of the boring and always repeated drawable.xml files. -
Navigation Toolbar for Android
:octocat: Navigation toolbar is a slide-modeled UI navigation controller made by @Ramotion -
CodeView
Display code with syntax highlighting :sparkles: in native way. -
Time
Type-safe time calculations in Kotlin, powered by generics. -
Pluto Debug Framework
Pluto is a on-device debugging framework for Android applications, which helps in inspection of HTTP requests/responses, capture Crashes and ANRs and manipulating application data on-the-go. -
Yasha
Kotlin-based modern RecyclerView rendering weapon -
Carousel Recyclerview
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager. -
MaterialTimelineView
With MaterialTimelineView you can easily create a material looking timeline. -
Android Kotlin Samples
Some basic samples of Kotlin for Android -
CrunchyCalendar โ awesome calendar widget for android apps
A beautiful material calendar with endless scroll, range selection and a lot more! -
sliding-panel
Android sliding panel that is part of the view hierarchy, not above it. -
MaterialDrawerKt
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library. -
Transition X
{ } Declarative Kotlin DSL for choreographing Android transitions -
Pdf Viewer For Android
A Lightweight PDF Viewer Android library which only occupies around 125kb while most of the Pdf viewer occupies up to 16MB space. -
Only
:bouquet: An easy way to persist and run code block only as many times as necessary on Android. -
Capturable
๐Jetpack Compose utility library for capturing Composable content and transforming it into Bitmap Image๐ผ๏ธ -
Swagger Gradle Codegen
๐ซ A Gradle Plugin to generate your networking code from Swagger -
SSCustomBottomNavigation
Animated TabBar with native control and Jetpack Navigation support..โจ๐๐ -
SSComposeCookBook
A Collection of major Jetpack compose UI components which are commonly used.๐๐๐ -
EasyPermissions-ktx
๐ Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher. -
Awesome Jetpack compose
A collaborative list of awesome jetpack compose resources. -
DeviceInfo-Sample
[Android Library] Get easy access to device information super fast, real quick -
CameraViewEx
Easy Android camera integration, advanced features. -
Aimybox voice assistant
Embeddable custom voice assistant for Android applications -
Events Calendar
Events Calendar is a user-friendly library that helps you achieve a cool Calendar UI with events mapping. You can customise every pixel of the calendar as per your wish and still achieve in implementing all the functionalities of the native android calendar in addition with adding dots to the calendar which represents the presence of an event on the respective dates. It can be done easily, you are just a few steps away from implementing your own badass looking Calendar for your very own project! -
Intro Showcase View
Highlight different features of the app using Jetpack Compose -
Nextflix-Composable
Includes jetpack compose, navigation, paging, hilt, retrofit, coil, coroutines, flow.. -
ZoomHelper
ZoomHelper will make any view to be zoomable just like Instagram pinch-to-zoom -
SSCustomEditTextOutLineBorder
Same as the Outlined text fields presented on the Material Design page but with some dynamic changes. ๐ ๐ -
Maildroid
Maildroid is a small robust android library for sending emails using SMTP server -
Vanilla Place Picker
Simple(vanilla) yet 'Do it all' place picker for your place picking needs in Android -
TimelineView
A customizable and easy-to-use Timeline View library for Android. Works as a RecyclerView decorator (ItemDecoration) -
Crowdin Android SDK
Crowdin Android SDK delivers all new translations from Crowdin project to the application immediately -
Turtle ๐ข
Run shell commands from a Kotlin script or application with ease -
DownloadX
Download tool based on kotlin and coroutine. -
PopKorn
DI can be simple. Forget about modules and components. Just use it! -
EasyCrypt
Android cryptography library with SecureRandom patches.
Appwrite - The Open Source Firebase alternative introduces iOS support
Do you think we are missing an alternative of Permission Flow for Android or a related project?
README
Permission Flow for Android
Know about real-time state of a Android app Permissions with Kotlin Flow APIs. Made with โค๏ธ for Android Developers.
๐กIntroduction
In big projects, app is generally divided in several modules and in such cases, if any individual module is just a data module (not having UI) and need to know state of a permission, it's not that easy. This library provides a way to know state of a permission throughout the app and from any layer of the application safely.
For example, you can listen for state of contacts permission in class where you'll instantly show list of contacts when permission is granted.
It's a simple and easy to use library. Just Plug and Play.
๐ Implementation
You can check /app directory which includes example application for demonstration.
1. Gradle setup
In build.gradle
of app module, include this dependency
dependencies {
implementation "dev.shreyaspatil.permission-flow:permission-flow-android:$version"
// For using in Jetpack Compose
implementation "dev.shreyaspatil.permission-flow:permission-flow-compose:$version"
}
You can find latest version and changelogs in the releases.
2. Initialization
Before using any API of the library, it needs to be initialized before.
Initialize PermissionFlow as follows (For example, in Application
class):
class MyApplication: Application() {
override fun onCreate() {
super.onCreate()
PermissionFlow.init(this)
}
}
3. Observing a Permission State
3.1 Observing Permission with StateFlow
A permission state can be subscribed by retrieving StateFlow<PermissionState>
or StateFlow<MultiplePermissionState>
as follows:
val permissionFlow = PermissionFlow.getInstance()
// Observe state of single permission
suspend fun observePermission() {
permissionFlow.getPermissionState(android.Manifest.permission.READ_CONTACTS).collect { state ->
if (state.isGranted) {
// Do something
}
}
}
// Observe state of multiple permissions
suspend fun observeMultiplePermissions() {
permissionFlow.getMultiplePermissionState(
android.Manifest.permission.READ_CONTACTS,
android.Manifest.permission.READ_SMS
).collect { state ->
// All permission states
val allPermissions = state.permissions
// Check whether all permissions are granted
val allGranted = state.allGranted
// List of granted permissions
val grantedPermissions = state.grantedPermissions
// List of denied permissions
val deniedPermissions = state.deniedPermissions
}
}
3.2 Observing permissions in Jetpack Compose
State of a permission and state of multiple permissions can also be observed in Jetpack Compose application as follows:
@Composable
fun ExampleSinglePermission() {
val state by rememberPermissionState(Manifest.permission.CAMERA)
if (state.isGranted) {
// Render something
} else {
// Render something else
}
}
@Composable
fun ExampleMultiplePermission() {
val state by rememberMultiplePermissionState(
Manifest.permission.CAMERA
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.READ_CONTACTS
)
if (state.allGranted) {
// Render something
}
val grantedPermissions = state.grantedPermissions
// Do something with `grantedPermissions`
val deniedPermissions = state.deniedPermissions
// Do something with `deniedPermissions`
}
4. Requesting permission with PermissionFlow
It's necessary to use utilities provided by this library to request permissions so that whenever permission state changes, this library takes care of notifying respective flows.
4.1 Request permission from Activity / Fragment
Use registerForPermissionFlowRequestsResult()
method to get ActivityResultLauncher
and use launch()
method to request for permission.
class ContactsActivity : AppCompatActivity() {
private val permissionLauncher = registerForPermissionFlowRequestsResult()
private fun askContactsPermission() {
permissionLauncher.launch(Manifest.permission.READ_CONTACTS, ...)
}
}
4.2 Request permission in Jetpack Compose
Use rememberPermissionFlowRequestLauncher()
method to get ManagedActivityResultLauncher
and use launch()
method to request for permission.
@Composable
fun Example() {
val permissionLauncher = rememberPermissionFlowRequestLauncher()
Button(onClick = { permissionLauncher.launch(android.Manifest.permission.CAMERA, ...) }) {
Text("Request Permissions")
}
}
5. Manually notifying permission state changes โ ๏ธ
If you're not using ActivityResultLauncher
APIs provided by this library then
you will not receive permission state change updates. But there's a provision by which
you can help this library to know about permission state changes.
Use PermissionFlow#notifyPermissionsChanged()
to notify the permission state changes
from your manual implementations.
For example:
class MyActivity: AppCompatActivity() {
private val permissionFlow = PermissionFlow.getInstance()
private val permissionLauncher = registerForActivityResult(RequestPermission()) { isGranted ->
permissionFlow.notifyPermissionsChanged(android.Manifest.permission.READ_CONTACTS)
}
}
6. Manually Start / Stop Listening โ ๏ธ
This library starts processing things lazily whenever getPermissionState()
or getMultiplePermissionState()
is called
for the first time. But this can be controlled with these methods:
fun doSomething() {
// Stops listening to the state changes of permissions throughout the application.
// This means the state of permission retrieved with [getMultiplePermissionState] method will not
// be updated after stopping listening.
permissionFlow.stopListening()
// Starts listening the changes of state of permissions after stopping listening
permissionFlow.startListening()
}
๐ API Documentation
Visit the API documentation of this library to get more information in detail. This documentation is generated using Dokka.
๐ Test coverage report
Check the Test Coverage Report of this library. This is generated using Kover.
๐โโ๏ธ Contribute
Read [contribution guidelines](CONTRIBUTING.md) for more information regarding contribution.
๐ฌ Discuss?
Have any questions, doubts or want to present your opinions, views? You're always welcome. You can start discussions.
๐ License
Copyright 2022 Shreyas Patil
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*Note that all licence references and agreements mentioned in the Permission Flow for Android README section above
are relevant to that project's source code only.