review fixes

This commit is contained in:
NIkita Fedrunov 2022-09-05 15:56:42 +02:00
parent f8ec268145
commit 74fd14af8f
5 changed files with 29 additions and 14 deletions

View File

@ -3227,8 +3227,10 @@
<string name="device_manager_other_sessions_description_unverified">Unverified · Last activity %1$s</string> <string name="device_manager_other_sessions_description_unverified">Unverified · Last activity %1$s</string>
<string name="onboarding_new_app_layout_welcome_title">Welcome to a new view!</string> <string name="onboarding_new_app_layout_welcome_title">Welcome to a new view!</string>
<string name="onboarding_new_app_layout_welcome_message">To simplify your Element, tabs are now optional. Manage them using the top-right menu.</string> <!-- Note to translators: for RTL languages, Spaces will be at the bottom left. Please translate "bottom-left" instead of "bottom-right". Thanks!-->
<string name="onboarding_new_app_layout_welcome_message">To simplify your ${app_name}, tabs are now optional. Manage them using the top-right menu.</string>
<string name="onboarding_new_app_layout_spaces_title">Access Spaces</string> <string name="onboarding_new_app_layout_spaces_title">Access Spaces</string>
<!-- Note to translators: for RTL languages, Spaces will be at the bottom left. Please translate "bottom-left" instead of "bottom-right". Thanks!-->
<string name="onboarding_new_app_layout_spaces_message">Access your Spaces (bottom-right) faster and easier than ever before.</string> <string name="onboarding_new_app_layout_spaces_message">Access your Spaces (bottom-right) faster and easier than ever before.</string>
<string name="onboarding_new_app_layout_feedback_title">Give Feedback</string> <string name="onboarding_new_app_layout_feedback_title">Give Feedback</string>
<string name="onboarding_new_app_layout_feedback_message">Tap top right to see the option to feedback.</string> <string name="onboarding_new_app_layout_feedback_message">Tap top right to see the option to feedback.</string>

View File

@ -83,7 +83,7 @@ class HomeActivityViewModel @AssistedInject constructor(
private val vectorPreferences: VectorPreferences, private val vectorPreferences: VectorPreferences,
private val analyticsTracker: AnalyticsTracker, private val analyticsTracker: AnalyticsTracker,
private val analyticsConfig: AnalyticsConfig, private val analyticsConfig: AnalyticsConfig,
private val releaseNotesPreferencesStore: ReleaseNotesPreferencesStore private val releaseNotesPreferencesStore: ReleaseNotesPreferencesStore,
) : VectorViewModel<HomeActivityViewState, HomeActivityViewActions, HomeActivityViewEvents>(initialState) { ) : VectorViewModel<HomeActivityViewState, HomeActivityViewActions, HomeActivityViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
@ -116,13 +116,15 @@ class HomeActivityViewModel @AssistedInject constructor(
initThreadsMigration() initThreadsMigration()
} }
private fun observeReleaseNotes() { private fun observeReleaseNotes() = withState { state ->
releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown -> if (state.authenticationDescription == null) {
if (!isAppLayoutOnboardingShown) { releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown ->
_viewEvents.post(HomeActivityViewEvents.ShowReleaseNotes) if (!isAppLayoutOnboardingShown) {
releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true) _viewEvents.post(HomeActivityViewEvents.ShowReleaseNotes)
} releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true)
}.launchIn(viewModelScope) }
}.launchIn(viewModelScope)
}
} }
private fun observeAnalytics() { private fun observeAnalytics() {

View File

@ -20,6 +20,8 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.fragmentViewModel
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
@ -51,11 +53,21 @@ class ReleaseNotesFragment : VectorBaseFragment<BottomSheetReleaseNotesBinding>(
tabLayoutMediator = TabLayoutMediator(views.releaseNotesCarouselIndicator, views.releaseNotesCarousel) { _, _ -> } tabLayoutMediator = TabLayoutMediator(views.releaseNotesCarouselIndicator, views.releaseNotesCarousel) { _, _ -> }
.also { it.attach() } .also { it.attach() }
views.releaseNotesCarousel.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { val pageCallback = object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) { override fun onPageSelected(position: Int) {
viewModel.handle(ReleaseNotesAction.PageSelected(position)) viewModel.handle(ReleaseNotesAction.PageSelected(position))
updateButtonText(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()) carouselController.setData(createCarouselData())
@ -99,7 +111,7 @@ class ReleaseNotesFragment : VectorBaseFragment<BottomSheetReleaseNotesBinding>(
} }
private fun close() { private fun close() {
requireActivity().onBackPressed() requireActivity().finish()
} }
private fun selectPage(index: Int) { private fun selectPage(index: Int) {

View File

@ -40,7 +40,7 @@ class ReleaseNotesViewModel @AssistedInject constructor(
private var selectedPageIndex = 0 private var selectedPageIndex = 0
init { init {
_viewEvents.post(ReleaseNotesViewEvents.SelectPage(selectedPageIndex)) _viewEvents.post(ReleaseNotesViewEvents.SelectPage(0))
} }
override fun handle(action: ReleaseNotesAction) { override fun handle(action: ReleaseNotesAction) {

View File

@ -5,8 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="?colorSurface" android:background="?colorSurface">
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/release_notes_btn_close" android:id="@+id/release_notes_btn_close"