aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-05-09 20:46:43 +0200
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-05-09 20:46:43 +0200
commita14a28973ada020234c60680a51cdff2f9129de9 (patch)
tree0023194f9d53d0db6f7844829e210e15d9b88663
parentb0a0863ba2c23023b0b04d813b1dc30bd638735e (diff)
nicer descriptions in notificaton for images and encrypted messages
Diffstat (limited to '')
-rw-r--r--res/values/strings.xml5
-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
5 files changed, 37 insertions, 7 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 61134d29..43ef5069 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -53,7 +53,7 @@
<string name="send_failed">unsuccessful delivery</string>
<string name="send_rejected">rejected</string>
<string name="receiving_image">Receiving image file. Please wait&#8230;</string>
- <string name="preparing_image">Preparing image for transmission. Please wait&#8230;</string>
+ <string name="preparing_image">Preparing image for transmission</string>
<string name="action_clear_history">Clear history</string>
<string name="clear_conversation_history">Clear Conversation History</string>
<string name="clear_histor_msg">Do you want to delete all messages within this Conversation?\n\n<b>Warning:</b> This will not influence messages stored on other devices or servers.</string>
@@ -86,4 +86,7 @@
<string name="offering">offering&#8230;</string>
<string name="no_pgp_key">No openPGP Key found</string>
<string name="contact_has_no_pgp_key">Conversations is unable to encrypt your messages because your contact is not announcing his or hers public key.\n\n<small>Please ask your contact to setup openPGP.</small></string>
+ <string name="encrypted_message_received"><i>Encrypted message received. Touch to view and decrypt.</i></string>
+ <string name="encrypted_image_received"><i>Encrypted image received. Touch to view and decrypt.</i></string>
+ <string name="image_file"><i>Image received. Touch to view</i></string>
</resources>
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());