mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-02 11:24:18 +00:00
status and nav bar colors
This commit is contained in:
@@ -29,7 +29,7 @@ class MainActivity: FragmentActivity() {
|
||||
mainActivity = WeakReference(this)
|
||||
platform.androidSetNightModeIfSupported()
|
||||
val c = CurrentColors.value.colors
|
||||
platform.androidSetStatusAndNavigationBarAppearance(c.isLight)
|
||||
platform.androidSetStatusAndNavigationBarAppearance(c.isLight, c.isLight)
|
||||
applyAppLocale(ChatModel.controller.appPrefs.appLanguage)
|
||||
// This flag makes status bar and navigation bar fully transparent. But on API level < 30 it breaks insets entirely
|
||||
// https://issuetracker.google.com/issues/236862874
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.os.*
|
||||
import android.view.View
|
||||
import android.view.WindowManager.LayoutParams
|
||||
import androidx.compose.animation.core.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
@@ -275,21 +274,26 @@ class SimplexApp: Application(), LifecycleEventObserver {
|
||||
uiModeManager.setApplicationNightMode(mode)
|
||||
}
|
||||
|
||||
override fun androidSetStatusAndNavigationBarAppearance(isLight: Boolean) {
|
||||
override fun androidSetStatusAndNavigationBarAppearance(isLightStatusBar: Boolean, isLightNavBar: Boolean) {
|
||||
val window = mainActivity.get()?.window ?: return
|
||||
@Suppress("DEPRECATION")
|
||||
val light = isLight && chatModel.activeCall.value == null
|
||||
val statusLight = isLightStatusBar && chatModel.activeCall.value == null
|
||||
val navBarLight = isLightNavBar || windowOrientation() == WindowOrientation.LANDSCAPE
|
||||
val windowInsetController = ViewCompat.getWindowInsetsController(window.decorView)
|
||||
if (windowInsetController?.isAppearanceLightStatusBars != light) {
|
||||
windowInsetController?.isAppearanceLightStatusBars = light
|
||||
if (windowInsetController?.isAppearanceLightStatusBars != statusLight) {
|
||||
windowInsetController?.isAppearanceLightStatusBars = statusLight
|
||||
}
|
||||
window.navigationBarColor = Color.Transparent.toArgb()
|
||||
if (windowInsetController?.isAppearanceLightNavigationBars != CurrentColors.value.colors.isLight) {
|
||||
windowInsetController?.isAppearanceLightNavigationBars = CurrentColors.value.colors.isLight
|
||||
if (windowInsetController?.isAppearanceLightNavigationBars != navBarLight) {
|
||||
windowInsetController?.isAppearanceLightNavigationBars = navBarLight
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||
window.decorView.systemUiVisibility = if (CurrentColors.value.colors.isLight) {
|
||||
window.decorView.systemUiVisibility = if (statusLight && navBarLight) {
|
||||
View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||
} else if (statusLight) {
|
||||
View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
} else if (navBarLight) {
|
||||
View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
||||
-8
@@ -38,14 +38,6 @@ actual fun SimpleAndAnimatedImageView(
|
||||
if (getLoadedFilePath(file) != null) {
|
||||
ModalManager.fullscreen.showCustomModal(animated = false) { close ->
|
||||
ImageFullScreenView(imageProvider, close)
|
||||
if (smallView) {
|
||||
DisposableEffect(Unit) {
|
||||
onDispose {
|
||||
val c = CurrentColors.value.colors
|
||||
platform.androidSetStatusAndNavigationBarAppearance(c.isLight)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -75,9 +75,9 @@ private fun GreenLine(statusBarHeight: Dp, call: Call) {
|
||||
CallDuration(call)
|
||||
}
|
||||
DisposableEffect(Unit) {
|
||||
platform.androidSetStatusAndNavigationBarAppearance(false)
|
||||
platform.androidSetStatusAndNavigationBarAppearance(false, CurrentColors.value.colors.isLight)
|
||||
onDispose {
|
||||
platform.androidSetStatusAndNavigationBarAppearance(CurrentColors.value.colors.isLight)
|
||||
platform.androidSetStatusAndNavigationBarAppearance(CurrentColors.value.colors.isLight, CurrentColors.value.colors.isLight)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ interface PlatformInterface {
|
||||
fun androidChatInitializedAndStarted() {}
|
||||
fun androidIsBackgroundCallAllowed(): Boolean = true
|
||||
fun androidSetNightModeIfSupported() {}
|
||||
fun androidSetStatusAndNavigationBarAppearance(isLight: Boolean) {}
|
||||
fun androidSetStatusAndNavigationBarAppearance(isLightStatusBar: Boolean, isLightNavBar: Boolean) {}
|
||||
fun androidStartCallActivity(acceptCall: Boolean, remoteHostId: Long? = null, chatId: ChatId? = null) {}
|
||||
fun androidPictureInPictureAllowed(): Boolean = true
|
||||
fun androidCallEnded() {}
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ object ThemeManager {
|
||||
CurrentColors.value = currentColors(null, null, chatModel.currentUser.value?.uiThemes, appPrefs.themeOverrides.get())
|
||||
platform.androidSetNightModeIfSupported()
|
||||
val c = CurrentColors.value.colors
|
||||
platform.androidSetStatusAndNavigationBarAppearance(c.isLight)
|
||||
platform.androidSetStatusAndNavigationBarAppearance(c.isLight, c.isLight)
|
||||
}
|
||||
|
||||
fun changeDarkTheme(theme: String) {
|
||||
|
||||
+8
-2
@@ -56,8 +56,14 @@ fun ImageFullScreenView(imageProvider: () -> ImageGalleryProvider, close: () ->
|
||||
val scope = rememberCoroutineScope()
|
||||
val playersToRelease = rememberSaveable { mutableSetOf<URI>() }
|
||||
DisposableEffectOnGone(
|
||||
always = { platform.androidSetStatusAndNavigationBarAppearance(CurrentColors.value.colors.isLight) },
|
||||
whenGone = { playersToRelease.forEach { VideoPlayerHolder.release(it, true, true) } }
|
||||
always = { platform.androidSetStatusAndNavigationBarAppearance(false, false) },
|
||||
whenDispose = {
|
||||
val c = CurrentColors.value.colors
|
||||
platform.androidSetStatusAndNavigationBarAppearance(c.isLight, c.isLight)
|
||||
},
|
||||
whenGone = {
|
||||
playersToRelease.forEach { VideoPlayerHolder.release(it, true, true) }
|
||||
}
|
||||
)
|
||||
|
||||
@Composable
|
||||
|
||||
Reference in New Issue
Block a user