~singpolyma/cheogram-android

c795cdb722a71059d0868aabb11682e5f46dfa23 — Daniel Gultsch 5 years ago b15777b
add icon for unknown file while keeping 'file' icon for documents
M src/main/java/eu/siacs/conversations/ui/adapter/MediaPreviewAdapter.java => src/main/java/eu/siacs/conversations/ui/adapter/MediaPreviewAdapter.java +14 -2
@@ 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));

A src/main/res/drawable-hdpi/ic_help_black_48dp.png => src/main/res/drawable-hdpi/ic_help_black_48dp.png +0 -0
A src/main/res/drawable-hdpi/ic_help_white_48dp.png => src/main/res/drawable-hdpi/ic_help_white_48dp.png +0 -0
A src/main/res/drawable-mdpi/ic_help_black_48dp.png => src/main/res/drawable-mdpi/ic_help_black_48dp.png +0 -0
A src/main/res/drawable-mdpi/ic_help_white_48dp.png => src/main/res/drawable-mdpi/ic_help_white_48dp.png +0 -0
A src/main/res/drawable-xhdpi/ic_help_black_48dp.png => src/main/res/drawable-xhdpi/ic_help_black_48dp.png +0 -0
A src/main/res/drawable-xhdpi/ic_help_white_48dp.png => src/main/res/drawable-xhdpi/ic_help_white_48dp.png +0 -0
A src/main/res/drawable-xxhdpi/ic_help_black_48dp.png => src/main/res/drawable-xxhdpi/ic_help_black_48dp.png +0 -0
A src/main/res/drawable-xxhdpi/ic_help_white_48dp.png => src/main/res/drawable-xxhdpi/ic_help_white_48dp.png +0 -0
A src/main/res/drawable-xxxhdpi/ic_help_black_48dp.png => src/main/res/drawable-xxxhdpi/ic_help_black_48dp.png +0 -0
A src/main/res/drawable-xxxhdpi/ic_help_white_48dp.png => src/main/res/drawable-xxxhdpi/ic_help_white_48dp.png +0 -0
M src/main/res/values/attrs.xml => src/main/res/values/attrs.xml +2 -1
@@ 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"/>

M src/main/res/values/themes.xml => src/main/res/values/themes.xml +4 -2
@@ 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>