mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 17:52:17 -05:00
nicer descriptions in notificaton for images and encrypted messages
This commit is contained in:
parent
b0a0863ba2
commit
a14a28973a
@ -53,7 +53,7 @@
|
|||||||
<string name="send_failed">unsuccessful delivery</string>
|
<string name="send_failed">unsuccessful delivery</string>
|
||||||
<string name="send_rejected">rejected</string>
|
<string name="send_rejected">rejected</string>
|
||||||
<string name="receiving_image">Receiving image file. Please wait…</string>
|
<string name="receiving_image">Receiving image file. Please wait…</string>
|
||||||
<string name="preparing_image">Preparing image for transmission. Please wait…</string>
|
<string name="preparing_image">Preparing image for transmission</string>
|
||||||
<string name="action_clear_history">Clear history</string>
|
<string name="action_clear_history">Clear history</string>
|
||||||
<string name="clear_conversation_history">Clear Conversation 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>
|
<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…</string>
|
<string name="offering">offering…</string>
|
||||||
<string name="no_pgp_key">No openPGP Key found</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="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>
|
</resources>
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package eu.siacs.conversations.entities;
|
package eu.siacs.conversations.entities;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.xmpp.jingle.JingleConnection;
|
import eu.siacs.conversations.xmpp.jingle.JingleConnection;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
|
||||||
public class Message extends AbstractEntity {
|
public class Message extends AbstractEntity {
|
||||||
@ -104,6 +106,20 @@ public class Message extends AbstractEntity {
|
|||||||
return body;
|
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() {
|
public long getTimeSent() {
|
||||||
return timeSent;
|
return timeSent;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ import android.widget.PopupMenu;
|
|||||||
import android.widget.PopupMenu.OnMenuItemClickListener;
|
import android.widget.PopupMenu.OnMenuItemClickListener;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class ConversationActivity extends XmppActivity {
|
public class ConversationActivity extends XmppActivity {
|
||||||
|
|
||||||
@ -112,6 +113,7 @@ public class ConversationActivity extends XmppActivity {
|
|||||||
|
|
||||||
protected ConversationActivity activity = this;
|
protected ConversationActivity activity = this;
|
||||||
private DisplayMetrics metrics;
|
private DisplayMetrics metrics;
|
||||||
|
private Toast prepareImageToast;
|
||||||
|
|
||||||
public List<Conversation> getConversationList() {
|
public List<Conversation> getConversationList() {
|
||||||
return this.conversationList;
|
return this.conversationList;
|
||||||
@ -178,7 +180,11 @@ public class ConversationActivity extends XmppActivity {
|
|||||||
Message latestMessage = conv.getLatestMessage();
|
Message latestMessage = conv.getLatestMessage();
|
||||||
|
|
||||||
if (latestMessage.getType() == Message.TYPE_TEXT) {
|
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);
|
convLastMsg.setVisibility(View.VISIBLE);
|
||||||
imagePreview.setVisibility(View.GONE);
|
imagePreview.setVisibility(View.GONE);
|
||||||
} else if (latestMessage.getType() == Message.TYPE_IMAGE) {
|
} else if (latestMessage.getType() == Message.TYPE_IMAGE) {
|
||||||
@ -639,11 +645,14 @@ public class ConversationActivity extends XmppActivity {
|
|||||||
selectedFragment.hidePgpPassphraseBox();
|
selectedFragment.hidePgpPassphraseBox();
|
||||||
}
|
}
|
||||||
} else if (requestCode == REQUEST_ATTACH_FILE_DIALOG) {
|
} else if (requestCode == REQUEST_ATTACH_FILE_DIALOG) {
|
||||||
|
prepareImageToast = Toast.makeText(getApplicationContext(), getText(R.string.preparing_image), Toast.LENGTH_LONG);
|
||||||
final Conversation conversation = getSelectedConversation();
|
final Conversation conversation = getSelectedConversation();
|
||||||
String presence = conversation.getNextPresence();
|
String presence = conversation.getNextPresence();
|
||||||
if (conversation.getNextEncryption() == Message.ENCRYPTION_NONE) {
|
if (conversation.getNextEncryption() == Message.ENCRYPTION_NONE) {
|
||||||
|
prepareImageToast.show();
|
||||||
xmppConnectionService.attachImageToConversation(conversation, presence, data.getData());
|
xmppConnectionService.attachImageToConversation(conversation, presence, data.getData());
|
||||||
} else if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
|
} else if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
|
prepareImageToast.show();
|
||||||
attachPgpFile(conversation,data.getData());
|
attachPgpFile(conversation,data.getData());
|
||||||
} else {
|
} else {
|
||||||
Log.d(LOGTAG,"unknown next message encryption: "+conversation.getNextEncryption());
|
Log.d(LOGTAG,"unknown next message encryption: "+conversation.getNextEncryption());
|
||||||
|
@ -492,7 +492,9 @@ public class ConversationFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
this.conversation.setNextMessage(chatMsg.getText().toString());
|
if (this.conversation!=null) {
|
||||||
|
this.conversation.setNextMessage(chatMsg.getText().toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBackendConnected() {
|
public void onBackendConnected() {
|
||||||
|
@ -389,7 +389,7 @@ public class UIHelper {
|
|||||||
context, true));
|
context, true));
|
||||||
mBuilder.setContentTitle(conversation.getName(useSubject));
|
mBuilder.setContentTitle(conversation.getName(useSubject));
|
||||||
if (notify) {
|
if (notify) {
|
||||||
mBuilder.setTicker(conversation.getLatestMessage().getBody().trim());
|
mBuilder.setTicker(conversation.getLatestMessage().getReadableBody(context));
|
||||||
}
|
}
|
||||||
StringBuilder bigText = new StringBuilder();
|
StringBuilder bigText = new StringBuilder();
|
||||||
List<Message> messages = conversation.getMessages();
|
List<Message> messages = conversation.getMessages();
|
||||||
@ -397,10 +397,10 @@ public class UIHelper {
|
|||||||
for (int i = messages.size() - 1; i >= 0; --i) {
|
for (int i = messages.size() - 1; i >= 0; --i) {
|
||||||
if (!messages.get(i).isRead()) {
|
if (!messages.get(i).isRead()) {
|
||||||
if (i == messages.size() - 1) {
|
if (i == messages.size() - 1) {
|
||||||
firstLine = messages.get(i).getBody().trim();
|
firstLine = messages.get(i).getReadableBody(context);
|
||||||
bigText.append(firstLine);
|
bigText.append(firstLine);
|
||||||
} else {
|
} else {
|
||||||
firstLine = messages.get(i).getBody().trim();
|
firstLine = messages.get(i).getReadableBody(context);
|
||||||
bigText.insert(0, firstLine + "\n");
|
bigText.insert(0, firstLine + "\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -422,7 +422,7 @@ public class UIHelper {
|
|||||||
names.append(unread.get(i).getName(useSubject));
|
names.append(unread.get(i).getName(useSubject));
|
||||||
}
|
}
|
||||||
style.addLine(Html.fromHtml("<b>" + 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.setContentTitle(unread.size() + " unread Conversations");
|
||||||
mBuilder.setContentText(names.toString());
|
mBuilder.setContentText(names.toString());
|
||||||
|
Loading…
Reference in New Issue
Block a user