Simplifying Android Permissions

Overview

Gota Libary

With Android 6.0 Marshmallow, Google introduced a new permission model that allows users to better understand why an application may be requesting specific permissions. Rather than the user blindly accepting all permissions at install time, the user is now prompted to accept permissions as they become necessary during application use. As you probably already know, such a change requires efforts on the part of the application developer, this libary will help you to requset any number of permissions with a simple way.

You can report any issue on issues page. Note: If you speak Arabic, you can submit issues with Arabic language and I will check them. :)


Install

Maven

<dependency>
<groupId>net.alhazmy13.Gota</groupId>
<artifactId>libary</artifactId>
<version>1.4.1</version>
</dependency>

Gradle

dependencies {
	compile 'net.alhazmy13.Gota:libary:1.4.1'
}

Usage

After adding the library, you just need to create an instance from Gota libary and passing an array of permissions.

new Gota.Builder(this)
                .withPermissions(Manifest.permission.CAMERA,Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.CALL_PHONE)
                .requestId(1)
                .setListener(this)
                .check();

OnRequestPermissionsBack

In order to receive the response, you will need to implement the OnRequestPermissionsBack interfaces.

   @Override
    public void onRequestBack(int requestId, @NonNull GotaResponse gotaResponse) {
        if(gotaResponse.isGranted(Manifest.permission.CAMERA)) {
           // Your Code
        }
    } 

GotaResponse methods

  • deniedPermissions()
    • Return a list of denied permissions.
  • grantedPermissions()
    • Return a list of grated permissions.
  • isGranted(String)
    • To check if the permission was granted or not.
  • isDenied(String)
    • To check if the permission was denied or not.
  • isAllGranted()
    • return true if the all permission was grated
  • isAllDenied()
    • return true if the all permission was denied
  • hasDeniedPermission()
    • return true if there's any denied permission
  • isOnNeverAskAgain()
    • return true if there's any permission that checked as never ask for permission again.
  • requestId
    • Id or token that was submited with Gota request.

Wiki

Comments
  • transition غريب عند استعمال المكتبة

    transition غريب عند استعمال المكتبة

    السلام عليكم..

    أنا أستعمل المكتبة بالشكل التالي:

      new Gota.Builder(this)
                    .withPermissions(Manifest.permission.ACCESS_FINE_LOCATION)
                    .requestId(1)
                    .setListener(this)
                    .check();
    

    لاحظت وجود حركة بالاكتفتي غير مرغوب فيها، وعند ازالة هذا السطر تزول هذه الحركة ezgif com-gif-maker

    enhancement 
    opened by AsimNet 2
  • Add more functions to GotaResponse

    Add more functions to GotaResponse

    Hi again Sir,

    I have another idea. You can add others functions to GotaResponse class as "On Never Ask Again" as this library do https://github.com/hotchemi/PermissionsDispatcher.

    A function called "isOnNeverAskAgain(String)" to know if the permission was denied and selected as never ask again. This could let the developers to know how to act in this kind of situation.

    Thanks in advace, Sir.

    Have a nice day

    enhancement 
    opened by denebchorny 1
  • Add a requestId or Token

    Add a requestId or Token

    The idea is simple, allow placing a requestId or token to be receiven in onRequestBack".

    What is this for? You may be wondering.

    I just happened that I require use variables to make a difference in functionality when I am using buttons that have almost the same permissions in different situations.

    For example, I have two buttons. One is to use the camera and another is to use the camera and contact list. For the first button I do not require permission contact but I require for the second one.

    If there is the token or requestId I could do something like:

    Activity{
    ...
    
    Gota.Builder permitionCamera;
        Gota.Builder permitionCameraAndContacts;
    
    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main2);
    
            permitionCamera = new Gota.Builder(this)
                    .withPermissions(Manifest.permission.CAMERA)
                    .requestId(0)                
                    .setListener(this);
    
            permitionCameraAndContacts = new Gota.Builder(this)
                    .withPermissions(Manifest.permission.CAMERA, Manifest.permission.READ_CONTACTS)
                     .requestId(1)
                    .setListener(this);
        }
    
    
    
    @Override
        public void onRequestBack(GotaResponse gotaResponse) {
            switch (gotaResponse.requestId) {
                case 0:
                    if (gotaResponse.isGranted(Manifest.permission.CAMERA)) {
                        //Do what you want
                    }
                    break;
    
                case 1:
                    if (gotaResponse.isAllGranted()) {
                        // do what you want
                    }
                    break;
            }
        }
    ...
    }
    

    I think it is easier to understand the code. I hope you understand me.

    Thanks for everything.

    enhancement 
    opened by denebchorny 1
  • Check permissions without calling onRequestBack

    Check permissions without calling onRequestBack

    Hi,

    I have started using your lib and I have a question about is there any way to check is permissions enabled inside onResume without calling onRequestBack?

    Thanks in advance

    opened by slikasgiedrius 0
  • Crash when listener is null

    Crash when listener is null

    Caused by java.lang.NullPointerException: Attempt to invoke interface method 'void net.alhazmy13.gota.a$b.a(int, net.alhazmy13.gota.b)' on a null object reference at net.alhazmy13.gota.GotaActivity.checkPermissions(GotaActivity.java:64) at net.alhazmy13.gota.GotaActivity.onCreate(GotaActivity.java:33) at android.app.Activity.performCreate(Activity.java:7365) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3137) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3279) at android.app.ActivityThread.-wrap12(Unknown Source) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1881) at android.os.Handler.dispatchMessage(Handler.java:108) at android.os.Looper.loop(Looper.java:166) at android.app.ActivityThread.main(ActivityThread.java:7406) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:926)`

    Could you please add checking of the listener to not be null before calling Gota.listener.onRequestBack in GotaActivity class.

    opened by SerhiiSolobaievUptech 0
Releases(1.3.0)
Owner
Abdullah Alhazmy
Addicted to learning | Sr. Software engineer | Founder @xpend | Co-Founder @Gwork-projects & @EmaanHq
Abdullah Alhazmy
Android runtime permissions powered by RxJava2

RxPermissions This library allows the usage of RxJava with the new Android M permission model. Setup To use this library your minSdkVersion must be >=

Thomas Bruyelle 10.4k Jan 8, 2023
Android library for permissions request (updated 27.11.2017)

NoPermission Simple Android library for permissions request. Consists of only one class. Why NoPermission: Not a framework. It's just one class Dialog

Alexey Bykov 106 Dec 9, 2022
Simplify Android M system permissions

EasyPermissions EasyPermissions is a wrapper library to simplify basic system permissions logic when targeting Android M or higher. Note: If your app

Google Samples 9.6k Dec 30, 2022
Simplifying Android Permissions

Gota Libary With Android 6.0 Marshmallow, Google introduced a new permission model that allows users to better understand why an application may be re

Abdullah Alhazmy 72 Nov 29, 2022
A collection of Android libraries for simplifying development

Andromeda A collection of Android libraries for simplifying development Usage Andromeda uses Jitpack for distribution, the following gradle dependency

Kyle Corry 11 Dec 6, 2022
A declarative API to handle Android runtime permissions.

PermissionsDispatcher Fully Kotlin/Java support Special permissions support 100% reflection-free PermissionsDispatcher provides a simple annotation-ba

PermissionsDispatcher 11.1k Jan 2, 2023
Android runtime permissions powered by RxJava2

RxPermissions This library allows the usage of RxJava with the new Android M permission model. Setup To use this library your minSdkVersion must be >=

Thomas Bruyelle 10.4k Jan 8, 2023
Android library for permissions request (updated 27.11.2017)

NoPermission Simple Android library for permissions request. Consists of only one class. Why NoPermission: Not a framework. It's just one class Dialog

Alexey Bykov 106 Dec 9, 2022
Simplify Android M system permissions

EasyPermissions EasyPermissions is a wrapper library to simplify basic system permissions logic when targeting Android M or higher. Note: If your app

Google Samples 9.6k Dec 30, 2022
🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.

EasyPermissions-ktx Kotlin version of the popular googlesample/easypermissions wrapper library to simplify basic system permissions logic on Android M

Madalin Valceleanu 326 Dec 23, 2022
Android Library to help you with your runtime Permissions.

PermissionHelper Android Library to help you with your runtime Permissions. Demo Android M Watch it in action. Pre M Watch it in action. Nexus 6 (M) N

Kosh Sergani 1.2k Dec 14, 2022
Android Library for requesting Permissions with Kotlin Coroutines or AndroidX LiveData

PEKO PErmissions with KOtlin Android Permissions with Kotlin Coroutines or LiveData No more callbacks, builders, listeners or verbose code for request

Marko Devcic 133 Dec 14, 2022
Get a unique ID for Android devices without any permissions.

Java and Kotlin Android library. Uniquely identify an Android device without any permissions and API restrictions. The recommended approach using DRM API.

Eyosiyas Bereketab 9 Aug 25, 2022
🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.

?? Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.

Madalin Valceleanu 327 Dec 30, 2022
Android permissions as suspend functions

Warden Permission handling in Android can be complicated. It requires boilerplate code to setup the permission request, receive the result and then fo

Alex Styl 183 Nov 2, 2022
A Android app Permissions with Kotlin Flow APIs

Know about real-time state of a Android app Permissions with Kotlin Flow APIs. Made with ❤️ for Android Developers.

Shreyas Patil 281 Dec 30, 2022
Sentinel is a simple one screen UI which provides a standardised entry point for tools used in development and QA alongside device, application and permissions data.

Sentinel Sentinel is a simple one screen UI that provides standardised entry point for tools used in development and QA alongside device, application

Infinum 29 Dec 12, 2022
Easy way to handle all permissions

BestPermissionUtil You can read the story from here https://hamurcuabi.medium.com/permissions-with-the-easiest-way-9c466ab1b2c1 Prerequisites Add this

Emre Hamurcu 8 May 12, 2022
AnyChart Android Chart is an amazing data visualization library for easily creating interactive charts in Android apps. It runs on API 19+ (Android 4.4) and features dozens of built-in chart types.

AnyChart for Android AnyChart Android Charts is an amazing data visualization library for easily creating interactive charts in Android apps. It runs

AnyChart 2k Jan 4, 2023