Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into renovate/versions.a…
Browse files Browse the repository at this point in the history
…pp_compat
  • Loading branch information
ArnasSmicius committed Sep 11, 2023
2 parents c5d379c + 9d76e73 commit 89eefc1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}
}
Expand All @@ -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()) {
Expand All @@ -51,36 +51,36 @@ launch {
}
```
##### Support for multiple permissions request:
```
```kotlin
val permissionResult = coper.request(
Manifest.permission.CAMERA, // granted
Manifest.permission.READ_EXTERNAL_STORAGE, // granted
Manifest.permission.BLUETOOTH //granted
)
permissionResult.isGranted() // returns true
```
```
```kotlin
val permissionResult = coper.request(
Manifest.permission.CAMERA, // granted
Manifest.permission.READ_EXTERNAL_STORAGE, // denied
Manifest.permission.BLUETOOTH //granted
)
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())
}
}
```
##### If you have some optional permissions:
```
```kotlin
launch {
if (coper.request(Manifest.permission.CAMERA).isSuccesfull()) {
launchCamera()
Expand All @@ -92,7 +92,7 @@ launch {
}
```
##### Permission result callbacks:
```
```kotlin
coper.request(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.CAMERA
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
}
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk11

0 comments on commit 89eefc1

Please sign in to comment.