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

Team mentions #4678

Merged
merged 12 commits into from
Feb 7, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import android.content.Context
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.res.ResourcesCompat
import coil.Coil
import coil.request.ImageRequest
import com.nextcloud.talk.R
import com.nextcloud.talk.adapters.items.ParticipantItem.ParticipantItemViewHolder
import com.nextcloud.talk.data.user.model.User
Expand Down Expand Up @@ -165,6 +167,22 @@ class MentionAutocompleteItem(
}
}

SOURCE_TEAMS -> {
holder.binding.avatarView.post {
val imageViewWidth = holder.binding.avatarView.width
val imageViewHeight = holder.binding.avatarView.height

val request = ImageRequest.Builder(context)
.data(R.drawable.icon_team)
.size(imageViewWidth, imageViewHeight)
.scale(coil.size.Scale.FILL)
.target(holder.binding.avatarView)
.build()

Coil.imageLoader(context).enqueue(request)
}
}

else -> {
holder.binding.avatarView.loadUserAvatar(
currentUser,
Expand Down Expand Up @@ -237,6 +255,7 @@ class MentionAutocompleteItem(
const val SOURCE_GUESTS = "guests"
const val SOURCE_GROUPS = "groups"
const val SOURCE_EMAILS = "emails"
const val SOURCE_TEAMS = "teams"
const val SOURCE_FEDERATION = "federated_users"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.nextcloud.talk.extensions.loadDefaultAvatar
import com.nextcloud.talk.extensions.loadDefaultGroupCallAvatar
import com.nextcloud.talk.extensions.loadFederatedUserAvatar
import com.nextcloud.talk.extensions.loadFirstLetterAvatar
import com.nextcloud.talk.extensions.loadTeamAvatar
import com.nextcloud.talk.extensions.loadUserAvatar
import com.nextcloud.talk.models.domain.ConversationModel
import com.nextcloud.talk.models.json.participants.Participant
Expand Down Expand Up @@ -207,10 +208,14 @@ class ParticipantItem(

private fun loadAvatars(holder: ParticipantItemViewHolder) {
when (model.calculatedActorType) {
Participant.ActorType.GROUPS, Participant.ActorType.CIRCLES -> {
Participant.ActorType.GROUPS -> {
holder.binding.avatarView.loadDefaultGroupCallAvatar(viewThemeUtils)
}

Participant.ActorType.CIRCLES -> {
holder.binding.avatarView.loadTeamAvatar(viewThemeUtils)
}

Participant.ActorType.USERS -> {
holder.binding.avatarView.loadUserAvatar(user, model.calculatedActorId!!, true, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,8 @@ class MessageInputFragment : Fragment() {
mentionId.contains("@") ||
mentionId.startsWith("guest/") ||
sowjanyakch marked this conversation as resolved.
Show resolved Hide resolved
mentionId.startsWith("group/") ||
mentionId.startsWith("email/")
mentionId.startsWith("email/") ||
mentionId.startsWith("team/")
if (shouldQuote) {
mentionId = "\"" + mentionId + "\""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ fun ImageView.loadDefaultGroupCallAvatar(viewThemeUtils: ViewThemeUtils): io.rea
return loadUserAvatar(data)
}

fun ImageView.loadTeamAvatar(viewThemeUtils: ViewThemeUtils): io.reactivex.disposables.Disposable {
val data: Any = viewThemeUtils.talk.themePlaceholderAvatar(this, R.drawable.icon_team) as Any
return loadUserAvatar(data)
}

fun ImageView.loadDefaultAvatar(viewThemeUtils: ViewThemeUtils): io.reactivex.disposables.Disposable {
val data: Any = viewThemeUtils.talk.themePlaceholderAvatar(this, R.drawable.account_circle_96dp) as Any
return loadUserAvatar(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class ChatUtils {

if (individualHashMap != null) {
val type = individualHashMap["type"]
resultMessage = if (type == "user" || type == "guest" || type == "call" || type == "email") {
resultMessage = if (type == "user" || type == "guest" || type == "call" || type == "email" ||
type == "circle"
) {
resultMessage?.replace("{$key}", "@" + individualHashMap["name"])
} else if (type == "geo-location") {
individualHashMap["name"]
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ object DisplayUtils {
} else {
chip.setChipIconResource(R.drawable.ic_circular_group)
}
if (type == "circle" || type == "teams") {
chip.setChipIconResource(R.drawable.icon_team)
}
chip.setBounds(0, 0, chip.intrinsicWidth, chip.intrinsicHeight)
if (!isCallOrGroup) {
var url = getUrlForAvatar(conversationUser.baseUrl, id, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class MessageUtils(val context: Context) {
val individualHashMap = message.messageParameters!![key]
if (individualHashMap != null) {
when (individualHashMap["type"]) {
"user", "guest", "call", "user-group", "email" -> {
"user", "guest", "call", "user-group", "email", "circle" -> {
val chip = if (individualHashMap["id"] == message.activeUser!!.userId) {
R.xml.chip_you
} else {
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/drawable-night/icon_team.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
~ Nextcloud Talk - Android Client
~
~ SPDX-FileCopyrightText: 2018-2025 Google LLC
~ SPDX-License-Identifier: Apache-2.0
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="44"
android:viewportHeight="44">
<path
android:pathData="M22,22m-22,0a22,22 0,1 1,44 0a22,22 0,1 1,-44 0"
android:fillColor="#3b3b3b"/>
<path
android:pathData="M22,14.75A3.5,3.5 0,0 1,25.5 18.25,3.5 3.5,0 0,1 22,21.75 3.5,3.5 0,0 1,18.5 18.25,3.5 3.5,0 0,1 22,14.75M15,17.25c0.56,0 1.08,0.15 1.53,0.42 -0.15,1.43 0.27,2.85 1.13,3.96 -0.5,0.96 -1.5,1.62 -2.66,1.62A3,3 0,0 1,12 20.25,3 3,0 0,1 15,17.25m14,0A3,3 0,0 1,32 20.25,3 3,0 0,1 29,23.25c-1.16,0 -2.16,-0.66 -2.66,-1.62 0.86,-1.11 1.28,-2.53 1.13,-3.96C27.92,17.4 28.44,17.25 29,17.25M15.5,27.5C15.5,25.43 18.41,23.75 22,23.75 25.59,23.75 28.5,25.43 28.5,27.5v1.75h-13v-1.75m-5.5,1.75V27.75c0,-1.39 1.89,-2.56 4.45,-2.9C13.86,25.53 13.5,26.47 13.5,27.5v1.75H10m24,0h-3.5v-1.75C30.5,26.47 30.14,25.53 29.55,24.85 32.11,25.19 34,26.36 34,27.75Z"
android:strokeWidth="1.00001"
android:fillColor="#ffffff"/>
</vector>
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/icon_team.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
~ Nextcloud Talk - Android Client
~
~ SPDX-FileCopyrightText: 2018-2025 Google LLC
~ SPDX-License-Identifier: Apache-2.0
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="44"
android:viewportHeight="44">
<path
android:pathData="M22,22m-22,0a22,22 0,1 1,44 0a22,22 0,1 1,-44 0"
android:fillColor="#6B6B6B"/>
<path
android:pathData="M22,14.75A3.5,3.5 0,0 1,25.5 18.25,3.5 3.5,0 0,1 22,21.75 3.5,3.5 0,0 1,18.5 18.25,3.5 3.5,0 0,1 22,14.75M15,17.25c0.56,0 1.08,0.15 1.53,0.42C16.38,19.1 16.8,20.52 17.66,21.63 17.16,22.59 16.16,23.25 15,23.25a3,3 0,0 1,-3 -3,3 3,0 0,1 3,-3m14,0a3,3 0,0 1,3 3A3,3 0,0 1,29 23.25c-1.16,0 -2.16,-0.66 -2.66,-1.62C27.2,20.52 27.62,19.1 27.47,17.67 27.92,17.4 28.44,17.25 29,17.25M15.5,27.5c0,-2.07 2.91,-3.75 6.5,-3.75C25.59,23.75 28.5,25.43 28.5,27.5v1.75h-13V27.5M10,29.25V27.75c0,-1.39 1.89,-2.56 4.45,-2.9C13.86,25.53 13.5,26.47 13.5,27.5v1.75H10m24,0H30.5V27.5c0,-1.03 -0.36,-1.97 -0.95,-2.65C32.11,25.19 34,26.36 34,27.75Z"
android:strokeWidth="1.00001"
android:fillColor="#ffffff"/>
</vector>
2 changes: 1 addition & 1 deletion detekt.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: GPL-3.0-or-later
build:
maxIssues: 78
maxIssues: 80
weights:
# complexity: 2
# LongParameterList: 1
Expand Down
Loading