mirror of
https://codeberg.org/monocles/monocles_chat.git
synced 2025-01-27 15:34:14 +01:00
Reactions popup appending emoticon
This commit is contained in:
parent
28e31181ff
commit
290c2e74df
2 changed files with 140 additions and 92 deletions
|
@ -119,12 +119,10 @@ import net.java.otr4j.session.SessionStatus;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.AbstractMap;
|
||||
|
@ -2161,7 +2159,7 @@ public class ConversationFragment extends XmppFragment
|
|||
return false;
|
||||
}
|
||||
|
||||
private void setThread(Element thread) {
|
||||
public void setThread(Element thread) {
|
||||
if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getBooleanPreference("show_thread_feature", R.bool.show_thread_feature)) {
|
||||
this.conversation.setThread(thread);
|
||||
}
|
||||
|
@ -2178,7 +2176,7 @@ public class ConversationFragment extends XmppFragment
|
|||
updateSendButton();
|
||||
}
|
||||
|
||||
private void setupReply(Message message) {
|
||||
public void setupReply(Message message) {
|
||||
conversation.setReplyTo(message);
|
||||
if (message == null) {
|
||||
binding.contextPreview.setVisibility(GONE);
|
||||
|
|
|
@ -1427,14 +1427,14 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
|
||||
@SuppressLint({"StringFormatInvalid", "ClickableViewAccessibility"})
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
final Message message = getItem(position);
|
||||
final boolean omemoEncryption = message.getEncryption() == Message.ENCRYPTION_AXOLOTL;
|
||||
final boolean isInValidSession = message.isValidInSession() && (!omemoEncryption || message.isTrusted());
|
||||
final Conversational conversation = message.getConversation();
|
||||
public View getView(int position1, View view, ViewGroup parent) {
|
||||
final Message[] message = {getItem(position1)};
|
||||
final boolean omemoEncryption = message[0].getEncryption() == Message.ENCRYPTION_AXOLOTL;
|
||||
final boolean isInValidSession = message[0].isValidInSession() && (!omemoEncryption || message[0].isTrusted());
|
||||
final Conversational conversation = message[0].getConversation();
|
||||
final Account account = conversation.getAccount();
|
||||
final List<Element> commands = message.getCommands();
|
||||
final int type = getItemViewType(position);
|
||||
final List<Element> commands = message[0].getCommands();
|
||||
final int type = getItemViewType(position1);
|
||||
ViewHolder viewHolder;
|
||||
if (view == null) {
|
||||
viewHolder = new ViewHolder();
|
||||
|
@ -1498,7 +1498,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
} else {
|
||||
viewHolder.contact_picture = view.findViewById(R.id.message_photo_square);
|
||||
}
|
||||
if (message.getConversation().getMode() == Conversation.MODE_SINGLE && activity.xmppConnectionService.getBooleanPreference("show_less_avatars", R.bool.show_less_avatars)) {
|
||||
if (message[0].getConversation().getMode() == Conversation.MODE_SINGLE && activity.xmppConnectionService.getBooleanPreference("show_less_avatars", R.bool.show_less_avatars)) {
|
||||
view.findViewById(R.id.message_photo).setVisibility(GONE);
|
||||
view.findViewById(R.id.message_photo_square).setVisibility(GONE);
|
||||
}
|
||||
|
@ -1555,7 +1555,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
|
||||
if (!activity.xmppConnectionService.getBooleanPreference("set_text_collapsable", R.bool.set_text_collapsable)) {
|
||||
viewHolder.messageBody.setMaxLines(Integer.MAX_VALUE);//Message TextView
|
||||
viewHolder.seeMore.setVisibility(View.GONE);
|
||||
viewHolder.seeMore.setVisibility(GONE);
|
||||
} else if (viewHolder.messageBody.getLineCount() > 7 && viewHolder.seeMore.getText().toString().equalsIgnoreCase(activity.getString(R.string.show_more))) {
|
||||
viewHolder.seeMore.setVisibility(View.VISIBLE);
|
||||
viewHolder.seeMore.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -1572,13 +1572,13 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
}
|
||||
});
|
||||
} else if (viewHolder.messageBody.getLineCount() <= 7) {
|
||||
viewHolder.seeMore.setVisibility(View.GONE);
|
||||
viewHolder.seeMore.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (viewHolder.thread_identicon != null) {
|
||||
viewHolder.thread_identicon.setVisibility(GONE);
|
||||
final Element thread = message.getThread();
|
||||
final Element thread = message[0].getThread();
|
||||
if (thread != null) {
|
||||
final String threadId = thread.getContent();
|
||||
if (threadId != null) {
|
||||
|
@ -1592,12 +1592,12 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
boolean darkBackground = activity.isDarkTheme();
|
||||
|
||||
if (type == DATE_SEPARATOR) {
|
||||
if (UIHelper.today(message.getTimeSent())) {
|
||||
if (UIHelper.today(message[0].getTimeSent())) {
|
||||
viewHolder.status_message.setText(R.string.today);
|
||||
} else if (UIHelper.yesterday(message.getTimeSent())) {
|
||||
} else if (UIHelper.yesterday(message[0].getTimeSent())) {
|
||||
viewHolder.status_message.setText(R.string.yesterday);
|
||||
} else {
|
||||
viewHolder.status_message.setText(DateUtils.formatDateTime(activity, message.getTimeSent(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR));
|
||||
viewHolder.status_message.setText(DateUtils.formatDateTime(activity, message[0].getTimeSent(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR));
|
||||
}
|
||||
viewHolder.status_message.setTextColor(ThemeHelper.getCallTextColor(getContext(), darkBackground));
|
||||
viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.date_bubble_dark : R.drawable.date_bubble);
|
||||
|
@ -1606,27 +1606,27 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
return view;
|
||||
} else if (type == RTP_SESSION) {
|
||||
final boolean isDarkTheme = activity.isDarkTheme();
|
||||
final boolean received = message.getStatus() <= Message.STATUS_RECEIVED;
|
||||
final String formattedTime = UIHelper.readableTimeDifferenceFull(activity, message.getMergedTimeSent());
|
||||
final RtpSessionStatus rtpSessionStatus = RtpSessionStatus.of(message.getBody());
|
||||
final boolean received = message[0].getStatus() <= Message.STATUS_RECEIVED;
|
||||
final String formattedTime = UIHelper.readableTimeDifferenceFull(activity, message[0].getMergedTimeSent());
|
||||
final RtpSessionStatus rtpSessionStatus = RtpSessionStatus.of(message[0].getBody());
|
||||
final long duration = rtpSessionStatus.duration;
|
||||
if (received) {
|
||||
if (duration > 0) {
|
||||
viewHolder.status_message.setText(activity.getString(R.string.incoming_call_duration_timestamp, TimeFrameUtils.resolve(activity, duration), UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent())));
|
||||
viewHolder.status_message.setText(activity.getString(R.string.incoming_call_duration_timestamp, TimeFrameUtils.resolve(activity, duration), UIHelper.readableTimeDifferenceFull(activity, message[0].getTimeSent())));
|
||||
viewHolder.status_message.setTextColor(ThemeHelper.getCallTextColor(getContext(), darkBackground));
|
||||
} else if (rtpSessionStatus.successful) {
|
||||
viewHolder.status_message.setText(R.string.incoming_call);
|
||||
viewHolder.status_message.setTextColor(ThemeHelper.getCallTextColor(getContext(), darkBackground));
|
||||
} else {
|
||||
viewHolder.status_message.setText(activity.getString(R.string.missed_call_timestamp, UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent())));
|
||||
viewHolder.status_message.setText(activity.getString(R.string.missed_call_timestamp, UIHelper.readableTimeDifferenceFull(activity, message[0].getTimeSent())));
|
||||
viewHolder.status_message.setTextColor(ThemeHelper.getMissedCallTextColor(activity, darkBackground));
|
||||
}
|
||||
} else {
|
||||
if (duration > 0) {
|
||||
viewHolder.status_message.setText(activity.getString(R.string.outgoing_call_duration_timestamp, TimeFrameUtils.resolve(activity, duration), UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent())));
|
||||
viewHolder.status_message.setText(activity.getString(R.string.outgoing_call_duration_timestamp, TimeFrameUtils.resolve(activity, duration), UIHelper.readableTimeDifferenceFull(activity, message[0].getTimeSent())));
|
||||
viewHolder.status_message.setTextColor(ThemeHelper.getCallTextColor(getContext(), darkBackground));
|
||||
} else {
|
||||
viewHolder.status_message.setText(activity.getString(R.string.outgoing_call_timestamp, UIHelper.readableTimeDifferenceFull(activity, message.getTimeSent())));
|
||||
viewHolder.status_message.setText(activity.getString(R.string.outgoing_call_timestamp, UIHelper.readableTimeDifferenceFull(activity, message[0].getTimeSent())));
|
||||
viewHolder.status_message.setTextColor(ThemeHelper.getCallTextColor(getContext(), darkBackground));
|
||||
}
|
||||
}
|
||||
|
@ -1636,22 +1636,22 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
activity.setBubbleColor(viewHolder.message_box, (date_bubble_color), -1); //themed color
|
||||
return view;
|
||||
} else if (type == STATUS) {
|
||||
if ("LOAD_MORE".equals(message.getBody())) {
|
||||
if ("LOAD_MORE".equals(message[0].getBody())) {
|
||||
viewHolder.status_message.setVisibility(GONE);
|
||||
viewHolder.contact_picture.setVisibility(GONE);
|
||||
viewHolder.load_more_messages.setVisibility(View.VISIBLE);
|
||||
viewHolder.load_more_messages.setOnClickListener(v -> loadMoreMessages((Conversation) message.getConversation()));
|
||||
viewHolder.load_more_messages.setOnClickListener(v -> loadMoreMessages((Conversation) message[0].getConversation()));
|
||||
} else {
|
||||
viewHolder.status_message.setVisibility(View.VISIBLE);
|
||||
viewHolder.load_more_messages.setVisibility(GONE);
|
||||
viewHolder.status_message.setText(message.getBody());
|
||||
viewHolder.status_message.setText(message[0].getBody());
|
||||
boolean showAvatar;
|
||||
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
||||
showAvatar = true;
|
||||
AvatarWorkerTask.loadAvatar(message, viewHolder.contact_picture, R.dimen.avatar_on_status_message);
|
||||
} else if (message.getCounterpart() != null || message.getTrueCounterpart() != null || (message.getCounterparts() != null && message.getCounterparts().size() > 0)) {
|
||||
AvatarWorkerTask.loadAvatar(message[0], viewHolder.contact_picture, R.dimen.avatar_on_status_message);
|
||||
} else if (message[0].getCounterpart() != null || message[0].getTrueCounterpart() != null || (message[0].getCounterparts() != null && message[0].getCounterparts().size() > 0)) {
|
||||
showAvatar = true;
|
||||
AvatarWorkerTask.loadAvatar(message, viewHolder.contact_picture, R.dimen.avatar_on_status_message);
|
||||
AvatarWorkerTask.loadAvatar(message[0], viewHolder.contact_picture, R.dimen.avatar_on_status_message);
|
||||
} else {
|
||||
showAvatar = false;
|
||||
}
|
||||
|
@ -1664,7 +1664,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
}
|
||||
return view;
|
||||
} else {
|
||||
AvatarWorkerTask.loadAvatar(message, viewHolder.contact_picture, R.dimen.avatar);
|
||||
AvatarWorkerTask.loadAvatar(message[0], viewHolder.contact_picture, R.dimen.avatar);
|
||||
}
|
||||
|
||||
resetClickListener(viewHolder.message_box, viewHolder.messageBody);
|
||||
|
@ -1672,17 +1672,17 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
viewHolder.message_box.setOnClickListener(v -> {
|
||||
if (MessageAdapter.this.mOnMessageBoxClickedListener != null) {
|
||||
MessageAdapter.this.mOnMessageBoxClickedListener
|
||||
.onContactPictureClicked(message);
|
||||
.onContactPictureClicked(message[0]);
|
||||
}
|
||||
});
|
||||
viewHolder.messageBody.setOnClickListener(v -> {
|
||||
if (MessageAdapter.this.mOnMessageBoxClickedListener != null) {
|
||||
MessageAdapter.this.mOnMessageBoxClickedListener
|
||||
.onContactPictureClicked(message);
|
||||
.onContactPictureClicked(message[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Reactions popup
|
||||
ReactionsConfig config = new ReactionsConfigBuilder(activity)
|
||||
.withReactions(new int[]{
|
||||
R.drawable.ic_fb_like,
|
||||
|
@ -1694,21 +1694,71 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
})
|
||||
.build();
|
||||
|
||||
ReactionPopup popup = new ReactionPopup(activity, config, (positionReact) -> {
|
||||
ReactionPopup popup = new ReactionPopup(activity, config, (position) -> {
|
||||
if (position.equals(0)) {
|
||||
mConversationFragment.setupReply(message[0]);
|
||||
while (message[0].mergeable(message[0].next())) {
|
||||
message[0] = message[0].next();
|
||||
}
|
||||
mConversationFragment.setThread(message[0].getThread());
|
||||
mConversationFragment.getConversation().setUserSelectedThread(true);
|
||||
mConversationFragment.binding.textinput.append("\uD83D\uDC4D");
|
||||
} else if (position.equals(1)) {
|
||||
mConversationFragment.setupReply(message[0]);
|
||||
while (message[0].mergeable(message[0].next())) {
|
||||
message[0] = message[0].next();
|
||||
}
|
||||
mConversationFragment.setThread(message[0].getThread());
|
||||
mConversationFragment.getConversation().setUserSelectedThread(true);
|
||||
mConversationFragment.binding.textinput.append("❤\uFE0F");
|
||||
} else if (position.equals(2)) {
|
||||
mConversationFragment.setupReply(message[0]);
|
||||
while (message[0].mergeable(message[0].next())) {
|
||||
message[0] = message[0].next();
|
||||
}
|
||||
mConversationFragment.setThread(message[0].getThread());
|
||||
mConversationFragment.getConversation().setUserSelectedThread(true);
|
||||
mConversationFragment.binding.textinput.append("\uD83D\uDE06");
|
||||
} else if (position.equals(3)) {
|
||||
mConversationFragment.setupReply(message[0]);
|
||||
while (message[0].mergeable(message[0].next())) {
|
||||
message[0] = message[0].next();
|
||||
}
|
||||
mConversationFragment.setThread(message[0].getThread());
|
||||
mConversationFragment.getConversation().setUserSelectedThread(true);
|
||||
mConversationFragment.binding.textinput.append("\uD83D\uDE32");
|
||||
} else if (position.equals(4)) {
|
||||
mConversationFragment.setupReply(message[0]);
|
||||
while (message[0].mergeable(message[0].next())) {
|
||||
message[0] = message[0].next();
|
||||
}
|
||||
mConversationFragment.setThread(message[0].getThread());
|
||||
mConversationFragment.getConversation().setUserSelectedThread(true);
|
||||
mConversationFragment.binding.textinput.append("\uD83D\uDE22");
|
||||
} else if (position.equals(5)) {
|
||||
mConversationFragment.setupReply(message[0]);
|
||||
while (message[0].mergeable(message[0].next())) {
|
||||
message[0] = message[0].next();
|
||||
}
|
||||
mConversationFragment.setThread(message[0].getThread());
|
||||
mConversationFragment.getConversation().setUserSelectedThread(true);
|
||||
mConversationFragment.binding.textinput.append("\uD83D\uDE20");
|
||||
|
||||
}
|
||||
return true; // true is closing popup, false is requesting a new selection
|
||||
});
|
||||
|
||||
viewHolder.messageBody.setOnClickListener(v -> {
|
||||
if (MessageAdapter.this.mOnMessageBoxClickedListener != null) {
|
||||
MessageAdapter.this.mOnMessageBoxClickedListener
|
||||
.onContactPictureClicked(message);
|
||||
.onContactPictureClicked(message[0]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
viewHolder.contact_picture.setOnClickListener(v -> {
|
||||
if (MessageAdapter.this.mOnContactPictureClickedListener != null) {
|
||||
MessageAdapter.this.mOnContactPictureClickedListener.onContactPictureClicked(message);
|
||||
MessageAdapter.this.mOnContactPictureClickedListener.onContactPictureClicked(message[0]);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1747,7 +1797,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
public void onOpen(SwipeLayout layout) {
|
||||
swipeLayout.refreshDrawableState();
|
||||
//when the BottomView totally show.
|
||||
if (mOnMessageBoxSwipedListener != null) mOnMessageBoxSwipedListener.onContactPictureClicked(message);
|
||||
if (mOnMessageBoxSwipedListener != null) mOnMessageBoxSwipedListener.onContactPictureClicked(message[0]);
|
||||
swipeLayout.close(true);
|
||||
swipeLayout.setClickToClose(true);
|
||||
}
|
||||
|
@ -1782,84 +1832,84 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
|
||||
viewHolder.contact_picture.setOnLongClickListener(v -> {
|
||||
if (MessageAdapter.this.mOnContactPictureLongClickedListener != null) {
|
||||
MessageAdapter.this.mOnContactPictureLongClickedListener.onContactPictureLongClicked(v, message);
|
||||
MessageAdapter.this.mOnContactPictureLongClickedListener.onContactPictureLongClicked(v, message[0]);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
final Transferable transferable = message.getTransferable();
|
||||
final boolean unInitiatedButKnownSize = MessageUtils.unInitiatedButKnownSize(message);
|
||||
if (unInitiatedButKnownSize || message.isFileDeleted() || (transferable != null && transferable.getStatus() != Transferable.STATUS_UPLOADING)) {
|
||||
if (unInitiatedButKnownSize || (message.isMessageDeleted() && message.getModerated() == null) || transferable != null && transferable.getStatus() == Transferable.STATUS_OFFER) {
|
||||
displayDownloadableMessage(viewHolder, message, activity.getString(R.string.download_x_file, UIHelper.getFileDescriptionString(activity, message)), darkBackground, type);
|
||||
final Transferable transferable = message[0].getTransferable();
|
||||
final boolean unInitiatedButKnownSize = MessageUtils.unInitiatedButKnownSize(message[0]);
|
||||
if (unInitiatedButKnownSize || message[0].isFileDeleted() || (transferable != null && transferable.getStatus() != Transferable.STATUS_UPLOADING)) {
|
||||
if (unInitiatedButKnownSize || (message[0].isMessageDeleted() && message[0].getModerated() == null) || transferable != null && transferable.getStatus() == Transferable.STATUS_OFFER) {
|
||||
displayDownloadableMessage(viewHolder, message[0], activity.getString(R.string.download_x_file, UIHelper.getFileDescriptionString(activity, message[0])), darkBackground, type);
|
||||
} else if (transferable != null && transferable.getStatus() == Transferable.STATUS_OFFER_CHECK_FILESIZE) {
|
||||
displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_x_filesize, UIHelper.getFileDescriptionString(activity, message)), darkBackground, type);
|
||||
displayDownloadableMessage(viewHolder, message[0], activity.getString(R.string.check_x_filesize, UIHelper.getFileDescriptionString(activity, message[0])), darkBackground, type);
|
||||
} else {
|
||||
/* todo why should we mark a file as deleted? --> causing strange side effects
|
||||
if (!activity.xmppConnectionService.getFileBackend().getFile(message).exists() && !message.isFileDeleted()) {
|
||||
new Thread(new markFileDeletedFinisher(message, activity)).start();
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.file_deleted), darkBackground, message);
|
||||
}*/
|
||||
if (checkFileExistence(message, view, viewHolder)) {
|
||||
new Thread(new markFileExistingFinisher(message, activity)).start();
|
||||
if (checkFileExistence(message[0], view, viewHolder)) {
|
||||
new Thread(new markFileExistingFinisher(message[0], activity)).start();
|
||||
}
|
||||
displayInfoMessage(viewHolder, UIHelper.getMessagePreview(activity, message).first, darkBackground, message);
|
||||
displayInfoMessage(viewHolder, UIHelper.getMessagePreview(activity, message[0]).first, darkBackground, message[0]);
|
||||
}
|
||||
} else if (message.isFileOrImage() && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
|
||||
if (message.getFileParams().width > 0 && message.getFileParams().height > 0) {
|
||||
displayMediaPreviewMessage(viewHolder, message, darkBackground, type);
|
||||
} else if (message.getFileParams().runtime > 0 && (message.getFileParams().width == 0 && message.getFileParams().height == 0)) {
|
||||
displayAudioMessage(viewHolder, message, darkBackground, type);
|
||||
} else if ("application/xdc+zip".equals(message.getFileParams().getMediaType()) && message.getConversation() instanceof Conversation && message.getThread() != null && !message.getFileParams().getCids().isEmpty() && message.getEncryption() == ENCRYPTION_NONE) {
|
||||
displayWebxdcMessage(viewHolder, message, darkBackground, type);
|
||||
} else if (message[0].isFileOrImage() && message[0].getEncryption() != Message.ENCRYPTION_PGP && message[0].getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
|
||||
if (message[0].getFileParams().width > 0 && message[0].getFileParams().height > 0) {
|
||||
displayMediaPreviewMessage(viewHolder, message[0], darkBackground, type);
|
||||
} else if (message[0].getFileParams().runtime > 0 && (message[0].getFileParams().width == 0 && message[0].getFileParams().height == 0)) {
|
||||
displayAudioMessage(viewHolder, message[0], darkBackground, type);
|
||||
} else if ("application/xdc+zip".equals(message[0].getFileParams().getMediaType()) && message[0].getConversation() instanceof Conversation && message[0].getThread() != null && !message[0].getFileParams().getCids().isEmpty() && message[0].getEncryption() == ENCRYPTION_NONE) {
|
||||
displayWebxdcMessage(viewHolder, message[0], darkBackground, type);
|
||||
} else {
|
||||
displayOpenableMessage(viewHolder, message, darkBackground, type);
|
||||
displayOpenableMessage(viewHolder, message[0], darkBackground, type);
|
||||
}
|
||||
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||
} else if (message[0].getEncryption() == Message.ENCRYPTION_PGP) {
|
||||
if (account.isPgpDecryptionServiceConnected()) {
|
||||
if (conversation instanceof Conversation && !account.hasPendingPgpIntent((Conversation) conversation)) {
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.message_decrypting), darkBackground, message);
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.message_decrypting), darkBackground, message[0]);
|
||||
} else {
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.pgp_message), darkBackground, message);
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.pgp_message), darkBackground, message[0]);
|
||||
}
|
||||
} else {
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.install_openkeychain), darkBackground, message);
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.install_openkeychain), darkBackground, message[0]);
|
||||
viewHolder.message_box.setOnClickListener(this::promptOpenKeychainInstall);
|
||||
viewHolder.messageBody.setOnClickListener(this::promptOpenKeychainInstall);
|
||||
}
|
||||
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.decryption_failed), darkBackground, message);
|
||||
} else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) {
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.not_encrypted_for_this_device), darkBackground, message);
|
||||
} else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL_FAILED) {
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.omemo_decryption_failed), darkBackground, message);
|
||||
} else if (message[0].getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.decryption_failed), darkBackground, message[0]);
|
||||
} else if (message[0].getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) {
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.not_encrypted_for_this_device), darkBackground, message[0]);
|
||||
} else if (message[0].getEncryption() == Message.ENCRYPTION_AXOLOTL_FAILED) {
|
||||
displayInfoMessage(viewHolder, activity.getString(R.string.omemo_decryption_failed), darkBackground, message[0]);
|
||||
} else {
|
||||
if (message.isGeoUri()) {
|
||||
displayLocationMessage(viewHolder, message, darkBackground, type);
|
||||
} else if (message.isXmppUri()) {
|
||||
displayXmppMessage(viewHolder, message.getBody().trim());
|
||||
} else if (message.treatAsDownloadable()) {
|
||||
if (message[0].isGeoUri()) {
|
||||
displayLocationMessage(viewHolder, message[0], darkBackground, type);
|
||||
} else if (message[0].isXmppUri()) {
|
||||
displayXmppMessage(viewHolder, message[0].getBody().trim());
|
||||
} else if (message[0].treatAsDownloadable()) {
|
||||
try {
|
||||
final URI uri = message.getOob();
|
||||
final URI uri = message[0].getOob();
|
||||
displayDownloadableMessage(viewHolder,
|
||||
message,
|
||||
message[0],
|
||||
activity.getString(R.string.check_x_filesize_on_host,
|
||||
UIHelper.getFileDescriptionString(activity, message),
|
||||
UIHelper.getFileDescriptionString(activity, message[0]),
|
||||
uri.getHost()),
|
||||
darkBackground, type);
|
||||
} catch (Exception e) {
|
||||
displayDownloadableMessage(viewHolder,
|
||||
message,
|
||||
message[0],
|
||||
activity.getString(R.string.check_x_filesize,
|
||||
UIHelper.getFileDescriptionString(activity, message)),
|
||||
UIHelper.getFileDescriptionString(activity, message[0])),
|
||||
darkBackground, type);
|
||||
}
|
||||
} else if (message.bodyIsOnlyEmojis() && message.getType() != Message.TYPE_PRIVATE) {
|
||||
displayEmojiMessage(viewHolder, getSpannableBody(message), darkBackground);
|
||||
} else if (message[0].bodyIsOnlyEmojis() && message[0].getType() != Message.TYPE_PRIVATE) {
|
||||
displayEmojiMessage(viewHolder, getSpannableBody(message[0]), darkBackground);
|
||||
} else {
|
||||
displayTextMessage(viewHolder, message, darkBackground, type);
|
||||
displayTextMessage(viewHolder, message[0], darkBackground, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1882,7 +1932,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
viewHolder.commands_list.setVisibility(GONE);
|
||||
viewHolder.commands_list.setOnItemClickListener(null);
|
||||
}
|
||||
if (message.isPrivateMessage()) {
|
||||
if (message[0].isPrivateMessage()) {
|
||||
viewHolder.answer_button.setVisibility(View.VISIBLE);
|
||||
Drawable icon = activity.getResources().getDrawable(R.drawable.ic_reply_circle_black_24dp);
|
||||
Drawable drawable = DrawableCompat.wrap(icon);
|
||||
|
@ -1894,7 +1944,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
ConversationFragment conversationFragment = ConversationFragment.get(activity);
|
||||
if (conversationFragment != null) {
|
||||
activity.invalidateOptionsMenu();
|
||||
conversationFragment.privateMessageWith(message.getCounterpart());
|
||||
conversationFragment.privateMessageWith(message[0].getCounterpart());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -1906,27 +1956,27 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
viewHolder.answer_button.setVisibility(GONE);
|
||||
}
|
||||
if (isInValidSession) {
|
||||
setBubbleBackgroundColor(viewHolder.message_box, type, message.isPrivateMessage(), isInValidSession);
|
||||
setBubbleBackgroundColor(viewHolder.message_box, type, message[0].isPrivateMessage(), isInValidSession);
|
||||
viewHolder.encryption.setVisibility(GONE);
|
||||
viewHolder.encryption.setTextColor(ThemeHelper.getMessageTextColor(activity, darkBackground, false));
|
||||
} else {
|
||||
setBubbleBackgroundColor(viewHolder.message_box, type, message.isPrivateMessage(), isInValidSession);
|
||||
setBubbleBackgroundColor(viewHolder.message_box, type, message[0].isPrivateMessage(), isInValidSession);
|
||||
viewHolder.encryption.setVisibility(View.VISIBLE);
|
||||
viewHolder.encryption.setTextColor(ThemeHelper.getWarningTextColor(activity, darkBackground));
|
||||
if (omemoEncryption && !message.isTrusted()) {
|
||||
if (omemoEncryption && !message[0].isTrusted()) {
|
||||
viewHolder.encryption.setText(R.string.not_trusted);
|
||||
} else {
|
||||
viewHolder.encryption.setText(CryptoHelper.encryptionTypeToText(message.getEncryption()));
|
||||
viewHolder.encryption.setText(CryptoHelper.encryptionTypeToText(message[0].getEncryption()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type == RECEIVED || type == SENT) {
|
||||
String subject = message.getSubject();
|
||||
if (subject == null && message.getThread() != null && ((Conversation) message.getConversation()).getThread(message.getThread().getContent()).getSubject() != null) {
|
||||
subject = ((Conversation) message.getConversation()).getThread(message.getThread().getContent()).getSubject();
|
||||
String subject = message[0].getSubject();
|
||||
if (subject == null && message[0].getThread() != null && ((Conversation) message[0].getConversation()).getThread(message[0].getThread().getContent()).getSubject() != null) {
|
||||
subject = ((Conversation) message[0].getConversation()).getThread(message[0].getThread().getContent()).getSubject();
|
||||
}
|
||||
if (subject == null) {
|
||||
viewHolder.subject.setVisibility(View.GONE);
|
||||
viewHolder.subject.setVisibility(GONE);
|
||||
} else {
|
||||
viewHolder.subject.setVisibility(View.VISIBLE);
|
||||
viewHolder.subject.setText(subject);
|
||||
|
@ -1934,9 +1984,9 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
}
|
||||
|
||||
if (type == SENT) {
|
||||
setBubbleBackgroundColor(viewHolder.message_box, type, message.isPrivateMessage(), isInValidSession);
|
||||
setBubbleBackgroundColor(viewHolder.message_box, type, message[0].isPrivateMessage(), isInValidSession);
|
||||
}
|
||||
displayStatus(viewHolder, message, type, darkBackground);
|
||||
displayStatus(viewHolder, message[0], type, darkBackground);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue