mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-08 15:09:49 +00:00
Merge pull request #2493 from nextcloud/feature/noid/improveLinkPreviews
improve link preview design, add link description
This commit is contained in:
commit
842dcfbb70
app/src/main
@ -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://"
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
Loading…
Reference in New Issue
Block a user