Skip to content

Commit 2a9f668

Browse files
brandonpagewmathurin
authored andcommitted
Merge pull request #2709 from brandonpage/fix-login-status-bar-icon-color
Fix status bar icon color for all cases.
1 parent 8f281b8 commit 2a9f668

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

libs/SalesforceSDK/src/com/salesforce/androidsdk/ui/LoginActivity.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ import androidx.browser.customtabs.CustomTabColorSchemeParams
9393
import androidx.browser.customtabs.CustomTabsIntent
9494
import androidx.compose.material3.MaterialTheme
9595
import androidx.compose.ui.graphics.Color
96+
import androidx.compose.ui.graphics.luminance
9697
import androidx.compose.ui.graphics.toArgb
9798
import androidx.core.content.ContextCompat
9899
import androidx.core.content.ContextCompat.getMainExecutor
@@ -920,7 +921,10 @@ open class LoginActivity : FragmentActivity() {
920921
?: return@evaluateJavascript
921922

922923
// Ensure Status Bar Icons are readable no matter which OS theme is used.
923-
val useLightIcons = viewModel.dynamicBackgroundTheme.value == DARK
924+
val titleTextColorLight = viewModel.titleTextColor?.luminance()?.let { it < 0.5 }
925+
val topAppBarDark = viewModel.topBarColor?.luminance()?.let { it < 0.5 }
926+
val dynamicThemeIsDark = viewModel.dynamicBackgroundTheme.value == DARK
927+
val useLightIcons = titleTextColorLight ?: topAppBarDark ?: dynamicThemeIsDark
924928
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = useLightIcons
925929
}.also {
926930
if (!viewModel.authFinished.value) {

0 commit comments

Comments
 (0)