1
0
mirror of https://github.com/nextcloud/talk-android synced 2025-03-08 15:09:49 +00:00

Merge pull request from nextcloud/feature/noid/improveLinkPreviews

improve link preview design, add link description
This commit is contained in:
Andy Scherzinger 2022-10-14 16:23:25 +02:00 committed by GitHub
commit 842dcfbb70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 7 deletions
app/src/main
java/com/nextcloud/talk/adapters/messages
res/layout

View File

@ -73,10 +73,18 @@ class LinkPreview {
binding.referenceName.visibility = View.GONE
}
val referenceDescription = reference.openGraphObject?.description
if (!referenceDescription.isNullOrEmpty()) {
binding.referenceDescription.visibility = View.VISIBLE
binding.referenceDescription.text = referenceDescription
} else {
binding.referenceDescription.visibility = View.GONE
}
val referenceLink = reference.openGraphObject?.link
if (!referenceLink.isNullOrEmpty()) {
binding.referenceLink.visibility = View.VISIBLE
binding.referenceLink.text = referenceLink
binding.referenceLink.text = referenceLink.replace(HTTPS_PROTOCOL, "")
} else {
binding.referenceLink.visibility = View.GONE
}
@ -104,6 +112,11 @@ class LinkPreview {
override fun onError(e: Throwable) {
Log.e(TAG, "failed to get openGraph data", e)
binding.referenceName.visibility = View.GONE
binding.referenceDescription.visibility = View.GONE
binding.referenceLink.visibility = View.GONE
binding.referenceThumbImage.visibility = View.GONE
binding.referenceIndentedSideBar.visibility = View.GONE
}
override fun onComplete() {
@ -115,5 +128,6 @@ class LinkPreview {
companion object {
private val TAG = LinkPreview::class.java.simpleName
private const val HTTPS_PROTOCOL = "https://"
}
}

View File

@ -27,11 +27,11 @@
android:layout_marginTop="5dp">
<View
android:id="@+id/referenceColoredView"
android:id="@+id/referenceIndentedSideBar"
android:layout_width="2dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:background="@color/high_emphasis_text"
android:background="@color/low_emphasis_text"
tools:layout_height="100dp"/>
<androidx.emoji.widget.EmojiTextView
@ -42,10 +42,15 @@
android:textAlignment="viewStart"
android:textIsSelectable="false"
android:layout_marginStart="10dp"
tools:text="Name of Website" />
android:visibility="gone"
android:ellipsize="end"
android:maxLines="2"
android:textStyle="bold"
tools:text="Name of Website"
tools:visibility="visible"/>
<androidx.emoji.widget.EmojiTextView
android:id="@+id/referenceLink"
android:id="@+id/referenceDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/referenceName"
@ -53,7 +58,28 @@
android:textAlignment="viewStart"
android:textIsSelectable="false"
android:layout_marginStart="10dp"
tools:text="http://nextcloud.com" />
android:visibility="gone"
android:ellipsize="end"
android:maxLines="2"
tools:text="Description of Website"
tools:visibility="visible"/>
<androidx.emoji.widget.EmojiTextView
android:id="@+id/referenceLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/referenceDescription"
android:lineSpacingMultiplier="1.2"
android:textAlignment="viewStart"
android:textIsSelectable="false"
android:layout_marginStart="10dp"
android:textColor="@color/medium_emphasis_text"
android:singleLine="true"
android:lines="1"
android:ellipsize="end"
android:visibility="gone"
tools:text="http://nextcloud.com"
tools:visibility="visible"/>
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/referenceThumbImage"
@ -63,5 +89,7 @@
android:layout_below="@id/referenceLink"
android:layout_marginTop="5dp"
android:layout_marginStart="10dp"
app:roundedCornerRadius="6dp" />
android:visibility="gone"
app:roundedCornerRadius="6dp"
tools:visibility="visible"/>
</RelativeLayout>