diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 2be3706269..b8acd95630 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -49,6 +49,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe // TODO: Selected message background color // TODO: Overflow menu background + text color + // TODO: Typing indicators private val adapter by lazy { val cursor = DatabaseFactory.getMmsSmsDatabase(this).getConversation(threadID) @@ -63,7 +64,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe }, onItemLongPress = { message, position -> handleLongPress(message, position) - } + }, + glide ) adapter } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt index 3a4ec7fa87..04723aa87a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt @@ -14,10 +14,12 @@ import org.thoughtcrime.securesms.database.CursorRecyclerViewAdapter import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.database.model.MessageRecord import org.thoughtcrime.securesms.loki.utilities.getColorWithID +import org.thoughtcrime.securesms.mms.GlideRequests import java.lang.IllegalStateException class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPress: (MessageRecord, Int, VisibleMessageView) -> Unit, - private val onItemSwipeToReply: (MessageRecord, Int) -> Unit, private val onItemLongPress: (MessageRecord, Int) -> Unit) + private val onItemSwipeToReply: (MessageRecord, Int) -> Unit, private val onItemLongPress: (MessageRecord, Int) -> Unit, + private val glide: GlideRequests) : CursorRecyclerViewAdapter(context, cursor) { private val messageDB = DatabaseFactory.getMmsSmsDatabase(context) var selectedItems = mutableSetOf() @@ -69,7 +71,7 @@ class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPr view.snIsSelected = isSelected view.messageTimestampTextView.isVisible = isSelected val position = viewHolder.adapterPosition - view.bind(message, getMessageBefore(position, cursor), getMessageAfter(position, cursor)) + view.bind(message, getMessageBefore(position, cursor), getMessageAfter(position, cursor), glide) view.onPress = { onItemPress(message, viewHolder.adapterPosition, view) } view.onSwipeToReply = { onItemSwipeToReply(message, viewHolder.adapterPosition) } view.onLongPress = { onItemLongPress(message, viewHolder.adapterPosition) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/LinkPreviewView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/LinkPreviewView.kt index 17bd350d5a..b5afcf56d1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/LinkPreviewView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/LinkPreviewView.kt @@ -1,12 +1,20 @@ package org.thoughtcrime.securesms.conversation.v2.messages import android.content.Context +import android.graphics.drawable.Drawable import android.util.AttributeSet import android.view.LayoutInflater +import android.view.ViewOutlineProvider import android.widget.LinearLayout +import com.bumptech.glide.load.engine.DiskCacheStrategy +import com.bumptech.glide.load.resource.bitmap.CenterCrop +import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions import kotlinx.android.synthetic.main.view_link_preview.view.* import network.loki.messenger.R -import org.thoughtcrime.securesms.database.model.MessageRecord +import org.thoughtcrime.securesms.database.model.MmsMessageRecord +import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri +import org.thoughtcrime.securesms.mms.GlideRequests +import org.thoughtcrime.securesms.mms.ImageSlide class LinkPreviewView : LinearLayout { @@ -21,8 +29,15 @@ class LinkPreviewView : LinearLayout { // endregion // region Updating - fun bind(message: MessageRecord) { - textView.text = "I'm a link preview" + fun bind(message: MmsMessageRecord, glide: GlideRequests) { + // Thumbnail + val linkPreview = message.linkPreviews.first() + // TODO: Handle downloading state + val uri = linkPreview.thumbnail.get().dataUri!! + glide.load(uri).into(thumbnailImageView) + // TODO: Properly use glide and the actual thumbnail + // Title + titleTextView.text = linkPreview.title } fun recycle() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/QuoteView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/QuoteView.kt index 6e6601877c..ea896c3580 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/QuoteView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/QuoteView.kt @@ -110,6 +110,9 @@ class QuoteView : LinearLayout { } else { attachments!! quoteViewAttachmentPreviewImageView.imageTintList = ColorStateList.valueOf(ResourcesCompat.getColor(resources, R.color.white, context.theme)) + val backgroundColorID = if (UiModeUtilities.isDayUiMode(context)) R.color.black else R.color.accent + val backgroundColor = ResourcesCompat.getColor(resources, backgroundColorID, context.theme) + quoteViewAttachmentPreviewContainer.backgroundTintList = ColorStateList.valueOf(backgroundColor) if (attachments.audioSlide != null) { quoteViewAttachmentPreviewImageView.setImageResource(R.drawable.ic_microphone) quoteViewBodyTextView.text = resources.getString(R.string.Slide_audio) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt index a7d707c69a..832f575933 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt @@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.loki.utilities.UiMode import org.thoughtcrime.securesms.loki.utilities.UiModeUtilities import org.thoughtcrime.securesms.loki.utilities.getColorWithID import org.thoughtcrime.securesms.loki.utilities.toPx +import org.thoughtcrime.securesms.mms.GlideRequests import java.lang.IllegalStateException class VisibleMessageContentView : LinearLayout { @@ -41,7 +42,7 @@ class VisibleMessageContentView : LinearLayout { // endregion // region Updating - fun bind(message: MessageRecord, isStartOfMessageCluster: Boolean, isEndOfMessageCluster: Boolean) { + fun bind(message: MessageRecord, isStartOfMessageCluster: Boolean, isEndOfMessageCluster: Boolean, glide: GlideRequests) { // Background val background = getBackground(message.isOutgoing, isStartOfMessageCluster, isEndOfMessageCluster) val colorID = if (message.isOutgoing) R.attr.message_sent_background_color else R.attr.message_received_background_color @@ -54,8 +55,10 @@ class VisibleMessageContentView : LinearLayout { onContentClick = null if (message is MmsMessageRecord && message.linkPreviews.isNotEmpty()) { val linkPreviewView = LinkPreviewView(context) - linkPreviewView.bind(message) + linkPreviewView.bind(message, glide) mainContainer.addView(linkPreviewView) + val bodyTextView = getBodyTextView(message) + mainContainer.addView(bodyTextView) } else if (message is MmsMessageRecord && message.quote != null) { val quote = message.quote!! val quoteView = QuoteView(context, QuoteView.Mode.Regular) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt index df57e44469..2b4a66ab91 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt @@ -25,6 +25,7 @@ import org.thoughtcrime.securesms.loki.utilities.disableClipping import org.thoughtcrime.securesms.loki.utilities.getColorWithID import org.thoughtcrime.securesms.loki.utilities.toDp import org.thoughtcrime.securesms.loki.utilities.toPx +import org.thoughtcrime.securesms.mms.GlideRequests import org.thoughtcrime.securesms.util.DateUtils import java.util.* import kotlin.math.abs @@ -66,7 +67,7 @@ class VisibleMessageView : LinearLayout { // endregion // region Updating - fun bind(message: MessageRecord, previous: MessageRecord?, next: MessageRecord?) { + fun bind(message: MessageRecord, previous: MessageRecord?, next: MessageRecord?, glide: GlideRequests) { val sender = message.individualRecipient val senderSessionID = sender.address.serialize() val threadID = message.threadId @@ -113,7 +114,7 @@ class VisibleMessageView : LinearLayout { val gravity = if (message.isOutgoing) Gravity.RIGHT else Gravity.LEFT mainContainer.gravity = gravity or Gravity.BOTTOM // Populate content view - messageContentView.bind(message, isStartOfMessageCluster, isEndOfMessageCluster) + messageContentView.bind(message, isStartOfMessageCluster, isEndOfMessageCluster, glide) } private fun setMessageSpacing(isStartOfMessageCluster: Boolean, isEndOfMessageCluster: Boolean) { diff --git a/app/src/main/res/layout/view_link_preview.xml b/app/src/main/res/layout/view_link_preview.xml index e54f8e930c..46790cae76 100644 --- a/app/src/main/res/layout/view_link_preview.xml +++ b/app/src/main/res/layout/view_link_preview.xml @@ -1,16 +1,31 @@ + + + android:layout_height="match_parent" + android:paddingStart="12dp" + android:gravity="center_vertical" + android:textSize="@dimen/small_font_size" + android:textStyle="bold" + tools:text="The Day The Dinosaurs Died - Minute by Minute" + android:maxLines="3" + android:ellipsize="end" + android:textColor="@color/text" + android:background="@color/link_preview_background" /> \ No newline at end of file diff --git a/app/src/main/res/values-notnight-v21/colors.xml b/app/src/main/res/values-notnight-v21/colors.xml index 02e903de96..ad3eeb6c27 100644 --- a/app/src/main/res/values-notnight-v21/colors.xml +++ b/app/src/main/res/values-notnight-v21/colors.xml @@ -28,6 +28,7 @@ #66000000 #FCFCFC #DFDFDF + #0F000000 #ffffff #fcfcfc diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 5ab72d4a44..86f18d6d60 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -35,6 +35,7 @@ #66FFFFFF #171717 #0C0C0C + #000000 #5ff8b0