-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from icerockdev/develop
Release 0.19.0
- Loading branch information
Showing
68 changed files
with
949 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
import dev.icerock.moko.gradle.utils.connectTargetsToSourceSet | ||
import dev.icerock.moko.gradle.utils.createMainTest | ||
import dev.icerock.moko.gradle.utils.setupDependency | ||
|
||
plugins { | ||
id("org.jetbrains.kotlin.multiplatform") | ||
id("dev.icerock.moko.gradle.publication") | ||
id("dev.icerock.moko.gradle.detekt") | ||
} | ||
|
||
kotlin { | ||
iosArm64() | ||
iosX64() | ||
iosSimulatorArm64() | ||
|
||
with(this.sourceSets) { | ||
// creation | ||
createMainTest("ios") | ||
|
||
// ios dependencies | ||
setupDependency("ios", "common") | ||
connectTargetsToSourceSet( | ||
targetNames = listOf("iosX64", "iosArm64", "iosSimulatorArm64"), | ||
sourceSetPrefix = "ios" | ||
) | ||
} | ||
} | ||
|
||
dependencies { | ||
commonMainApi(projects.permissions) | ||
commonMainImplementation(libs.coroutines) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
plugins { | ||
id("dev.icerock.moko.gradle.multiplatform.mobile") | ||
id("dev.icerock.moko.gradle.publication") | ||
id("dev.icerock.moko.gradle.stub.javadoc") | ||
id("dev.icerock.moko.gradle.detekt") | ||
} | ||
|
||
android { | ||
namespace = "dev.icerock.moko.permissions.bluetooth" | ||
} | ||
|
||
dependencies { | ||
commonMainApi(projects.permissions) | ||
commonMainImplementation(libs.coroutines) | ||
} |
90 changes: 90 additions & 0 deletions
90
...androidMain/kotlin/dev/icerock/moko/permissions/bluetooth/BluetoothPermissions.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package dev.icerock.moko.permissions.bluetooth | ||
|
||
import android.Manifest | ||
import android.content.Context | ||
import android.os.Build | ||
import dev.icerock.moko.permissions.PermissionDelegate | ||
|
||
/** | ||
* @see https://developer.android.com/guide/topics/connectivity/bluetooth/permissions | ||
*/ | ||
|
||
actual val bluetoothLEDelegate = object : PermissionDelegate { | ||
override fun getPermissionStateOverride(applicationContext: Context) = null | ||
|
||
override fun getPlatformPermission() = allBluetoothPermissions() | ||
|
||
/** | ||
* Bluetooth permissions | ||
* | ||
* @see https://developer.android.com/guide/topics/connectivity/bluetooth/permissions | ||
*/ | ||
private fun allBluetoothPermissions(): List<String> = buildSet { | ||
addAll(bluetoothConnectCompat()) | ||
addAll(bluetoothScanCompat()) | ||
addAll(bluetoothAdvertiseCompat()) | ||
}.toList() | ||
|
||
private fun bluetoothScanCompat(): List<String> { | ||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
listOf(Manifest.permission.BLUETOOTH_SCAN) | ||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { | ||
listOf(Manifest.permission.ACCESS_FINE_LOCATION) | ||
} else { | ||
listOf(Manifest.permission.ACCESS_COARSE_LOCATION) | ||
} | ||
} | ||
|
||
private fun bluetoothAdvertiseCompat(): List<String> { | ||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
listOf(Manifest.permission.BLUETOOTH_ADVERTISE) | ||
} else { | ||
listOf(Manifest.permission.BLUETOOTH) | ||
} | ||
} | ||
|
||
private fun bluetoothConnectCompat(): List<String> { | ||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
listOf(Manifest.permission.BLUETOOTH_CONNECT) | ||
} else { | ||
listOf(Manifest.permission.BLUETOOTH) | ||
} | ||
} | ||
} | ||
|
||
actual val bluetoothScanDelegate = object : PermissionDelegate { | ||
override fun getPermissionStateOverride(applicationContext: Context) = null | ||
|
||
override fun getPlatformPermission() = | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
listOf(Manifest.permission.BLUETOOTH_SCAN) | ||
} else { | ||
listOf(Manifest.permission.BLUETOOTH) | ||
} | ||
} | ||
|
||
actual val bluetoothAdvertiseDelegate = object : PermissionDelegate { | ||
override fun getPermissionStateOverride(applicationContext: Context) = null | ||
|
||
override fun getPlatformPermission() = | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
listOf(Manifest.permission.BLUETOOTH_ADVERTISE) | ||
} else { | ||
listOf(Manifest.permission.BLUETOOTH) | ||
} | ||
} | ||
|
||
actual val bluetoothConnectDelegate = object : PermissionDelegate { | ||
override fun getPermissionStateOverride(applicationContext: Context) = null | ||
|
||
override fun getPlatformPermission() = | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
listOf(Manifest.permission.BLUETOOTH_CONNECT) | ||
} else { | ||
listOf(Manifest.permission.BLUETOOTH) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ooth/src/commonMain/kotlin/dev/icerock/moko/permissions/bluetooth/BluetoothPermissions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package dev.icerock.moko.permissions.bluetooth | ||
|
||
import dev.icerock.moko.permissions.Permission | ||
import dev.icerock.moko.permissions.PermissionDelegate | ||
|
||
internal expect val bluetoothLEDelegate: PermissionDelegate | ||
internal expect val bluetoothScanDelegate: PermissionDelegate | ||
internal expect val bluetoothAdvertiseDelegate: PermissionDelegate | ||
internal expect val bluetoothConnectDelegate: PermissionDelegate | ||
|
||
object BluetoothLEPermission : Permission { | ||
override val delegate get() = bluetoothLEDelegate | ||
} | ||
|
||
object BluetoothScanPermission : Permission { | ||
override val delegate get() = bluetoothScanDelegate | ||
} | ||
|
||
object BluetoothAdvertisePermission : Permission { | ||
override val delegate get() = bluetoothAdvertiseDelegate | ||
} | ||
|
||
object BluetoothConnectPermission : Permission { | ||
override val delegate get() = bluetoothConnectDelegate | ||
} | ||
|
||
val Permission.Companion.BLUETOOTH_LE get() = BluetoothLEPermission | ||
val Permission.Companion.BLUETOOTH_SCAN get() = BluetoothScanPermission | ||
val Permission.Companion.BLUETOOTH_ADVERTISE get() = BluetoothAdvertisePermission | ||
val Permission.Companion.BLUETOOTH_CONNECT get() = BluetoothConnectPermission |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
plugins { | ||
id("dev.icerock.moko.gradle.multiplatform.mobile") | ||
id("dev.icerock.moko.gradle.publication") | ||
id("dev.icerock.moko.gradle.stub.javadoc") | ||
id("dev.icerock.moko.gradle.detekt") | ||
} | ||
|
||
android { | ||
namespace = "dev.icerock.moko.permissions.camera" | ||
} | ||
|
||
dependencies { | ||
commonMainApi(projects.permissions) | ||
iosMainImplementation(projects.permissionsAvfoundation) | ||
commonMainImplementation(libs.coroutines) | ||
} |
14 changes: 14 additions & 0 deletions
14
...ra/src/androidMain/kotlin/dev/icerock/moko/permissions/camera/CameraPermission.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package dev.icerock.moko.permissions.camera | ||
|
||
import android.Manifest | ||
import android.content.Context | ||
import dev.icerock.moko.permissions.PermissionDelegate | ||
|
||
actual val cameraDelegate = object : PermissionDelegate { | ||
override fun getPermissionStateOverride(applicationContext: Context) = null | ||
override fun getPlatformPermission() = listOf(Manifest.permission.CAMERA) | ||
} |
16 changes: 16 additions & 0 deletions
16
...ions-camera/src/commonMain/kotlin/dev/icerock/moko/permissions/camera/CameraPermission.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package dev.icerock.moko.permissions.camera | ||
|
||
import dev.icerock.moko.permissions.Permission | ||
import dev.icerock.moko.permissions.PermissionDelegate | ||
|
||
internal expect val cameraDelegate: PermissionDelegate | ||
|
||
object CameraPermission : Permission { | ||
override val delegate get() = cameraDelegate | ||
} | ||
|
||
val Permission.Companion.CAMERA get() = CameraPermission |
15 changes: 15 additions & 0 deletions
15
...ons-camera/src/iosMain/kotlin/dev/icerock/moko/permissions/camera/CameraPermission.ios.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package dev.icerock.moko.permissions.camera | ||
|
||
import dev.icerock.moko.permissions.Permission | ||
import dev.icerock.moko.permissions.PermissionDelegate | ||
import dev.icerock.moko.permissions.avfoundation.AVCaptureDelegate | ||
import platform.AVFoundation.AVMediaTypeVideo | ||
|
||
actual val cameraDelegate: PermissionDelegate = AVCaptureDelegate( | ||
AVMediaTypeVideo, | ||
Permission.CAMERA | ||
) |
Oops, something went wrong.