Skip to content
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 @@ -93,7 +93,7 @@ class MentionAutocompleteAdapter(
)
viewThemeUtils.talk.themeAndHighlightText(
holder.binding.secondaryText,
"@${item.objectId}",
secondaryText(item),
filterQuery
)
} else {
Expand All @@ -104,6 +104,9 @@ class MentionAutocompleteAdapter(
drawStatus(holder, item)
}

private fun secondaryText(item: MentionAutocompleteItem): String =
secondaryText(item.source, item.objectId, context.resources.getString(R.string.nc_team))

private fun setAvatar(holder: ViewHolder, item: MentionAutocompleteItem) {
val avatarView = holder.binding.avatarView
when (item.source) {
Expand Down Expand Up @@ -188,5 +191,13 @@ class MentionAutocompleteAdapter(
private const val STATUS_SIZE_IN_DP = 9f
private const val NO_ICON = ""
private const val NO_USER_STATUS_DP_FROM_TOP: Float = 10f

// Teams use a "team/<id>" objectId that should not be exposed; show "Team" like the web client does.
fun secondaryText(source: String?, objectId: String?, teamLabel: String): String =
if (source == SOURCE_TEAMS) {
teamLabel
} else {
"@$objectId"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.nextcloud.talk.chat

import com.nextcloud.talk.adapters.items.MentionAutocompleteItem.Companion.SOURCE_TEAMS
import org.junit.Assert.assertEquals
import org.junit.Test

class MentionAutocompleteAdapterTest {

@Test
fun teamSourceShowsTeamLabelInsteadOfObjectId() {
assertEquals(
"Team",
MentionAutocompleteAdapter.secondaryText(SOURCE_TEAMS, "team/RFu2UR8oOhEaI6OKUlQ", "Team")
)
}

@Test
fun nonTeamSourceShowsMentionHandle() {
assertEquals(
"@admin",
MentionAutocompleteAdapter.secondaryText("users", "admin", "Team")
)
}
}
Loading