mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Add support for received call link previews.
This commit is contained in:
@@ -7,12 +7,16 @@ package org.thoughtcrime.securesms.calls.links
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.appcompat.widget.LinearLayoutCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import org.thoughtcrime.securesms.R
|
||||
|
||||
/**
|
||||
* ConversationItem action button for joining a call link.
|
||||
*/
|
||||
class CallLinkJoinButton @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
@@ -22,10 +26,19 @@ class CallLinkJoinButton @JvmOverloads constructor(
|
||||
inflate(context, R.layout.call_link_join_button, this)
|
||||
}
|
||||
|
||||
private val joinStroke: View = findViewById(R.id.join_stroke)
|
||||
private val joinButton: MaterialButton = findViewById(R.id.join_button)
|
||||
|
||||
fun setTextColor(@ColorRes textColorResId: Int) {
|
||||
joinButton.setTextColor(ContextCompat.getColor(context, textColorResId))
|
||||
val color = ContextCompat.getColor(context, textColorResId)
|
||||
|
||||
joinButton.setTextColor(color)
|
||||
}
|
||||
|
||||
fun setStrokeColor(@ColorRes strokeColorResId: Int) {
|
||||
val color = ContextCompat.getColor(context, strokeColorResId)
|
||||
|
||||
joinStroke.setBackgroundColor(color)
|
||||
}
|
||||
|
||||
fun setJoinClickListener(onClickListener: OnClickListener) {
|
||||
|
||||
@@ -1153,7 +1153,8 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
CallLinkRootKey callLinkRootKey = CallLinks.parseUrl(linkPreview.getUrl());
|
||||
if (callLinkRootKey != null) {
|
||||
joinCallLinkStub.setVisibility(View.VISIBLE);
|
||||
joinCallLinkStub.get().setTextColor(messageRecord.isOutgoing() ? R.color.signal_colorOnCustom : R.color.signal_colorOnSurface);
|
||||
joinCallLinkStub.get().setTextColor(messageRecord.isOutgoing() ? R.color.signal_colorOnCustom : R.color.signal_colorPrimary);
|
||||
joinCallLinkStub.get().setStrokeColor(messageRecord.isOutgoing() ? R.color.signal_colorOnCustom : R.color.signal_colorOutline);
|
||||
joinCallLinkStub.get().setJoinClickListener(v -> {
|
||||
if (eventListener != null) {
|
||||
eventListener.onJoinCallLink(callLinkRootKey);
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.thoughtcrime.securesms.attachments.Attachment
|
||||
import org.thoughtcrime.securesms.attachments.PointerAttachment
|
||||
import org.thoughtcrime.securesms.attachments.TombstoneAttachment
|
||||
import org.thoughtcrime.securesms.attachments.UriAttachment
|
||||
import org.thoughtcrime.securesms.calls.links.CallLinks
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiUtil
|
||||
import org.thoughtcrime.securesms.contactshare.Contact
|
||||
import org.thoughtcrime.securesms.contactshare.ContactModelMapper
|
||||
@@ -1117,8 +1118,9 @@ object DataMessageProcessor {
|
||||
val hasTitle = !TextUtils.isEmpty(title.orElse(""))
|
||||
val presentInBody = url.isPresent && urlsInMessage.containsUrl(url.get())
|
||||
val validDomain = url.isPresent && LinkUtil.isValidPreviewUrl(url.get())
|
||||
val isForCallLink = url.isPresent && CallLinks.isCallLink(url.get())
|
||||
|
||||
if (hasTitle && (presentInBody || isStoryEmbed) && validDomain) {
|
||||
if ((hasTitle || isForCallLink) && (presentInBody || isStoryEmbed) && validDomain) {
|
||||
val linkPreview = LinkPreview(url.get(), title.orElse(""), description.orElse(""), preview.date, thumbnail.toOptional())
|
||||
linkPreview
|
||||
} else {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<View
|
||||
android:id="@+id/join_stroke"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginStart="12dp"
|
||||
|
||||
Reference in New Issue
Block a user