From 74fd14af8f346be02d9cc7127d4c0627ae2de242 Mon Sep 17 00:00:00 2001 From: NIkita Fedrunov Date: Mon, 5 Sep 2022 15:56:42 +0200 Subject: [PATCH] review fixes --- .../ui-strings/src/main/res/values/strings.xml | 4 +++- .../app/features/home/HomeActivityViewModel.kt | 18 ++++++++++-------- .../list/home/release/ReleaseNotesFragment.kt | 16 ++++++++++++++-- .../list/home/release/ReleaseNotesViewModel.kt | 2 +- .../res/layout/bottom_sheet_release_notes.xml | 3 +-- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index fcace5066b..97c2595cfd 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3227,8 +3227,10 @@ Unverified ยท Last activity %1$s Welcome to a new view! - To simplify your Element, tabs are now optional. Manage them using the top-right menu. + + To simplify your ${app_name}, tabs are now optional. Manage them using the top-right menu. Access Spaces + Access your Spaces (bottom-right) faster and easier than ever before. Give Feedback Tap top right to see the option to feedback. 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 02648e77fc..ccd7e45bba 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 @@ -83,7 +83,7 @@ class HomeActivityViewModel @AssistedInject constructor( private val vectorPreferences: VectorPreferences, private val analyticsTracker: AnalyticsTracker, private val analyticsConfig: AnalyticsConfig, - private val releaseNotesPreferencesStore: ReleaseNotesPreferencesStore + private val releaseNotesPreferencesStore: ReleaseNotesPreferencesStore, ) : VectorViewModel(initialState) { @AssistedFactory @@ -116,13 +116,15 @@ class HomeActivityViewModel @AssistedInject constructor( initThreadsMigration() } - private fun observeReleaseNotes() { - releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown -> - if (!isAppLayoutOnboardingShown) { - _viewEvents.post(HomeActivityViewEvents.ShowReleaseNotes) - releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true) - } - }.launchIn(viewModelScope) + private fun observeReleaseNotes() = withState { state -> + if (state.authenticationDescription == null) { + releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown -> + if (!isAppLayoutOnboardingShown) { + _viewEvents.post(HomeActivityViewEvents.ShowReleaseNotes) + releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true) + } + }.launchIn(viewModelScope) + } } private fun observeAnalytics() { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesFragment.kt index 72cf875410..3fe4ea61ba 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesFragment.kt @@ -20,6 +20,8 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.LifecycleOwner import androidx.viewpager2.widget.ViewPager2 import com.airbnb.mvrx.fragmentViewModel import com.google.android.material.tabs.TabLayoutMediator @@ -51,11 +53,21 @@ class ReleaseNotesFragment : VectorBaseFragment( tabLayoutMediator = TabLayoutMediator(views.releaseNotesCarouselIndicator, views.releaseNotesCarousel) { _, _ -> } .also { it.attach() } - views.releaseNotesCarousel.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { + val pageCallback = object : ViewPager2.OnPageChangeCallback() { override fun onPageSelected(position: Int) { viewModel.handle(ReleaseNotesAction.PageSelected(position)) updateButtonText(position) } + } + + viewLifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver { + override fun onCreate(owner: LifecycleOwner) { + views.releaseNotesCarousel.registerOnPageChangeCallback(pageCallback) + } + + override fun onDestroy(owner: LifecycleOwner) { + views.releaseNotesCarousel.unregisterOnPageChangeCallback(pageCallback) + } }) carouselController.setData(createCarouselData()) @@ -99,7 +111,7 @@ class ReleaseNotesFragment : VectorBaseFragment( } private fun close() { - requireActivity().onBackPressed() + requireActivity().finish() } private fun selectPage(index: Int) { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesViewModel.kt index 7fa2d8659a..7402a2fcdb 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/release/ReleaseNotesViewModel.kt @@ -40,7 +40,7 @@ class ReleaseNotesViewModel @AssistedInject constructor( private var selectedPageIndex = 0 init { - _viewEvents.post(ReleaseNotesViewEvents.SelectPage(selectedPageIndex)) + _viewEvents.post(ReleaseNotesViewEvents.SelectPage(0)) } override fun handle(action: ReleaseNotesAction) { diff --git a/vector/src/main/res/layout/bottom_sheet_release_notes.xml b/vector/src/main/res/layout/bottom_sheet_release_notes.xml index 09d60e49cb..f967088ff6 100644 --- a/vector/src/main/res/layout/bottom_sheet_release_notes.xml +++ b/vector/src/main/res/layout/bottom_sheet_release_notes.xml @@ -5,8 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="bottom" - android:background="?colorSurface" - android:orientation="vertical"> + android:background="?colorSurface">