Merge pull request #7041 from vector-im/feature/bma/debug_release_note
Debug release note
This commit is contained in:
commit
c5d3eaffb9
|
@ -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}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<ActivitySimpleBinding>() {
|
||||
|
||||
@Inject lateinit var orientationLocker: ScreenOrientationLocker
|
||||
@Inject lateinit var releaseNotesPreferencesStore: ReleaseNotesPreferencesStore
|
||||
|
||||
override fun getBinding() = ActivitySimpleBinding.inflate(layoutInflater)
|
||||
|
||||
|
@ -38,4 +41,11 @@ class ReleaseNotesActivity : VectorBaseActivity<ActivitySimpleBinding>() {
|
|||
addFragment(views.simpleFragmentContainer, ReleaseNotesFragment::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
lifecycleScope.launch {
|
||||
releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue