Improved empty list display due to filter not matching any item

This commit is contained in:
Sylvain Berfini 2024-07-08 16:13:27 +02:00
parent 5ae345e794
commit 964a597aa1
13 changed files with 31 additions and 23 deletions

View file

@ -143,17 +143,20 @@ class MeetingsListViewModel @UiThread constructor() : AbstractMainViewModel() {
meetingForTodayFound = true
}
// If no meeting was found for today, insert "Today" fake model before the next meeting to come
// If no meeting was found for today, insert "Today" fake model before the next meeting to come,
// but only add that fake meeting if filter is empty
if (!meetingForTodayFound && model.isAfterToday) {
val todayWeekLabel = TimestampUtils.firstAndLastDayOfWeek(
System.currentTimeMillis(),
false
)
val first = previousModelWeekLabel != todayWeekLabel
list.add(MeetingListItemModel(null, first))
meetingForTodayFound = true
previousModelWeekLabel = todayWeekLabel
firstMeetingOfTheWeek = false
if (filter.isEmpty()) {
val todayWeekLabel = TimestampUtils.firstAndLastDayOfWeek(
System.currentTimeMillis(),
false
)
val first = previousModelWeekLabel != todayWeekLabel
list.add(MeetingListItemModel(null, first))
meetingForTodayFound = true
previousModelWeekLabel = todayWeekLabel
firstMeetingOfTheWeek = false
}
} else {
previousModelWeekLabel = model.weekLabel
}
@ -163,8 +166,9 @@ class MeetingsListViewModel @UiThread constructor() : AbstractMainViewModel() {
}
}
// If no meeting was found after today, insert "Today" fake model at the end
if (!meetingForTodayFound) {
// If no meeting was found after today, insert "Today" fake model at the end,
// but only add that fake meeting if filter is empty
if (!meetingForTodayFound && filter.isEmpty()) {
val todayWeekLabel = TimestampUtils.firstAndLastDayOfWeek(
System.currentTimeMillis(),
false

View file

@ -66,6 +66,8 @@ open class AbstractMainViewModel @UiThread constructor() : GenericViewModel() {
val unreadMessages = MutableLiveData<Int>()
val isFilterEmpty = MutableLiveData<Boolean>()
val focusSearchBarEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
}
@ -170,6 +172,7 @@ open class AbstractMainViewModel @UiThread constructor() : GenericViewModel() {
}
searchBarVisible.value = false
isFilterEmpty.value = true
}
@UiThread
@ -214,6 +217,7 @@ open class AbstractMainViewModel @UiThread constructor() : GenericViewModel() {
fun applyFilter(filter: String = currentFilter) {
Log.i("$TAG New filter set by user [$filter]")
currentFilter = filter
isFilterEmpty.postValue(filter.isEmpty())
filter()
}

View file

@ -87,7 +87,7 @@
android:id="@+id/no_conversation_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/conversations_list_empty"
android:text="@{viewModel.isFilterEmpty ? @string/conversations_list_empty : @string/list_filter_no_result_found, default=@string/conversations_list_empty}"
app:layout_constraintBottom_toTopOf="@id/background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/bottom_nav_bar"

View file

@ -142,7 +142,7 @@
android:id="@+id/no_contacts_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/contacts_list_empty"
android:text="@{viewModel.isFilterEmpty ? @string/contacts_list_empty : @string/list_filter_no_result_found, default=@string/contacts_list_empty}"
app:layout_constraintBottom_toTopOf="@id/lists"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/bottom_nav_bar"

View file

@ -107,7 +107,7 @@
android:id="@+id/no_calls_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/history_list_empty_history"
android:text="@{viewModel.isFilterEmpty ? @string/history_list_empty_history : @string/list_filter_no_result_found, default=@string/history_list_empty_history}"
app:layout_constraintBottom_toTopOf="@id/background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/bottom_nav_bar"

View file

@ -104,7 +104,7 @@
android:id="@+id/no_meeting_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/meetings_list_empty"
android:text="@{viewModel.isFilterEmpty ? @string/meetings_list_empty : @string/list_filter_no_result_found, default=@string/meetings_list_empty}"
app:layout_constraintBottom_toTopOf="@id/background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/bottom_nav_bar"

View file

@ -246,7 +246,7 @@
android:id="@+id/no_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/conversation_filter_no_matching_result"
android:text="@string/list_filter_no_result_found"
android:textColor="?attr/color_main2_600"
android:textSize="16sp"
android:visibility="@{viewModel.noMatchingResultForFilter ? View.VISIBLE : View.GONE}"

View file

@ -77,7 +77,7 @@
android:id="@+id/no_conversation_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/conversations_list_empty"
android:text="@{viewModel.isFilterEmpty ? @string/conversations_list_empty : @string/list_filter_no_result_found, default=@string/conversations_list_empty}"
app:layout_constraintBottom_toTopOf="@id/background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View file

@ -134,7 +134,7 @@
android:id="@+id/no_contacts_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/contacts_list_empty"
android:text="@{viewModel.isFilterEmpty ? @string/contacts_list_empty : @string/list_filter_no_result_found, default=@string/contacts_list_empty}"
app:layout_constraintBottom_toTopOf="@id/lists"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View file

@ -97,7 +97,7 @@
android:id="@+id/no_calls_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/history_list_empty_history"
android:text="@{viewModel.isFilterEmpty ? @string/history_list_empty_history : @string/list_filter_no_result_found, default=@string/history_list_empty_history}"
app:layout_constraintBottom_toTopOf="@id/background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View file

@ -94,7 +94,7 @@
android:id="@+id/no_meeting_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/meetings_list_empty"
android:text="@{viewModel.isFilterEmpty ? @string/meetings_list_empty : @string/list_filter_no_result_found, default=@string/meetings_list_empty}"
app:layout_constraintBottom_toTopOf="@id/background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View file

@ -419,7 +419,6 @@
<string name="conversation_menu_documents_files">Documents</string>
<string name="conversation_no_media_found">Aucun média pour le moment…</string>
<string name="conversation_no_document_found">Aucun document pour le moment…</string>
<string name="conversation_filter_no_matching_result">Aucun résultat…</string>
<string name="conversation_end_to_end_encrypted_event_title">Conversation chiffrée de bout en bout</string>
<string name="conversation_end_to_end_encrypted_event_subtitle">Les messages de cette conversation sont chiffrés de bout en bout. Seul votre correspondant peut les déchiffrer.</string>
<string name="conversation_end_to_end_encrypted_bottom_sheet_title">La confidentialité de vos échanges garantie</string>
@ -686,6 +685,7 @@
<string name="purple">Violet</string>
<!-- Misc -->
<string name="list_filter_no_result_found">Aucun résultat…</string>
<string name="multiple_participants_selection_placeholder">Les participants selectionnés apparaîtront ici</string>
<string name="connection_error_for_non_default_account">Compte(s) non connecté(s)</string>
<plurals name="pending_notification_for_other_accounts" tools:ignore="MissingQuantity">

View file

@ -456,7 +456,6 @@
<string name="conversation_menu_documents_files">Documents</string>
<string name="conversation_no_media_found">No media found…</string>
<string name="conversation_no_document_found">No document found…</string>
<string name="conversation_filter_no_matching_result">No matching result</string>
<string name="conversation_end_to_end_encrypted_event_title">End-to-end encrypted conversation</string>
<string name="conversation_end_to_end_encrypted_event_subtitle">Messages in this conversation are e2e encrypted. Only your correspondent can decrypt them.</string>
<string name="conversation_end_to_end_encrypted_bottom_sheet_title">Guaranteed confidentiality</string>
@ -723,6 +722,7 @@
<string name="purple">Purple</string>
<!-- Misc -->
<string name="list_filter_no_result_found">No result found…</string>
<string name="multiple_participants_selection_placeholder">Selected participants will appear here</string>
<string name="connection_error_for_non_default_account">Account(s) connection error</string>
<plurals name="pending_notification_for_other_accounts">