mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-22 21:19:31 +01:00
Improve previews
This commit is contained in:
parent
2d3e255f97
commit
b265994031
@ -27,7 +27,6 @@ import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Handler
|
||||
import android.view.View
|
||||
import androidx.emoji.widget.EmojiTextView
|
||||
import butterknife.BindView
|
||||
@ -89,6 +88,7 @@ class MagicPreviewMessageViewHolder(itemView: View?) : IncomingImageMessageViewH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (message.messageType == SINGLE_NC_ATTACHMENT_MESSAGE) {
|
||||
// it's a preview for a Nextcloud share
|
||||
|
||||
@ -99,8 +99,9 @@ class MagicPreviewMessageViewHolder(itemView: View?) : IncomingImageMessageViewH
|
||||
)
|
||||
|
||||
if (message.getSelectedIndividualHashMap().containsKey("mimetype")) {
|
||||
// we now handle this directly in imageloader
|
||||
//image.load(getDrawableResourceIdForMimeType(message.getSelectedIndividualHashMap().get ("mimetype")))
|
||||
if (message.imageUrl == "no-preview") {
|
||||
image.load(getDrawableResourceIdForMimeType(message.getSelectedIndividualHashMap()["mimetype"]))
|
||||
}
|
||||
} else {
|
||||
fetchFileInformation(
|
||||
"/" + message.getSelectedIndividualHashMap()["path"],
|
||||
@ -187,11 +188,8 @@ class MagicPreviewMessageViewHolder(itemView: View?) : IncomingImageMessageViewH
|
||||
if (davResponse.data != null) {
|
||||
val browserFileList =
|
||||
davResponse.data as List<BrowserFile>
|
||||
if (!browserFileList.isEmpty()) {
|
||||
Handler(context.mainLooper)
|
||||
.post {
|
||||
image.load(getDrawableResourceIdForMimeType(browserFileList[0].mimeType))
|
||||
}
|
||||
if (browserFileList.isNotEmpty()) {
|
||||
image.load(getDrawableResourceIdForMimeType(browserFileList[0].mimeType))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -202,10 +200,13 @@ class MagicPreviewMessageViewHolder(itemView: View?) : IncomingImageMessageViewH
|
||||
|
||||
override fun getPayloadForImageLoader(message: ChatMessage): Any {
|
||||
val map = HashMap<String, Any>()
|
||||
// used for setting a placeholder
|
||||
if (message.getSelectedIndividualHashMap().containsKey("mimetype")) {
|
||||
map["mimetype"] = message.getSelectedIndividualHashMap().get("mimetype")!!
|
||||
map["mimetype"] = message.getSelectedIndividualHashMap()["mimetype"]!!
|
||||
}
|
||||
|
||||
map["hasPreview"] = message.selectedIndividualHashMap.getOrDefault("has-preview", false)
|
||||
|
||||
return ImageLoaderPayload(map)
|
||||
}
|
||||
|
||||
|
@ -364,21 +364,23 @@ class ChatController(args: Bundle) : BaseController(), MessagesListAdapter
|
||||
adapter = MessagesListAdapter(
|
||||
conversationUser?.userId, messageHolders, ImageLoader { imageView, url, payload ->
|
||||
|
||||
imageView.load(url) {
|
||||
if (conversationUser != null && url!!.startsWith(conversationUser.baseUrl) && (url.contains(
|
||||
"index.php/core/preview?fileId=") || url.contains("/avatar/"))) {
|
||||
addHeader("Authorization", conversationUser.getCredentials())
|
||||
}
|
||||
if (url != "no-preview") {
|
||||
imageView.load(url) {
|
||||
if (conversationUser != null && url!!.startsWith(conversationUser.baseUrl) && (url.contains(
|
||||
"index.php/core/preview?fileId=") || url.contains("/avatar/"))) {
|
||||
addHeader("Authorization", conversationUser.getCredentials())
|
||||
}
|
||||
|
||||
if (url!!.contains("/avatar/")) {
|
||||
transformations(CircleCropTransformation())
|
||||
} else {
|
||||
if (payload is ImageLoaderPayload) {
|
||||
payload.map?.get("mimetype")?.let {
|
||||
if (url!!.contains("/avatar/")) {
|
||||
transformations(CircleCropTransformation())
|
||||
} else {
|
||||
if (payload is ImageLoaderPayload) {
|
||||
payload.map?.get("mimetype")?.let {
|
||||
val mimeTypeDrawableResource = getDrawableResourceIdForMimeType(it as String)
|
||||
val drawable = context.getDrawable(mimeTypeDrawableResource)
|
||||
placeholder(drawable)
|
||||
error(drawable)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,13 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent
|
||||
Map<String, String> individualHashMap = messageParameters.get(key);
|
||||
if (individualHashMap.get("type").equals("file")) {
|
||||
selectedIndividualHashMap = individualHashMap;
|
||||
return (ApiUtils.getUrlForFilePreviewWithFileId(getActiveUser().getBaseUrl(),
|
||||
if (selectedIndividualHashMap.containsKey("preview-available")) {
|
||||
if (selectedIndividualHashMap.get("preview-available").equals("no")) {
|
||||
return "no-preview";
|
||||
}
|
||||
}
|
||||
|
||||
return (ApiUtils.getUrlForFilePreviewWithFileId(activeUser.getBaseUrl(),
|
||||
individualHashMap.get("id"), NextcloudTalkApplication.Companion.getSharedApplication()
|
||||
.getResources()
|
||||
.getDimensionPixelSize(R.dimen.maximum_file_preview_size)));
|
||||
@ -157,7 +163,7 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent
|
||||
}
|
||||
|
||||
if (!messageTypesToIgnore.contains(getMessageType()) && isLinkPreviewAllowed) {
|
||||
return getMessage().trim();
|
||||
return message.trim();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user