add icons for gpx files
| 
						 | 
				
			
			@ -11,6 +11,7 @@ import android.support.annotation.AttrRes;
 | 
			
		|||
import android.support.annotation.DimenRes;
 | 
			
		||||
import android.support.annotation.NonNull;
 | 
			
		||||
import android.support.v7.widget.RecyclerView;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
import android.view.LayoutInflater;
 | 
			
		||||
import android.view.ViewGroup;
 | 
			
		||||
import android.widget.ImageView;
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +22,7 @@ import java.util.Arrays;
 | 
			
		|||
import java.util.List;
 | 
			
		||||
import java.util.concurrent.RejectedExecutionException;
 | 
			
		||||
 | 
			
		||||
import eu.siacs.conversations.Config;
 | 
			
		||||
import eu.siacs.conversations.R;
 | 
			
		||||
import eu.siacs.conversations.databinding.MediaBinding;
 | 
			
		||||
import eu.siacs.conversations.services.ExportBackupService;
 | 
			
		||||
| 
						 | 
				
			
			@ -51,14 +53,16 @@ public class MediaAdapter extends RecyclerView.Adapter<MediaAdapter.MediaViewHol
 | 
			
		|||
        this.mediaSize = Math.round(activity.getResources().getDimension(mediaSize));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings("rawtypes")
 | 
			
		||||
    public static void setMediaSize(RecyclerView recyclerView, int mediaSize) {
 | 
			
		||||
        RecyclerView.Adapter adapter = recyclerView.getAdapter();
 | 
			
		||||
        final RecyclerView.Adapter adapter = recyclerView.getAdapter();
 | 
			
		||||
        if (adapter instanceof MediaAdapter) {
 | 
			
		||||
            ((MediaAdapter) adapter).setMediaSize(mediaSize);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static @AttrRes int getImageAttr(Attachment attachment) {
 | 
			
		||||
    private static @AttrRes
 | 
			
		||||
    int getImageAttr(Attachment attachment) {
 | 
			
		||||
        final @AttrRes int attr;
 | 
			
		||||
        if (attachment.getType() == Attachment.Type.LOCATION) {
 | 
			
		||||
            attr = R.attr.media_preview_location;
 | 
			
		||||
| 
						 | 
				
			
			@ -66,6 +70,7 @@ public class MediaAdapter extends RecyclerView.Adapter<MediaAdapter.MediaViewHol
 | 
			
		|||
            attr = R.attr.media_preview_recording;
 | 
			
		||||
        } else {
 | 
			
		||||
            final String mime = attachment.getMime();
 | 
			
		||||
            Log.d(Config.LOGTAG, "mime=" + mime);
 | 
			
		||||
            if (mime == null) {
 | 
			
		||||
                attr = R.attr.media_preview_unknown;
 | 
			
		||||
            } else if (mime.startsWith("audio/")) {
 | 
			
		||||
| 
						 | 
				
			
			@ -84,6 +89,8 @@ public class MediaAdapter extends RecyclerView.Adapter<MediaAdapter.MediaViewHol
 | 
			
		|||
                attr = R.attr.media_preview_backup;
 | 
			
		||||
            } else if (DOCUMENT_MIMES.contains(mime)) {
 | 
			
		||||
                attr = R.attr.media_preview_document;
 | 
			
		||||
            } else if (mime.equals("application/gpx+xml")) {
 | 
			
		||||
                attr = R.attr.media_preview_tour;
 | 
			
		||||
            } else {
 | 
			
		||||
                attr = R.attr.media_preview_unknown;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,6 +36,8 @@ import android.net.Uri;
 | 
			
		|||
import android.os.Parcel;
 | 
			
		||||
import android.os.Parcelable;
 | 
			
		||||
 | 
			
		||||
import com.google.common.base.MoreObjects;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
| 
						 | 
				
			
			@ -87,6 +89,16 @@ public class Attachment implements Parcelable {
 | 
			
		|||
        return type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return MoreObjects.toStringHelper(this)
 | 
			
		||||
                .add("uri", uri)
 | 
			
		||||
                .add("type", type)
 | 
			
		||||
                .add("uuid", uuid)
 | 
			
		||||
                .add("mime", mime)
 | 
			
		||||
                .toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public enum Type {
 | 
			
		||||
        FILE, IMAGE, LOCATION, RECORDING
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,6 +14,7 @@
 | 
			
		|||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
package eu.siacs.conversations.utils;
 | 
			
		||||
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.net.Uri;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +39,7 @@ import eu.siacs.conversations.services.ExportBackupService;
 | 
			
		|||
public final class MimeUtils {
 | 
			
		||||
    private static final Map<String, String> mimeTypeToExtensionMap = new HashMap<>();
 | 
			
		||||
    private static final Map<String, String> extensionToMimeTypeMap = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    static {
 | 
			
		||||
        // The following table is based on /etc/mime.types data minus
 | 
			
		||||
        // chemical/* MIME types and MIME types that don't map to any
 | 
			
		||||
| 
						 | 
				
			
			@ -53,6 +55,7 @@ public final class MimeUtils {
 | 
			
		|||
        add("application/andrew-inset", "ez");
 | 
			
		||||
        add("application/dsptype", "tsp");
 | 
			
		||||
        add("application/epub+zip", "epub");
 | 
			
		||||
        add("application/gpx+xml", "gpx");
 | 
			
		||||
        add("application/hta", "hta");
 | 
			
		||||
        add("application/mac-binhex40", "hqx");
 | 
			
		||||
        add("application/mathematica", "nb");
 | 
			
		||||
| 
						 | 
				
			
			@ -393,6 +396,7 @@ public final class MimeUtils {
 | 
			
		|||
        add("x-epoc/x-sisx-app", "sisx");
 | 
			
		||||
        applyOverrides();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void add(String mimeType, String extension) {
 | 
			
		||||
        // If we have an existing x -> y mapping, we do not want to
 | 
			
		||||
        // override it with another mapping x -> y2.
 | 
			
		||||
| 
						 | 
				
			
			@ -406,6 +410,7 @@ public final class MimeUtils {
 | 
			
		|||
            extensionToMimeTypeMap.put(extension, mimeType);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static InputStream getContentTypesPropertiesStream() {
 | 
			
		||||
        // User override?
 | 
			
		||||
        String userTable = System.getProperty("content.types.user.table");
 | 
			
		||||
| 
						 | 
				
			
			@ -428,6 +433,7 @@ public final class MimeUtils {
 | 
			
		|||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This isn't what the RI does. The RI doesn't have hard-coded defaults, so supplying your
 | 
			
		||||
     * own "content.types.user.table" means you don't get any of the built-ins, and the built-ins
 | 
			
		||||
| 
						 | 
				
			
			@ -456,10 +462,13 @@ public final class MimeUtils {
 | 
			
		|||
        } catch (IOException ignored) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private MimeUtils() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns true if the given MIME type has an entry in the map.
 | 
			
		||||
     *
 | 
			
		||||
     * @param mimeType A MIME type (i.e. text/plain)
 | 
			
		||||
     * @return True iff there is a mimeType entry in the map.
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -469,8 +478,10 @@ public final class MimeUtils {
 | 
			
		|||
        }
 | 
			
		||||
        return mimeTypeToExtensionMap.containsKey(mimeType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the MIME type for the given extension.
 | 
			
		||||
     *
 | 
			
		||||
     * @param extension A file extension without the leading '.'
 | 
			
		||||
     * @return The MIME type for the given extension or null iff there is none.
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -480,8 +491,10 @@ public final class MimeUtils {
 | 
			
		|||
        }
 | 
			
		||||
        return extensionToMimeTypeMap.get(extension.toLowerCase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns true if the given extension has a registered MIME type.
 | 
			
		||||
     *
 | 
			
		||||
     * @param extension A file extension without the leading '.'
 | 
			
		||||
     * @return True iff there is an extension entry in the map.
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			@ -491,10 +504,12 @@ public final class MimeUtils {
 | 
			
		|||
        }
 | 
			
		||||
        return extensionToMimeTypeMap.containsKey(extension);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the registered extension for the given MIME type. Note that some
 | 
			
		||||
     * MIME types map to multiple extensions. This call will return the most
 | 
			
		||||
     * common extension for the given MIME type.
 | 
			
		||||
     *
 | 
			
		||||
     * @param mimeType A MIME type (i.e. text/plain)
 | 
			
		||||
     * @return The extension for the given MIME type or null iff there is none.
 | 
			
		||||
     */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -497,6 +497,8 @@ public class UIHelper {
 | 
			
		|||
            return context.getString(R.string.event);
 | 
			
		||||
        } else if (mime.equals("application/epub+zip") || mime.equals("application/vnd.amazon.mobi8-ebook")) {
 | 
			
		||||
            return context.getString(R.string.ebook);
 | 
			
		||||
        } else if (mime.equals("application/gpx+xml")) {
 | 
			
		||||
            return context.getString(R.string.gpx_track);
 | 
			
		||||
        } else {
 | 
			
		||||
            return mime;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
		 After Width: | Height: | Size: 369 B  | 
| 
		 After Width: | Height: | Size: 372 B  | 
| 
		 After Width: | Height: | Size: 273 B  | 
| 
		 After Width: | Height: | Size: 277 B  | 
| 
		 After Width: | Height: | Size: 451 B  | 
| 
		 After Width: | Height: | Size: 451 B  | 
| 
		 After Width: | Height: | Size: 662 B  | 
| 
		 After Width: | Height: | Size: 662 B  | 
| 
		 After Width: | Height: | Size: 809 B  | 
| 
		 After Width: | Height: | Size: 809 B  | 
| 
						 | 
				
			
			@ -66,6 +66,7 @@
 | 
			
		|||
    <attr name="media_preview_recording" format="reference" />
 | 
			
		||||
    <attr name="media_preview_audio" format="reference" />
 | 
			
		||||
    <attr name="media_preview_location" format="reference" />
 | 
			
		||||
    <attr name="media_preview_tour" format="reference" />
 | 
			
		||||
    <attr name="media_preview_contact" format="reference" />
 | 
			
		||||
    <attr name="media_preview_app" format="reference" />
 | 
			
		||||
    <attr name="media_preview_calendar" format="reference" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -925,6 +925,7 @@
 | 
			
		|||
    <string name="could_not_switch_camera">Could not switch camera</string>
 | 
			
		||||
    <string name="add_to_favorites">Add to favorites</string>
 | 
			
		||||
    <string name="remove_from_favorites">Remove from favorites</string>
 | 
			
		||||
    <string name="gpx_track">GPX track</string>
 | 
			
		||||
    <plurals name="view_users">
 | 
			
		||||
        <item quantity="one">View %1$d Participant</item>
 | 
			
		||||
        <item quantity="other">View %1$d Participants</item>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -85,6 +85,7 @@
 | 
			
		|||
        <item name="media_preview_recording" type="reference">@drawable/ic_mic_black_48dp</item>
 | 
			
		||||
        <item name="media_preview_audio" type="reference">@drawable/ic_headset_black_48dp</item>
 | 
			
		||||
        <item name="media_preview_location" type="reference">@drawable/ic_room_black_48dp</item>
 | 
			
		||||
        <item name="media_preview_tour" type="reference">@drawable/baseline_tour_black_48</item>
 | 
			
		||||
        <item name="media_preview_contact" type="reference">@drawable/ic_person_black_48dp</item>
 | 
			
		||||
        <item name="media_preview_app" type="reference">@drawable/ic_android_black_48dp</item>
 | 
			
		||||
        <item name="media_preview_calendar" type="reference">@drawable/ic_event_black_48dp</item>
 | 
			
		||||
| 
						 | 
				
			
			@ -240,6 +241,7 @@
 | 
			
		|||
        <item name="media_preview_recording" type="reference">@drawable/ic_mic_white_48dp</item>
 | 
			
		||||
        <item name="media_preview_audio" type="reference">@drawable/ic_headset_white_48dp</item>
 | 
			
		||||
        <item name="media_preview_location" type="reference">@drawable/ic_room_white_48dp</item>
 | 
			
		||||
        <item name="media_preview_tour" type="reference">@drawable/baseline_tour_white_48</item>
 | 
			
		||||
        <item name="media_preview_contact" type="reference">@drawable/ic_person_white_48dp</item>
 | 
			
		||||
        <item name="media_preview_app" type="reference">@drawable/ic_android_white_48dp</item>
 | 
			
		||||
        <item name="media_preview_calendar" type="reference">@drawable/ic_event_white_48dp</item>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||