Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tab inserting the toString of objects instead of autocompletion when sharing folder #1316

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class AvailableShareableItemsAdapter(
private var itemList: ArrayList<Shareable>,
var notShareableIds: ArrayList<Int> = arrayListOf(),
var notShareableEmails: ArrayList<String> = arrayListOf(),
private val getCurrentText: () -> CharSequence,
private val onItemClick: (item: Shareable) -> Unit,
) : ArrayAdapter<Shareable>(context, R.layout.item_user, itemList), Filterable {

Expand Down Expand Up @@ -171,6 +172,8 @@ class AvailableShareableItemsAdapter(

notifyDataSetChanged()
}

override fun convertResultToString(resultValue: Any?): CharSequence = getCurrentText()
}

private fun CharSequence.standardize(): String = this.toString().trim().lowercase()
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/com/infomaniak/drive/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,18 @@ fun MaterialAutoCompleteTextView.setupAvailableShareableItems(
itemList: List<Shareable>,
notShareableIds: ArrayList<Int> = arrayListOf(),
notShareableEmails: ArrayList<String> = arrayListOf(),
onDataPassed: (item: Shareable) -> Unit
onDataPassed: (item: Shareable) -> Unit,
): AvailableShareableItemsAdapter {
setDropDownBackgroundResource(R.drawable.background_popup)
val availableUsersAdapter = AvailableShareableItemsAdapter(
context = context,
itemList = ArrayList(itemList),
notShareableIds = notShareableIds,
notShareableEmails = notShareableEmails
) { item ->
onDataPassed(item)
}
notShareableEmails = notShareableEmails,
getCurrentText = { text },
onItemClick = onDataPassed,
)

setAdapter(availableUsersAdapter)
handleActionDone { if (text.isNotBlank()) !availableUsersAdapter.addFirstAvailableItem() }

Expand Down
Loading