Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ mockk = { module = "io.mockk:mockk", version = "1.14.11" }
robolectric = { module = "org.robolectric:robolectric", version = "4.16.1" }
serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version = "1.11.0" }
tomlkt = { module = "net.peanuuutz.tomlkt:tomlkt", version = "0.5.0" }
tuulbox-coroutines = { module = "com.juul.tuulbox:coroutines", version.ref = "tuulbox" }
voyager-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" }
voyager-screenmodel = { module = "cafe.adriel.voyager:voyager-screenmodel", version.ref = "voyager" }
voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", version.ref = "voyager" }
Expand Down
1 change: 0 additions & 1 deletion kable-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ kotlin {
implementation(libs.androidx.core)
implementation(libs.androidx.startup)
implementation(libs.kotlin.parcelize.runtime)
implementation(libs.tuulbox.coroutines)
}

named("androidHostTest").dependencies {
Expand Down
1 change: 0 additions & 1 deletion kable-core/src/androidMain/kotlin/BluetoothState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.bluetooth.BluetoothAdapter.ACTION_STATE_CHANGED
import android.bluetooth.BluetoothAdapter.ERROR
import android.bluetooth.BluetoothAdapter.EXTRA_STATE
import android.content.IntentFilter
import com.juul.tuulbox.coroutines.flow.broadcastReceiverFlow
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.SharingStarted.Companion.WhileSubscribed
Expand Down
27 changes: 27 additions & 0 deletions kable-core/src/androidMain/kotlin/BroadcastReceiverFlow.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.juul.kable

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.RECEIVER_NOT_EXPORTED
import androidx.core.content.ContextCompat.RegisterReceiverFlags
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow

// Copied from Tuulbox.
// https://github.com/JuulLabs/tuulbox/blob/8.1.0/coroutines/src/androidMain/kotlin/flow/BroadcastReceiverFlow.kt
internal fun broadcastReceiverFlow(
intentFilter: IntentFilter,
@RegisterReceiverFlags flags: Int = RECEIVER_NOT_EXPORTED,
): Flow<Intent> = callbackFlow {
val broadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
trySend(intent)
}
}
ContextCompat.registerReceiver(applicationContext, broadcastReceiver, intentFilter, flags)
awaitClose { applicationContext.unregisterReceiver(broadcastReceiver) }
}
1 change: 0 additions & 1 deletion samples/sensortag/bluetooth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ kotlin {

androidMain.dependencies {
implementation(libs.compose.activity)
implementation(libs.tuulbox.coroutines)
}
}
}
Loading