mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Show starred contacts first in lists
This commit is contained in:
parent
3a23c8813e
commit
a3ed13bc79
4 changed files with 27 additions and 8 deletions
|
|
@ -47,8 +47,9 @@ class ConversationsContactsAndSuggestionsListAdapter :
|
|||
HeaderAdapter {
|
||||
companion object {
|
||||
private const val CONTACT_TYPE = 0
|
||||
private const val SUGGESTION_TYPE = 1
|
||||
private const val CONVERSATION_TYPE = 2
|
||||
private const val FAVORITE_TYPE = 1
|
||||
private const val SUGGESTION_TYPE = 2
|
||||
private const val CONVERSATION_TYPE = 3
|
||||
}
|
||||
|
||||
val onClickedEvent: MutableLiveData<Event<ConversationContactOrSuggestionModel>> by lazy {
|
||||
|
|
@ -56,7 +57,7 @@ class ConversationsContactsAndSuggestionsListAdapter :
|
|||
}
|
||||
|
||||
override fun displayHeaderForPosition(position: Int): Boolean {
|
||||
if (position == 0) { // Conversations
|
||||
if (position == 0) { // Always start by a header
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -74,6 +75,9 @@ class ConversationsContactsAndSuggestionsListAdapter :
|
|||
SUGGESTION_TYPE -> {
|
||||
AppUtils.getString(R.string.generic_address_picker_suggestions_list_title)
|
||||
}
|
||||
FAVORITE_TYPE -> {
|
||||
AppUtils.getString(R.string.generic_address_picker_favorites_list_title)
|
||||
}
|
||||
else -> {
|
||||
AppUtils.getString(R.string.generic_address_picker_contacts_list_title)
|
||||
}
|
||||
|
|
@ -86,7 +90,11 @@ class ConversationsContactsAndSuggestionsListAdapter :
|
|||
return if (model.localAddress != null) {
|
||||
CONVERSATION_TYPE
|
||||
} else if (model.friend != null) {
|
||||
CONTACT_TYPE
|
||||
if (model.friend.starred) {
|
||||
FAVORITE_TYPE
|
||||
} else {
|
||||
CONTACT_TYPE
|
||||
}
|
||||
} else {
|
||||
SUGGESTION_TYPE
|
||||
}
|
||||
|
|
@ -110,7 +118,7 @@ class ConversationsContactsAndSuggestionsListAdapter :
|
|||
}
|
||||
ConversationViewHolder(binding)
|
||||
}
|
||||
CONTACT_TYPE -> {
|
||||
CONTACT_TYPE, FAVORITE_TYPE -> {
|
||||
val binding: GenericAddressPickerContactListCellBinding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
R.layout.generic_address_picker_contact_list_cell,
|
||||
|
|
@ -148,7 +156,7 @@ class ConversationsContactsAndSuggestionsListAdapter :
|
|||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
when (getItemViewType(position)) {
|
||||
CONVERSATION_TYPE -> (holder as ConversationViewHolder).bind(getItem(position))
|
||||
CONTACT_TYPE -> (holder as ContactViewHolder).bind(getItem(position))
|
||||
CONTACT_TYPE, FAVORITE_TYPE -> (holder as ContactViewHolder).bind(getItem(position))
|
||||
else -> (holder as SuggestionViewHolder).bind(getItem(position))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,6 +262,7 @@ abstract class AddressSelectionViewModel
|
|||
arrayListOf()
|
||||
}
|
||||
|
||||
val favoritesList = arrayListOf<ConversationContactOrSuggestionModel>()
|
||||
val contactsList = arrayListOf<ConversationContactOrSuggestionModel>()
|
||||
val suggestionsList = arrayListOf<ConversationContactOrSuggestionModel>()
|
||||
|
||||
|
|
@ -289,7 +290,11 @@ abstract class AddressSelectionViewModel
|
|||
)
|
||||
model.avatarModel.postValue(avatarModel)
|
||||
|
||||
contactsList.add(model)
|
||||
if (friend.starred) {
|
||||
favoritesList.add(model)
|
||||
} else {
|
||||
contactsList.add(model)
|
||||
}
|
||||
} else {
|
||||
val defaultAccountAddress = coreContext.core.defaultAccount?.params?.identityAddress
|
||||
if (defaultAccountAddress != null && address.weakEqual(defaultAccountAddress)) {
|
||||
|
|
@ -307,6 +312,9 @@ abstract class AddressSelectionViewModel
|
|||
}
|
||||
|
||||
val collator = Collator.getInstance(Locale.getDefault())
|
||||
favoritesList.sortWith { model1, model2 ->
|
||||
collator.compare(model1.name, model2.name)
|
||||
}
|
||||
contactsList.sortWith { model1, model2 ->
|
||||
collator.compare(model1.name, model2.name)
|
||||
}
|
||||
|
|
@ -316,12 +324,13 @@ abstract class AddressSelectionViewModel
|
|||
|
||||
val list = arrayListOf<ConversationContactOrSuggestionModel>()
|
||||
list.addAll(conversationsList)
|
||||
list.addAll(favoritesList)
|
||||
list.addAll(contactsList)
|
||||
list.addAll(suggestionsList)
|
||||
modelsList.postValue(list)
|
||||
isEmpty.postValue(list.isEmpty())
|
||||
Log.i(
|
||||
"$TAG Processed [${results.size}] results: [${conversationsList.size}] conversations, [${contactsList.size}] contacts and [${suggestionsList.size}] suggestions"
|
||||
"$TAG Processed [${results.size}] results: [${conversationsList.size}] conversations, [${favoritesList.size}] favorites, [${contactsList.size}] contacts and [${suggestionsList.size}] suggestions"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -745,6 +745,7 @@
|
|||
<string name="operation_in_progress_overlay">Opération en cours, merci de patienter…</string>
|
||||
<string name="generic_address_picker_conversations_list_title">Conversations</string>
|
||||
<string name="generic_address_picker_contacts_list_title">Contacts</string>
|
||||
<string name="generic_address_picker_favorites_list_title">Favoris</string>
|
||||
<string name="generic_address_picker_suggestions_list_title">Suggestions</string>
|
||||
<string name="post_notifications_permission_not_granted">La permission de poster des notifications n\'est pas donnée !</string>
|
||||
<plurals name="mwi_messages_are_waiting">
|
||||
|
|
|
|||
|
|
@ -783,6 +783,7 @@
|
|||
<string name="operation_in_progress_overlay">Operation in progress, please wait</string>
|
||||
<string name="generic_address_picker_conversations_list_title">Conversations</string>
|
||||
<string name="generic_address_picker_contacts_list_title">Contacts</string>
|
||||
<string name="generic_address_picker_favorites_list_title">Favorites</string>
|
||||
<string name="generic_address_picker_suggestions_list_title">Suggestions</string>
|
||||
<string name="post_notifications_permission_not_granted">Post notifications permission not granted!</string>
|
||||
<plurals name="mwi_messages_are_waiting">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue