mirror of
https://github.com/bitwarden/android.git
synced 2025-03-16 03:08:50 +03:00
[PM-10071] Sort search items with same logic as displayed items (#3683)
This commit is contained in:
parent
18cd66a34b
commit
0085388446
1 changed files with 15 additions and 2 deletions
|
@ -11,6 +11,7 @@ import com.bitwarden.vault.CipherView
|
|||
import com.bitwarden.vault.CollectionView
|
||||
import com.bitwarden.vault.FolderView
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.data.platform.util.CompareStringSpecialCharWithPrecedence
|
||||
import com.x8bit.bitwarden.data.platform.util.subtitle
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.asText
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.removeDiacritics
|
||||
|
@ -159,7 +160,8 @@ fun List<CipherView>.toViewState(
|
|||
isIconLoadingDisabled = isIconLoadingDisabled,
|
||||
isAutofill = isAutofill,
|
||||
isPremiumUser = isPremiumUser,
|
||||
),
|
||||
)
|
||||
.sortAlphabetically(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -314,7 +316,8 @@ fun List<SendView>.toViewState(
|
|||
displayItems = toDisplayItemList(
|
||||
baseWebSendUrl = baseWebSendUrl,
|
||||
clock = clock,
|
||||
),
|
||||
)
|
||||
.sortAlphabetically(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -360,6 +363,16 @@ private fun SendView.toDisplayItem(
|
|||
shouldDisplayMasterPasswordReprompt = false,
|
||||
)
|
||||
|
||||
/**
|
||||
* Sort a list of [SearchState.DisplayItem] by their titles alphabetically giving digits and
|
||||
* special characters higher precedence.
|
||||
*/
|
||||
private fun List<SearchState.DisplayItem>.sortAlphabetically(): List<SearchState.DisplayItem> {
|
||||
return this.sortedWith { item1, item2 ->
|
||||
CompareStringSpecialCharWithPrecedence.compare(item1.title, item2.title)
|
||||
}
|
||||
}
|
||||
|
||||
private enum class SortPriority {
|
||||
HIGH,
|
||||
LOW,
|
||||
|
|
Loading…
Add table
Reference in a new issue