mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Add initial thumbnail restore for message backup.
This commit is contained in:
@@ -32,11 +32,13 @@ public class PartAuthority {
|
||||
|
||||
private static final String AUTHORITY = BuildConfig.APPLICATION_ID;
|
||||
private static final String PART_URI_STRING = "content://" + AUTHORITY + "/part";
|
||||
private static final String PART_THUMBNAIL_STRING = "content://" + AUTHORITY + "/thumbnail";
|
||||
private static final String STICKER_URI_STRING = "content://" + AUTHORITY + "/sticker";
|
||||
private static final String WALLPAPER_URI_STRING = "content://" + AUTHORITY + "/wallpaper";
|
||||
private static final String EMOJI_URI_STRING = "content://" + AUTHORITY + "/emoji";
|
||||
private static final String AVATAR_PICKER_URI_STRING = "content://" + AUTHORITY + "/avatar_picker";
|
||||
private static final Uri PART_CONTENT_URI = Uri.parse(PART_URI_STRING);
|
||||
private static final Uri PART_THUMBNAIL_URI = Uri.parse(PART_THUMBNAIL_STRING);
|
||||
private static final Uri STICKER_CONTENT_URI = Uri.parse(STICKER_URI_STRING);
|
||||
private static final Uri WALLPAPER_CONTENT_URI = Uri.parse(WALLPAPER_URI_STRING);
|
||||
private static final Uri EMOJI_CONTENT_URI = Uri.parse(EMOJI_URI_STRING);
|
||||
@@ -49,12 +51,14 @@ public class PartAuthority {
|
||||
private static final int WALLPAPER_ROW = 5;
|
||||
private static final int EMOJI_ROW = 6;
|
||||
private static final int AVATAR_PICKER_ROW = 7;
|
||||
private static final int THUMBNAIL_ROW = 8;
|
||||
|
||||
private static final UriMatcher uriMatcher;
|
||||
|
||||
static {
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI(AUTHORITY, "part/#", PART_ROW);
|
||||
uriMatcher.addURI(AUTHORITY, "thumbnail/#", THUMBNAIL_ROW);
|
||||
uriMatcher.addURI(AUTHORITY, "sticker/#", STICKER_ROW);
|
||||
uriMatcher.addURI(AUTHORITY, "wallpaper/*", WALLPAPER_ROW);
|
||||
uriMatcher.addURI(AUTHORITY, "emoji/*", EMOJI_ROW);
|
||||
@@ -83,6 +87,7 @@ public class PartAuthority {
|
||||
case WALLPAPER_ROW: return WallpaperStorage.read(context, getWallpaperFilename(uri));
|
||||
case EMOJI_ROW: return EmojiFiles.openForReading(context, getEmojiFilename(uri));
|
||||
case AVATAR_PICKER_ROW: return AvatarPickerStorage.read(context, getAvatarPickerFilename(uri));
|
||||
case THUMBNAIL_ROW: return SignalDatabase.attachments().getAttachmentThumbnailStream(new PartUriParser(uri).getPartId(), 0);
|
||||
default: return openExternalFileStream(context, uri);
|
||||
}
|
||||
} catch (SecurityException se) {
|
||||
@@ -178,7 +183,7 @@ public class PartAuthority {
|
||||
}
|
||||
|
||||
public static Uri getAttachmentThumbnailUri(AttachmentId attachmentId) {
|
||||
return getAttachmentDataUri(attachmentId);
|
||||
return ContentUris.withAppendedId(PART_THUMBNAIL_URI, attachmentId.id);
|
||||
}
|
||||
|
||||
public static Uri getStickerUri(long id) {
|
||||
|
||||
@@ -49,9 +49,18 @@ public abstract class Slide {
|
||||
return attachment.contentType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Uri getThumbnailUri() {
|
||||
return attachment.getThumbnailUri();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Uri getUri() {
|
||||
return attachment.getUri();
|
||||
Uri attachmentUri = attachment.getUri();
|
||||
if (attachmentUri != null) {
|
||||
return attachmentUri;
|
||||
}
|
||||
return attachment.getThumbnailUri();
|
||||
}
|
||||
|
||||
public @Nullable Uri getPublicUri() {
|
||||
|
||||
Reference in New Issue
Block a user