enable media forwarding

fixes #1362
closes #4589
// FREEBIE
This commit is contained in:
Jake McGinty
2015-11-18 12:54:40 -08:00
parent 6a99c6c4ac
commit 02c37e815c
7 changed files with 101 additions and 79 deletions

View File

@@ -27,6 +27,7 @@ import android.provider.ContactsContract;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
@@ -46,6 +47,8 @@ import org.whispersystems.libaxolotl.util.guava.Optional;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import ws.com.google.android.mms.ContentType;
public class AttachmentManager {
private final static String TAG = AttachmentManager.class.getSimpleName();
@@ -279,5 +282,14 @@ public class AttachmentManager {
default: throw new AssertionError("unrecognized enum");
}
}
public static @Nullable MediaType from(final @Nullable String mimeType) {
if (TextUtils.isEmpty(mimeType)) return null;
if (MediaUtil.isGif(mimeType)) return GIF;
if (ContentType.isImageType(mimeType)) return IMAGE;
if (ContentType.isAudioType(mimeType)) return AUDIO;
if (ContentType.isVideoType(mimeType)) return VIDEO;
return null;
}
}
}

View File

@@ -76,4 +76,16 @@ public class PartAuthority {
Uri uri = Uri.withAppendedPath(THUMB_CONTENT_URI, String.valueOf(attachmentId.getUniqueId()));
return ContentUris.withAppendedId(uri, attachmentId.getRowId());
}
public static boolean isLocalUri(final @NonNull Uri uri) {
int match = uriMatcher.match(uri);
switch (match) {
case PART_ROW:
case THUMB_ROW:
case PERSISTENT_ROW:
case SINGLE_USE_ROW:
return true;
}
return false;
}
}