Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
afollestad committed Mar 30, 2016
1 parent 095eecc commit 818ab7c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 15 deletions.
68 changes: 61 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ Assent is designed to make Marshmallow's runtime permissions easier to use. Have
2. [Dependency](https://github.com/afollestad/assent#dependency)
2. [Basics](https://github.com/afollestad/assent#basics)
3. [Without AssentActivity](https://github.com/afollestad/assent#without-assentactivity)
4. [Using PermissionResultSet](https://github.com/afollestad/assent#using-permissionresultset)
5. [Fragments](https://github.com/afollestad/assent#fragments)
6. [Duplicate and Simultaneous Requests](https://github.com/afollestad/assent#duplicate-and-simultaneous-requests)
4. [Without AssentFragment](https://github.com/afollestad/assent#without-assentfragment)
5. [Using PermissionResultSet](https://github.com/afollestad/assent#using-permissionresultset)
6. [Fragments](https://github.com/afollestad/assent#fragments)
7. [Duplicate and Simultaneous Requests](https://github.com/afollestad/assent#duplicate-and-simultaneous-requests)
1. [Duplicate Request Handling](https://github.com/afollestad/assent#duplicate-request-handling)
2. [Simultaneous Request Handling](https://github.com/afollestad/assent#simultaneous-request-handling)
7. [AfterPermissionResult Annotation](https://github.com/afollestad/assent#afterpermissionresult-annotation)
8. [AfterPermissionResult Annotation](https://github.com/afollestad/assent#afterpermissionresult-annotation)

---

Expand All @@ -32,7 +33,7 @@ Add this in your root `build.gradle` file (**not** your module `build.gradle` fi
```gradle
allprojects {
repositories {
...
// ...
maven { url "https://jitpack.io" }
}
}
Expand All @@ -44,8 +45,8 @@ Add this to your module's `build.gradle` file:

```gradle
dependencies {
...
compile('com.github.afollestad:assent:0.2.0') {
// ...
compile('com.github.afollestad:assent:0.2.1') {
transitive = true
}
}
Expand All @@ -58,6 +59,8 @@ dependencies {
**Note**: *you need to have needed permissions in your AndroidManifest.xml too, otherwise Android will
always deny them, even on Marshmallow.*

#### Activities

The first way to use this library is to have Activities which request permissions extend `AssentActivity`.
AssentActivity will handle some dirty work internally, so all that you have to do is use the `requestPermissions` method:

Expand Down Expand Up @@ -90,6 +93,19 @@ Assent.requestPermissions(callback,
Assent.WRITE_EXTERNAL_STORAGE, Assent.ACCESS_FINE_LOCATION);
```

#### Fragments

If you use `Fragment`'s in your app, it's recommended that they extend `AssentFragment`. They will update
Context references in Assent, and handle Fragment permission results for you. Relying on the Fragment's
Activity can lead to occasional problems.

```java
public class MainFragment extends AssentFragment {

// Use Assent the same way you would in an Activity
}
```

---

# Without AssentActivity
Expand Down Expand Up @@ -144,6 +160,44 @@ public class MainActivity extends AppCompatActivity {

---

# Without AssentFragment

If you don't want to extend `AssentFragment`, you can use some of Assent's other methods in order to
mimic the behavior:

```java
public class AssentFragment extends Fragment
implements FragmentCompat.OnRequestPermissionsResultCallback {

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Assent.setFragment(this, this);
}

@Override
public void onResume() {
super.onResume();
Assent.setFragment(this, this);
}

@Override
public void onPause() {
super.onPause();
if (getActivity() != null && getActivity().isFinishing())
Assent.setFragment(this, null);
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
Assent.handleResult(permissions, grantResults);
}
}
```

---

# Using PermissionResultSet

`PermissionResultSet` is returned in callbacks. It has a few useful methods:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha3'
classpath 'com.android.tools.build:gradle:2.1.0-alpha4'
}
}

Expand Down
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 4
versionName "0.2.0"
versionCode 5
versionName "0.2.1"
}
lintOptions {
abortOnError false
Expand All @@ -22,6 +22,6 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:support-v13:23.2.1'
}
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.afollestad.assentsample"
minSdkVersion 14
targetSdkVersion 23
versionCode 4
versionName "0.2.0"
versionCode 5
versionName "0.2.1"
}
lintOptions {
abortOnError false
Expand All @@ -23,6 +23,6 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile project(':library')
}

0 comments on commit 818ab7c

Please sign in to comment.