Skip to content

Commit

Permalink
Merge pull request #62 from icerockdev/develop
Browse files Browse the repository at this point in the history
Release 0.13.0
  • Loading branch information
Alex009 authored Oct 28, 2022
2 parents 2e09c9e + 9992b03 commit 89c5350
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ allprojects {
project **build.gradle**
```groovy
dependencies {
commonMainApi("dev.icerock.moko:permissions:0.12.0")
commonTestImplementation("dev.icerock.moko:permissions-test:0.12.0")
commonMainApi("dev.icerock.moko:permissions:0.13.0")
commonTestImplementation("dev.icerock.moko:permissions-test:0.13.0")
}
```

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ kotlin.mpp.enableCompatibilityMetadataVariant=true

android.useAndroidX=true

moko.android.targetSdk=31
moko.android.compileSdk=31
moko.android.targetSdk=33
moko.android.compileSdk=33
moko.android.minSdk=16

moko.publish.name=MOKO permissions
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ androidLifecycleVersion = "2.1.0"
androidCoreTestingVersion = "2.1.0"
coroutinesVersion = "1.6.0-native-mt"
mokoMvvmVersion = "0.12.0"
mokoPermissionsVersion = "0.12.0"
mokoPermissionsVersion = "0.13.0"

[libraries]
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class PermissionsControllerImpl(
}

override fun isPermissionGranted(permission: Permission): Boolean {
if (permission == Permission.REMOTE_NOTIFICATION && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (permission == Permission.REMOTE_NOTIFICATION &&
Build.VERSION.SDK_INT in VERSIONS_WITHOUT_NOTIFICATION_PERMISSION
) {
return NotificationManagerCompat.from(applicationContext).areNotificationsEnabled()
}
return permission.toPlatformPermission().all {
Expand All @@ -69,7 +71,9 @@ class PermissionsControllerImpl(

@Suppress("ReturnCount")
override suspend fun getPermissionState(permission: Permission): PermissionState {
if (permission == Permission.REMOTE_NOTIFICATION && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (permission == Permission.REMOTE_NOTIFICATION &&
Build.VERSION.SDK_INT in VERSIONS_WITHOUT_NOTIFICATION_PERMISSION
) {
val isNotificationsEnabled = NotificationManagerCompat.from(applicationContext)
.areNotificationsEnabled()
return if (isNotificationsEnabled) {
Expand Down Expand Up @@ -133,7 +137,14 @@ class PermissionsControllerImpl(
Permission.WRITE_STORAGE -> listOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)
Permission.LOCATION -> listOf(Manifest.permission.ACCESS_FINE_LOCATION)
Permission.COARSE_LOCATION -> listOf(Manifest.permission.ACCESS_COARSE_LOCATION)
Permission.REMOTE_NOTIFICATION -> emptyList()
Permission.REMOTE_NOTIFICATION -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
listOf(Manifest.permission.POST_NOTIFICATIONS)
} else {
emptyList()
}
}

Permission.RECORD_AUDIO -> listOf(Manifest.permission.RECORD_AUDIO)
Permission.BLUETOOTH_LE -> allBluetoothPermissions()
Permission.BLUETOOTH_SCAN -> bluetoothScanCompat()
Expand Down Expand Up @@ -180,4 +191,9 @@ class PermissionsControllerImpl(
} else {
listOf(Manifest.permission.BLUETOOTH)
}

private companion object {
val VERSIONS_WITHOUT_NOTIFICATION_PERMISSION =
Build.VERSION_CODES.KITKAT until Build.VERSION_CODES.TIRAMISU
}
}
1 change: 1 addition & 0 deletions sample/android-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:label="moko-permissions test app"
Expand Down

0 comments on commit 89c5350

Please sign in to comment.