@@ -23,7 +23,6 @@ import android.content.Intent
2323import android.os.Build
2424import android.os.Bundle
2525import android.view.WindowManager
26- import android.widget.Toast
2726import androidx.activity.compose.setContent
2827import androidx.activity.enableEdgeToEdge
2928import androidx.activity.viewModels
@@ -49,6 +48,7 @@ import androidx.compose.ui.platform.LocalContext
4948import androidx.compose.ui.platform.LocalSoftwareKeyboardController
5049import androidx.compose.ui.semantics.semantics
5150import androidx.compose.ui.semantics.testTagsAsResourceId
51+ import androidx.core.content.ContextCompat.startActivity
5252import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
5353import androidx.lifecycle.Lifecycle
5454import androidx.lifecycle.flowWithLifecycle
@@ -59,7 +59,6 @@ import com.ramcosta.composedestinations.spec.Route
5959import com.ramcosta.composedestinations.utils.destination
6060import com.ramcosta.composedestinations.utils.route
6161import com.wire.android.BuildConfig
62- import com.wire.android.R
6362import com.wire.android.appLogger
6463import com.wire.android.config.CustomUiConfigurationProvider
6564import com.wire.android.config.LocalCustomUiConfigurationProvider
@@ -76,7 +75,6 @@ import com.wire.android.navigation.startDestination
7675import com.wire.android.navigation.style.BackgroundStyle
7776import com.wire.android.navigation.style.BackgroundType
7877import com.wire.android.ui.authentication.login.LoginPasswordPath
79- import com.wire.android.ui.authentication.login.PreFilledUserIdentifierType
8078import com.wire.android.ui.authentication.login.WireAuthBackgroundLayout
8179import com.wire.android.ui.calling.getIncomingCallIntent
8280import com.wire.android.ui.calling.getOutgoingCallIntent
@@ -88,16 +86,13 @@ import com.wire.android.ui.common.topappbar.CommonTopAppBar
8886import com.wire.android.ui.common.topappbar.CommonTopAppBarState
8987import com.wire.android.ui.common.topappbar.CommonTopAppBarViewModel
9088import com.wire.android.ui.common.visbility.rememberVisibilityState
91- import com.wire.android.ui.destinations.ConversationScreenDestination
9289import com.wire.android.ui.destinations.E2EIEnrollmentScreenDestination
9390import com.wire.android.ui.destinations.E2eiCertificateDetailsScreenDestination
9491import com.wire.android.ui.destinations.HomeScreenDestination
95- import com.wire.android.ui.destinations.ImportMediaScreenDestination
9692import com.wire.android.ui.destinations.LoginScreenDestination
9793import com.wire.android.ui.destinations.MigrationScreenDestination
9894import com.wire.android.ui.destinations.NewLoginScreenDestination
9995import com.wire.android.ui.destinations.NewWelcomeEmptyStartScreenDestination
100- import com.wire.android.ui.destinations.OtherUserProfileScreenDestination
10196import com.wire.android.ui.destinations.SelfDevicesScreenDestination
10297import com.wire.android.ui.destinations.SelfUserProfileScreenDestination
10398import com.wire.android.ui.destinations.WelcomeScreenDestination
@@ -290,6 +285,7 @@ class WireActivity : AppCompatActivity() {
290285 SetUpNavigation (navigator)
291286 HandleScreenshotCensoring ()
292287 HandleDialogs (navigator)
288+ HandleViewActions (viewModel.actions, navigator, loginTypeSelector)
293289 }
294290 }
295291 }
@@ -713,104 +709,7 @@ class WireActivity : AppCompatActivity() {
713709 }
714710 return
715711 } else {
716- viewModel.handleDeepLink(
717- intent = intent,
718- onOpenConversation = {
719- if (it.switchedAccount) {
720- navigate(
721- NavigationCommand (
722- HomeScreenDestination ,
723- BackStackMode .CLEAR_WHOLE
724- )
725- )
726- }
727- navigate(
728- NavigationCommand (
729- ConversationScreenDestination (it.conversationId),
730- BackStackMode .UPDATE_EXISTED
731- )
732- )
733- },
734- onIsSharingIntent = {
735- navigate(
736- NavigationCommand (
737- ImportMediaScreenDestination ,
738- BackStackMode .UPDATE_EXISTED
739- )
740- )
741- },
742- onCannotLoginDuringACall = {
743- runOnUiThread {
744- Toast .makeText(
745- this ,
746- resources.getString(R .string.cant_switch_account_in_call),
747- Toast .LENGTH_SHORT
748- ).show()
749- }
750- },
751- onAuthorizationNeeded = {
752- if (navigator.isEmptyWelcomeStartDestination()) {
753- // log in needed so if "welcome empty start" screen then switch "start" screen to login by navigating to it
754- navigate(NavigationCommand (NewLoginScreenDestination (), BackStackMode .CLEAR_WHOLE ))
755- }
756- runOnUiThread {
757- Toast .makeText(
758- this ,
759- resources.getString(R .string.deeplink_authorization_needed),
760- Toast .LENGTH_SHORT
761- ).show()
762- }
763- },
764- onUnknown = {
765- if (navigator.isEmptyWelcomeStartDestination()) {
766- // log in needed so if "welcome empty start" screen then switch "start" screen to login by navigating to it
767- navigate(NavigationCommand (NewLoginScreenDestination (), BackStackMode .CLEAR_WHOLE ))
768- }
769- },
770- onMigrationLogin = {
771- navigate(
772- NavigationCommand (
773- when (loginTypeSelector.canUseNewLogin()) {
774- true -> NewLoginScreenDestination (userHandle = PreFilledUserIdentifierType .PreFilled (it.userHandle))
775- false -> LoginScreenDestination (userHandle = PreFilledUserIdentifierType .PreFilled (it.userHandle))
776- },
777- // if "welcome empty start" screen then switch "start" screen to proper one
778- when (navigator.shouldReplaceWelcomeLoginStartDestination()) {
779- true -> BackStackMode .CLEAR_WHOLE
780- false -> BackStackMode .UPDATE_EXISTED
781- },
782- )
783- )
784- },
785- onOpenOtherUserProfile = {
786- if (it.switchedAccount) {
787- navigate(
788- NavigationCommand (
789- HomeScreenDestination ,
790- BackStackMode .CLEAR_WHOLE
791- )
792- )
793- }
794- navigate(
795- NavigationCommand (
796- OtherUserProfileScreenDestination (it.userId),
797- BackStackMode .UPDATE_EXISTED
798- )
799- )
800- },
801- onSSOLogin = {
802- navigate(
803- NavigationCommand (
804- when (navigator.navController.currentBackStackEntry?.destination()?.route?.getBaseRoute()) {
805- // if SSO login started from new login screen then go back to the new login flow
806- NewLoginScreenDestination .route.getBaseRoute() -> NewLoginScreenDestination (ssoLoginResult = it)
807- else -> LoginScreenDestination (ssoLoginResult = it)
808- },
809- BackStackMode .UPDATE_EXISTED ,
810- )
811- )
812- }
813- )
712+ viewModel.handleDeepLink(intent)
814713 intent.putExtra(HANDLED_DEEPLINK_FLAG , true )
815714 }
816715 }
@@ -824,26 +723,26 @@ class WireActivity : AppCompatActivity() {
824723 }
825724 }
826725
827- private fun Navigator.shouldReplaceWelcomeLoginStartDestination (): Boolean {
828- val firstDestinationBaseRoute = navController.startDestination()?.route()?.route?.getBaseRoute()
829- val welcomeScreens = listOf (WelcomeScreenDestination , NewWelcomeEmptyStartScreenDestination )
830- val loginScreens = listOf (LoginScreenDestination , NewLoginScreenDestination )
831- val welcomeAndLoginBaseRoutes = (welcomeScreens + loginScreens).map { it.route.getBaseRoute() }
832- return welcomeAndLoginBaseRoutes.contains(firstDestinationBaseRoute)
833- }
834-
835- private fun Navigator.isEmptyWelcomeStartDestination (): Boolean {
836- val firstDestinationBaseRoute = navController.startDestination()?.route()?.route?.getBaseRoute()
837- return firstDestinationBaseRoute == NewWelcomeEmptyStartScreenDestination .route.getBaseRoute()
838- }
839-
840726 companion object {
841727 private const val HANDLED_DEEPLINK_FLAG = " deeplink_handled_flag_key"
842728 private const val ORIGINAL_SAVED_INTENT_FLAG = " original_saved_intent"
843729 private const val TAG = " WireActivity"
844730 }
845731}
846732
733+ internal fun Navigator.shouldReplaceWelcomeLoginStartDestination (): Boolean {
734+ val firstDestinationBaseRoute = navController.startDestination()?.route()?.route?.getBaseRoute()
735+ val welcomeScreens = listOf (WelcomeScreenDestination , NewWelcomeEmptyStartScreenDestination )
736+ val loginScreens = listOf (LoginScreenDestination , NewLoginScreenDestination )
737+ val welcomeAndLoginBaseRoutes = (welcomeScreens + loginScreens).map { it.route.getBaseRoute() }
738+ return welcomeAndLoginBaseRoutes.contains(firstDestinationBaseRoute)
739+ }
740+
741+ internal fun Navigator.isEmptyWelcomeStartDestination (): Boolean {
742+ val firstDestinationBaseRoute = navController.startDestination()?.route()?.route?.getBaseRoute()
743+ return firstDestinationBaseRoute == NewWelcomeEmptyStartScreenDestination .route.getBaseRoute()
744+ }
745+
847746val LocalActivity = staticCompositionLocalOf<Activity > {
848747 error(" No Activity provided" )
849748}
0 commit comments