diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/filter/DeviceManagerFilterBottomSheet.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/filter/DeviceManagerFilterBottomSheet.kt index 4eee482348..4ab5acd496 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/filter/DeviceManagerFilterBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/filter/DeviceManagerFilterBottomSheet.kt @@ -17,19 +17,29 @@ package im.vector.app.features.settings.devices.v2.filter import android.os.Bundle +import android.os.Parcelable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import com.airbnb.mvrx.args import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment.ResultListener.Companion.RESULT_OK import im.vector.app.databinding.BottomSheetDeviceManagerFilterBinding 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 class DeviceManagerFilterBottomSheet : VectorBaseBottomSheetDialogFragment() { + private val args: DeviceManagerFilterBottomSheetArgs by args() + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetDeviceManagerFilterBinding { return BottomSheetDeviceManagerFilterBinding.inflate(inflater, container, false) } @@ -46,6 +56,14 @@ class DeviceManagerFilterBottomSheet : VectorBaseBottomSheetDialogFragment 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 -> onFilterTypeChanged(checkedId) } @@ -64,10 +82,11 @@ class DeviceManagerFilterBottomSheet : VectorBaseBottomSheetDialogFragment() private fun initFilterView() { views.otherSessionsFilterFrameLayout.debouncedClicks { - DeviceManagerFilterBottomSheet - .newInstance(this) - .show(requireActivity().supportFragmentManager, "SHOW_DEVICE_MANAGER_FILTER_BOTTOM_SHEET") + withState(viewModel) { state -> + DeviceManagerFilterBottomSheet + .newInstance(state.currentFilter, this) + .show(requireActivity().supportFragmentManager, "SHOW_DEVICE_MANAGER_FILTER_BOTTOM_SHEET") + } } }