Merge pull request #4537 from vector-im/feature/bma/more_cleanup
Feature/bma/more cleanup
This commit is contained in:
commit
ca34812f82
|
@ -0,0 +1 @@
|
||||||
|
Fix a crash when displaying the bootstrap bottom sheet
|
|
@ -5,6 +5,7 @@
|
||||||
<application>
|
<application>
|
||||||
<activity android:name=".features.debug.TestLinkifyActivity" />
|
<activity android:name=".features.debug.TestLinkifyActivity" />
|
||||||
<activity android:name=".features.debug.DebugPermissionActivity" />
|
<activity android:name=".features.debug.DebugPermissionActivity" />
|
||||||
|
<activity android:name=".features.debug.settings.DebugPrivateSettingsActivity" />
|
||||||
<activity android:name=".features.debug.sas.DebugSasEmojiActivity" />
|
<activity android:name=".features.debug.sas.DebugSasEmojiActivity" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ import im.vector.app.core.utils.registerForPermissionsResult
|
||||||
import im.vector.app.core.utils.toast
|
import im.vector.app.core.utils.toast
|
||||||
import im.vector.app.databinding.ActivityDebugMenuBinding
|
import im.vector.app.databinding.ActivityDebugMenuBinding
|
||||||
import im.vector.app.features.debug.sas.DebugSasEmojiActivity
|
import im.vector.app.features.debug.sas.DebugSasEmojiActivity
|
||||||
|
import im.vector.app.features.debug.settings.DebugPrivateSettingsActivity
|
||||||
import im.vector.app.features.qrcode.QrCodeScannerActivity
|
import im.vector.app.features.qrcode.QrCodeScannerActivity
|
||||||
import im.vector.lib.ui.styles.debug.DebugMaterialThemeDarkDefaultActivity
|
import im.vector.lib.ui.styles.debug.DebugMaterialThemeDarkDefaultActivity
|
||||||
import im.vector.lib.ui.styles.debug.DebugMaterialThemeDarkTestActivity
|
import im.vector.lib.ui.styles.debug.DebugMaterialThemeDarkTestActivity
|
||||||
|
@ -75,6 +76,7 @@ class DebugMenuActivity : VectorBaseActivity<ActivityDebugMenuBinding>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
|
views.debugPrivateSetting.setOnClickListener { openPrivateSettings() }
|
||||||
views.debugTestTextViewLink.setOnClickListener { testTextViewLink() }
|
views.debugTestTextViewLink.setOnClickListener { testTextViewLink() }
|
||||||
views.debugOpenButtonStylesLight.setOnClickListener {
|
views.debugOpenButtonStylesLight.setOnClickListener {
|
||||||
startActivity(Intent(this, DebugVectorButtonStylesLightActivity::class.java))
|
startActivity(Intent(this, DebugVectorButtonStylesLightActivity::class.java))
|
||||||
|
@ -115,6 +117,10 @@ class DebugMenuActivity : VectorBaseActivity<ActivityDebugMenuBinding>() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openPrivateSettings() {
|
||||||
|
startActivity(Intent(this, DebugPrivateSettingsActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
private fun renderQrCode(text: String) {
|
private fun renderQrCode(text: String) {
|
||||||
views.debugQrCode.setData(text)
|
views.debugQrCode.setData(text)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.features.debug.di
|
||||||
|
|
||||||
|
import dagger.Binds
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.hilt.InstallIn
|
||||||
|
import dagger.multibindings.IntoMap
|
||||||
|
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||||
|
import im.vector.app.core.di.MavericksViewModelComponent
|
||||||
|
import im.vector.app.core.di.MavericksViewModelKey
|
||||||
|
import im.vector.app.features.debug.settings.DebugPrivateSettingsViewModel
|
||||||
|
|
||||||
|
@InstallIn(MavericksViewModelComponent::class)
|
||||||
|
@Module
|
||||||
|
interface MavericksViewModelDebugModule {
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
@IntoMap
|
||||||
|
@MavericksViewModelKey(DebugPrivateSettingsViewModel::class)
|
||||||
|
fun debugPrivateSettingsViewModelFactory(factory: DebugPrivateSettingsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.features.debug.settings
|
||||||
|
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import im.vector.app.R
|
||||||
|
import im.vector.app.core.extensions.addFragment
|
||||||
|
import im.vector.app.core.platform.VectorBaseActivity
|
||||||
|
import im.vector.app.databinding.ActivitySimpleBinding
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class DebugPrivateSettingsActivity : VectorBaseActivity<ActivitySimpleBinding>() {
|
||||||
|
|
||||||
|
override fun getBinding() = ActivitySimpleBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
|
override fun initUiAndData() {
|
||||||
|
if (isFirstCreation()) {
|
||||||
|
addFragment(
|
||||||
|
R.id.simpleFragmentContainer,
|
||||||
|
DebugPrivateSettingsFragment::class.java
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.features.debug.settings
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
|
import com.airbnb.mvrx.withState
|
||||||
|
import im.vector.app.core.platform.VectorBaseFragment
|
||||||
|
import im.vector.app.databinding.FragmentDebugPrivateSettingsBinding
|
||||||
|
|
||||||
|
class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSettingsBinding>() {
|
||||||
|
|
||||||
|
private val viewModel: DebugPrivateSettingsViewModel by fragmentViewModel()
|
||||||
|
|
||||||
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentDebugPrivateSettingsBinding {
|
||||||
|
return FragmentDebugPrivateSettingsBinding.inflate(inflater, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
setViewListeners()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setViewListeners() {
|
||||||
|
views.forceDialPadTabDisplay.setOnCheckedChangeListener { _, isChecked ->
|
||||||
|
viewModel.handle(DebugPrivateSettingsViewActions.SetDialPadVisibility(isChecked))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun invalidate() = withState(viewModel) {
|
||||||
|
views.forceDialPadTabDisplay.isChecked = it.dialPadVisible
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.features.debug.settings
|
||||||
|
|
||||||
|
import im.vector.app.core.platform.VectorViewModelAction
|
||||||
|
|
||||||
|
sealed class DebugPrivateSettingsViewActions : VectorViewModelAction {
|
||||||
|
data class SetDialPadVisibility(val force: Boolean) : DebugPrivateSettingsViewActions()
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.features.debug.settings
|
||||||
|
|
||||||
|
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||||
|
import dagger.assisted.Assisted
|
||||||
|
import dagger.assisted.AssistedFactory
|
||||||
|
import dagger.assisted.AssistedInject
|
||||||
|
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||||
|
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||||
|
import im.vector.app.core.platform.EmptyViewEvents
|
||||||
|
import im.vector.app.core.platform.VectorViewModel
|
||||||
|
import im.vector.app.features.settings.VectorDataStore
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class DebugPrivateSettingsViewModel @AssistedInject constructor(
|
||||||
|
@Assisted initialState: DebugPrivateSettingsViewState,
|
||||||
|
private val vectorDataStore: VectorDataStore
|
||||||
|
) : VectorViewModel<DebugPrivateSettingsViewState, DebugPrivateSettingsViewActions, EmptyViewEvents>(initialState) {
|
||||||
|
|
||||||
|
@AssistedFactory
|
||||||
|
interface Factory : MavericksAssistedViewModelFactory<DebugPrivateSettingsViewModel, DebugPrivateSettingsViewState> {
|
||||||
|
override fun create(initialState: DebugPrivateSettingsViewState): DebugPrivateSettingsViewModel
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object : MavericksViewModelFactory<DebugPrivateSettingsViewModel, DebugPrivateSettingsViewState> by hiltMavericksViewModelFactory()
|
||||||
|
|
||||||
|
init {
|
||||||
|
observeVectorDataStore()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun observeVectorDataStore() {
|
||||||
|
vectorDataStore.forceDialPadDisplayFlow.setOnEach {
|
||||||
|
copy(
|
||||||
|
dialPadVisible = it
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handle(action: DebugPrivateSettingsViewActions) {
|
||||||
|
when (action) {
|
||||||
|
is DebugPrivateSettingsViewActions.SetDialPadVisibility -> handleSetDialPadVisibility(action)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleSetDialPadVisibility(action: DebugPrivateSettingsViewActions.SetDialPadVisibility) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
vectorDataStore.setForceDialPadDisplay(action.force)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.app.features.debug.settings
|
||||||
|
|
||||||
|
import com.airbnb.mvrx.MavericksState
|
||||||
|
|
||||||
|
data class DebugPrivateSettingsViewState(
|
||||||
|
val dialPadVisible: Boolean = false
|
||||||
|
) : MavericksState
|
|
@ -20,6 +20,12 @@
|
||||||
android:padding="@dimen/layout_horizontal_margin"
|
android:padding="@dimen/layout_horizontal_margin"
|
||||||
android:showDividers="middle">
|
android:showDividers="middle">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/debug_private_setting"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Private settings" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/debug_test_text_view_link"
|
android:id="@+id/debug_test_text_view_link"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/coordinatorLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".features.debug.settings.DebugPrivateSettingsActivity"
|
||||||
|
tools:ignore="HardcodedText">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:divider="@drawable/linear_divider"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="@dimen/layout_horizontal_margin"
|
||||||
|
android:showDividers="middle">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/forceDialPadTabDisplay"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Force DialPad tab display" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -556,7 +556,8 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
|
||||||
|
|
||||||
open fun initUiAndData() = Unit
|
open fun initUiAndData() = Unit
|
||||||
|
|
||||||
override fun invalidate() = Unit
|
// Note: does not seem to be called
|
||||||
|
final override fun invalidate() = Unit
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
open fun getTitleRes() = -1
|
open fun getTitleRes() = -1
|
||||||
|
|
|
@ -23,7 +23,6 @@ import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.iterator
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.airbnb.mvrx.activityViewModel
|
import com.airbnb.mvrx.activityViewModel
|
||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
|
|
|
@ -38,7 +38,6 @@ import im.vector.app.features.invite.showInvites
|
||||||
import im.vector.app.features.settings.VectorDataStore
|
import im.vector.app.features.settings.VectorDataStore
|
||||||
import im.vector.app.features.ui.UiStateRepository
|
import im.vector.app.features.ui.UiStateRepository
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.collect
|
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.filterIsInstance
|
import kotlinx.coroutines.flow.filterIsInstance
|
||||||
import kotlinx.coroutines.flow.flatMapLatest
|
import kotlinx.coroutines.flow.flatMapLatest
|
||||||
|
@ -60,15 +59,16 @@ import timber.log.Timber
|
||||||
* View model used to update the home bottom bar notification counts, observe the sync state and
|
* View model used to update the home bottom bar notification counts, observe the sync state and
|
||||||
* change the selected room list view
|
* change the selected room list view
|
||||||
*/
|
*/
|
||||||
class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: HomeDetailViewState,
|
class HomeDetailViewModel @AssistedInject constructor(
|
||||||
private val session: Session,
|
@Assisted initialState: HomeDetailViewState,
|
||||||
private val uiStateRepository: UiStateRepository,
|
private val session: Session,
|
||||||
private val vectorDataStore: VectorDataStore,
|
private val uiStateRepository: UiStateRepository,
|
||||||
private val callManager: WebRtcCallManager,
|
private val vectorDataStore: VectorDataStore,
|
||||||
private val directRoomHelper: DirectRoomHelper,
|
private val callManager: WebRtcCallManager,
|
||||||
private val appStateHandler: AppStateHandler,
|
private val directRoomHelper: DirectRoomHelper,
|
||||||
private val autoAcceptInvites: AutoAcceptInvites) :
|
private val appStateHandler: AppStateHandler,
|
||||||
VectorViewModel<HomeDetailViewState, HomeDetailAction, HomeDetailViewEvents>(initialState),
|
private val autoAcceptInvites: AutoAcceptInvites
|
||||||
|
) : VectorViewModel<HomeDetailViewState, HomeDetailAction, HomeDetailViewEvents>(initialState),
|
||||||
CallProtocolsChecker.Listener {
|
CallProtocolsChecker.Listener {
|
||||||
|
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
|
@ -90,7 +90,7 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho
|
||||||
observeSyncState()
|
observeSyncState()
|
||||||
observeRoomGroupingMethod()
|
observeRoomGroupingMethod()
|
||||||
observeRoomSummaries()
|
observeRoomSummaries()
|
||||||
updateShowDialPadTab()
|
updatePstnSupportFlag()
|
||||||
observeDataStore()
|
observeDataStore()
|
||||||
callManager.addProtocolsCheckerListener(this)
|
callManager.addProtocolsCheckerListener(this)
|
||||||
session.flow().liveUser(session.myUserId).execute {
|
session.flow().liveUser(session.myUserId).execute {
|
||||||
|
@ -101,14 +101,16 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeDataStore() {
|
private fun observeDataStore() {
|
||||||
viewModelScope.launch {
|
vectorDataStore.pushCounterFlow.setOnEach { nbOfPush ->
|
||||||
vectorDataStore.pushCounterFlow.collect { nbOfPush ->
|
copy(
|
||||||
setState {
|
pushCounter = nbOfPush
|
||||||
copy(
|
)
|
||||||
pushCounter = nbOfPush
|
}
|
||||||
)
|
|
||||||
}
|
vectorDataStore.forceDialPadDisplayFlow.setOnEach { force ->
|
||||||
}
|
copy(
|
||||||
|
forceDialPadTab = force
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,12 +152,12 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPSTNSupportUpdated() {
|
override fun onPSTNSupportUpdated() {
|
||||||
updateShowDialPadTab()
|
updatePstnSupportFlag()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateShowDialPadTab() {
|
private fun updatePstnSupportFlag() {
|
||||||
setState {
|
setState {
|
||||||
copy(showDialPadTab = callManager.supportsPSTNProtocol)
|
copy(pstnSupportFlag = callManager.supportsPSTNProtocol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,11 @@ data class HomeDetailViewState(
|
||||||
val syncState: SyncState = SyncState.Idle,
|
val syncState: SyncState = SyncState.Idle,
|
||||||
val incrementalSyncStatus: SyncStatusService.Status.IncrementalSyncStatus = SyncStatusService.Status.IncrementalSyncIdle,
|
val incrementalSyncStatus: SyncStatusService.Status.IncrementalSyncStatus = SyncStatusService.Status.IncrementalSyncIdle,
|
||||||
val pushCounter: Int = 0,
|
val pushCounter: Int = 0,
|
||||||
val showDialPadTab: Boolean = false
|
val pstnSupportFlag: Boolean = false,
|
||||||
) : MavericksState
|
val forceDialPadTab: Boolean = false
|
||||||
|
) : MavericksState {
|
||||||
|
val showDialPadTab = forceDialPadTab || pstnSupportFlag
|
||||||
|
}
|
||||||
|
|
||||||
sealed class HomeTab(@StringRes val titleRes: Int) {
|
sealed class HomeTab(@StringRes val titleRes: Int) {
|
||||||
data class RoomList(val displayMode: RoomListDisplayMode) : HomeTab(displayMode.titleRes)
|
data class RoomList(val displayMode: RoomListDisplayMode) : HomeTab(displayMode.titleRes)
|
||||||
|
|
|
@ -56,7 +56,6 @@ import im.vector.app.features.settings.VectorDataStore
|
||||||
import im.vector.app.features.settings.VectorPreferences
|
import im.vector.app.features.settings.VectorPreferences
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.collect
|
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
|
@ -180,14 +179,10 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeDataStore() {
|
private fun observeDataStore() {
|
||||||
viewModelScope.launch {
|
vectorDataStore.pushCounterFlow.setOnEach { nbOfPush ->
|
||||||
vectorDataStore.pushCounterFlow.collect { nbOfPush ->
|
copy(
|
||||||
setState {
|
pushCounter = nbOfPush
|
||||||
copy(
|
)
|
||||||
pushCounter = nbOfPush
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,13 @@ package im.vector.app.features.settings
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.datastore.core.DataStore
|
import androidx.datastore.core.DataStore
|
||||||
import androidx.datastore.preferences.core.Preferences
|
import androidx.datastore.preferences.core.Preferences
|
||||||
|
import androidx.datastore.preferences.core.booleanPreferencesKey
|
||||||
import androidx.datastore.preferences.core.edit
|
import androidx.datastore.preferences.core.edit
|
||||||
import androidx.datastore.preferences.core.intPreferencesKey
|
import androidx.datastore.preferences.core.intPreferencesKey
|
||||||
import androidx.datastore.preferences.preferencesDataStore
|
import androidx.datastore.preferences.preferencesDataStore
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "vector_settings")
|
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "vector_settings")
|
||||||
|
@ -44,4 +46,17 @@ class VectorDataStore @Inject constructor(
|
||||||
settings[pushCounter] = currentCounterValue + 1
|
settings[pushCounter] = currentCounterValue + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For debug only
|
||||||
|
private val forceDialPadDisplay = booleanPreferencesKey("force_dial_pad_display")
|
||||||
|
|
||||||
|
val forceDialPadDisplayFlow: Flow<Boolean> = context.dataStore.data.map { preferences ->
|
||||||
|
preferences[forceDialPadDisplay].orFalse()
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun setForceDialPadDisplay(force: Boolean) {
|
||||||
|
context.dataStore.edit { settings ->
|
||||||
|
settings[forceDialPadDisplay] = force
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue