aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java41
-rw-r--r--src/main/java/eu/siacs/conversations/utils/UIHelper.java29
-rw-r--r--src/main/res/values/strings.xml10
3 files changed, 19 insertions, 61 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index a1361fa1..1d8b2e44 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -487,39 +487,14 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
});
- if (message.getDownloadable() != null && message.getDownloadable().getStatus() != Downloadable.STATUS_UPLOADING) {
- Downloadable d = message.getDownloadable();
- if (d.getStatus() == Downloadable.STATUS_DOWNLOADING) {
- if (message.getType() == Message.TYPE_FILE) {
- displayInfoMessage(viewHolder,activity.getString(R.string.receiving_x_file,
- UIHelper.getFileDescriptionString(activity,message),
- d.getProgress()));
- } else {
- displayInfoMessage(viewHolder,activity.getString(R.string.receiving_image,d.getProgress()));
- }
- } else if (d.getStatus() == Downloadable.STATUS_CHECKING) {
- displayInfoMessage(viewHolder,activity.getString(R.string.checking_image));
- } else if (d.getStatus() == Downloadable.STATUS_DELETED) {
- if (message.getType() == Message.TYPE_FILE) {
- displayInfoMessage(viewHolder, activity.getString(R.string.file_deleted));
- } else {
- displayInfoMessage(viewHolder, activity.getString(R.string.image_file_deleted));
- }
- } else if (d.getStatus() == Downloadable.STATUS_OFFER) {
- if (message.getType() == Message.TYPE_FILE) {
- displayDownloadableMessage(viewHolder,message,activity.getString(R.string.download_x_file,
- UIHelper.getFileDescriptionString(activity,message)));
- } else {
- displayDownloadableMessage(viewHolder, message,activity.getString(R.string.download_image));
- }
- } else if (d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) {
- displayDownloadableMessage(viewHolder, message,activity.getString(R.string.check_image_filesize));
- } else if (d.getStatus() == Downloadable.STATUS_FAILED) {
- if (message.getType() == Message.TYPE_FILE) {
- displayInfoMessage(viewHolder, activity.getString(R.string.file_transmission_failed));
- } else {
- displayInfoMessage(viewHolder, activity.getString(R.string.image_transmission_failed));
- }
+ final Downloadable downloadable = message.getDownloadable();
+ if (downloadable != null && downloadable.getStatus() != Downloadable.STATUS_UPLOADING) {
+ if (downloadable.getStatus() == Downloadable.STATUS_OFFER) {
+ displayDownloadableMessage(viewHolder,message,activity.getString(R.string.download_x_file, UIHelper.getFileDescriptionString(activity, message)));
+ } else if (downloadable.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) {
+ displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_image_filesize));
+ } else {
+ displayInfoMessage(viewHolder, UIHelper.getMessagePreview(activity, message).first);
}
} else if (message.getType() == Message.TYPE_IMAGE && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
displayImageMessage(viewHolder, message);
diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
index b2ca8e4a..d1a4b4a9 100644
--- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
@@ -118,33 +118,17 @@ public class UIHelper {
case Downloadable.STATUS_CHECKING:
return new Pair<>(context.getString(R.string.checking_image),true);
case Downloadable.STATUS_DOWNLOADING:
- if (message.getType() == Message.TYPE_FILE) {
- return new Pair<>(context.getString(R.string.receiving_x_file,
+ return new Pair<>(context.getString(R.string.receiving_x_file,
getFileDescriptionString(context,message),
d.getProgress()),true);
- } else {
- return new Pair<>(context.getString(R.string.receiving_image, d.getProgress()),true);
- }
case Downloadable.STATUS_OFFER:
case Downloadable.STATUS_OFFER_CHECK_FILESIZE:
- if (message.getType() == Message.TYPE_FILE) {
- return new Pair<>(context.getString(R.string.x_file_offered_for_download,
+ return new Pair<>(context.getString(R.string.x_file_offered_for_download,
getFileDescriptionString(context,message)),true);
- } else {
- return new Pair<>(context.getString(R.string.image_offered_for_download),true);
- }
case Downloadable.STATUS_DELETED:
- if (message.getType() == Message.TYPE_FILE) {
- return new Pair<>(context.getString(R.string.file_deleted),true);
- } else {
- return new Pair<>(context.getString(R.string.image_file_deleted),true);
- }
+ return new Pair<>(context.getString(R.string.file_deleted),true);
case Downloadable.STATUS_FAILED:
- if (message.getType() == Message.TYPE_FILE) {
- return new Pair<>(context.getString(R.string.file_transmission_failed),true);
- } else {
- return new Pair<>(context.getString(R.string.image_transmission_failed),true);
- }
+ return new Pair<>(context.getString(R.string.file_transmission_failed),true);
default:
return new Pair<>("",false);
}
@@ -167,13 +151,16 @@ public class UIHelper {
}
public static String getFileDescriptionString(final Context context, final Message message) {
+ if (message.getType() == Message.TYPE_IMAGE) {
+ return context.getString(R.string.image);
+ }
final String path = message.getRelativeFilePath();
if (path == null) {
return "";
}
final String mime;
try {
- mime = URLConnection.guessContentTypeFromName(path);
+ mime = URLConnection.guessContentTypeFromName(path.replace("#",""));
} catch (final StringIndexOutOfBoundsException ignored) {
return context.getString(R.string.file);
}
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 8baf794a..c50355ed 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -72,7 +72,6 @@
<string name="add_contact">Add contact</string>
<string name="send_failed">delivery failed</string>
<string name="send_rejected">rejected</string>
- <string name="receiving_image">Receiving image file (%1$d%%)</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>
@@ -85,7 +84,6 @@
<string name="send_pgp_message">Send OpenPGP encrypted message</string>
<string name="your_nick_has_been_changed">Your nickname has been changed</string>
<string name="download_image">Download Image</string>
- <string name="image_offered_for_download"><i>Image file offered for download</i></string>
<string name="send_unencrypted">Send unencrypted</string>
<string name="decryption_failed">Decryption failed. Maybe you don’t have the proper private key.</string>
<string name="openkeychain_required">OpenKeychain</string>
@@ -99,8 +97,6 @@
<string name="no_pgp_keys">No OpenPGP Keys found</string>
<string name="contacts_have_no_pgp_keys">Conversations is unable to encrypt your messages because your contacts are not announcing their public key.\n\n<small>Please ask your contacts 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>
<string name="pref_general">General</string>
<string name="pref_xmpp_resource">XMPP resource</string>
<string name="pref_xmpp_resource_summary">The name this client identifies itself with</string>
@@ -437,9 +433,9 @@
<string name="pref_enter_is_send_summary">Use enter key to send message</string>
<string name="pref_display_enter_key">Show enter key</string>
<string name="pref_display_enter_key_summary">Change the emoticons key to an enter key</string>
- <string name="audio">audio file</string>
- <string name="video">video file</string>
- <string name="image">image file</string>
+ <string name="audio">audio</string>
+ <string name="video">video</string>
+ <string name="image">image</string>
<string name="pdf_document">PDF document</string>
<string name="apk">Android App</string>
<string name="vcard">Contact</string>