-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4537 from vector-im/feature/bma/more_cleanup
Feature/bma/more cleanup
- Loading branch information
Showing
17 changed files
with
332 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a crash when displaying the bootstrap bottom sheet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
vector/src/debug/java/im/vector/app/features/debug/di/MavericksViewModelDebugModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<*, *> | ||
} |
38 changes: 38 additions & 0 deletions
38
vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...r/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewActions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} |
65 changes: 65 additions & 0 deletions
65
vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
vector/src/debug/res/layout/fragment_debug_private_settings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.