add icon for unknown file while keeping 'file' icon for documents
|
@ -17,6 +17,7 @@ import android.widget.ImageView;
|
|||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
|
@ -29,6 +30,15 @@ import eu.siacs.conversations.ui.util.StyledAttributes;
|
|||
|
||||
public class MediaPreviewAdapter extends RecyclerView.Adapter<MediaPreviewAdapter.MediaPreviewViewHolder> {
|
||||
|
||||
private static final List<String> DOCUMENT_MIMES = Arrays.asList(
|
||||
"application/pdf",
|
||||
"application/vnd.oasis.opendocument.text",
|
||||
"application/msword",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"text/x-tex",
|
||||
"text/plain"
|
||||
);
|
||||
|
||||
private final ArrayList<Attachment> mediaPreviews = new ArrayList<>();
|
||||
|
||||
private final ConversationFragment conversationFragment;
|
||||
|
@ -64,7 +74,7 @@ public class MediaPreviewAdapter extends RecyclerView.Adapter<MediaPreviewAdapte
|
|||
} else {
|
||||
final String mime = attachment.getMime();
|
||||
if (mime == null) {
|
||||
attr = R.attr.media_preview_file;
|
||||
attr = R.attr.media_preview_unknown;
|
||||
} else if (mime.startsWith("audio/")) {
|
||||
attr = R.attr.media_preview_audio;
|
||||
} else if (mime.equals("text/calendar") || (mime.equals("text/x-vcalendar"))) {
|
||||
|
@ -75,8 +85,10 @@ public class MediaPreviewAdapter extends RecyclerView.Adapter<MediaPreviewAdapte
|
|||
attr = R.attr.media_preview_app;
|
||||
} else if (mime.equals("application/zip") || mime.equals("application/rar")) {
|
||||
attr = R.attr.media_preview_archive;
|
||||
} else if (DOCUMENT_MIMES.contains(mime)) {
|
||||
attr = R.attr.media_preview_document;
|
||||
} else {
|
||||
attr = R.attr.media_preview_file;
|
||||
attr = R.attr.media_preview_unknown;
|
||||
}
|
||||
}
|
||||
holder.binding.mediaPreview.setImageDrawable(StyledAttributes.getDrawable(context, attr));
|
||||
|
|
BIN
src/main/res/drawable-hdpi/ic_help_black_48dp.png
Normal file
After Width: | Height: | Size: 834 B |
BIN
src/main/res/drawable-hdpi/ic_help_white_48dp.png
Normal file
After Width: | Height: | Size: 842 B |
BIN
src/main/res/drawable-mdpi/ic_help_black_48dp.png
Normal file
After Width: | Height: | Size: 579 B |
BIN
src/main/res/drawable-mdpi/ic_help_white_48dp.png
Normal file
After Width: | Height: | Size: 585 B |
BIN
src/main/res/drawable-xhdpi/ic_help_black_48dp.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
src/main/res/drawable-xhdpi/ic_help_white_48dp.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
src/main/res/drawable-xxhdpi/ic_help_black_48dp.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
src/main/res/drawable-xxhdpi/ic_help_white_48dp.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
src/main/res/drawable-xxxhdpi/ic_help_black_48dp.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
src/main/res/drawable-xxxhdpi/ic_help_white_48dp.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
|
@ -52,7 +52,7 @@
|
|||
<attr name="icon_alpha" format="float"/>
|
||||
<attr name="delete_icon_alpha" format="float"/>
|
||||
|
||||
<attr name="media_preview_file" format="reference"/>
|
||||
<attr name="media_preview_document" format="reference"/>
|
||||
<attr name="media_preview_recording" format="reference"/>
|
||||
<attr name="media_preview_audio" format="reference"/>
|
||||
<attr name="media_preview_location" format="reference"/>
|
||||
|
@ -60,6 +60,7 @@
|
|||
<attr name="media_preview_app" format="reference"/>
|
||||
<attr name="media_preview_calendar" format="reference"/>
|
||||
<attr name="media_preview_archive" format="reference" />
|
||||
<attr name="media_preview_unknown" format="reference" />
|
||||
|
||||
|
||||
<attr name="icon_add_group" format="reference"/>
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<item name="dialog_horizontal_padding">24dp</item>
|
||||
<item name="dialog_vertical_padding">16dp</item>
|
||||
|
||||
<item type="reference" name="media_preview_file">@drawable/ic_description_black_48dp</item>
|
||||
<item type="reference" name="media_preview_document">@drawable/ic_description_black_48dp</item>
|
||||
<item type="reference" name="media_preview_recording">@drawable/ic_mic_black_48dp</item>
|
||||
<item type="reference" name="media_preview_audio">@drawable/ic_headset_black_48dp</item>
|
||||
<item type="reference" name="media_preview_location">@drawable/ic_room_black_48dp</item>
|
||||
|
@ -71,6 +71,7 @@
|
|||
<item type="reference" name="media_preview_app">@drawable/ic_android_black_48dp</item>
|
||||
<item type="reference" name="media_preview_calendar">@drawable/ic_event_black_48dp</item>
|
||||
<item type="reference" name="media_preview_archive">@drawable/ic_archive_black_48dp</item>
|
||||
<item type="reference" name="media_preview_unknown">@drawable/ic_help_black_48dp</item>
|
||||
|
||||
<item type="reference" name="icon_add_group">@drawable/ic_group_add_white_24dp</item>
|
||||
<item type="reference" name="icon_add_person">@drawable/ic_person_add_white_24dp</item>
|
||||
|
@ -173,7 +174,7 @@
|
|||
<item name="dialog_horizontal_padding">24dp</item>
|
||||
<item name="dialog_vertical_padding">16dp</item>
|
||||
|
||||
<item type="reference" name="media_preview_file">@drawable/ic_description_white_48dp</item>
|
||||
<item type="reference" name="media_preview_document">@drawable/ic_description_white_48dp</item>
|
||||
<item type="reference" name="media_preview_recording">@drawable/ic_mic_white_48dp</item>
|
||||
<item type="reference" name="media_preview_audio">@drawable/ic_headset_white_48dp</item>
|
||||
<item type="reference" name="media_preview_location">@drawable/ic_room_white_48dp</item>
|
||||
|
@ -181,6 +182,7 @@
|
|||
<item type="reference" name="media_preview_app">@drawable/ic_android_white_48dp</item>
|
||||
<item type="reference" name="media_preview_calendar">@drawable/ic_event_white_48dp</item>
|
||||
<item type="reference" name="media_preview_archive">@drawable/ic_archive_white_48dp</item>
|
||||
<item type="reference" name="media_preview_unknown">@drawable/ic_help_white_48dp</item>
|
||||
|
||||
<item type="reference" name="icon_add_group">@drawable/ic_group_add_white_24dp</item>
|
||||
<item type="reference" name="icon_add_person">@drawable/ic_person_add_white_24dp</item>
|
||||
|
|