mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-23 03:05:26 +00:00
Fix window insets for pixel 10 devices.
This commit is contained in:
committed by
Alex Hart
parent
3e07834c20
commit
585fb3eea8
@@ -6,13 +6,16 @@
|
||||
package org.thoughtcrime.securesms.main
|
||||
|
||||
import androidx.annotation.Px
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.asPaddingValues
|
||||
import androidx.compose.foundation.layout.navigationBars
|
||||
import androidx.compose.foundation.layout.statusBars
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.unit.Density
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
@@ -48,20 +51,47 @@ fun InsetsViewModelUpdater(
|
||||
val navigationBarPadding = navigationBarInsets.asPaddingValues()
|
||||
val density = LocalDensity.current
|
||||
|
||||
LaunchedEffect(statusBarPadding, navigationBarPadding, density) {
|
||||
val statusBarPx = with(density) {
|
||||
(statusBarPadding.calculateTopPadding() + statusBarPadding.calculateBottomPadding()).toPx()
|
||||
}
|
||||
LaunchedEffect(
|
||||
statusBarPadding,
|
||||
navigationBarPadding,
|
||||
density
|
||||
) {
|
||||
calculateAndUpdateInsets(
|
||||
density,
|
||||
insetsViewModel,
|
||||
statusBarPadding,
|
||||
navigationBarPadding
|
||||
)
|
||||
}
|
||||
|
||||
val navBarPx = with(density) {
|
||||
(navigationBarPadding.calculateTopPadding() + navigationBarPadding.calculateBottomPadding()).toPx()
|
||||
}
|
||||
|
||||
insetsViewModel.updateInsets(
|
||||
InsetsViewModel.Insets(
|
||||
statusBar = statusBarPx,
|
||||
navBar = navBarPx
|
||||
)
|
||||
SideEffect {
|
||||
calculateAndUpdateInsets(
|
||||
density,
|
||||
insetsViewModel,
|
||||
statusBarPadding,
|
||||
navigationBarPadding
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculateAndUpdateInsets(
|
||||
density: Density,
|
||||
insetsViewModel: InsetsViewModel,
|
||||
statusBarPadding: PaddingValues,
|
||||
navigationBarPadding: PaddingValues
|
||||
) {
|
||||
val statusBarPx = with(density) {
|
||||
(statusBarPadding.calculateTopPadding() + statusBarPadding.calculateBottomPadding()).toPx()
|
||||
}
|
||||
|
||||
val navBarPx = with(density) {
|
||||
(navigationBarPadding.calculateTopPadding() + navigationBarPadding.calculateBottomPadding()).toPx()
|
||||
}
|
||||
|
||||
insetsViewModel.updateInsets(
|
||||
InsetsViewModel.Insets(
|
||||
statusBar = statusBarPx,
|
||||
navBar = navBarPx
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -575,13 +575,12 @@ object RemoteConfig {
|
||||
/** Whether or not the user is an 'internal' one, which activates certain developer tools. */
|
||||
@JvmStatic
|
||||
@get:JvmName("internalUser")
|
||||
val internalUser: Boolean = true
|
||||
// val internalUser: Boolean by remoteValue(
|
||||
// key = "android.internalUser",
|
||||
// hotSwappable = true
|
||||
// ) { value ->
|
||||
// value.asBoolean(false) || Environment.IS_NIGHTLY || Environment.IS_STAGING
|
||||
// }
|
||||
val internalUser: Boolean by remoteValue(
|
||||
key = "android.internalUser",
|
||||
hotSwappable = true
|
||||
) { value ->
|
||||
value.asBoolean(false) || Environment.IS_NIGHTLY || Environment.IS_STAGING
|
||||
}
|
||||
|
||||
/** The raw client expiration JSON string. */
|
||||
@JvmStatic
|
||||
@@ -1132,11 +1131,11 @@ object RemoteConfig {
|
||||
)
|
||||
|
||||
/** Whether to allow different WindowSizeClasses to be used to determine screen layout */
|
||||
val largeScreenUi: Boolean = true /*by remoteBoolean(
|
||||
val largeScreenUi: Boolean by remoteBoolean(
|
||||
key = "android.largeScreenUI",
|
||||
hotSwappable = false,
|
||||
defaultValue = false
|
||||
)*/
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("useMessageSendRestFallback")
|
||||
|
||||
Reference in New Issue
Block a user