fix: crash in contact photo and auto download flags

This commit is contained in:
0x330a
2022-11-09 22:22:10 +11:00
parent 833fc66da2
commit 5180b826f3
3 changed files with 18 additions and 6 deletions

View File

@@ -306,6 +306,20 @@ public class RecipientDatabase extends Database {
notifyRecipientListeners();
}
public void setAutoDownloadAttachments(@NonNull Recipient recipient, boolean shouldAutoDownloadAttachments) {
SQLiteDatabase db = getWritableDatabase();
db.beginTransaction();
try {
ContentValues values = new ContentValues();
values.put(AUTO_DOWNLOAD, shouldAutoDownloadAttachments ? 1 : 0);
db.update(TABLE_NAME, values, ADDRESS+ " = ?", new String[]{recipient.getAddress().serialize()});
recipient.resolve().setAutoDownloadAttachments(true);
} finally {
db.endTransaction();
}
notifyRecipientListeners();
}
public void setMuted(@NonNull Recipient recipient, long until) {
ContentValues values = new ContentValues();
values.put(MUTE_UNTIL, until);

View File

@@ -686,14 +686,15 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
}
override fun shouldAutoDownloadAttachments(recipient: Recipient): Boolean {
TODO("Not yet implemented")
return recipient.autoDownloadAttachments
}
override fun setAutoDownloadAttachments(
recipient: Recipient,
shouldAutoDownloadAttachments: Boolean
) {
TODO("Not yet implemented")
val recipientDb = DatabaseComponent.get(context).recipientDatabase()
recipientDb.setAutoDownloadAttachments(recipient, shouldAutoDownloadAttachments)
}
override fun getLastUpdated(threadID: Long): Long {

View File

@@ -40,10 +40,7 @@ public class ResourceContactPhoto implements FallbackContactPhoto {
foreground.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
}
Drawable gradient = context.getResources().getDrawable(ThemeUtil.isDarkTheme(context) ? R.drawable.avatar_gradient_dark
: R.drawable.avatar_gradient_light);
return new ExpandingLayerDrawable(new Drawable[] {background, foreground, gradient});
return new ExpandingLayerDrawable(new Drawable[] {background, foreground});
}
private static class ExpandingLayerDrawable extends LayerDrawable {