mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Add support for animated stickers.
This commit is contained in:
committed by
Cody Henthorne
parent
bb708e0aa3
commit
f4a199f621
@@ -38,21 +38,22 @@ public class StickerDatabase extends Database {
|
||||
|
||||
private static final String TAG = Log.tag(StickerDatabase.class);
|
||||
|
||||
public static final String TABLE_NAME = "sticker";
|
||||
public static final String _ID = "_id";
|
||||
static final String PACK_ID = "pack_id";
|
||||
private static final String PACK_KEY = "pack_key";
|
||||
private static final String PACK_TITLE = "pack_title";
|
||||
private static final String PACK_AUTHOR = "pack_author";
|
||||
private static final String STICKER_ID = "sticker_id";
|
||||
private static final String EMOJI = "emoji";
|
||||
private static final String COVER = "cover";
|
||||
private static final String PACK_ORDER = "pack_order";
|
||||
private static final String INSTALLED = "installed";
|
||||
private static final String LAST_USED = "last_used";
|
||||
public static final String FILE_PATH = "file_path";
|
||||
public static final String FILE_LENGTH = "file_length";
|
||||
public static final String FILE_RANDOM = "file_random";
|
||||
public static final String TABLE_NAME = "sticker";
|
||||
public static final String _ID = "_id";
|
||||
static final String PACK_ID = "pack_id";
|
||||
private static final String PACK_KEY = "pack_key";
|
||||
private static final String PACK_TITLE = "pack_title";
|
||||
private static final String PACK_AUTHOR = "pack_author";
|
||||
private static final String STICKER_ID = "sticker_id";
|
||||
private static final String EMOJI = "emoji";
|
||||
public static final String CONTENT_TYPE = "content_type";
|
||||
private static final String COVER = "cover";
|
||||
private static final String PACK_ORDER = "pack_order";
|
||||
private static final String INSTALLED = "installed";
|
||||
private static final String LAST_USED = "last_used";
|
||||
public static final String FILE_PATH = "file_path";
|
||||
public static final String FILE_LENGTH = "file_length";
|
||||
public static final String FILE_RANDOM = "file_random";
|
||||
|
||||
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
PACK_ID + " TEXT NOT NULL, " +
|
||||
@@ -63,6 +64,7 @@ public class StickerDatabase extends Database {
|
||||
COVER + " INTEGER, " +
|
||||
PACK_ORDER + " INTEGER, " +
|
||||
EMOJI + " TEXT NOT NULL, " +
|
||||
CONTENT_TYPE + " TEXT DEFAULT NULL, " +
|
||||
LAST_USED + " INTEGER, " +
|
||||
INSTALLED + " INTEGER," +
|
||||
FILE_PATH + " TEXT NOT NULL, " +
|
||||
@@ -94,6 +96,7 @@ public class StickerDatabase extends Database {
|
||||
contentValues.put(PACK_AUTHOR, sticker.getPackAuthor());
|
||||
contentValues.put(STICKER_ID, sticker.getStickerId());
|
||||
contentValues.put(EMOJI, sticker.getEmoji());
|
||||
contentValues.put(CONTENT_TYPE, sticker.getContentType());
|
||||
contentValues.put(COVER, sticker.isCover() ? 1 : 0);
|
||||
contentValues.put(INSTALLED, sticker.isInstalled() ? 1 : 0);
|
||||
contentValues.put(FILE_PATH, fileInfo.getFile().getAbsolutePath());
|
||||
@@ -460,6 +463,7 @@ public class StickerDatabase extends Database {
|
||||
cursor.getString(cursor.getColumnIndexOrThrow(PACK_KEY)),
|
||||
cursor.getInt(cursor.getColumnIndexOrThrow(STICKER_ID)),
|
||||
cursor.getString(cursor.getColumnIndexOrThrow(EMOJI)),
|
||||
cursor.getString(cursor.getColumnIndexOrThrow(CONTENT_TYPE)),
|
||||
cursor.getLong(cursor.getColumnIndexOrThrow(FILE_LENGTH)),
|
||||
cursor.getInt(cursor.getColumnIndexOrThrow(COVER)) == 1);
|
||||
}
|
||||
|
||||
@@ -144,8 +144,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||
private static final int PINNED_CONVERSATIONS = 69;
|
||||
private static final int MENTION_GLOBAL_SETTING_MIGRATION = 70;
|
||||
private static final int UNKNOWN_STORAGE_FIELDS = 71;
|
||||
private static final int STICKER_CONTENT_TYPE = 72;
|
||||
|
||||
private static final int DATABASE_VERSION = 71;
|
||||
private static final int DATABASE_VERSION = 72;
|
||||
private static final String DATABASE_NAME = "signal.db";
|
||||
|
||||
private final Context context;
|
||||
@@ -1013,6 +1014,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||
db.execSQL("ALTER TABLE recipient ADD COLUMN storage_proto TEXT DEFAULT NULL");
|
||||
}
|
||||
|
||||
if (oldVersion < STICKER_CONTENT_TYPE) {
|
||||
db.execSQL("ALTER TABLE sticker ADD COLUMN content_type TEXT DEFAULT NULL");
|
||||
}
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.database.model;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class IncomingSticker {
|
||||
|
||||
@@ -10,6 +11,7 @@ public class IncomingSticker {
|
||||
private final String packAuthor;
|
||||
private final int stickerId;
|
||||
private final String emoji;
|
||||
private final String contentType;
|
||||
private final boolean isCover;
|
||||
private final boolean isInstalled;
|
||||
|
||||
@@ -19,6 +21,7 @@ public class IncomingSticker {
|
||||
@NonNull String packAuthor,
|
||||
int stickerId,
|
||||
@NonNull String emoji,
|
||||
@Nullable String contentType,
|
||||
boolean isCover,
|
||||
boolean isInstalled)
|
||||
{
|
||||
@@ -28,6 +31,7 @@ public class IncomingSticker {
|
||||
this.packAuthor = packAuthor;
|
||||
this.stickerId = stickerId;
|
||||
this.emoji = emoji;
|
||||
this.contentType = contentType;
|
||||
this.isCover = isCover;
|
||||
this.isInstalled = isInstalled;
|
||||
}
|
||||
@@ -56,6 +60,10 @@ public class IncomingSticker {
|
||||
return emoji;
|
||||
}
|
||||
|
||||
public @Nullable String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public boolean isCover() {
|
||||
return isCover;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ package org.thoughtcrime.securesms.database.model;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -18,6 +20,7 @@ public final class StickerRecord {
|
||||
private final String packKey;
|
||||
private final int stickerId;
|
||||
private final String emoji;
|
||||
private final String contentType;
|
||||
private final long size;
|
||||
private final boolean isCover;
|
||||
|
||||
@@ -26,16 +29,18 @@ public final class StickerRecord {
|
||||
@NonNull String packKey,
|
||||
int stickerId,
|
||||
@NonNull String emoji,
|
||||
@Nullable String contentType,
|
||||
long size,
|
||||
boolean isCover)
|
||||
{
|
||||
this.rowId = rowId;
|
||||
this.packId = packId;
|
||||
this.packKey = packKey;
|
||||
this.stickerId = stickerId;
|
||||
this.emoji = emoji;
|
||||
this.size = size;
|
||||
this.isCover = isCover;
|
||||
this.rowId = rowId;
|
||||
this.packId = packId;
|
||||
this.packKey = packKey;
|
||||
this.stickerId = stickerId;
|
||||
this.emoji = emoji;
|
||||
this.contentType = contentType;
|
||||
this.size = size;
|
||||
this.isCover = isCover;
|
||||
}
|
||||
|
||||
public long getRowId() {
|
||||
@@ -62,6 +67,10 @@ public final class StickerRecord {
|
||||
return emoji;
|
||||
}
|
||||
|
||||
public @NonNull String getContentType() {
|
||||
return contentType == null ? MediaUtil.IMAGE_WEBP : contentType;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
@@ -81,11 +90,12 @@ public final class StickerRecord {
|
||||
isCover == that.isCover &&
|
||||
packId.equals(that.packId) &&
|
||||
packKey.equals(that.packKey) &&
|
||||
emoji.equals(that.emoji);
|
||||
emoji.equals(that.emoji) &&
|
||||
Objects.equals(contentType, that.contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(rowId, packId, packKey, stickerId, emoji, size, isCover);
|
||||
return Objects.hash(rowId, packId, packKey, stickerId, emoji, contentType, size, isCover);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user