Fix white flash on app start (#1909)

## Description
This fixes the brief full screen white flash when the app starts or
reloads.

I bisected to find the cause which was #1653. The newly added `Surface`
uses `MaterialTheme` to set its colors. `MaterialTheme` defaults to a
generic _light_ color scheme. So this PR applies the Wholphin's default
purple theme, which will then be overridden once the app preferences are
loaded.

### Related issues
Mentioned in
https://github.com/damontecres/Wholphin/issues/1576#issuecomment-5376373039

### Testing
Used emulator with "Don't keep activities" and repeatedly opened &
closed the app to see if the white flash visually occurred

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-08-26 21:46:48 -04:00 • committed by GitHub
parent f91bca18ff
commit 786b95a393
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,6 +28,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import androidx.navigation3.runtime.NavBackStack import androidx.navigation3.runtime.NavBackStack
import androidx.tv.material3.ExperimentalTvMaterial3Api import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Surface import androidx.tv.material3.Surface
import com.github.damontecres.wholphin.data.ServerRepository import com.github.damontecres.wholphin.data.ServerRepository
import com.github.damontecres.wholphin.preferences.AppPreferences import com.github.damontecres.wholphin.preferences.AppPreferences
@ -62,6 +63,7 @@ import com.github.damontecres.wholphin.ui.nav.Destination
import com.github.damontecres.wholphin.ui.playback.PlayExternalViewModel import com.github.damontecres.wholphin.ui.playback.PlayExternalViewModel
import com.github.damontecres.wholphin.ui.showToast import com.github.damontecres.wholphin.ui.showToast
import com.github.damontecres.wholphin.ui.theme.WholphinTheme import com.github.damontecres.wholphin.ui.theme.WholphinTheme
import com.github.damontecres.wholphin.ui.theme.colors.PurpleThemeColors
import com.github.damontecres.wholphin.ui.util.ProvideLocalClock import com.github.damontecres.wholphin.ui.util.ProvideLocalClock
import com.github.damontecres.wholphin.util.DebugLogTree import com.github.damontecres.wholphin.util.DebugLogTree
import com.github.damontecres.wholphin.util.ExceptionHandler import com.github.damontecres.wholphin.util.ExceptionHandler
@ -228,11 +230,8 @@ class MainActivity : AppCompatActivity() {
viewModel.appStart(intent) viewModel.appStart(intent)
setContent { setContent {
Surface( MaterialTheme(colorScheme = PurpleThemeColors.darkScheme) {
Modifier Surface(Modifier.fillMaxSize()) {
.fillMaxSize()
.background(Color.Black),
) {
val userPreferences by userPreferencesService.flow.collectAsState(null) val userPreferences by userPreferencesService.flow.collectAsState(null)
if (userPreferences == null) { if (userPreferences == null) {
// Show loading page if it is taking a while to get app preferences // Show loading page if it is taking a while to get app preferences
@ -286,6 +285,7 @@ class MainActivity : AppCompatActivity() {
} }
} }
} }
}
override fun dispatchKeyEvent(event: KeyEvent): Boolean { override fun dispatchKeyEvent(event: KeyEvent): Boolean {
if (screensaverService.state.value.show) { if (screensaverService.state.value.show) {