aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java
index f27aabb6..a2ed6d81 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java
@@ -210,16 +210,26 @@ public class UIHelper {
} else if (mime.startsWith("image/")) {
return context.getString(R.string.image);
} else if (mime.contains("pdf")) {
- return context.getString(R.string.pdf_document) ;
+ return context.getString(R.string.pdf_document);
} else if (mime.contains("application/vnd.android.package-archive")) {
- return context.getString(R.string.apk) ;
+ return context.getString(R.string.apk);
} else if (mime.contains("vcard")) {
- return context.getString(R.string.vcard) ;
+ return context.getString(R.string.vcard);
} else {
- return message.getRelativeFilePath();
+ String filename = getDisplayFilename(message);
+ if (null == filename) {
+ return context.getString(R.string.file);
+ } else {
+ return filename;
+ }
}
}
+ public static String getDisplayFilename(final Message message) {
+ String originalFilename = (null != message.getFileParams()) ? message.getFileParams().getOriginalFilename() : null;
+ return (null != originalFilename) ? originalFilename : message.getRelativeFilePath();
+ }
+
public static String getMessageDisplayName(final Message message) {
final Conversation conversation = message.getConversation();
if (message.getStatus() == Message.STATUS_RECEIVED) {
@@ -280,7 +290,20 @@ public class UIHelper {
return LOCATION_QUESTIONS.contains(body);
}
- public static String getHumanReadableFileSize(long filesize) {
+ public static String getHumanReadableFileSize(long size) {
+ String filesize;
+ if (size > (1.5 * 1024 * 1024)) {
+ filesize = size / (1024 * 1024)+ " MiB";
+ } else if (size > 0) {
+ filesize = size / 1024 + " KiB";
+ } else {
+ filesize = null;
+ }
+
+ return filesize;
+ }
+
+ public static String getHumanReadableDetailedFileSize(long filesize) {
if (0 > filesize) {
return "?";
}