aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs')
-rw-r--r--src/eu/siacs/conversations/entities/Message.java16
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java11
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java4
-rw-r--r--src/eu/siacs/conversations/utils/UIHelper.java8
4 files changed, 33 insertions, 6 deletions
diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java
index a17d552f..33f7a8d4 100644
--- a/src/eu/siacs/conversations/entities/Message.java
+++ b/src/eu/siacs/conversations/entities/Message.java
@@ -1,7 +1,9 @@
package eu.siacs.conversations.entities;
+import eu.siacs.conversations.R;
import eu.siacs.conversations.xmpp.jingle.JingleConnection;
import android.content.ContentValues;
+import android.content.Context;
import android.database.Cursor;
public class Message extends AbstractEntity {
@@ -103,6 +105,20 @@ public class Message extends AbstractEntity {
public String getBody() {
return body;
}
+
+ public String getReadableBody(Context context) {
+ if ((encryption == ENCRYPTION_PGP)&&(type == TYPE_TEXT)) {
+ return ""+context.getText(R.string.encrypted_message_received);
+ } else if ((encryption == ENCRYPTION_OTR)&&(type == TYPE_IMAGE)) {
+ return ""+context.getText(R.string.encrypted_image_received);
+ } else if (encryption == ENCRYPTION_DECRYPTION_FAILED) {
+ return ""+context.getText(R.string.decryption_failed);
+ } else if (type == TYPE_IMAGE) {
+ return ""+context.getText(R.string.image_file);
+ } else {
+ return body.trim();
+ }
+ }
public long getTimeSent() {
return timeSent;
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 646eb3c0..d3e3737f 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -55,6 +55,7 @@ import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.TextView;
import android.widget.ImageView;
+import android.widget.Toast;
public class ConversationActivity extends XmppActivity {
@@ -112,6 +113,7 @@ public class ConversationActivity extends XmppActivity {
protected ConversationActivity activity = this;
private DisplayMetrics metrics;
+ private Toast prepareImageToast;
public List<Conversation> getConversationList() {
return this.conversationList;
@@ -178,7 +180,11 @@ public class ConversationActivity extends XmppActivity {
Message latestMessage = conv.getLatestMessage();
if (latestMessage.getType() == Message.TYPE_TEXT) {
- convLastMsg.setText(conv.getLatestMessage().getBody());
+ if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP)&&(latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
+ convLastMsg.setText(conv.getLatestMessage().getBody());
+ } else {
+ convLastMsg.setText(getText(R.string.encrypted_message_received));
+ }
convLastMsg.setVisibility(View.VISIBLE);
imagePreview.setVisibility(View.GONE);
} else if (latestMessage.getType() == Message.TYPE_IMAGE) {
@@ -639,11 +645,14 @@ public class ConversationActivity extends XmppActivity {
selectedFragment.hidePgpPassphraseBox();
}
} else if (requestCode == REQUEST_ATTACH_FILE_DIALOG) {
+ prepareImageToast = Toast.makeText(getApplicationContext(), getText(R.string.preparing_image), Toast.LENGTH_LONG);
final Conversation conversation = getSelectedConversation();
String presence = conversation.getNextPresence();
if (conversation.getNextEncryption() == Message.ENCRYPTION_NONE) {
+ prepareImageToast.show();
xmppConnectionService.attachImageToConversation(conversation, presence, data.getData());
} else if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
+ prepareImageToast.show();
attachPgpFile(conversation,data.getData());
} else {
Log.d(LOGTAG,"unknown next message encryption: "+conversation.getNextEncryption());
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index e06c9eeb..6850ac54 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -492,7 +492,9 @@ public class ConversationFragment extends Fragment {
@Override
public void onStop() {
super.onStop();
- this.conversation.setNextMessage(chatMsg.getText().toString());
+ if (this.conversation!=null) {
+ this.conversation.setNextMessage(chatMsg.getText().toString());
+ }
}
public void onBackendConnected() {
diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java
index 1c52ff0b..8baa3c25 100644
--- a/src/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/eu/siacs/conversations/utils/UIHelper.java
@@ -389,7 +389,7 @@ public class UIHelper {
context, true));
mBuilder.setContentTitle(conversation.getName(useSubject));
if (notify) {
- mBuilder.setTicker(conversation.getLatestMessage().getBody().trim());
+ mBuilder.setTicker(conversation.getLatestMessage().getReadableBody(context));
}
StringBuilder bigText = new StringBuilder();
List<Message> messages = conversation.getMessages();
@@ -397,10 +397,10 @@ public class UIHelper {
for (int i = messages.size() - 1; i >= 0; --i) {
if (!messages.get(i).isRead()) {
if (i == messages.size() - 1) {
- firstLine = messages.get(i).getBody().trim();
+ firstLine = messages.get(i).getReadableBody(context);
bigText.append(firstLine);
} else {
- firstLine = messages.get(i).getBody().trim();
+ firstLine = messages.get(i).getReadableBody(context);
bigText.insert(0, firstLine + "\n");
}
} else {
@@ -422,7 +422,7 @@ public class UIHelper {
names.append(unread.get(i).getName(useSubject));
}
style.addLine(Html.fromHtml("<b>" + unread.get(i).getName(useSubject)
- + "</b> " + unread.get(i).getLatestMessage().getBody().trim()));
+ + "</b> " + unread.get(i).getLatestMessage().getReadableBody(context)));
}
mBuilder.setContentTitle(unread.size() + " unread Conversations");
mBuilder.setContentText(names.toString());