From a14a28973ada020234c60680a51cdff2f9129de9 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 9 May 2014 20:46:43 +0200 Subject: nicer descriptions in notificaton for images and encrypted messages --- src/eu/siacs/conversations/ui/ConversationActivity.java | 11 ++++++++++- src/eu/siacs/conversations/ui/ConversationFragment.java | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/eu/siacs/conversations/ui') diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index 646eb3c04..d3e3737fa 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 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 e06c9eeb7..6850ac54f 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() { -- cgit v1.2.3