diff --git a/build.gradle b/build.gradle
index d832de3..0cb82e8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,10 +3,11 @@
buildscript {
repositories {
jcenter()
+ google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.1'
- classpath 'com.novoda:bintray-release:0.3.4'
+ classpath 'com.android.tools.build:gradle:2.3.3'
+ classpath 'com.novoda:bintray-release:0.5.0'
// NOTE: Do not place your application dependencies here; they belong
@@ -17,6 +18,7 @@ buildscript {
allprojects {
repositories {
jcenter()
+ google()
}
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 73417cc..3b2c99f 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sun Jul 30 18:37:38 MSK 2017
+#Wed Oct 11 10:27:50 MSK 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
diff --git a/library/build.gradle b/library/build.gradle
index 5d583e6..a5b89ff 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -5,7 +5,7 @@ apply plugin: 'com.novoda.bintray-release'
android {
compileSdkVersion 25
- buildToolsVersion "25.0.3"
+ buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 15
@@ -42,7 +42,7 @@ dependencies {
publish {
groupId = 'ru.alexbykov'
artifactId = 'nopermission'
- publishVersion = '1.0.8'
+ publishVersion = '1.1.0'
desc = 'Permission library for Android'
licences = ['Apache-2.0']
website = 'https://github.com/NoNews/NoPermission'
diff --git a/library/src/main/java/ru/alexbykov/nopermission/PermissionHelper.java b/library/src/main/java/ru/alexbykov/nopermission/PermissionHelper.java
index 55e1239..33eff8f 100644
--- a/library/src/main/java/ru/alexbykov/nopermission/PermissionHelper.java
+++ b/library/src/main/java/ru/alexbykov/nopermission/PermissionHelper.java
@@ -97,7 +97,7 @@ public void run() {
successListener.run();
}
} else {
- throw new RuntimeException("OnPermissionSuccessListener or OnPermissionFailureListener or OnPermissionNewerAskAgainListener not implemented. Use methods: onSuccess, onFailure and onNewerAskAgain");
+ throw new RuntimeException("OnPermissionSuccessListener or OnPermissionFailureListener not installed. Please, use onSuccess and onFailure methods");
}
}
@@ -121,7 +121,7 @@ private void checkPermissions() {
* Check listeners for null
*/
private boolean isListenersCorrect() {
- return successListener != null && failureListener != null && neverAskAgainListener != null;
+ return successListener != null && failureListener != null;
}
@@ -148,7 +148,7 @@ private String[] getPermissionsForRequest() {
/**
- * if permission not granted, check newerAskAgain, else call failure
+ * if permission not granted, check neverAskAgain, else call failure
* if permission grander, call success
*
* @param grantResults Permissions, which granted
@@ -156,17 +156,15 @@ private String[] getPermissionsForRequest() {
* @param requestCode requestCode of out request
*/
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
- if (requestCode == PERMISSION_REQUEST_CODE) {
+ if (requestCode == PERMISSION_REQUEST_CODE && isNeedToAskPermissions()) {
for (String permission : permissions) {
- if (isNeedToAskPermissions()) {
- if (isPermissionNotGranted(permission)) {
- if (isNeverAskAgain(permission)) {
- neverAskAgainListener.run();
- } else {
- failureListener.run();
- }
- return;
+ if (isPermissionNotGranted(permission)) {
+ if (isNeverAskAgain(permission)) {
+ runNeverAskAgain();
+ } else {
+ failureListener.run();
}
+ return;
}
}
}
@@ -174,6 +172,16 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
}
+ /**
+ * run never ask again callback
+ */
+ private void runNeverAskAgain() {
+ if (neverAskAgainListener != null) {
+ neverAskAgainListener.run();
+ }
+ }
+
+
/**
* @param permission for check
* @return true if permission granted and false if permission not granted
@@ -196,12 +204,8 @@ private boolean isNeverAskAgain(String permission) {
*/
public void unsubscribe() {
activity = null;
- if (failureListener != null) {
- failureListener = null;
- }
- if (successListener != null) {
- successListener = null;
- }
+ failureListener = null;
+ successListener = null;
if (neverAskAgainListener != null) {
neverAskAgainListener = null;
}
diff --git a/sample/build.gradle b/sample/build.gradle
index 80bde16..78dd69a 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 26
- buildToolsVersion "26.0.1"
+ buildToolsVersion '26.0.2'
defaultConfig {
applicationId "ru.alexbykov.permissionssample"
@@ -31,5 +31,5 @@ dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile project(':library')
-// compile 'ru.alexbykov:nopermission:1.0.7'
+// compile 'ru.alexbykov:nopermission:1.1.0'
}
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index 3d6205b..68aad1e 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
package="ru.alexbykov.permissionssample">
+
PermissionsSample
Ask location permission
+ Location success
+ Locration failure
+ Location never ask again