From 2b86daa9f7f291338e5e2f958e39d8e98e54db15 Mon Sep 17 00:00:00 2001 From: lutsenko-yuriy Date: Mon, 5 Mar 2018 01:26:59 +0300 Subject: [PATCH] Code cleanup --- app-kotlin/build.gradle | 2 +- app-kotlin/src/main/AndroidManifest.xml | 3 ++- .../{yurich => gun0912}/app_kotlin/MainActivity.kt | 12 +++++++----- gradle/wrapper/gradle-wrapper.properties | 4 ++-- .../src/main/AndroidManifest.xml | 3 +-- .../tedpermission_kotlin_dsl/dsl/CheckPermissions.kt | 2 +- .../tedpermission_kotlin_dsl/dsl/Dsl.kt | 6 +++--- .../listener/PermissionListenerBuilder.kt | 8 ++++---- .../com/gun0912/tedpermission/PermissionBuilder.java | 10 +++------- 9 files changed, 24 insertions(+), 26 deletions(-) rename app-kotlin/src/main/java/com/{yurich => gun0912}/app_kotlin/MainActivity.kt (82%) rename tedpermission-kotlin-dsl/src/main/java/com/{yurich => gun0912}/tedpermission_kotlin_dsl/dsl/CheckPermissions.kt (75%) rename tedpermission-kotlin-dsl/src/main/java/com/{yurich => gun0912}/tedpermission_kotlin_dsl/dsl/Dsl.kt (94%) rename tedpermission-kotlin-dsl/src/main/java/com/{yurich => gun0912}/tedpermission_kotlin_dsl/listener/PermissionListenerBuilder.kt (74%) diff --git a/app-kotlin/build.gradle b/app-kotlin/build.gradle index 0eb7cf5..df07502 100644 --- a/app-kotlin/build.gradle +++ b/app-kotlin/build.gradle @@ -7,7 +7,7 @@ android { defaultConfig { - applicationId "com.yurich.app_kotlin" + applicationId "com.gun0912.app_kotlin" minSdkVersion 14 targetSdkVersion 27 versionCode 1 diff --git a/app-kotlin/src/main/AndroidManifest.xml b/app-kotlin/src/main/AndroidManifest.xml index 186fe6c..5558c1e 100644 --- a/app-kotlin/src/main/AndroidManifest.xml +++ b/app-kotlin/src/main/AndroidManifest.xml @@ -1,10 +1,11 @@ + package="com.gun0912.app_kotlin"> + [Permission]") } - inSettings { + onProceedingToSettings { closeButtonText("Go to settings") } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9a778d6..84379c5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Dec 28 10:00:20 PST 2015 +#Mon Mar 05 01:18:53 MSK 2018 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/tedpermission-kotlin-dsl/src/main/AndroidManifest.xml b/tedpermission-kotlin-dsl/src/main/AndroidManifest.xml index dc19c05..b0a5585 100644 --- a/tedpermission-kotlin-dsl/src/main/AndroidManifest.xml +++ b/tedpermission-kotlin-dsl/src/main/AndroidManifest.xml @@ -1,2 +1 @@ - + diff --git a/tedpermission-kotlin-dsl/src/main/java/com/yurich/tedpermission_kotlin_dsl/dsl/CheckPermissions.kt b/tedpermission-kotlin-dsl/src/main/java/com/gun0912/tedpermission_kotlin_dsl/dsl/CheckPermissions.kt similarity index 75% rename from tedpermission-kotlin-dsl/src/main/java/com/yurich/tedpermission_kotlin_dsl/dsl/CheckPermissions.kt rename to tedpermission-kotlin-dsl/src/main/java/com/gun0912/tedpermission_kotlin_dsl/dsl/CheckPermissions.kt index 53436f2..8ac2b63 100644 --- a/tedpermission-kotlin-dsl/src/main/java/com/yurich/tedpermission_kotlin_dsl/dsl/CheckPermissions.kt +++ b/tedpermission-kotlin-dsl/src/main/java/com/gun0912/tedpermission_kotlin_dsl/dsl/CheckPermissions.kt @@ -1,6 +1,6 @@ @file:JvmName("CheckPermissions") -package com.yurich.tedpermission_kotlin_dsl.dsl +package com.gun0912.tedpermission_kotlin_dsl.dsl import android.content.Context diff --git a/tedpermission-kotlin-dsl/src/main/java/com/yurich/tedpermission_kotlin_dsl/dsl/Dsl.kt b/tedpermission-kotlin-dsl/src/main/java/com/gun0912/tedpermission_kotlin_dsl/dsl/Dsl.kt similarity index 94% rename from tedpermission-kotlin-dsl/src/main/java/com/yurich/tedpermission_kotlin_dsl/dsl/Dsl.kt rename to tedpermission-kotlin-dsl/src/main/java/com/gun0912/tedpermission_kotlin_dsl/dsl/Dsl.kt index ce0b657..e2a2197 100644 --- a/tedpermission-kotlin-dsl/src/main/java/com/yurich/tedpermission_kotlin_dsl/dsl/Dsl.kt +++ b/tedpermission-kotlin-dsl/src/main/java/com/gun0912/tedpermission_kotlin_dsl/dsl/Dsl.kt @@ -1,11 +1,11 @@ -package com.yurich.tedpermission_kotlin_dsl.dsl +package com.gun0912.tedpermission_kotlin_dsl.dsl import android.content.Context import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED import android.support.annotation.StringRes import com.gun0912.tedpermission.PermissionBuilder import com.gun0912.tedpermission.TedPermission -import com.yurich.tedpermission_kotlin_dsl.listener.PermissionListenerBuilder +import com.gun0912.tedpermission_kotlin_dsl.listener.PermissionListenerBuilder class Dsl(context: Context) { @@ -39,7 +39,7 @@ class Dsl(context: Context) { Rationale().apply(body) } - fun inSettings(body: GoToSettings.() -> Unit) { + fun onProceedingToSettings(body: GoToSettings.() -> Unit) { tedPermission.setGotoSettingButton(true) GoToSettings().apply(body) } diff --git a/tedpermission-kotlin-dsl/src/main/java/com/yurich/tedpermission_kotlin_dsl/listener/PermissionListenerBuilder.kt b/tedpermission-kotlin-dsl/src/main/java/com/gun0912/tedpermission_kotlin_dsl/listener/PermissionListenerBuilder.kt similarity index 74% rename from tedpermission-kotlin-dsl/src/main/java/com/yurich/tedpermission_kotlin_dsl/listener/PermissionListenerBuilder.kt rename to tedpermission-kotlin-dsl/src/main/java/com/gun0912/tedpermission_kotlin_dsl/listener/PermissionListenerBuilder.kt index a2f8f1f..343fb75 100644 --- a/tedpermission-kotlin-dsl/src/main/java/com/yurich/tedpermission_kotlin_dsl/listener/PermissionListenerBuilder.kt +++ b/tedpermission-kotlin-dsl/src/main/java/com/gun0912/tedpermission_kotlin_dsl/listener/PermissionListenerBuilder.kt @@ -1,6 +1,6 @@ @file:Suppress("PackageName") -package com.yurich.tedpermission_kotlin_dsl.listener +package com.gun0912.tedpermission_kotlin_dsl.listener import com.gun0912.tedpermission.PermissionListener @@ -8,14 +8,14 @@ class PermissionListenerBuilder { private var onPermissionGrantedListener: () -> Unit = {} - private var onPermissionDeniedListener: (ArrayList?) -> Unit = {} + private var onPermissionDeniedListener: (List?) -> Unit = {} fun onPermissionGranted(body: () -> Unit): PermissionListenerBuilder { this.onPermissionGrantedListener = body return this } - fun onPermissionDenied(body: (ArrayList?) -> Unit): PermissionListenerBuilder { + fun onPermissionDenied(body: (List?) -> Unit): PermissionListenerBuilder { this.onPermissionDeniedListener = body return this } @@ -26,7 +26,7 @@ class PermissionListenerBuilder { onPermissionGrantedListener() } - override fun onPermissionDenied(deniedPermissions: ArrayList?) { + override fun onPermissionDenied(deniedPermissions: ArrayList) { onPermissionDeniedListener(deniedPermissions) } diff --git a/tedpermission/src/main/java/com/gun0912/tedpermission/PermissionBuilder.java b/tedpermission/src/main/java/com/gun0912/tedpermission/PermissionBuilder.java index 681f5c3..c69b542 100644 --- a/tedpermission/src/main/java/com/gun0912/tedpermission/PermissionBuilder.java +++ b/tedpermission/src/main/java/com/gun0912/tedpermission/PermissionBuilder.java @@ -22,12 +22,15 @@ public abstract class PermissionBuilder { private static final String PREFS_IS_FIRST_REQUEST = "PREFS_IS_FIRST_REQUEST"; private PermissionListener listener; + private final List permissions = new ArrayList<>(); private CharSequence rationaleTitle; private CharSequence rationaleMessage; + private CharSequence denyTitle; private CharSequence denyMessage; + private CharSequence settingButtonText; private boolean hasSettingBtn = true; @@ -106,13 +109,6 @@ public T addPermissions(List permissions) { return (T) this; } - public T addPermissions(String[] permissions) { - if (permissions != null) { - this.permissions.addAll(Arrays.asList(permissions)); - } - return (T) this; - } - public T addSinglePermission(String permission) { this.permissions.add(permission); return (T) this;