Procházet zdrojové kódy

fix missing deck card links / always show links if available in message

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe před 4 roky
rodič
revize
42fea1a588

+ 3 - 0
CHANGELOG.md

@@ -6,7 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 Types of changes can be: Added/Changed/Deprecated/Removed/Fixed/Security
 
 ## [Unreleased]
+### Added
 
+### Fixed
+- show links for deck-cards
 
 ## [11.0.0] - 2021-02-23
 ### Added

+ 1 - 1
app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java

@@ -210,7 +210,7 @@ public class NotificationWorker extends Worker {
 
                         if (notification.getMessageRichParameters() != null &&
                                 notification.getMessageRichParameters().size() > 0) {
-                            decryptedPushMessage.setText(ChatUtils.getParsedMessage(notification.getMessageRich(),
+                            decryptedPushMessage.setText(ChatUtils.Companion.getParsedMessage(notification.getMessageRich(),
                                     notification.getMessageRichParameters()));
                         } else {
                             decryptedPushMessage.setText(notification.getMessage());

+ 1 - 1
app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java

@@ -155,7 +155,7 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent
 
     @Override
     public String getText() {
-        return ChatUtils.getParsedMessage(getMessage(), getMessageParameters());
+        return ChatUtils.Companion.getParsedMessage(getMessage(), getMessageParameters());
     }
 
     public String getLastMessageDisplayText() {

+ 0 - 43
app/src/main/java/com/nextcloud/talk/models/json/chat/ChatUtils.java

@@ -1,43 +0,0 @@
-/*
- * Nextcloud Talk application
- *
- * @author Mario Danic
- * Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.nextcloud.talk.models.json.chat;
-
-import java.util.HashMap;
-
-public class ChatUtils {
-
-    public static String getParsedMessage(String message, HashMap<String, HashMap<String, String>> messageParameters) {
-        if (messageParameters != null && messageParameters.size() > 0) {
-            for (String key : messageParameters.keySet()) {
-                HashMap<String, String> individualHashMap = messageParameters.get(key);
-                if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest") || individualHashMap.get("type").equals("call")) {
-                    message = message.replaceAll("\\{" + key + "\\}", "@" +
-                            messageParameters.get(key).get("name"));
-                } else if (individualHashMap.get("type").equals("file")) {
-                    message = message.replaceAll("\\{" + key + "\\}", messageParameters.get(key).get("name"));
-                }
-            }
-        }
-
-
-        return message;
-    }
-}

+ 49 - 0
app/src/main/java/com/nextcloud/talk/models/json/chat/ChatUtils.kt

@@ -0,0 +1,49 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
+ * @author Marcel Hibbe
+ * Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.models.json.chat
+
+class ChatUtils {
+    companion object {
+        fun getParsedMessage(message: String?, messageParameters: HashMap<String?, HashMap<String?, String?>>?):
+                String? {
+            var resultMessage = message
+            if (messageParameters != null && messageParameters.size > 0) {
+                for (key in messageParameters.keys) {
+                    val individualHashMap = messageParameters[key]
+                    val type = individualHashMap?.get("type")
+                    if (type == "user" || type == "guest" || type == "call") {
+                        resultMessage = resultMessage?.replace("{$key}", "@" + individualHashMap["name"])
+                    } else if (individualHashMap?.containsKey("link") == true) {
+                        resultMessage = if (type == "file") {
+                            resultMessage?.replace("{$key}", individualHashMap["name"].toString())
+                        } else {
+                            individualHashMap["link"].toString()
+                        }
+                    }
+                }
+            }
+            return resultMessage
+        }
+    }
+}
+