Skip to content

Commit

Permalink
fix: Keep screen active when user is recording audio (WPB-3479) (#2056)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreferris authored and github-actions[bot] committed Aug 3, 2023
1 parent c4ac90b commit 280581e
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
*/
package com.wire.android.ui.home.messagecomposer.recordaudio

import android.app.Activity
import android.text.format.DateUtils
import android.view.WindowManager
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Column
Expand All @@ -30,6 +32,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -38,6 +41,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.sp
Expand Down Expand Up @@ -100,6 +104,14 @@ fun RecordAudioButtonRecording(
seconds += 1
}
}
val activity = LocalContext.current as Activity

DisposableEffect(Unit) {
activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
onDispose {
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
}

RecordAudioButton(
onClick = onClick,
Expand Down

0 comments on commit 280581e

Please sign in to comment.