From c55f523d6d5aae95557037ef2c6cfe4be7039b1e Mon Sep 17 00:00:00 2001 From: HanSJin Date: Thu, 2 Dec 2021 21:17:02 +0900 Subject: [PATCH] Bugfix: ThrowInvalidMutabilityException in requiredPermissions. (#9) * Bugfix: ThrowInvalidMutabilityException in requiredPermissions. * Update: variable type 'var' to 'val' of requiredPermission. Co-authored-by: HanPro --- build.gradle.kts | 2 +- kmm_location.podspec | 2 +- sample/shared/build.gradle.kts | 2 +- .../kotlin/com/linecorp/abc/location/LocationManager.kt | 6 +++--- .../com/linecorp/abc/location/extension/ABCLocationExt.kt | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 290efb0..916dcb8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.cli.common.toBooleanLenient import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget val isSnapshotUpload = System.getProperty("snapshot").toBooleanLenient() ?: false -val libVersion = "0.2.8" +val libVersion = "0.2.9" val gitName = "abc-${project.name}" buildscript { diff --git a/kmm_location.podspec b/kmm_location.podspec index 2c8fba2..8988f3d 100644 --- a/kmm_location.podspec +++ b/kmm_location.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'kmm_location' - spec.version = '0.2.8' + spec.version = '0.2.9' spec.homepage = '' spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" } spec.authors = '' diff --git a/sample/shared/build.gradle.kts b/sample/shared/build.gradle.kts index 9891695..719dc72 100644 --- a/sample/shared/build.gradle.kts +++ b/sample/shared/build.gradle.kts @@ -6,7 +6,7 @@ plugins { kotlin("native.cocoapods") } -val abcLocationLib = "com.linecorp.abc:kmm-location:0.2.8" +val abcLocationLib = "com.linecorp.abc:kmm-location:0.2.9" version = "1.0" diff --git a/src/iosMain/kotlin/com/linecorp/abc/location/LocationManager.kt b/src/iosMain/kotlin/com/linecorp/abc/location/LocationManager.kt index 2bdd785..2ab6bce 100644 --- a/src/iosMain/kotlin/com/linecorp/abc/location/LocationManager.kt +++ b/src/iosMain/kotlin/com/linecorp/abc/location/LocationManager.kt @@ -16,7 +16,7 @@ internal actual class LocationManager { // ------------------------------------------------------------------------------------------- actual fun isPermissionAllowed() = - authorizationStatus == requiredPermission + authorizationStatus == requiredPermission.value actual fun removeAllListeners() { onAlwaysAllowsPermissionRequiredBlockMap.value = emptyMap() @@ -58,7 +58,7 @@ internal actual class LocationManager { // Public // ------------------------------------------------------------------------------------------- - var requiredPermission = LocationAuthorizationStatus.AuthorizedAlways + val requiredPermission = NativeAtomicReference(LocationAuthorizationStatus.AuthorizedAlways) val previousAuthorizationStatus = NativeAtomicReference(LocationAuthorizationStatus.NotSet) fun onAlwaysAllowsPermissionRequired( @@ -79,7 +79,7 @@ internal actual class LocationManager { // ------------------------------------------------------------------------------------------- private val isRequiredAllowAlways: Boolean - get() = requiredPermission == LocationAuthorizationStatus.AuthorizedAlways + get() = requiredPermission.value == LocationAuthorizationStatus.AuthorizedAlways private val authorizationStatus: LocationAuthorizationStatus get() = if (Version(UIDevice.currentDevice.systemVersion) >= Version("14")) { diff --git a/src/iosMain/kotlin/com/linecorp/abc/location/extension/ABCLocationExt.kt b/src/iosMain/kotlin/com/linecorp/abc/location/extension/ABCLocationExt.kt index fe830a4..5ed3e76 100644 --- a/src/iosMain/kotlin/com/linecorp/abc/location/extension/ABCLocationExt.kt +++ b/src/iosMain/kotlin/com/linecorp/abc/location/extension/ABCLocationExt.kt @@ -7,8 +7,8 @@ import com.linecorp.abc.location.LocationAuthorizationStatus typealias OnAlwaysAllowsPermissionRequiredBlock = () -> Unit var ABCLocation.Companion.requiredPermission: LocationAuthorizationStatus - get() = locationManager.requiredPermission - set(value) { locationManager.requiredPermission = value } + get() = locationManager.requiredPermission.value + set(value) { locationManager.requiredPermission.value = value } fun ABCLocation.Companion.onAlwaysAllowsPermissionRequired( target: Any,