From 6ffbe18bc5a56a7d1f1ea3df7f02922700512fc4 Mon Sep 17 00:00:00 2001 From: Andrea Severi Date: Fri, 20 Dec 2024 00:05:11 +0100 Subject: [PATCH] Apply spotless --- .../samples/apps/nowinandroid/MainActivity.kt | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt index f26cc5a19..34c538374 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt @@ -105,7 +105,7 @@ class MainActivity : ComponentActivity() { darkTheme = uiState.shouldUseDarkTheme(systemDark), androidTheme = uiState.shouldUseAndroidTheme, disableDynamicTheming = uiState.shouldDisableDynamicTheming, - shouldFollowSystemTheme = uiState.shouldFollowSystemTheme + shouldFollowSystemTheme = uiState.shouldFollowSystemTheme, ) } .onEach { themeSettings = it } @@ -130,7 +130,7 @@ class MainActivity : ComponentActivity() { ) setAppTheme( uiModeManager = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager, - themeSettings = themeSettings + themeSettings = themeSettings, ) } } @@ -182,28 +182,26 @@ class MainActivity : ComponentActivity() { */ private fun setAppTheme( uiModeManager: UiModeManager, - themeSettings: ThemeSettings + themeSettings: ThemeSettings, ) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - uiModeManager.setApplicationNightMode( - if (themeSettings.shouldFollowSystemTheme) { - UiModeManager.MODE_NIGHT_AUTO - } else if (themeSettings.darkTheme) { - UiModeManager.MODE_NIGHT_YES - } else { - UiModeManager.MODE_NIGHT_NO - } - ) + val mode = if (themeSettings.shouldFollowSystemTheme) { + UiModeManager.MODE_NIGHT_AUTO + } else if (themeSettings.darkTheme) { + UiModeManager.MODE_NIGHT_YES + } else { + UiModeManager.MODE_NIGHT_NO + } + uiModeManager.setApplicationNightMode(mode) } else { - AppCompatDelegate.setDefaultNightMode( - if (themeSettings.shouldFollowSystemTheme) { - AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM - } else if (themeSettings.darkTheme) { - AppCompatDelegate.MODE_NIGHT_YES - } else { - AppCompatDelegate.MODE_NIGHT_NO - } - ) + val mode = if (themeSettings.shouldFollowSystemTheme) { + AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM + } else if (themeSettings.darkTheme) { + AppCompatDelegate.MODE_NIGHT_YES + } else { + AppCompatDelegate.MODE_NIGHT_NO + } + AppCompatDelegate.setDefaultNightMode(mode) } }