Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/talk-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMarcel Hibbe <dev@mhibbe.de>2022-10-14 00:52:49 +0300
committerMarcel Hibbe <dev@mhibbe.de>2022-10-14 00:52:49 +0300
commit84ba72f130e690fff535713c3d57f7360a304ccd (patch)
treecbaec84c24f9bff038a089ea625f4cf2794da2d7 /app
parenta17acc779c265c9b893aee75058820bc9ef2cedb (diff)
improve link preview design, add link description
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/nextcloud/talk/adapters/messages/LinkPreview.kt16
-rw-r--r--app/src/main/res/layout/reference_inside_message.xml40
2 files changed, 49 insertions, 7 deletions
diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/LinkPreview.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/LinkPreview.kt
index 9f5b572ed..5a80b08ef 100644
--- a/app/src/main/java/com/nextcloud/talk/adapters/messages/LinkPreview.kt
+++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/LinkPreview.kt
@@ -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://"
}
}
diff --git a/app/src/main/res/layout/reference_inside_message.xml b/app/src/main/res/layout/reference_inside_message.xml
index 4e87579a1..681ee1b8c 100644
--- a/app/src/main/res/layout/reference_inside_message.xml
+++ b/app/src/main/res/layout/reference_inside_message.xml
@@ -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> \ No newline at end of file