Add some debug tools about ReleaseNotesActivity.

- reset the show status
- display this Activity
This commit is contained in:
Benoit Marty 2022-09-06 15:50:48 +02:00
parent 16fad63e49
commit f54979ce13
5 changed files with 54 additions and 3 deletions

View File

@ -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<FragmentDebugPrivateSettingsBinding>() {
@ -35,7 +38,6 @@ class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSett
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setViewListeners()
}
@ -46,6 +48,12 @@ class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSett
views.forceLoginFallback.setOnCheckedChangeListener { _, isChecked ->
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<FragmentDebugPrivateSett
viewModel.handle(DebugPrivateSettingsViewActions.SetAvatarCapabilityOverride(option))
}
views.forceLoginFallback.isChecked = it.forceLoginFallback
@SuppressLint("SetTextI18n")
views.releaseNotesActivityHasBeenDisplayed.text = "ReleaseNotesActivity has been displayed: ${it.releaseNotesActivityHasBeenDisplayed}"
}
}

View File

@ -23,4 +23,5 @@ sealed interface DebugPrivateSettingsViewActions : VectorViewModelAction {
data class SetForceLoginFallbackEnabled(val force: Boolean) : DebugPrivateSettingsViewActions
data class SetDisplayNameCapabilityOverride(val option: BooleanHomeserverCapabilitiesOverride?) : DebugPrivateSettingsViewActions
data class SetAvatarCapabilityOverride(val option: BooleanHomeserverCapabilitiesOverride?) : DebugPrivateSettingsViewActions
object ResetReleaseNotesActivityHasBeenDisplayed : DebugPrivateSettingsViewActions
}

View File

@ -27,11 +27,13 @@ import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.debug.features.DebugVectorOverrides
import im.vector.app.features.debug.settings.DebugPrivateSettingsViewActions.SetAvatarCapabilityOverride
import im.vector.app.features.debug.settings.DebugPrivateSettingsViewActions.SetDisplayNameCapabilityOverride
import im.vector.app.features.home.room.list.home.release.ReleaseNotesPreferencesStore
import kotlinx.coroutines.launch
class DebugPrivateSettingsViewModel @AssistedInject constructor(
@Assisted initialState: DebugPrivateSettingsViewState,
private val debugVectorOverrides: DebugVectorOverrides
private val debugVectorOverrides: DebugVectorOverrides,
private val releaseNotesPreferencesStore: ReleaseNotesPreferencesStore,
) : VectorViewModel<DebugPrivateSettingsViewState, DebugPrivateSettingsViewActions, EmptyViewEvents>(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)
}
}

View File

@ -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(

View File

@ -49,6 +49,27 @@
android:layout_marginEnd="16dp"
android:layout_marginBottom="4dp" />
<TextView
android:id="@+id/releaseNotesActivityHasBeenDisplayed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
tools:text="ReleaseNotesActivity has been displayed: " />
<Button
android:id="@+id/releaseNotesActivityHasBeenDisplayedReset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="Reset" />
<Button
android:id="@+id/showReleaseNotesActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SHOW ReleaseNotesActivity"
android:textAllCaps="false" />
</LinearLayout>
</ScrollView>