Skip to content

Commit b73037c

Browse files
Fix edge cases: Share Link, Translation, and Call Recording button
Signed-off-by: thirumani-vihaan <arjunthirumani02@gmail.com>
1 parent a0fe8a1 commit b73037c

9 files changed

Lines changed: 56 additions & 21 deletions

File tree

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
* Stefan Niedermann <info@niedermann.it>
5353
* Stephan Ritscher <no3pam@gmail.com>
5454
* Tarek Loubani <tarek@tarek.org>
55+
* thirumani-vihaan <arjunthirumani02@gmail.com>
5556
* Tilo Spannagel <development@tilosp.de>
5657
* Tim Krüger <t@timkrueger.me>
5758
* Tobias Kaminsky <tobias@kaminsky.me>

app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3154,10 +3154,15 @@ class CallActivity : CallBaseActivity() {
31543154
}
31553155

31563156
val isAllowedToStartOrStopRecording: Boolean
3157-
get() = (
3158-
isCallRecordingAvailable(conversationUser!!.capabilities!!.spreedCapability!!) &&
3159-
isModerator
3160-
)
3157+
get() {
3158+
val spreedCap = conversationUser.capabilities?.spreedCapability
3159+
val isClassified = currentConversation?.let {
3160+
com.nextcloud.talk.utils.ConversationUtils.isClassified(it, spreedCap)
3161+
} ?: false
3162+
return isCallRecordingAvailable(conversationUser.capabilities!!.spreedCapability!!) &&
3163+
isModerator &&
3164+
!isClassified
3165+
}
31613166
val isAllowedToRaiseHand: Boolean
31623167
get() = hasSpreedFeatureCapability(
31633168
conversationUser.capabilities!!.spreedCapability!!,

app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,9 @@ class ChatActivity :
19101910
val isOneToOne = isOneToOneConversation()
19111911
val capabilitiesReady = ::spreedCapabilities.isInitialized
19121912

1913-
val isClassified = conversation != null && capabilitiesReady && ConversationUtils.isClassified(conversation, spreedCapabilities)
1913+
val isClassified = conversation != null &&
1914+
capabilitiesReady &&
1915+
ConversationUtils.isClassified(conversation, spreedCapabilities)
19141916
chatToolbarState = chatToolbarState.copy(
19151917
title = buildToolbarTitle(conversation),
19161918
subtitle = buildToolbarSubtitle(conversation),

app/src/main/java/com/nextcloud/talk/chat/MessageInputFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ class MessageInputFragment : Fragment() {
331331

332332
override fun onSuccess(result: Drawable) {
333333
binding.fragmentCallStarted.callAuthorChip.chipIcon = result
334-
335334
}
336335
})
337336
.build()

app/src/main/java/com/nextcloud/talk/chat/ui/ChatToolbar.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import androidx.compose.animation.core.tween
3030
import androidx.compose.foundation.layout.padding
3131
import androidx.compose.foundation.shape.CircleShape
3232
import androidx.compose.foundation.shape.RoundedCornerShape
33-
import androidx.compose.ui.graphics.Color
3433
import androidx.compose.foundation.text.BasicTextField
3534
import androidx.compose.foundation.text.KeyboardActions
3635
import androidx.compose.foundation.text.KeyboardOptions
@@ -333,12 +332,12 @@ private fun ConversationHeader(state: ChatToolbarState, onClick: (() -> Unit)?)
333332
)
334333
Surface(
335334
modifier = Modifier.padding(top = 2.dp),
336-
color = Color.Red.copy(alpha = alpha),
335+
color = MaterialTheme.colorScheme.error.copy(alpha = alpha),
337336
shape = RoundedCornerShape(4.dp)
338337
) {
339338
Text(
340339
text = "🛡️ Classified conversation",
341-
color = Color.White,
340+
color = MaterialTheme.colorScheme.onError,
342341
fontSize = 10.sp,
343342
modifier = Modifier.padding(horizontal = 4.dp, vertical = 2.dp)
344343
)

app/src/main/java/com/nextcloud/talk/chat/ui/MessageActionsBottomSheet.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ internal fun buildMessageActionsState(
225225
val hasUserId = user?.userId?.isNotEmpty() == true && user.userId != "?"
226226
val hasUserActorId = message.actorType == "users" && message.actorId != conversation?.actorId
227227

228+
val isClassifiedRoom = conversation != null && ConversationUtils.isClassified(conversation, spreedCapabilities)
229+
228230
return MessageActionsState(
229231
showEmojiBar = showEmojiBar,
230232
selfReactions = message.reactionsSelf?.toSet() ?: emptySet(),
@@ -237,12 +239,12 @@ internal fun buildMessageActionsState(
237239
hasUserActorId &&
238240
conversation?.type != ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL &&
239241
isOnline &&
240-
!(conversation != null && ConversationUtils.isClassified(conversation, spreedCapabilities)),
242+
!isClassifiedRoom,
241243
showOpenThread = message.isThread && conversationThreadId == null,
242244
showForward = ChatMessage.MessageType.REGULAR_TEXT_MESSAGE == messageType &&
243245
!(message.isDeletedCommentMessage || message.isDeleted) &&
244246
isOnline &&
245-
!(conversation != null && ConversationUtils.isClassified(conversation, spreedCapabilities)),
247+
!isClassifiedRoom,
246248
showEdit = isMessageEditable,
247249
showCopy = !message.isDeleted,
248250
showCopyMessageLink = !message.isDeleted &&
@@ -261,10 +263,12 @@ internal fun buildMessageActionsState(
261263
showTranslate = !message.isDeleted &&
262264
ChatMessage.MessageType.REGULAR_TEXT_MESSAGE == messageType &&
263265
CapabilitiesUtil.isTranslationsSupported(spreedCapabilities) &&
264-
isOnline,
266+
isOnline &&
267+
!isClassifiedRoom,
265268
showShareToNote = !message.isDeleted &&
266269
!ConversationUtils.isNoteToSelfConversation(conversation) &&
267-
isOnline,
270+
isOnline &&
271+
!isClassifiedRoom,
268272
showShare = messageHasFileAttachment || (messageHasRegularText && isOnline),
269273
showSave = messageHasFileAttachment,
270274
showOpenInFiles = messageHasFileAttachment && isOnline,

app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,10 +1050,27 @@ class ChatViewModel @AssistedInject constructor(
10501050
expandedSystemMessageParents
10511051
) { messages, lastCommonRead, parentMap, convAndCaps, expandedParents ->
10521052
val (conversation, capabilities) = convAndCaps
1053-
CombinedInput(messages, lastCommonRead, parentMap, conversation.lastReadMessage, expandedParents, conversation, capabilities)
1053+
CombinedInput(
1054+
messages,
1055+
lastCommonRead,
1056+
parentMap,
1057+
conversation.lastReadMessage,
1058+
expandedParents,
1059+
conversation,
1060+
capabilities
1061+
)
10541062
}
10551063
.debounce(MESSAGES_REBUILD_DEBOUNCE_MS)
1056-
.map { (messages, lastCommonRead, parentMap, conversationLastRead, expandedParents, conversation, capabilities) ->
1064+
.map { input ->
1065+
val (
1066+
messages,
1067+
lastCommonRead,
1068+
parentMap,
1069+
conversationLastRead,
1070+
expandedParents,
1071+
conversation,
1072+
capabilities
1073+
) = input
10571074
val messageMap: Map<Long, ChatMessage> = messages.associateBy { it.jsonMessageId.toLong() }
10581075
val combinedMap: Map<Long, ChatMessage> = messageMap + parentMap
10591076

app/src/main/java/com/nextcloud/talk/conversationinfo/viewmodel/ConversationInfoViewModel.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ class ConversationInfoViewModel @Inject constructor(
345345
val recordingConsentType = CapabilitiesUtil.getRecordingConsentType(spreedCapabilities)
346346
val showRecordingConsent = isModerator &&
347347
!isNoteToSelf &&
348-
recordingConsentType != CapabilitiesUtil.RECORDING_CONSENT_NOT_REQUIRED && !isClassified
348+
recordingConsentType != CapabilitiesUtil.RECORDING_CONSENT_NOT_REQUIRED &&
349+
!isClassified
349350
val showRecordingConsentSwitch =
350351
showRecordingConsent && recordingConsentType == CapabilitiesUtil.RECORDING_CONSENT_DEPEND_ON_CONVERSATION
351352
val showRecordingConsentAll =
@@ -373,7 +374,8 @@ class ConversationInfoViewModel @Inject constructor(
373374
val hasPassword = guestsAllowed && conversationModel.hasPassword
374375
val showPasswordProtection = guestsAllowed
375376
val showResendInvitations = guestsAllowed &&
376-
user.capabilities?.spreedCapability?.features?.contains("sip-support") == true && !isClassified
377+
user.capabilities?.spreedCapability?.features?.contains("sip-support") == true &&
378+
!isClassified
377379

378380
val showSharedItems = hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.RICH_OBJECT_LIST_MEDIA) &&
379381
conversationModel.remoteServer.isNullOrEmpty()
@@ -382,7 +384,8 @@ class ConversationInfoViewModel @Inject constructor(
382384
val isWebinarRoom = isGroup || isPublic
383385
val showWebinarSettings = hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.WEBINARY_LOBBY) &&
384386
isWebinarRoom &&
385-
canModerate && !isClassified
387+
canModerate &&
388+
!isClassified
386389

387390
val showImportantConversation =
388391
hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.IMPORTANT_CONVERSATIONS)
@@ -413,7 +416,7 @@ class ConversationInfoViewModel @Inject constructor(
413416
}
414417

415418
val showEditButton = canModerate && hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.AVATAR)
416-
val showShareConversationButton = !isNoteToSelf
419+
val showShareConversationButton = !isNoteToSelf && !isClassified
417420
val showListBans = canModerate && !isOne2One
418421
val showMessageExpiration = isModerator &&
419422
hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.MESSAGE_EXPIRATION)

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.nextcloud.talk.models.json.participants.Participant
1313

1414
object ConversationUtils {
1515
private val TAG = ConversationUtils::class.java.simpleName
16+
private const val CLASSIFIED_ATTRIBUTE_BIT = 4
1617

1718
fun isPublic(conversation: ConversationModel): Boolean =
1819
ConversationEnums.ConversationType.ROOM_PUBLIC_CALL == conversation.type
@@ -59,10 +60,14 @@ object ConversationUtils {
5960
currentConversation != null &&
6061
currentConversation.type == ConversationEnums.ConversationType.NOTE_TO_SELF
6162

63+
fun isClassified(conversation: ConversationModel, spreedCapabilities: SpreedCapability?): Boolean =
64+
CapabilitiesUtil.hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.CLASSIFIED_CONVERSATIONS) &&
65+
((conversation.attributes ?: 0) and CLASSIFIED_ATTRIBUTE_BIT) != 0
66+
6267
fun isClassified(
63-
conversation: ConversationModel,
68+
conversation: com.nextcloud.talk.models.json.conversations.Conversation,
6469
spreedCapabilities: SpreedCapability?
6570
): Boolean =
6671
CapabilitiesUtil.hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.CLASSIFIED_CONVERSATIONS) &&
67-
((conversation.attributes ?: 0) and 4) != 0
72+
((conversation.attributes ?: 0) and CLASSIFIED_ATTRIBUTE_BIT) != 0
6873
}

0 commit comments

Comments
 (0)