From a7460c6e7905a426dbdd2a71c133f970ecfad83e Mon Sep 17 00:00:00 2001 From: Taras Smakula <tarassmakula@gmail.com> Date: Wed, 14 Jun 2023 19:00:01 +0300 Subject: [PATCH] Make navigation to setup circles optional --- app/src/main/java/org/futo/circles/App.kt | 3 --- .../feature/log_in/stages/LogInStagesFragment.kt | 12 +++++++++--- .../sign_up/setup_profile/SetupProfileFragment.kt | 14 ++++++++++---- auth/src/main/res/navigation/nav_graph_auth.xml | 5 +++++ .../java/org/futo/circles/core/CirclesAppConfig.kt | 10 +++++++++- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/futo/circles/App.kt b/app/src/main/java/org/futo/circles/App.kt index f427cf6af..3bad960c7 100644 --- a/app/src/main/java/org/futo/circles/App.kt +++ b/app/src/main/java/org/futo/circles/App.kt @@ -44,9 +44,6 @@ class App : Application() { .appName(getString(R.string.app_name)) .euDomain(getString(if (BuildConfig.DEBUG) R.string.debug_eu_domain else R.string.release_eu_domain)) .usDomain(getString(if (BuildConfig.DEBUG) R.string.debug_us_domain else R.string.release_us_domain)) - .isSubscriptionEnabled(false) - .isMediaBackupEnabled(false) - .isRageshakeEnabled(false) .init() MatrixSessionProvider.initSession( diff --git a/auth/src/main/java/org/futo/circles/auth/feature/log_in/stages/LogInStagesFragment.kt b/auth/src/main/java/org/futo/circles/auth/feature/log_in/stages/LogInStagesFragment.kt index cf49514dd..cc01debb8 100644 --- a/auth/src/main/java/org/futo/circles/auth/feature/log_in/stages/LogInStagesFragment.kt +++ b/auth/src/main/java/org/futo/circles/auth/feature/log_in/stages/LogInStagesFragment.kt @@ -17,6 +17,7 @@ import org.futo.circles.auth.base.LoginStageNavigationEvent import org.futo.circles.auth.databinding.FragmentLoginStagesBinding import org.futo.circles.auth.feature.log_in.EnterPassPhraseDialog import org.futo.circles.auth.feature.log_in.EnterPassPhraseDialogListener +import org.futo.circles.core.CirclesAppConfig import org.futo.circles.core.extensions.observeData import org.futo.circles.core.extensions.observeResponse import org.futo.circles.core.extensions.onBackPressed @@ -83,7 +84,7 @@ class LogInStagesFragment : Fragment(R.layout.fragment_login_stages), viewModel.loginNavigationLiveData.observeData(this) { event -> when (event) { LoginNavigationEvent.Main -> navigateToBottomMenuFragment() - LoginNavigationEvent.SetupCircles -> navigateToSetupCircles() + LoginNavigationEvent.SetupCircles -> navigateToSetupCirclesOrHome() LoginNavigationEvent.PassPhrase -> showPassPhraseDialog() else -> navigateToBottomMenuFragment() } @@ -121,8 +122,13 @@ class LogInStagesFragment : Fragment(R.layout.fragment_login_stages), findNavController().navigate(LogInStagesFragmentDirections.toHomeFragment()) } - private fun navigateToSetupCircles() { - findNavController().navigate(LogInStagesFragmentDirections.toSetupCirclesFragment()) + private fun navigateToSetupCirclesOrHome() { + findNavController().navigate( + if (CirclesAppConfig.isSetupCirclesEnabled) + LogInStagesFragmentDirections.toSetupCirclesFragment() + else + LogInStagesFragmentDirections.toHomeFragment() + ) } private fun showDiscardDialog() { diff --git a/auth/src/main/java/org/futo/circles/auth/feature/sign_up/setup_profile/SetupProfileFragment.kt b/auth/src/main/java/org/futo/circles/auth/feature/sign_up/setup_profile/SetupProfileFragment.kt index b2f63bfe5..561017875 100644 --- a/auth/src/main/java/org/futo/circles/auth/feature/sign_up/setup_profile/SetupProfileFragment.kt +++ b/auth/src/main/java/org/futo/circles/auth/feature/sign_up/setup_profile/SetupProfileFragment.kt @@ -10,6 +10,7 @@ import by.kirich1409.viewbindingdelegate.viewBinding import dagger.hilt.android.AndroidEntryPoint import org.futo.circles.auth.R import org.futo.circles.auth.databinding.FragmentSetupProfileBinding +import org.futo.circles.core.CirclesAppConfig import org.futo.circles.core.extensions.getText import org.futo.circles.core.extensions.observeData import org.futo.circles.core.extensions.observeResponse @@ -33,7 +34,7 @@ class SetupProfileFragment : Fragment(R.layout.fragment_setup_profile), HasLoadi private fun setupViews() { with(binding) { - btnSkip.setOnClickListener { navigateToSetupCircles() } + btnSkip.setOnClickListener { navigateToSetupCirclesOrHome() } btnSave.setOnClickListener { startLoading(btnSave) viewModel.saveProfileInfo(tilDisplayName.getText()) @@ -60,12 +61,17 @@ class SetupProfileFragment : Fragment(R.layout.fragment_setup_profile), HasLoadi } viewModel.saveProfileResponseLiveData.observeResponse( this, - success = { navigateToSetupCircles() } + success = { navigateToSetupCirclesOrHome() } ) } - private fun navigateToSetupCircles() { - findNavController().navigate(SetupProfileFragmentDirections.toSetupCirclesFragment()) + private fun navigateToSetupCirclesOrHome() { + findNavController().navigate( + if (CirclesAppConfig.isSetupCirclesEnabled) + SetupProfileFragmentDirections.toSetupCirclesFragment() + else + SetupProfileFragmentDirections.toHomeFragment() + ) } private fun setSaveButtonEnabled() { diff --git a/auth/src/main/res/navigation/nav_graph_auth.xml b/auth/src/main/res/navigation/nav_graph_auth.xml index 955505324..f3ca8a361 100644 --- a/auth/src/main/res/navigation/nav_graph_auth.xml +++ b/auth/src/main/res/navigation/nav_graph_auth.xml @@ -59,5 +59,10 @@ app:destination="@id/setupCirclesFragment" app:popUpTo="@id/setupProfileFragment" app:popUpToInclusive="true" /> + <action + android:id="@+id/to_homeFragment" + app:destination="@id/homeFragment" + app:popUpTo="@id/setupProfileFragment" + app:popUpToInclusive="true" /> </fragment> </navigation> diff --git a/core/src/main/java/org/futo/circles/core/CirclesAppConfig.kt b/core/src/main/java/org/futo/circles/core/CirclesAppConfig.kt index bf1374912..9e3cc66bc 100644 --- a/core/src/main/java/org/futo/circles/core/CirclesAppConfig.kt +++ b/core/src/main/java/org/futo/circles/core/CirclesAppConfig.kt @@ -28,6 +28,9 @@ object CirclesAppConfig { var isRageshakeEnabled = false private set + var isSetupCirclesEnabled = true + private set + data class Initializer( private var appId: String? = null, private var version: String? = null, @@ -37,7 +40,8 @@ object CirclesAppConfig { private var euDomain: String? = null, private var subscriptionEnabled: Boolean = false, private var mediaBackupEnabled: Boolean = false, - private var rageshakeEnabled: Boolean = false + private var rageshakeEnabled: Boolean = false, + private var setupCirclesEnabled: Boolean = true ) { fun buildConfigInfo(appId: String, version: String, flavour: String = "empty") = @@ -60,6 +64,9 @@ object CirclesAppConfig { fun isRageshakeEnabled(isEnabled: Boolean) = apply { this.rageshakeEnabled = isEnabled } + fun isSetupCirclesEnabled(isEnabled: Boolean) = + apply { this.setupCirclesEnabled = isEnabled } + fun init() { CirclesAppConfig.appId = appId?.takeIf { it.isNotEmpty() } ?: throw IllegalArgumentException("Illegal appId $appId") @@ -82,6 +89,7 @@ object CirclesAppConfig { isSubscriptionsEnabled = subscriptionEnabled isMediaBackupEnabled = mediaBackupEnabled isRageshakeEnabled = rageshakeEnabled + isSetupCirclesEnabled = setupCirclesEnabled } } -- GitLab