diff options
author | TheOneric <Nyff@protonmail.ch> | 2019-11-15 18:33:58 +0100 |
---|---|---|
committer | Christian Schneppe <kriztan@users.noreply.github.com> | 2019-11-15 18:33:58 +0100 |
commit | ba225074d5dc89173b8058660535d417c156de2e (patch) | |
tree | 501b63180b8d52bedce478e303bebfe3b29f5512 /src/main/java/de/pixart/messenger/ui/adapter | |
parent | 60b96381f3831f8a53a084a086ae0d6645f5bea6 (diff) |
Fix empty grey box for unknown file types (#405)
Previously if files, whose mime-type was not recognized by MimeUtils, were being sent to a Pix-Art-Client only a grey box without text would be shown.
With this commit the general "open file" text is now shown for these files. Previously this text was only shown for files with recognized mime-types, not being specially handled (like images).
Also the Advanced SSA (*.ass) subtitle format was added to MimeUtils as 'text/plain'.
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/adapter')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 9d9c68b19..aed314288 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -641,29 +641,27 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie viewHolder.richlinkview.setVisibility(View.GONE); viewHolder.download_button.setVisibility(View.VISIBLE); final String mimeType = message.getMimeType(); - if (mimeType != null) { - if (message.getMimeType().contains("pdf")) { - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file_pdf_grey600_48dp, 0, 0, 0); - viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message))); - } else if (message.getMimeType().contains("vcard")) { - try { - showVCard(message, viewHolder); - } catch (Exception e) { - e.printStackTrace(); - } - } else if (message.getMimeType().contains("calendar")) { - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_calendar_grey600_48dp, 0, 0, 0); - viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message))); - } else if (message.getMimeType().equals("application/vnd.android.package-archive")) { - try { - showAPK(message, viewHolder); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file_grey600_48dp, 0, 0, 0); - viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message))); + if (mimeType != null && message.getMimeType().contains("pdf")) { + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file_pdf_grey600_48dp, 0, 0, 0); + viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message))); + } else if (mimeType != null && message.getMimeType().contains("vcard")) { + try { + showVCard(message, viewHolder); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (mimeType != null && message.getMimeType().contains("calendar")) { + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_calendar_grey600_48dp, 0, 0, 0); + viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message))); + } else if (mimeType != null && message.getMimeType().equals("application/vnd.android.package-archive")) { + try { + showAPK(message, viewHolder); + } catch (Exception e) { + e.printStackTrace(); } + } else { + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_file_grey600_48dp, 0, 0, 0); + viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message))); } viewHolder.download_button.setOnClickListener(v -> openDownloadable(message)); } |