mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-07 01:50:05 +00:00
android, desktop: withLongRunningApi when needed (#3710)
This commit is contained in:
+2
-4
@@ -8,9 +8,7 @@ import androidx.core.content.ContextCompat
|
||||
import chat.simplex.common.R
|
||||
import chat.simplex.common.platform.SoundPlayerInterface
|
||||
import chat.simplex.common.platform.androidAppContext
|
||||
import chat.simplex.common.views.helpers.withScope
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
object SoundPlayer: SoundPlayerInterface {
|
||||
private var player: MediaPlayer? = null
|
||||
@@ -31,7 +29,7 @@ object SoundPlayer: SoundPlayerInterface {
|
||||
val vibrator = ContextCompat.getSystemService(androidAppContext, Vibrator::class.java)
|
||||
val effect = VibrationEffect.createOneShot(250, VibrationEffect.DEFAULT_AMPLITUDE)
|
||||
playing = true
|
||||
withScope(scope) {
|
||||
scope.launch {
|
||||
while (playing) {
|
||||
if (sound) player?.start()
|
||||
vibrator?.vibrate(effect)
|
||||
|
||||
+1
-1
@@ -383,7 +383,7 @@ private fun DisabledBackgroundCallsButton() {
|
||||
Modifier
|
||||
.padding(bottom = 24.dp)
|
||||
.clickable {
|
||||
withBGApi {
|
||||
withLongRunningApi {
|
||||
show = !platform.androidAskToAllowBackgroundCalls()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ actual fun QRCodeScanner(
|
||||
}
|
||||
}
|
||||
!cameraPermissionState.hasPermission -> {
|
||||
Button({ withBGApi { cameraPermissionState.launchPermissionRequest() } }, modifier = modifier, colors = buttonColors) {
|
||||
Button({ cameraPermissionState.launchPermissionRequest() }, modifier = modifier, colors = buttonColors) {
|
||||
Icon(painterResource(MR.images.ic_camera_enhance), null)
|
||||
Spacer(Modifier.width(DEFAULT_PADDING_HALF))
|
||||
Text(stringResource(MR.strings.enable_camera_access))
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ fun AppearanceScope.AppearanceLayout(
|
||||
val state = rememberSaveable { mutableStateOf(languagePref.get() ?: "system") }
|
||||
LangSelector(state) {
|
||||
state.value = it
|
||||
withBGApi {
|
||||
withApi {
|
||||
delay(200)
|
||||
val activity = context as? Activity
|
||||
if (activity != null) {
|
||||
|
||||
Reference in New Issue
Block a user