diff --git a/README.md b/README.md index 23ccb49..f1b9d43 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ Fragment lifecycle is covered by this library, so you should not worry about req It is designed to use in any place like ViewModel as in fragment or activity. ### Download -``` +```groovy allprojects { repositories { - ... + // ... maven { url 'https://jitpack.io' } } } @@ -23,24 +23,24 @@ dependencies { ``` ### Api -``` +```kotlin val coper: Coper = CoperBuilder() .setFragmentActivity(activity) .build() ``` -###### Note: -You must provide fragment manager to build coper. +> [!NOTE] +> You must provide fragment manager to build coper. ### Usage ##### Request: -``` +```kotlin launch { val permissionResult: PermissionResult = coper.request(Manifest.permission.CAMERA) } ``` -###### Note: -Calling permission on a background thread or request with 0 permissions will throw `IllegalStateException` +> [!NOTE] +> Calling permission on a background thread or request with 0 permissions will throw `IllegalStateException` ##### Example: -``` +```kotlin launch { val permissionResult = coper.request(Manifest.permission.CAMERA) if (permissionResult.isSuccessful()) { @@ -51,7 +51,7 @@ launch { } ``` ##### Support for multiple permissions request: -``` +```kotlin val permissionResult = coper.request( Manifest.permission.CAMERA, // granted Manifest.permission.READ_EXTERNAL_STORAGE, // granted @@ -59,7 +59,7 @@ val permissionResult = coper.request( ) permissionResult.isGranted() // returns true ``` -``` +```kotlin val permissionResult = coper.request( Manifest.permission.CAMERA, // granted Manifest.permission.READ_EXTERNAL_STORAGE, // denied @@ -67,12 +67,12 @@ val permissionResult = coper.request( ) permissionResult.isGranted() // returns false ``` -###### Note: -If any of the requests fail, then request returns `PermissionsResult.Denied` with all denied permissions and its deny value (denied rationale or denied permanently). +> [!NOTE] +> If any of the requests fail, then request returns `PermissionsResult.Denied` with all denied permissions and its deny value (denied rationale or denied permanently). ##### Error handling: -``` -if(permissionResult.isDenied()) { - if(permissionResult.isRationale()) { +```kotlin +if (permissionResult.isDenied()) { + if (permissionResult.isRationale()) { showRationale(permissionResult.getDeniedRationale()) } else { showPermanent(permissionResult.getDeniedPermanently()) @@ -80,7 +80,7 @@ if(permissionResult.isDenied()) { } ``` ##### If you have some optional permissions: -``` +```kotlin launch { if (coper.request(Manifest.permission.CAMERA).isSuccesfull()) { launchCamera() @@ -92,7 +92,7 @@ launch { } ``` ##### Permission result callbacks: -``` +```kotlin coper.request( Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA @@ -103,24 +103,24 @@ coper.request( } ``` ##### Execute body if all permissions enabled or throw error: -``` +```kotlin coper.withPermissions(Manifest.permission.CAMERA) { launchCamera() } ``` -###### Note: -If permission will not be granted, then request crash with `PermissionsRequestFailedException` +> [!NOTE] +> If permission will not be granted, then request crash with `PermissionsRequestFailedException` ##### Additional functionality: ###### Request pending check: -``` +```kotlin coper.isRequestPendingSafe() ``` ###### Granted permissions check: -``` +```kotlin // Returns true if all permissions granted coper.isPermissionsGrantedSafe(Manifest.permission.CAMERA, Manifest.permission.ACCESS_FINE_LOCATION) ``` -### Cancelation +### Cancellation If you cancel job, request will be left until user will submit, but client will not get response. ### State recreation Sometimes after application killed (for example temporally killing to preserve memory), the dialog could be still visible, but reference to request will be lost. diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 86a4207..25d3555 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,13 +1,13 @@ object Versions { const val APP_COMPAT = "1.6.1" - const val KOTLIN = "1.9.0" + const val KOTLIN = "1.8.22" const val COROUTINES = "1.7.3" const val ANDROID_GRADLE_PLUGIN = "7.4.2" const val JUNIT = "4.13.2" const val ROBOLECTRIC = "4.3" const val MOCKITO = "3.12.4" const val MOCKITO_KOTILN = "3.2.0" - const val CORE_KTX = "1.2.0" + const val CORE_KTX = "1.10.1" const val FRAGMENT_KTX = "1.2.4" const val DETEKT_RUNTIME = "1.23.1" const val LIFECYCLE = "2.2.0" @@ -19,7 +19,7 @@ object Versions { private const val MAJOR = 0 private const val MINOR = 6 - private const val PATCH = 0 + private const val PATCH = 3 const val VERSION_NAME: String = "$MAJOR.$MINOR.$PATCH" } diff --git a/gradle.properties b/gradle.properties index 23339e0..83df5e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,5 @@ org.gradle.jvmargs=-Xmx1536m # Android operating system, and which are packaged with your app's APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..adb3fe1 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +jdk: + - openjdk11