Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tk2232 authored Sep 7, 2018
1 parent e9549a4 commit 7bdaade
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# EasyPermissions


## Setup

```java
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```

```java
dependencies {
implementation 'com.github.tk2232:EasyPermissions:v1.0.1'
}
```

Declare specific permissions in your AndroidMnifest.xml<br/>
Example:
```java
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
```

## Usage:

### In Activity:

```java
private void takePicture() {
if (!EasyPermissions.config(this).checkCameraAndStorragePermissions()) {
//takePicture
} else {
EasyPermissions.config(this).requestCameraAndStorragePermissions();
}
}
```

```java
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
EasyPermissions.handleRequestPermissionsResult(requestCode, permissions, grantResults, new PermissionCallback() {
@Override
public void onPermissionGranted(int requestCode, String[] permissions) {
log("Granted", permissions);
}

@Override
public void onPermissionDenied(int requestCode, String[] permissions, int[] grantResults) {
log("Denied", permissions);
}
});
}
```

## Examples
### Check permissions

```java
EasyPermissions.config(this).checkAccessCoarseLocationPermission();
EasyPermissions.config(this).checkAccessFineLocationPermission();
EasyPermissions.config(this).checkCameraAndStorragePermissions();
EasyPermissions.config(this).checkCameraPermission();
EasyPermissions.config(this).checkReadExternalStorragePermission();
EasyPermissions.config(this).checkWriteExternalStorragePermission();
EasyPermissions.config(this).checkReadWriteStorragePermission();

Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
EasyPermissions.config(this).isExplicitCameraPermissionRequired();
```
### Request permissions

```java
EasyPermissions.config(this).requestCameraAndStorragePermissions();
EasyPermissions.config(this).requestCameraPermission();
EasyPermissions.config(this).requestCoarseLocation();
EasyPermissions.config(this).requestFineLocation();
EasyPermissions.config(this).requestReadExternalStorrage();
EasyPermissions.config(this).requestWriteExternalStorrage();
EasyPermissions.config(this).requestReadWriteExternalStorrage();
EasyPermissions.config(this).requestPermissions(Sring[] permissions, int PERMISSION_REQUEST);
```

### Configuration

```java
EasyPermissions.config(this).customExplanationSnackBar(Snackbar snackbar);
EasyPermissions.config(this).setupExplanationSnackBar(String actionTitle, String actionDescription);
EasyPermissions.config(this).showExplanationSnackBar(boolean show);
EasyPermissions.config(this).explanationDialog(AlertDialog dialog);
```

0 comments on commit 7bdaade

Please sign in to comment.