From 16fad63e49eb408a4ccf066341e5b9cd5745fc66 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 6 Sep 2022 15:15:59 +0200 Subject: [PATCH 1/2] Better to call setAppLayoutOnboardingShown when we are sure the Activity has been run. --- .../vector/app/features/home/HomeActivityViewModel.kt | 1 - .../room/list/home/release/ReleaseNotesActivity.kt | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt index dd54285fb5..123ad2d83e 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt @@ -123,7 +123,6 @@ class HomeActivityViewModel @AssistedInject constructor( if (state.authenticationDescription == null && vectorFeatures.isNewAppLayoutEnabled()) { releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown -> if (!isAppLayoutOnboardingShown) { - releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true) _viewEvents.post(HomeActivityViewEvents.ShowReleaseNotes) } }.launchIn(viewModelScope) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesActivity.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesActivity.kt index c5cc55d7bb..4d8cfc9f23 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesActivity.kt @@ -16,17 +16,20 @@ package im.vector.app.features.home.room.list.home.release +import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.ScreenOrientationLocker import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivitySimpleBinding +import kotlinx.coroutines.launch import javax.inject.Inject @AndroidEntryPoint class ReleaseNotesActivity : VectorBaseActivity() { @Inject lateinit var orientationLocker: ScreenOrientationLocker + @Inject lateinit var releaseNotesPreferencesStore: ReleaseNotesPreferencesStore override fun getBinding() = ActivitySimpleBinding.inflate(layoutInflater) @@ -38,4 +41,11 @@ class ReleaseNotesActivity : VectorBaseActivity() { addFragment(views.simpleFragmentContainer, ReleaseNotesFragment::class.java) } } + + override fun onResume() { + super.onResume() + lifecycleScope.launch { + releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true) + } + } } From f54979ce131195c2ae81a79a4531c0a3c9a7f05f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 6 Sep 2022 15:50:48 +0200 Subject: [PATCH 2/2] Add some debug tools about ReleaseNotesActivity. - reset the show status - display this Activity --- .../settings/DebugPrivateSettingsFragment.kt | 12 ++++++++++- .../DebugPrivateSettingsViewActions.kt | 1 + .../settings/DebugPrivateSettingsViewModel.kt | 20 +++++++++++++++++- .../settings/DebugPrivateSettingsViewState.kt | 3 ++- .../fragment_debug_private_settings.xml | 21 +++++++++++++++++++ 5 files changed, 54 insertions(+), 3 deletions(-) diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt index 38253fe7c2..be3d41e0e1 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt @@ -16,6 +16,8 @@ package im.vector.app.features.debug.settings +import android.annotation.SuppressLint +import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -24,6 +26,7 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentDebugPrivateSettingsBinding +import im.vector.app.features.home.room.list.home.release.ReleaseNotesActivity class DebugPrivateSettingsFragment : VectorBaseFragment() { @@ -35,7 +38,6 @@ class DebugPrivateSettingsFragment : VectorBaseFragment viewModel.handle(DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled(isChecked)) } + views.releaseNotesActivityHasBeenDisplayedReset.setOnClickListener { + viewModel.handle(DebugPrivateSettingsViewActions.ResetReleaseNotesActivityHasBeenDisplayed) + } + views.showReleaseNotesActivity.setOnClickListener { + startActivity(Intent(requireActivity(), ReleaseNotesActivity::class.java)) + } } override fun invalidate() = withState(viewModel) { @@ -57,5 +65,7 @@ class DebugPrivateSettingsFragment : VectorBaseFragment(initialState) { @AssistedFactory @@ -43,6 +45,15 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor( init { observeVectorOverrides() + observeReleaseNotesPreferencesStore() + } + + private fun observeReleaseNotesPreferencesStore() { + releaseNotesPreferencesStore.appLayoutOnboardingShown.setOnEach { + copy( + releaseNotesActivityHasBeenDisplayed = it + ) + } } private fun observeVectorOverrides() { @@ -72,6 +83,13 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor( is DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled -> handleSetForceLoginFallbackEnabled(action) is SetDisplayNameCapabilityOverride -> handleSetDisplayNameCapabilityOverride(action) is SetAvatarCapabilityOverride -> handleSetAvatarCapabilityOverride(action) + DebugPrivateSettingsViewActions.ResetReleaseNotesActivityHasBeenDisplayed -> handleResetReleaseNotesActivityHasBeenDisplayed() + } + } + + private fun handleResetReleaseNotesActivityHasBeenDisplayed() { + viewModelScope.launch { + releaseNotesPreferencesStore.setAppLayoutOnboardingShown(false) } } diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt index 749b11a744..a390c94942 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt @@ -22,7 +22,8 @@ import im.vector.app.features.debug.settings.OverrideDropdownView.OverrideDropdo data class DebugPrivateSettingsViewState( val dialPadVisible: Boolean = false, val forceLoginFallback: Boolean = false, - val homeserverCapabilityOverrides: HomeserverCapabilityOverrides = HomeserverCapabilityOverrides() + val homeserverCapabilityOverrides: HomeserverCapabilityOverrides = HomeserverCapabilityOverrides(), + val releaseNotesActivityHasBeenDisplayed: Boolean = false, ) : MavericksState data class HomeserverCapabilityOverrides( diff --git a/vector/src/debug/res/layout/fragment_debug_private_settings.xml b/vector/src/debug/res/layout/fragment_debug_private_settings.xml index c42ad68dce..55824930bc 100644 --- a/vector/src/debug/res/layout/fragment_debug_private_settings.xml +++ b/vector/src/debug/res/layout/fragment_debug_private_settings.xml @@ -49,6 +49,27 @@ android:layout_marginEnd="16dp" android:layout_marginBottom="4dp" /> + + +