From 0ec67c1ab82ecfd8ffdb0f2e975f4dbb7cc073d0 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 13 Sep 2022 13:10:03 +0300 Subject: [PATCH] Implement clear filter. --- .../src/main/res/values/strings.xml | 4 +++ .../v2/othersessions/OtherSessionsFragment.kt | 9 ++++++ .../res/layout/fragment_other_sessions.xml | 31 +++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 5eaeae4d86..b28c7c638c 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3304,5 +3304,9 @@ Consider signing out from old sessions (%1$d day or more) you don’t use anymore. Consider signing out from old sessions (%1$d days or more) you don’t use anymore. + No verified sessions found. + No unverified sessions found. + No inactive sessions found. + Clear Filter diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsFragment.kt index 8d2de8d756..7fd0b755c9 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsFragment.kt @@ -64,6 +64,10 @@ class OtherSessionsFragment : VectorBaseFragment() .show(requireActivity().supportFragmentManager, "SHOW_DEVICE_MANAGER_FILTER_BOTTOM_SHEET") } } + + views.otherSessionsClearFilterButton.debouncedClicks { + viewModel.handle(DevicesAction.FilterDevices(DeviceManagerFilterType.ALL_SESSIONS)) + } } override fun onBottomSheetResult(resultCode: Int, data: Any?) { @@ -98,6 +102,7 @@ class OtherSessionsFragment : VectorBaseFragment() imageTintColorResourceId = colorProvider.getColor(R.color.shield_color_trust_background) ) ) + views.otherSessionsNotFoundTextView.text = getString(R.string.device_manager_other_sessions_no_verified_sessions_found) } DeviceManagerFilterType.UNVERIFIED -> { views.otherSessionsSecurityRecommendationView.render( @@ -108,6 +113,7 @@ class OtherSessionsFragment : VectorBaseFragment() imageTintColorResourceId = colorProvider.getColor(R.color.shield_color_warning_background) ) ) + views.otherSessionsNotFoundTextView.text = getString(R.string.device_manager_other_sessions_no_unverified_sessions_found) } DeviceManagerFilterType.INACTIVE -> { views.otherSessionsSecurityRecommendationView.render( @@ -122,14 +128,17 @@ class OtherSessionsFragment : VectorBaseFragment() imageTintColorResourceId = ThemeUtils.getColor(requireContext(), R.attr.vctr_system) ) ) + views.otherSessionsNotFoundTextView.text = getString(R.string.device_manager_other_sessions_no_inactive_sessions_found) } DeviceManagerFilterType.ALL_SESSIONS -> { /* NOOP. View is not visible */ } } if (devices.isNullOrEmpty()) { views.deviceListOtherSessions.isVisible = false + views.otherSessionsNotFoundLayout.isVisible = true } else { views.deviceListOtherSessions.isVisible = true + views.otherSessionsNotFoundLayout.isVisible = false views.deviceListOtherSessions.render(devices, devices.size) } } diff --git a/vector/src/main/res/layout/fragment_other_sessions.xml b/vector/src/main/res/layout/fragment_other_sessions.xml index ae9ca5ae50..a6181d05f5 100644 --- a/vector/src/main/res/layout/fragment_other_sessions.xml +++ b/vector/src/main/res/layout/fragment_other_sessions.xml @@ -75,6 +75,37 @@ app:otherSessionsRecommendationTitle="@string/device_manager_other_sessions_recommendation_title_unverified" tools:visibility="visible" /> + + + + +