Keep initial filter type on bottom sheet.
This commit is contained in:
parent
41ca662dcc
commit
11079afa6b
@ -17,19 +17,29 @@
|
|||||||
package im.vector.app.features.settings.devices.v2.filter
|
package im.vector.app.features.settings.devices.v2.filter
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Parcelable
|
||||||
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 com.airbnb.mvrx.args
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
||||||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment.ResultListener.Companion.RESULT_OK
|
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment.ResultListener.Companion.RESULT_OK
|
||||||
import im.vector.app.databinding.BottomSheetDeviceManagerFilterBinding
|
import im.vector.app.databinding.BottomSheetDeviceManagerFilterBinding
|
||||||
import im.vector.app.features.settings.devices.v2.list.SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS
|
import im.vector.app.features.settings.devices.v2.list.SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data class DeviceManagerFilterBottomSheetArgs(
|
||||||
|
val initialFilterType: DeviceManagerFilterType,
|
||||||
|
) : Parcelable
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DeviceManagerFilterBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetDeviceManagerFilterBinding>() {
|
class DeviceManagerFilterBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetDeviceManagerFilterBinding>() {
|
||||||
|
|
||||||
|
private val args: DeviceManagerFilterBottomSheetArgs by args()
|
||||||
|
|
||||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetDeviceManagerFilterBinding {
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetDeviceManagerFilterBinding {
|
||||||
return BottomSheetDeviceManagerFilterBinding.inflate(inflater, container, false)
|
return BottomSheetDeviceManagerFilterBinding.inflate(inflater, container, false)
|
||||||
}
|
}
|
||||||
@ -46,6 +56,14 @@ class DeviceManagerFilterBottomSheet : VectorBaseBottomSheetDialogFragment<Botto
|
|||||||
SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS
|
SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val radioButtonId = when (args.initialFilterType) {
|
||||||
|
DeviceManagerFilterType.ALL_SESSIONS -> R.id.filterOptionAllSessionsRadioButton
|
||||||
|
DeviceManagerFilterType.VERIFIED -> R.id.filterOptionVerifiedRadioButton
|
||||||
|
DeviceManagerFilterType.UNVERIFIED -> R.id.filterOptionUnverifiedRadioButton
|
||||||
|
DeviceManagerFilterType.INACTIVE -> R.id.filterOptionInactiveRadioButton
|
||||||
|
}
|
||||||
|
views.filterOptionsRadioGroup.check(radioButtonId)
|
||||||
|
|
||||||
views.filterOptionsRadioGroup.setOnCheckedChangeListener { _, checkedId ->
|
views.filterOptionsRadioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||||
onFilterTypeChanged(checkedId)
|
onFilterTypeChanged(checkedId)
|
||||||
}
|
}
|
||||||
@ -64,10 +82,11 @@ class DeviceManagerFilterBottomSheet : VectorBaseBottomSheetDialogFragment<Botto
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(resultListener: ResultListener): DeviceManagerFilterBottomSheet {
|
fun newInstance(initialFilterType: DeviceManagerFilterType, resultListener: ResultListener): DeviceManagerFilterBottomSheet {
|
||||||
val bottomSheet = DeviceManagerFilterBottomSheet()
|
return DeviceManagerFilterBottomSheet().apply {
|
||||||
bottomSheet.resultListener = resultListener
|
this.resultListener = resultListener
|
||||||
return bottomSheet
|
setArguments(DeviceManagerFilterBottomSheetArgs(initialFilterType))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,13 @@ class OtherSessionsFragment : VectorBaseFragment<FragmentOtherSessionsBinding>()
|
|||||||
|
|
||||||
private fun initFilterView() {
|
private fun initFilterView() {
|
||||||
views.otherSessionsFilterFrameLayout.debouncedClicks {
|
views.otherSessionsFilterFrameLayout.debouncedClicks {
|
||||||
|
withState(viewModel) { state ->
|
||||||
DeviceManagerFilterBottomSheet
|
DeviceManagerFilterBottomSheet
|
||||||
.newInstance(this)
|
.newInstance(state.currentFilter, this)
|
||||||
.show(requireActivity().supportFragmentManager, "SHOW_DEVICE_MANAGER_FILTER_BOTTOM_SHEET")
|
.show(requireActivity().supportFragmentManager, "SHOW_DEVICE_MANAGER_FILTER_BOTTOM_SHEET")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBottomSheetResult(resultCode: Int, data: Any?) {
|
override fun onBottomSheetResult(resultCode: Int, data: Any?) {
|
||||||
if (resultCode == RESULT_OK && data != null && data is DeviceManagerFilterType) {
|
if (resultCode == RESULT_OK && data != null && data is DeviceManagerFilterType) {
|
||||||
|
Loading…
Reference in New Issue
Block a user