FudiPermission

Introduction: Android Library for easy permissions
More: Author   ReportBugs   OfficialWebsite   
Tags:

Platform License Bintray Jitpack CircleCi

by Romell Domínguez

latestVersion is 1.0.a

Add the following in your app's build.gradle file:

repositories {
    jcenter()
}
dependencies {
    compile 'com.romellfudi.permission:fudi-permission:${latestVersion}'

}

First Android need confirmation by user from version 6 , its fot that create a sample how build a Adroid permission library (jar or aar file):

Permissions that you have deploy (needPermissions.txt):

CALENDAR
    READ_CALENDAR
    WRITE_CALENDAR
CAMERA
    CAMERA
CONTACTS
    READ_CONTACTS
    WRITE_CONTACTS
    GET_ACCOUNTS
LOCATION
    ACCESS_FINE_LOCATION
    ACCESS_COARSE_LOCATION
MICROPHONE
    RECORD_AUDIO
PHONE
    READ_PHONE_STATE
    CALL_PHONE
    READ_CALL_LOG
    WRITE_CALL_LOG
    ADD_VOICEMAIL
    USE_SIP
    PROCESS_OUTGOING_CALLS
SENSORS
    BODY_SENSORS
SMS
    SEND_SMS
    RECEIVE_SMS
    READ_SMS
    RECEIVE_WAP_PUSH
    RECEIVE_MMS
STORAGE
    READ_EXTERNAL_STORAGE
    WRITE_EXTERNAL_STORAGE

Import library:

If you use aar component you need add this lines into gradle:

repositories{
    flatDir {
        dirs 'libs'
    }
}

add dependency into app project, use only one to reject conflict:

dependencies {
//    compile project(':fudi-permission')
//    compile(name: 'fudi-permission-1.0.a', ext: 'aar')
//    compile files('libs/fudi-permission-1.0.a.jar')
    implementation 'com.romellfudi.permission:fudi-permission:1.0.a'
}

How use

Add normally permissions on your manifest app:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Import class permissions variables, ex:

import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import static android.Manifest.permission.CAMERA;

Build an callback object to catch the rsponse for user. If have 1 or more refuse permissions, onRefuse method activate, otherwise onFinally

private PermissionService.Callback callback = new PermissionService.Callback() {
        @Override
        public void onRefuse(ArrayList<String> RefusePermissions) {
            // todo
        }

        @Override
        public void onFinally() {
            // todo
        }
    };

Invoke service inside at Activity/onCreate method :

new PermissionService(this).request(
                new String[]{ACCESS_FINE_LOCATION, CAMERA},
                callback);

Override onRequestPermissions method from Activity class, note if necessary use if-case sentence:

@Override
public void onRequestPermissionsResult(int requestCode, 
            @NonNull String[] permissions, @NonNull int[] grantResults) {
            callback.handler(permissions, grantResults);
    }

License

Copyright 2018 Romell D.Z.

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.

2018, July

Support Me
Apps
About Me
Google+: Trinea trinea
GitHub: Trinea