Default to WEBP for sticker contentTypes.

master
Greyson Parrelli 2020-09-22 22:22:52 -04:00
parent 45915bed90
commit 41b10630bb
3 changed files with 15 additions and 3 deletions

View File

@ -148,8 +148,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int STICKER_CONTENT_TYPE = 72;
private static final int STICKER_EMOJI_IN_NOTIFICATIONS = 73;
private static final int THUMBNAIL_CLEANUP = 74;
private static final int STICKER_CONTENT_TYPE_CLEANUP = 75;
private static final int DATABASE_VERSION = 74;
private static final int DATABASE_VERSION = 75;
private static final String DATABASE_NAME = "signal.db";
private final Context context;
@ -1049,6 +1050,16 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
Log.w(TAG, "Deleted " + deleted + "/" + total + " thumbnail files.");
}
if (oldVersion < STICKER_CONTENT_TYPE_CLEANUP) {
ContentValues values = new ContentValues();
values.put("ct", "image/webp");
String query = "sticker_id NOT NULL AND (ct IS NULL OR ct = '')";
int rows = db.update("part", values, query, null);
Log.i(TAG, "Updated " + rows + " sticker attachment content types.");
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();

View File

@ -7,6 +7,7 @@ import androidx.annotation.Nullable;
import org.thoughtcrime.securesms.mms.PartAuthority;
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.Util;
import java.util.Objects;
@ -68,7 +69,7 @@ public final class StickerRecord {
}
public @NonNull String getContentType() {
return contentType == null ? MediaUtil.IMAGE_WEBP : contentType;
return Util.isEmpty(contentType) ? MediaUtil.IMAGE_WEBP : contentType;
}
public long getSize() {

View File

@ -153,8 +153,8 @@ public final class AttachmentCompressionJob extends BaseJob {
if (MediaUtil.isJpeg(attachment)) {
MediaStream stripped = getResizedMedia(context, attachment, constraints);
attachmentDatabase.updateAttachmentData(attachment, stripped, false);
attachmentDatabase.markAttachmentAsTransformed(attachmentId);
}
attachmentDatabase.markAttachmentAsTransformed(attachmentId);
} else if (constraints.canResize(attachment)) {
MediaStream resized = getResizedMedia(context, attachment, constraints);
attachmentDatabase.updateAttachmentData(attachment, resized, false);