Skip to content

Commit

Permalink
Clean up docs and gradle files
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelpinto committed Jan 9, 2021
1 parent 65b32e5 commit d5658b4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ permission acceptance rate.

## How to include in your project

Add custom maven url repository (publishing to JCentral is in progress)
The library is available via JCentral:

```groovy
allprojects {
Expand All @@ -49,6 +49,8 @@ allprojects {
}
```

Add it to your module dependencies:

```groovy
dependencies {
implementation 'dev.marcelpinto.permissions:permissions-ktx:0.4'
Expand Down Expand Up @@ -119,8 +121,9 @@ locationPermissionRequest.safeLaunch(
```
> Note: only ``onRequireRational`` lambda is required.
For an example of this check the [Simple sample](app/src/main/java/dev/marcelpinto/permissionktx/simple/SimpleFragment.kt)
Check the [Simple sample](app/src/main/java/dev/marcelpinto/permissionktx/simple/SimpleFragment.kt)
or the [Compose Sample](app/src/main/java/dev/marcelpinto/permissionktx/compose)
for more.

### via launch()

Expand Down Expand Up @@ -193,6 +196,7 @@ allowing the test to control the status of the permission without Android depend

```kotlin
// Using a StateFlow to change the values provided by the Observer and Checker
// You could use other mechanisms or directly a simple variable
private var permissionStatus = MutableStateFlow<Permission.Status>(
Permission.Status.Revoked(
name = Manifest.permission.ACCESS_FINE_LOCATION,
Expand Down Expand Up @@ -231,11 +235,12 @@ fun test() {
To allow control of the permission flow without having to grant/revoke Android permissions
the library provides an overload of the Permission.Init method that allows to provide
custom implementation for Checker, Observer and the ActivityResultRegistry to use
when launching the permission request.
when launching the permission request
(see [Testing ActivityResult](https://developer.android.com/training/basics/intents/result#test)).

This allow full control and customization of the Permission status
and permission request results, allowing to fully test the permission flow
without interacting with the Android System.
without interacting with the Android framework.

```kotlin
private var permissionStatus: Permission.Status = Permission.Status.Revoked(
Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ android {
dependencies {
implementation(kotlin("stdlib", KotlinCompilerVersion.VERSION))

implementation(project(":lib"))
//implementation(project(":lib"))
implementation("dev.marcelpinto.permissions:permissions-ktx:0.4")

implementation("androidx.core:core-ktx:1.3.2")
implementation("androidx.appcompat:appcompat:1.2.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,9 @@ class AdvanceViewModelTest {
@Test
fun testGivenPermissionRevokedWithRationalWhenLocationClickThenShowRational() =
testScope.runBlockingTest {
permissionStatus.emit(
Permission.Status.Revoked(
permissionStatus.value.name,
Permission.Rational.REQUIRED
)
permissionStatus.value = Permission.Status.Revoked(
permissionStatus.value.name,
Permission.Rational.REQUIRED
)
val target = AdvanceViewModel(locationFlow)

Expand All @@ -123,7 +121,7 @@ class AdvanceViewModelTest {
val target = AdvanceViewModel(locationFlow)

target.onLocationClick()
permissionStatus.emit(Permission.Status.Granted(permissionStatus.value.name))
permissionStatus.value = Permission.Status.Granted(permissionStatus.value.name)

target.getViewData().value!!.run {
assertThat(location).isEqualTo(actualFlow.value)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.0-alpha03")
classpath("com.android.tools.build:gradle:7.0.0-alpha04")
classpath(kotlin("gradle-plugin", version = "1.4.21"))
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id("com.android.library")
kotlin("android")
id("org.jetbrains.dokka") version "1.4.20"
id("com.jfrog.bintray") version "1.8.5"
`maven-publish`
id("com.jfrog.bintray") version "1.8.5"
}
Expand Down
1 change: 1 addition & 0 deletions lib/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class dev.marcelpinto.permissionktx.Permission$PermissionInitializer

0 comments on commit d5658b4

Please sign in to comment.