aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-08-13 22:40:00 +0200
committerChristian Schneppe <christian@pix-art.de>2017-08-13 22:43:49 +0200
commit04db5052ccee3cba54c52d64e3ec199d78b675ad (patch)
tree8d6674745798918e2e5e02ac10ea9e19b6dcf607 /src/main/java/de/pixart/messenger/ui
parent1fd688b9d84efc46c747cc7c941c3323b2732e06 (diff)
cache some information generated from body like isEmojiOnly, fileParams, isGeoUri and isXmppUri
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java23
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java4
2 files changed, 10 insertions, 17 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 30d0f19ff..7dab99278 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -73,10 +73,8 @@ import de.pixart.messenger.ui.adapter.MessageAdapter;
import de.pixart.messenger.ui.adapter.MessageAdapter.OnContactPictureClicked;
import de.pixart.messenger.ui.adapter.MessageAdapter.OnContactPictureLongClicked;
import de.pixart.messenger.ui.widget.ListSelectionManager;
-import de.pixart.messenger.utils.GeoHelper;
import de.pixart.messenger.utils.NickValidityChecker;
import de.pixart.messenger.utils.UIHelper;
-import de.pixart.messenger.utils.XmppUri;
import de.pixart.messenger.xmpp.XmppConnection;
import de.pixart.messenger.xmpp.chatstate.ChatState;
import de.pixart.messenger.xmpp.jid.Jid;
@@ -636,20 +634,15 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
MenuItem downloadFile = menu.findItem(R.id.download_file);
MenuItem deleteFile = menu.findItem(R.id.delete_file);
MenuItem showErrorMessage = menu.findItem(R.id.show_error_message);
- if (!treatAsFile && !GeoHelper.isGeoUri(m.getBody()) && !m.treatAsDownloadable()) {
+ if (!treatAsFile && !m.isGeoUri() && !m.isXmppUri() && !m.treatAsDownloadable()) {
selectText.setVisible(ListSelectionManager.isSupported());
}
if (m.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
retryDecryption.setVisible(true);
}
- if (((relevantForCorrection.getType() == Message.TYPE_TEXT
+ if (relevantForCorrection.getType() == Message.TYPE_TEXT
&& relevantForCorrection.isLastCorrectableMessage()
- && conversation.getMode() == Conversation.MODE_SINGLE)
- || (relevantForCorrection.getType() == Message.TYPE_TEXT
- && relevantForCorrection.isLastCorrectableMessage()
- && conversation.getMode() == Conversation.MODE_MULTI
- && m.getConversation().getMucOptions().nonanonymous()))
- && !(GeoHelper.isGeoUri(m.getBody()) || XmppUri.isXmppUri(m.getBody()))) {
+ && (m.getConversation().getMucOptions().nonanonymous() || m.getConversation().getMode() == Conversation.MODE_SINGLE)) {
correctMessage.setVisible(true);
}
if (treatAsFile || (m.getType() == Message.TYPE_TEXT && !m.treatAsDownloadable())) {
@@ -660,8 +653,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
sendAgain.setVisible(true);
}
if (m.hasFileOnRemoteHost()
- || GeoHelper.isGeoUri(m.getBody())
- || XmppUri.isXmppUri(m.getBody())
+ || m.isGeoUri()
+ || m.isXmppUri()
|| m.treatAsDownloadable()
|| (t != null && t instanceof HttpDownloadConnection)) {
copyUrl.setVisible(true);
@@ -739,7 +732,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
private void shareWith(Message message) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
- if (GeoHelper.isGeoUri(message.getBody())) {
+ if (message.isGeoUri() || message.isXmppUri()) {
shareIntent.putExtra(Intent.EXTRA_TEXT, message.getBody());
shareIntent.setType("text/plain");
} else if (!message.isFileOrImage()) {
@@ -811,10 +804,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
private void copyUrl(Message message) {
final String url;
final int resId;
- if (GeoHelper.isGeoUri(message.getBody())) {
+ if (message.isGeoUri()) {
resId = R.string.location;
url = message.getBody();
- } else if (XmppUri.isXmppUri(message.getBody())) {
+ } else if (message.isXmppUri()) {
resId = R.string.contact;
url = message.getBody();
} else if (message.hasFileOnRemoteHost()) {
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index b9969e27c..d923172b5 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -961,11 +961,11 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
displayDecryptionFailed(viewHolder, darkBackground);
} else {
- if (GeoHelper.isGeoUri(message.getBody())) {
+ if (message.isGeoUri()) {
displayLocationMessage(viewHolder, message);
} else if (message.bodyIsOnlyEmojis()) {
displayEmojiMessage(viewHolder, message.getBody().replaceAll("\\s", ""));
- } else if (message.bodyIsXmpp()) {
+ } else if (message.isXmppUri()) {
displayXmppMessage(viewHolder, message.getBody().trim());
} else if (message.treatAsDownloadable()) {
try {