Skip to content

Commit e982864

Browse files
authored
Merge pull request #5131 from nextcloud/fix_autocomplete
Fix mentions of phone conversation
2 parents 5704be6 + 61c0490 commit e982864

File tree

7 files changed

+115
-9
lines changed

7 files changed

+115
-9
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Nextcloud Talk - Android Client
3+
*
4+
* SPDX-FileCopyrightText: 2025 Sowjanya Kota <[email protected]>
5+
* SPDX-License-Identifier: GPL-3.0-or-later
6+
*/
7+
8+
package com.nextcloud.talk
9+
10+
object PhoneUtils {
11+
fun isPhoneNumber(input: String?): Boolean {
12+
return input?.matches(Regex("^\\+?\\d+$")) == true
13+
}
14+
}

app/src/main/java/com/nextcloud/talk/adapters/items/MentionAutocompleteItem.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
1515
import androidx.core.content.res.ResourcesCompat
1616
import coil.Coil
1717
import coil.request.ImageRequest
18+
import com.nextcloud.talk.PhoneUtils.isPhoneNumber
1819
import com.nextcloud.talk.R
1920
import com.nextcloud.talk.adapters.items.ParticipantItem.ParticipantItemViewHolder
2021
import com.nextcloud.talk.data.user.model.User
@@ -129,14 +130,22 @@ class MentionAutocompleteItem(
129130
private fun setAvatar(holder: ParticipantItemViewHolder, objectId: String?) {
130131
when (source) {
131132
SOURCE_CALLS -> {
132-
run {}
133133
run {
134-
holder.binding.avatarView.loadUserAvatar(
135-
viewThemeUtils.talk.themePlaceholderAvatar(
136-
holder.binding.avatarView,
137-
R.drawable.ic_avatar_group
134+
if (isPhoneNumber(displayName)) {
135+
holder.binding.avatarView.loadUserAvatar(
136+
viewThemeUtils.talk.themePlaceholderAvatar(
137+
holder.binding.avatarView,
138+
R.drawable.ic_phone_small
139+
)
138140
)
139-
)
141+
} else {
142+
holder.binding.avatarView.loadUserAvatar(
143+
viewThemeUtils.talk.themePlaceholderAvatar(
144+
holder.binding.avatarView,
145+
R.drawable.ic_avatar_group
146+
)
147+
)
148+
}
140149
}
141150
}
142151

app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import coil.request.ImageRequest
5454
import coil.target.Target
5555
import coil.transform.CircleCropTransformation
5656
import com.google.android.material.chip.ChipDrawable
57+
import com.nextcloud.talk.PhoneUtils.isPhoneNumber
5758
import com.nextcloud.talk.R
5859
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
5960
import com.nextcloud.talk.data.user.model.User
@@ -162,8 +163,9 @@ object DisplayUtils {
162163
val config = context.resources.configuration
163164
chip.setLayoutDirection(config.layoutDirection)
164165
val drawable: Int
165-
val isCallOrGroup = "call" == type || "calls" == type || "groups" == type || "user-group" == type
166-
if (!isCallOrGroup) {
166+
val isCall = "call" == type || "calls" == type
167+
val isGroup = "groups" == type || "user-group" == type
168+
if (!isGroup && !isCall) {
167169
drawable = if (chipResource == R.xml.chip_you) {
168170
R.drawable.mention_chip
169171
} else {
@@ -176,8 +178,12 @@ object DisplayUtils {
176178
if (type == "circle" || type == "teams") {
177179
chip.setChipIconResource(R.drawable.icon_team)
178180
}
181+
182+
if (isCall && isPhoneNumber(label.toString())) {
183+
chip.setChipIconResource(R.drawable.icon_circular_phone)
184+
}
179185
chip.setBounds(0, 0, chip.intrinsicWidth, chip.intrinsicHeight)
180-
if (!isCallOrGroup) {
186+
if (!isGroup) {
181187
var url = getUrlForAvatar(conversationUser.baseUrl, id, false)
182188
if ("guests" == type || "guest" == type || "email" == type) {
183189
url = getUrlForGuestAvatar(
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--
2+
~ Nextcloud Talk - Android Client
3+
~
4+
~ SPDX-FileCopyrightText: 2018-2025 Google LLC
5+
~ SPDX-License-Identifier: Apache-2.0
6+
-->
7+
8+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
9+
android:width="48dp"
10+
android:height="48dp"
11+
android:viewportWidth="24"
12+
android:viewportHeight="24">
13+
14+
<path
15+
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2z"
16+
android:fillColor="#3B3B3B" />
17+
18+
<group
19+
android:scaleX="0.55"
20+
android:scaleY="0.55"
21+
android:pivotX="12"
22+
android:pivotY="12">
23+
<path
24+
android:pathData="M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38l2.2,-2.2c0.27,-0.27 0.67,-0.36 1.02,-0.24 1.12,0.37 2.33,0.57 3.57,0.57 0.55,0 1,0.45 1,1v3.5c0,0.55 -0.45,1 -1,1C10.07,21 3,13.93 3,5.5 3,4.95 3.45,4.5 4,4.5H7.5c0.55,0 1,0.45 1,1 0,1.24 0.2,2.45 0.57,3.57 0.11,0.35 0.03,0.74 -0.25,1.02l-2.2,2.2z"
25+
android:fillColor="#FFFFFF" />
26+
</group>
27+
</vector>

app/src/main/res/drawable/ic_phone.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
android:fillColor="@android:color/white"
1515
android:pathData="M798,840Q673,840 551,785.5Q429,731 329,631Q229,531 174.5,409Q120,287 120,162Q120,144 132,132Q144,120 162,120L324,120Q338,120 349,129.5Q360,139 362,152L388,292Q390,308 387,319Q384,330 376,338L279,436Q299,473 326.5,507.5Q354,542 387,574Q418,605 452,631.5Q486,658 524,680L618,586Q627,577 641.5,572.5Q656,568 670,570L808,598Q822,602 831,612.5Q840,623 840,636L840,798Q840,816 828,828Q816,840 798,840ZM241,360L307,294Q307,294 307,294Q307,294 307,294L290,200Q290,200 290,200Q290,200 290,200L201,200Q201,200 201,200Q201,200 201,200Q206,241 215,281Q224,321 241,360ZM599,718Q638,735 678.5,745Q719,755 760,758Q760,758 760,758Q760,758 760,758L760,670Q760,670 760,670Q760,670 760,670L666,651Q666,651 666,651Q666,651 666,651L599,718ZM241,360Q241,360 241,360Q241,360 241,360Q241,360 241,360Q241,360 241,360L241,360Q241,360 241,360Q241,360 241,360L241,360Q241,360 241,360Q241,360 241,360ZM599,718L599,718Q599,718 599,718Q599,718 599,718L599,718Q599,718 599,718Q599,718 599,718L599,718Q599,718 599,718Q599,718 599,718Q599,718 599,718Q599,718 599,718Z" />
1616
</vector>
17+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
~ Nextcloud Talk - Android Client
3+
~
4+
~ SPDX-FileCopyrightText: 2018-2025 Google LLC
5+
~ SPDX-License-Identifier: Apache-2.0
6+
-->
7+
8+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
9+
android:width="24dp"
10+
android:height="24dp"
11+
android:viewportWidth="960"
12+
android:viewportHeight="960">
13+
<group
14+
android:pivotX="480"
15+
android:pivotY="480"
16+
android:scaleX="0.6"
17+
android:scaleY="0.6">
18+
<path
19+
android:fillColor="@android:color/white"
20+
android:pathData="M798,840Q673,840 551,785.5Q429,731 329,631Q229,531 174.5,409Q120,287 120,162Q120,144 132,132Q144,120 162,120L324,120Q338,120 349,129.5Q360,139 362,152L388,292Q390,308 387,319Q384,330 376,338L279,436Q299,473 326.5,507.5Q354,542 387,574Q418,605 452,631.5Q486,658 524,680L618,586Q627,577 641.5,572.5Q656,568 670,570L808,598Q822,602 831,612.5Q840,623 840,636L840,798Q840,816 828,828Q816,840 798,840Z" />
21+
</group>
22+
</vector>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--
2+
~ Nextcloud Talk - Android Client
3+
~
4+
~ SPDX-FileCopyrightText: 2018-2025 Google LLC
5+
~ SPDX-License-Identifier: Apache-2.0
6+
-->
7+
8+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
9+
android:width="24dp"
10+
android:height="24dp"
11+
android:viewportWidth="24"
12+
android:viewportHeight="24">
13+
14+
<path
15+
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2z"
16+
android:fillColor="#6B6B6B" />
17+
18+
<group
19+
android:scaleX="0.55"
20+
android:scaleY="0.55"
21+
android:pivotX="12"
22+
android:pivotY="12">
23+
<path
24+
android:pathData="M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38l2.2,-2.2c0.27,-0.27 0.67,-0.36 1.02,-0.24 1.12,0.37 2.33,0.57 3.57,0.57 0.55,0 1,0.45 1,1v3.5c0,0.55 -0.45,1 -1,1C10.07,21 3,13.93 3,5.5 3,4.95 3.45,4.5 4,4.5H7.5c0.55,0 1,0.45 1,1 0,1.24 0.2,2.45 0.57,3.57 0.11,0.35 0.03,0.74 -0.25,1.02l-2.2,2.2z"
25+
android:fillColor="#FFFFFF" />
26+
</group>
27+
</vector>

0 commit comments

Comments
 (0)