Description
Kotlin version of the popular googlesample/easypermissions wrapper library to simplify basic system
permissions logic on Android M or higher.
This library lifts the burden that comes with writing a bunch of check statements whether a permission has been granted or not from you, in order to keep your code clean and safe.
EasyPermissions-ktx alternatives and similar packages
Based on the "Kotlin" category.
Alternatively, view EasyPermissions-ktx 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. -
Carousel Recyclerview
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager. -
Pluto Debug Framework
Android Pluto is a on-device debugging framework for Android applications, which helps intercept Network calls, capture Crashes & ANRs, manipulate application data on-the-go, and much more. -
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. -
Android Kotlin Samples
Some basic samples of Kotlin for Android -
Capturable
🚀Jetpack Compose utility library for capturing Composable content and transforming it into Bitmap Image🖼️ -
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. -
MaterialTimelineView
With MaterialTimelineView you can easily create a material looking timeline. -
MaterialDrawerKt
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library. -
SSComposeCookBook
A Collection of major Jetpack compose UI components which are commonly used.🎉🔝👌 -
Transition X
{ } Declarative Kotlin DSL for choreographing Android transitions -
Only
:bouquet: An easy way to persist and run code block only as many times as necessary on Android. -
SSCustomBottomNavigation
Animated TabBar with native control and Jetpack Navigation support..✨🔖🚀 -
Swagger Gradle Codegen
💫 A Gradle Plugin to generate your networking code from Swagger -
Permission Flow for Android
Know about real-time state of a Android app Permissions with Kotlin Flow APIs. -
Awesome Jetpack compose
A collaborative list of awesome jetpack compose resources. -
Nextflix-Composable
Includes jetpack compose, navigation, paging, hilt, retrofit, coil, coroutines, flow.. -
DeviceInfo-Sample
[Android Library] Get easy access to device information super fast, real quick -
CameraViewEx
Easy Android camera integration, advanced features. -
Intro Showcase View
Highlight different features of the app using Jetpack Compose -
Aimybox voice assistant
Embeddable custom voice assistant for Android applications -
ZoomHelper
ZoomHelper will make any view to be zoomable just like Instagram pinch-to-zoom -
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! -
Mutekt
Simplify mutating "immutable" state models (a Kotlin multiplatform library) -
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 -
Turtle 🐢
Run shell commands from Kotlin scripts, apps or Gradle tasks with ease. -
TimelineView
A customizable and easy-to-use Timeline View library for Android. Works as a RecyclerView decorator (ItemDecoration) -
Compose Compiler Reports to HTML Generator
A utility (Gradle Plugin + CLI) to convert Jetpack Compose compiler metrics and reports to beautified HTML page. -
Vanilla Place Picker
Simple(vanilla) yet 'Do it all' place picker for your place picking needs in Android -
Crowdin Android SDK
Crowdin Android SDK delivers all new translations from Crowdin project to the application immediately -
Awesome Mobile Libraries
This repo contains all the Open-source Libraries from iOS, Android, Flutter and React-Native.✨
Appwrite - The Open Source Firebase alternative introduces iOS support
Do you think we are missing an alternative of EasyPermissions-ktx or a related project?
README
EasyPermissions-ktx
Kotlin version of the popular googlesample/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.
This library lifts the burden that comes with writing a bunch of check statements whether a permission has been granted or not from you, in order to keep your code clean and safe.
Installation
EasyPermissions-ktx is installed by adding the following dependency to your build.gradle
file:
dependencies {
implementation 'com.vmadalin:easypermissions-ktx:1.0.0'
}
Tutorial
This video tutorial helps and guide you regarding all the process to integrate the library to your project and configure it, thanks to Stevdza-San.
Usage
Basic
To begin using EasyPermissions-ktx, have your Activity
(or Fragment
) override the onRequestPermissionsResult
method:
class MainActivity : AppCompatActivity() {
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
// EasyPermissions handles the request result.
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this)
}
}
Request Permissions
The example below shows how to request permissions for a method that requires both
CAMERA
and ACCESS_FINE_LOCATION
permissions. There are a few things to note:
- Using
EasyPermissions#hasPermissions(...)
to check if the app already has the required permissions. This method can take any number of permissions as its final argument. - Requesting permissions with
EasyPermissions#requestPermissions
. This method will request the system permissions and show the rationale string provided if necessary. The request code provided should be unique to this request, and the method can take any number of permissions as its final argument. - Use of the
AfterPermissionGranted
annotation. This is optional, but provided for convenience. If all of the permissions in a given request are granted, all methods annotated with the proper request code will be executed(be sure to have an unique request code). The annotated method needs to be void and without input parameters (instead, you can use onSaveInstanceState in order to keep the state of your suppressed parameters). This is to simplify the common flow of needing to run the requesting method after all of its permissions have been granted. This can also be achieved by adding logic on theonPermissionsGranted
callback.
@AfterPermissionGranted(REQUEST_CODE_LOCATION_AND_CONTACTS_PERMISSION)
private void methodRequiresTwoPermission() {
if (EasyPermissions.hasPermissions(this, ACCESS_FINE_LOCATION, READ_CONTACTS)) {
// Already have permission, do the thing
// ...
} else {
// Do not have permissions, request them now
EasyPermissions.requestPermissions(
host = this,
rationale = getString(R.string.permission_location_and_contacts_rationale_message),
requestCode = REQUEST_CODE_LOCATION_AND_CONTACTS_PERMISSION,
perms = ACCESS_FINE_LOCATION, READ_CONTACTS
)
}
}
Or for finer control over the rationale dialog, use a PermissionRequest
:
val request = PermissionRequest.Builder(spyActivity)
.code(REQUEST_CODE)
.perms(REQUEST_CODE_LOCATION_AND_CONTACTS_PERMISSION)
.theme(R.style.my_fancy_style)
.rationale(R.string.camera_and_location_rationale)
.positiveButtonText(R.string.rationale_ask_ok)
.negativeButtonText(R.string.rationale_ask_cancel)
.build()
EasyPermissions.requestPermissions(spyActivity, request)
Optionally, for a finer control, you can have your Activity
/ Fragment
implement
the PermissionCallbacks
interface.
class MainActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks {
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
// EasyPermissions handles the request result.
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this)
}
override fun onPermissionsGranted(requestCode: Int, perms: List<String>) {
// Some permissions have been granted
// ...
}
override fun onPermissionsDenied(requestCode: Int, perms: List<String>) {
// Some permissions have been denied
// ...
}
}
Required Permissions
In some cases your app will not function properly without certain permissions. If the user
denies these permissions with the "Never Ask Again" option, you will be unable to request
these permissions from the user and they must be changed in app settings. You can use the
method EasyPermissions.somePermissionPermanentlyDenied(...)
to display a dialog to the
user in this situation and direct them to the system setting screen for your app:
Note: Due to a limitation in the information provided by the Android
framework permissions API, the somePermissionPermanentlyDenied
method only
works after the permission has been denied and your app has received
the onPermissionsDenied
callback. Otherwise the library cannot distinguish
permanent denial from the "not yet denied" case.
override fun onPermissionsDenied(requestCode: Int, perms: List<String>) {
Log.d(TAG, "onPermissionsDenied: $requestCode :${perms.size()}")
// (Optional) Check whether the user denied any permissions and checked "NEVER ASK AGAIN."
// This will display a dialog directing them to enable the permission in app settings.
if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
SettingsDialog.Builder(this).build().show()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == DEFAULT_SETTINGS_REQ_CODE) {
val yes = getString(R.string.yes)
val no = getString(R.string.no)
// Do something after user returned from app settings screen, like showing a Toast.
Toast.makeText(
this,
getString(
R.string.returned_from_app_settings_to_activity,
if (hasCameraPermission()) yes else no,
if (hasLocationAndContactsPermissions()) yes else no,
if (hasSmsPermission()) yes else no,
if (hasStoragePermission()) yes else no
),
LENGTH_LONG
).show()
}
}
Interacting with the rationale dialog
Implement the EasyPermissions.RationaleCallbacks
if you want to interact with the rationale dialog.
override fun onRationaleAccepted(requestCode: Int) {
// Rationale accepted to request some permissions
// ...
}
override fun onRationaleDenied(requestCode: Int) {
// Rationale denied to request some permissions
// ...
}
Rationale callbacks don't necessarily imply permission changes. To check for those, see the EasyPermissions.PermissionCallbacks
.
LICENSE
Copyright 2017 Google
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 EasyPermissions-ktx README section above
are relevant to that project's source code only.