Simplifying Android Permissions

Related tags

Utility Gota
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
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
Android Shared preference wrapper than encrypts the values of Shared Preferences. It's not bullet proof security but rather a quick win for incrementally making your android app more secure.

Secure-preferences - Deprecated Please use EncryptedSharedPreferences from androidx.security in preferenced to secure-preference. (There are no active

Scott Alexander-Bown 1.5k Dec 24, 2022
Android library which makes it easy to handle the different obstacles while calling an API (Web Service) in Android App.

API Calling Flow API Calling Flow is a Android library which can help you to simplify handling different conditions while calling an API (Web Service)

Rohit Surwase 19 Nov 9, 2021
Gesture detector framework for multitouch handling on Android, based on Android's ScaleGestureDetector

Android Gesture Detectors Framework Introduction Since I was amazed Android has a ScaleGestureDetector since API level 8 but (still) no such thing as

null 1.1k Nov 30, 2022
Use Android as Rubber Ducky against another Android device

Use Android as Rubber Ducky against another Android device

null 1.4k Jan 9, 2023
Android Utilities Library build in kotlin Provide user 100 of pre defined method to create advanced native android app.

Android Utilities Library build in kotlin Provide user 100 of pre defined method to create advanced native android app.

Shahid Iqbal 4 Nov 29, 2022
A util for setting status bar style on Android App.

StatusBarUtil A util for setting status bar style on Android App. It can work above API 19(KitKat 4.4). 中文版点我 Sample Download StatusBarUtil-Demo Chang

Jaeger 8.8k Jan 6, 2023
A logger with a small, extensible API which provides utility on top of Android's normal Log class.

This is a logger with a small, extensible API which provides utility on top of Android's normal Log class. I copy this class into all the little apps

Jake Wharton 9.8k Dec 30, 2022
Java implementation of a Disk-based LRU cache which specifically targets Android compatibility.

Disk LRU Cache A cache that uses a bounded amount of space on a filesystem. Each cache entry has a string key and a fixed number of values. Each key m

Jake Wharton 5.7k Dec 31, 2022
a simple cache for android and java

ASimpleCache ASimpleCache 是一个为android制定的 轻量级的 开源缓存框架。轻量到只有一个java文件(由十几个类精简而来)。 1、它可以缓存什么东西? 普通的字符串、JsonObject、JsonArray、Bitmap、Drawable、序列化的java对象,和 b

Michael Yang 3.7k Dec 14, 2022
gRPC and protocol buffers for Android, Kotlin, and Java.

Wire “A man got to have a code!” - Omar Little See the project website for documentation and APIs. As our teams and programs grow, the variety and vol

Square 3.9k Dec 31, 2022
✔️ Secure, simple key-value storage for Android

Hawk 2.0 Secure, simple key-value storage for android Important Note This version has no backward compatibility with Hawk 1+ versions. If you still wa

Orhan Obut 3.9k Dec 20, 2022
A robust native library loader for Android.

ReLinker A robust native library loader for Android. More information can be found in our blog post Min SDK: 9 JavaDoc Overview The Android PackageMan

Keepsafe 2.9k Dec 27, 2022
A lightning fast, transactional, file-based FIFO for Android and Java.

Tape by Square, Inc. Tape is a collection of queue-related classes for Android and Java. QueueFile is a lightning-fast, transactional, file-based FIFO

Square 2.4k Dec 30, 2022
Joda-Time library with Android specialization

joda-time-android This library is a version of Joda-Time built with Android in mind. Why Joda-Time? Android has built-in date and time handling - why

Daniel Lew 2.6k Dec 9, 2022
a SharedPreferences replacement for Android with multiprocess support

DEPRECATED - no longer actively maintained Tray - a SharedPreferences replacement for Android If you have read the documentation of the SharedPreferen

HCI @ gcx 2.3k Nov 17, 2022
OpenKeychain is an OpenPGP implementation for Android.

OpenKeychain (for Android) OpenKeychain is an OpenPGP implementation for Android. For a more detailed description and installation instructions go to

OpenKeychain 1.8k Jan 3, 2023
UPnP/DLNA library for Java and Android

Cling EOL: This project is no longer actively maintained, code may be outdated. If you are interested in maintaining and developing this project, comm

4th Line 1.6k Jan 4, 2023
WebSocket & WAMP in Java for Android and Java 8

Autobahn|Java Client library providing WAMP on Java 8 (Netty) and Android, plus (secure) WebSocket for Android. Autobahn|Java is a subproject of the A

Crossbar.io 1.5k Dec 9, 2022