mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Improved start call lists behavior when doing search
This commit is contained in:
parent
10bd90ab18
commit
bfe56579aa
6 changed files with 55 additions and 16 deletions
|
|
@ -130,6 +130,7 @@ class StartCallFragment : GenericFragment() {
|
|||
viewLifecycleOwner
|
||||
) {
|
||||
contactsAdapter.submitList(it)
|
||||
viewModel.emptyContactsList.value = it.isEmpty()
|
||||
|
||||
(view.parent as? ViewGroup)?.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
|
|
@ -138,6 +139,7 @@ class StartCallFragment : GenericFragment() {
|
|||
|
||||
suggestionsListViewModel.suggestionsList.observe(viewLifecycleOwner) {
|
||||
suggestionsAdapter.submitList(it)
|
||||
viewModel.emptySuggestionsList.value = it.isEmpty()
|
||||
}
|
||||
|
||||
viewModel.searchFilter.observe(viewLifecycleOwner) { filter ->
|
||||
|
|
|
|||
|
|
@ -24,4 +24,8 @@ import androidx.lifecycle.ViewModel
|
|||
|
||||
class StartCallViewModel : ViewModel() {
|
||||
val searchFilter = MutableLiveData<String>()
|
||||
|
||||
val emptyContactsList = MutableLiveData<Boolean>()
|
||||
|
||||
val emptySuggestionsList = MutableLiveData<Boolean>()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,30 +93,24 @@ class SuggestionsListViewModel : ViewModel() {
|
|||
|
||||
@WorkerThread
|
||||
fun processMagicSearchResults(results: Array<SearchResult>) {
|
||||
Log.i("$TAG Processing ${results.size} results")
|
||||
Log.i("$TAG Processing [${results.size}] results")
|
||||
suggestionsList.value.orEmpty().forEach(ContactAvatarModel::destroy)
|
||||
|
||||
val list = arrayListOf<ContactAvatarModel>()
|
||||
|
||||
for (result in results) {
|
||||
val friend = result.friend
|
||||
// We don't want Friends here as they would also be in contacts list
|
||||
if (result.friend == null) {
|
||||
val fakeFriend = createFriendFromSearchResult(result)
|
||||
val model = ContactAvatarModel(fakeFriend)
|
||||
model.noAlphabet.postValue(true)
|
||||
|
||||
val model = if (friend != null) {
|
||||
ContactAvatarModel(friend)
|
||||
} else {
|
||||
Log.w("$TAG SearchResult [$result] has no Friend!")
|
||||
val fakeFriend =
|
||||
createFriendFromSearchResult(result)
|
||||
ContactAvatarModel(fakeFriend)
|
||||
list.add(model)
|
||||
}
|
||||
model.noAlphabet.postValue(true)
|
||||
|
||||
list.add(model)
|
||||
}
|
||||
|
||||
suggestionsList.postValue(list)
|
||||
|
||||
Log.i("$TAG Processed ${results.size} results")
|
||||
Log.i("$TAG Processed [${results.size}] results, extracted [${list.size}] suggestions")
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class ContactsListViewModel : ViewModel() {
|
|||
|
||||
@WorkerThread
|
||||
fun processMagicSearchResults(results: Array<SearchResult>) {
|
||||
Log.i("$TAG Processing ${results.size} results")
|
||||
Log.i("$TAG Processing [${results.size}] results")
|
||||
contactsList.value.orEmpty().forEach(ContactAvatarModel::destroy)
|
||||
|
||||
val list = arrayListOf<ContactAvatarModel>()
|
||||
|
|
@ -143,7 +143,7 @@ class ContactsListViewModel : ViewModel() {
|
|||
favourites.postValue(favouritesList)
|
||||
contactsList.postValue(list)
|
||||
|
||||
Log.i("$TAG Processed ${results.size} results")
|
||||
Log.i("$TAG Processed [${results.size}] results")
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
|
|||
|
|
@ -103,6 +103,34 @@
|
|||
app:layout_constraintTop_toTopOf="@id/group_call_icon"
|
||||
app:layout_constraintBottom_toBottomOf="@id/group_call_icon"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/no_contacts_nor_suggestion_image"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/illu"
|
||||
android:layout_margin="10dp"
|
||||
android:visibility="@{viewModel.emptyContactsList && viewModel.emptySuggestionsList ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintHeight_max="200dp"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:layout_constraintBottom_toTopOf="@id/no_contacts_nor_suggestion_label"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/group_call_icon" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/no_contacts_nor_suggestion_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="No suggestion and no contact for the moment..."
|
||||
android:textSize="16sp"
|
||||
android:visibility="@{viewModel.emptyContactsList && viewModel.emptySuggestionsList ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/no_contacts_nor_suggestion_image" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/all_contacts_label"
|
||||
|
|
@ -114,6 +142,9 @@
|
|||
android:layout_marginTop="16dp"
|
||||
android:text="Contacts"
|
||||
android:textSize="16sp"
|
||||
android:visibility="@{viewModel.emptyContactsList ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintVertical_bias="0"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/group_call_icon"
|
||||
|
|
@ -124,6 +155,8 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:visibility="@{viewModel.emptyContactsList ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintVertical_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/all_contacts_label"
|
||||
|
|
@ -140,6 +173,8 @@
|
|||
android:layout_marginTop="16dp"
|
||||
android:text="Suggestions"
|
||||
android:textSize="16sp"
|
||||
android:visibility="@{viewModel.emptySuggestionsList ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintVertical_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/contacts_list"
|
||||
|
|
@ -150,6 +185,8 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:visibility="@{viewModel.emptySuggestionsList ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintVertical_bias="0"
|
||||
app:layout_constraintHeight_max="220dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="zero">0dp</dimen>
|
||||
|
||||
<dimen name="landscape_nav_bar_width">75dp</dimen>
|
||||
<dimen name="sliding_pane_left_fragment_width">280dp</dimen>
|
||||
<!-- This value is the result of the above two added together -->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue