Skip to content

Commit

Permalink
refactor: adjust to edge-to-edge, remove deprecated APIs [WPB-14903] (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
saleniuk authored Jan 9, 2025
1 parent f45ed9e commit b711329
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package com.wire.android.navigation
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
import com.ramcosta.composedestinations.DestinationsNavHost
Expand All @@ -44,6 +45,7 @@ import com.wire.android.ui.home.newconversation.NewConversationViewModel
fun MainNavHost(
navigator: Navigator,
startDestination: Route,
modifier: Modifier = Modifier,
) {
val navHostEngine = rememberAnimatedNavHostEngine(
rootDefaultAnimations = DefaultRootNavGraphAnimations,
Expand All @@ -55,6 +57,7 @@ fun MainNavHost(
)

DestinationsNavHost(
modifier = modifier,
navGraph = WireMainNavGraph,
engine = navHostEngine,
startRoute = startDestination,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/kotlin/com/wire/android/ui/AppLockActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package com.wire.android.ui

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.biometric.BiometricManager
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.core.view.WindowCompat
import com.wire.android.appLogger
import com.wire.android.navigation.MainNavHost
import com.wire.android.navigation.rememberNavigator
Expand All @@ -39,7 +39,7 @@ import dagger.hilt.android.AndroidEntryPoint
class AppLockActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
enableEdgeToEdge()
setContent {
val snackbarHostState = remember { SnackbarHostState() }
CompositionLocalProvider(
Expand Down
19 changes: 10 additions & 9 deletions app/src/main/kotlin/com/wire/android/ui/WireActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ import android.os.Bundle
import android.view.WindowManager
import android.widget.Toast
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.statusBars
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
Expand All @@ -47,7 +50,6 @@ import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -163,7 +165,7 @@ class WireActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
splashScreen.setKeepOnScreenCondition { shouldKeepSplashOpen }

WindowCompat.setDecorFitsSystemWindows(window, false)
enableEdgeToEdge()

lifecycleScope.launch {

Expand Down Expand Up @@ -232,18 +234,17 @@ class WireActivity : AppCompatActivity() {
WireTheme {
Column(
modifier = Modifier
.statusBarsPadding()
.semantics { testTagsAsResourceId = true }
) {
val navigator = rememberNavigator(this@WireActivity::finish)
WireTopAppBar(
themeOption = viewModel.globalAppState.themeOption,
commonTopAppBarState = commonTopAppBarViewModel.state,
)
CompositionLocalProvider(LocalNavigator provides navigator) {
MainNavHost(
navigator = navigator,
startDestination = startDestination
startDestination = startDestination,
modifier = Modifier.consumeWindowInsets(WindowInsets.statusBars)
)
}

Expand All @@ -260,11 +261,11 @@ class WireActivity : AppCompatActivity() {

@Composable
private fun WireTopAppBar(
themeOption: ThemeOption,
commonTopAppBarState: CommonTopAppBarState
commonTopAppBarState: CommonTopAppBarState,
modifier: Modifier = Modifier,
) {
CommonTopAppBar(
themeOption = themeOption,
modifier = modifier,
commonTopAppBarState = commonTopAppBarState,
onReturnToCallClick = { establishedCall ->
getOngoingCallIntent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.togetherWith
import androidx.compose.material3.SnackbarHostState
Expand All @@ -33,7 +34,6 @@ import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.core.view.WindowCompat
import com.wire.android.appLogger
import com.wire.android.navigation.style.TransitionAnimationType
import com.wire.android.ui.LocalActivity
Expand Down Expand Up @@ -87,7 +87,7 @@ class StartingCallActivity : CallActivity() {
setUpScreenshotPreventionFlag()
setUpCallingFlags()

WindowCompat.setDecorFitsSystemWindows(window, false)
enableEdgeToEdge()

handleNewIntent(intent)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.graphics.drawable.Icon
import android.os.Bundle
import android.util.Rational
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.togetherWith
import androidx.compose.material3.SnackbarHostState
Expand All @@ -38,7 +39,6 @@ import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.core.view.WindowCompat
import com.wire.android.R
import com.wire.android.appLogger
import com.wire.android.navigation.style.TransitionAnimationType
Expand Down Expand Up @@ -90,7 +90,7 @@ class OngoingCallActivity : CallActivity() {
setUpScreenshotPreventionFlag()
setUpCallingFlags()

WindowCompat.setDecorFitsSystemWindows(window, false)
enableEdgeToEdge()

handleNewIntent(intent)

Expand Down
Loading

0 comments on commit b711329

Please sign in to comment.