add logic for geolocation message

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2021-05-26 14:47:54 +02:00 committed by Andy Scherzinger
parent 965692ce7e
commit 73becd432d
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
3 changed files with 23 additions and 1 deletions

View File

@ -177,7 +177,8 @@ public class MagicPreviewMessageViewHolder extends MessageHolders.IncomingImageM
} catch (ExecutionException | InterruptedException e) {
Log.e(TAG, "Error when checking if worker already exists", e);
}
} else if (message.getMessageType() == ChatMessage.MessageType.SINGLE_NC_GEOLOCATION_MESSAGE) {
Log.d(TAG, "handle geolocation here");
} else if (message.getMessageType() == ChatMessage.MessageType.SINGLE_LINK_GIPHY_MESSAGE) {
messageText.setText("GIPHY");
DisplayUtils.setClickableString("GIPHY", "https://giphy.com", messageText);

View File

@ -103,6 +103,19 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent
return false;
}
private boolean hasGeoLocation() {
if (messageParameters != null && messageParameters.size() > 0) {
for (String key : messageParameters.keySet()) {
Map<String, String> individualHashMap = messageParameters.get(key);
if (individualHashMap.get("type").equals("geo-location")) {
return true;
}
}
}
return false;
}
@Nullable
@Override
public String getImageUrl() {
@ -133,6 +146,11 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent
return MessageType.SINGLE_NC_ATTACHMENT_MESSAGE;
}
if (hasGeoLocation()) {
return MessageType.SINGLE_NC_GEOLOCATION_MESSAGE;
}
return TextMatchers.getMessageTypeFromString(getText());
}
@ -548,6 +566,7 @@ public class ChatMessage implements IMessage, MessageContentType, MessageContent
SINGLE_LINK_IMAGE_MESSAGE,
SINGLE_LINK_AUDIO_MESSAGE,
SINGLE_NC_ATTACHMENT_MESSAGE,
SINGLE_NC_GEOLOCATION_MESSAGE,
}
public enum SystemMessageType {

View File

@ -33,6 +33,8 @@ class ChatUtils {
val type = individualHashMap?.get("type")
if (type == "user" || type == "guest" || type == "call") {
resultMessage = resultMessage?.replace("{$key}", "@" + individualHashMap["name"])
} else if(type == "geo-location"){
resultMessage = individualHashMap.get("name")
} else if (individualHashMap?.containsKey("link") == true) {
resultMessage = if (type == "file") {
resultMessage?.replace("{$key}", individualHashMap["name"].toString())