diff options
Diffstat (limited to '')
3 files changed, 25 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java index 19af8b31b..0a9c2d513 100644 --- a/src/main/java/de/pixart/messenger/Config.java +++ b/src/main/java/de/pixart/messenger/Config.java @@ -112,7 +112,7 @@ public final class Config { public static final boolean PUT_AUTH_TAG_INTO_KEY = true; public static final int MAX_DISPLAY_MESSAGE_CHARS = 4096; - public static final int MAX_STORAGE_MESSAGE_CHARS = 1024 * 1024; //1MB + public static final int MAX_STORAGE_MESSAGE_CHARS = 2 * 1024 * 1024; //2MB public static final boolean ExportLogs = true; // automatically export logs public static final int ExportLogs_Hour = 4; //Time - hours: valid values from 0 to 23 diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java index 44e78015f..9f78b631c 100644 --- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java @@ -51,6 +51,7 @@ import de.pixart.messenger.entities.Roster; import de.pixart.messenger.entities.ServiceDiscoveryResult; import de.pixart.messenger.services.ShortcutService; import de.pixart.messenger.utils.CryptoHelper; +import de.pixart.messenger.utils.CursorUtils; import de.pixart.messenger.utils.FtsUtils; import de.pixart.messenger.utils.Resolver; import de.pixart.messenger.xmpp.InvalidJid; @@ -793,12 +794,10 @@ public class DatabaseBackend extends SQLiteOpenHelper { null, null, Message.TIME_SENT + " DESC", String.valueOf(limit)); } + CursorUtils.upgradeCursorWindowSize(cursor); while (cursor.moveToNext()) { try { - final Message message = Message.fromCursor(cursor, conversation); - if (message != null && !message.isMessageDeleted()) { - list.add(0, message); - } + list.add(0, Message.fromCursor(cursor, conversation)); } catch (Exception e) { Log.e(Config.LOGTAG, "unable to restore message"); } diff --git a/src/main/java/de/pixart/messenger/utils/CursorUtils.java b/src/main/java/de/pixart/messenger/utils/CursorUtils.java new file mode 100644 index 000000000..39b4df908 --- /dev/null +++ b/src/main/java/de/pixart/messenger/utils/CursorUtils.java @@ -0,0 +1,21 @@ +package de.pixart.messenger.utils; + +import android.database.AbstractWindowedCursor; +import android.database.Cursor; +import android.database.CursorWindow; +import android.database.sqlite.SQLiteCursor; + +public class CursorUtils { + + public static void upgradeCursorWindowSize(final Cursor cursor) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) { + if (cursor instanceof AbstractWindowedCursor) { + final AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor) cursor; + windowedCursor.setWindow(new CursorWindow("8k", 8 * 1024 * 1024)); + } + if (cursor instanceof SQLiteCursor) { + ((SQLiteCursor) cursor).setFillWindowForwardOnly(true); + } + } + } +}
\ No newline at end of file |