Use non deprecated flags in BrightDisplayActivity

This commit is contained in:
Ensar Sarajčić 2023-10-05 13:06:53 +02:00
parent 0a37a82ac9
commit 8a30781893
1 changed files with 17 additions and 6 deletions

View File

@ -12,6 +12,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.core.view.WindowCompat
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
@ -22,6 +23,7 @@ import com.simplemobiletools.commons.compose.theme.AppThemeSurface
import com.simplemobiletools.commons.dialogs.ColorPickerAlertDialog import com.simplemobiletools.commons.dialogs.ColorPickerAlertDialog
import com.simplemobiletools.commons.extensions.getContrastColor import com.simplemobiletools.commons.extensions.getContrastColor
import com.simplemobiletools.commons.extensions.getFormattedDuration import com.simplemobiletools.commons.extensions.getFormattedDuration
import com.simplemobiletools.commons.helpers.isOreoMr1Plus
import com.simplemobiletools.flashlight.extensions.config import com.simplemobiletools.flashlight.extensions.config
import com.simplemobiletools.flashlight.helpers.SleepTimer import com.simplemobiletools.flashlight.helpers.SleepTimer
import com.simplemobiletools.flashlight.helpers.stopSleepTimerCountDown import com.simplemobiletools.flashlight.helpers.stopSleepTimerCountDown
@ -38,12 +40,17 @@ class BrightDisplayActivity : ComponentActivity() {
private val preferences by lazy { config } private val preferences by lazy { config }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
window.addFlags( if (isOreoMr1Plus()) {
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or setShowWhenLocked(true)
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or setTurnScreenOn(true)
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or } else {
WindowManager.LayoutParams.FLAG_FULLSCREEN window.addFlags(
) WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
}
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
enableEdgeToEdgeSimple() enableEdgeToEdgeSimple()
@ -56,6 +63,10 @@ class BrightDisplayActivity : ComponentActivity() {
ScreenContent(colorPickerDialogState::show) ScreenContent(colorPickerDialogState::show)
} }
} }
if (isOreoMr1Plus()) {
WindowCompat.getInsetsController(window, window.decorView.rootView)
}
} }
@Composable @Composable