mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Implement shared file system emssage
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
bcb16bb251
commit
bf123dfc15
@ -20,8 +20,11 @@
|
||||
|
||||
package com.nextcloud.talk.adapters.messages;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
@ -54,25 +57,32 @@ public class MagicSystemMessageViewHolder extends MessageHolders.IncomingTextMes
|
||||
|
||||
Spannable messageString = new SpannableString(message.getText());
|
||||
|
||||
Context context = NextcloudTalkApplication.getSharedApplication().getApplicationContext();
|
||||
if (message.getMessageParameters() != null && message.getMessageParameters().size() > 0) {
|
||||
for (String key : message.getMessageParameters().keySet()) {
|
||||
Map<String, String> individualHashMap = message.getMessageParameters().get(key);
|
||||
int color;
|
||||
if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest")) {
|
||||
int color;
|
||||
|
||||
if (individualHashMap.get("id").equals(message.getActiveUserId())) {
|
||||
color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color
|
||||
.nc_incoming_text_mention_you);
|
||||
color = context.getResources().getColor(R.color.nc_incoming_text_mention_you);
|
||||
} else {
|
||||
color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color
|
||||
.nc_incoming_text_mention_others);
|
||||
color = context.getResources().getColor(R.color.nc_incoming_text_mention_others);
|
||||
}
|
||||
|
||||
messageString = DisplayUtils.searchAndColor(message.getText(),
|
||||
messageString, "@" + individualHashMap.get("name"), color);
|
||||
} else if (individualHashMap.get("type").equals("file")) {
|
||||
color = context.getResources().getColor(R.color
|
||||
.colorPrimary);
|
||||
messageString = DisplayUtils.searchAndColor(message.getText(), messageString, individualHashMap
|
||||
.get("name"), color);
|
||||
itemView.setOnClickListener(v -> {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link")));
|
||||
context.startActivity(browserIntent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
text.setText(messageString);
|
||||
|
@ -57,7 +57,7 @@ public class ChatMessage implements IMessage, MessageContentType {
|
||||
USER_REMOVED,
|
||||
MODERATOR_PROMOTED,
|
||||
MODERATOR_DEMOTED,
|
||||
|
||||
FILE_SHARED,
|
||||
}
|
||||
|
||||
String baseUrl;
|
||||
|
@ -31,6 +31,8 @@ public class ChatUtils {
|
||||
if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest")) {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,8 @@ public class EnumSystemMessageTypeConverter extends StringBasedTypeConverter<Cha
|
||||
return MODERATOR_PROMOTED;
|
||||
case "moderator_demoted":
|
||||
return MODERATOR_DEMOTED;
|
||||
case "file_shared":
|
||||
return FILE_SHARED;
|
||||
default:
|
||||
return DUMMY;
|
||||
}
|
||||
@ -115,6 +117,8 @@ public class EnumSystemMessageTypeConverter extends StringBasedTypeConverter<Cha
|
||||
return "moderator_promoted";
|
||||
case MODERATOR_DEMOTED:
|
||||
return "moderator_demoted";
|
||||
case FILE_SHARED:
|
||||
return "file_shared";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user