Loading app/core/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ dependencies { testImplementation project(':mail:testing') testImplementation project(":backend:imap") testImplementation project(":mail:protocols:smtp") testImplementation project(":app:storage") testImplementation "org.robolectric:robolectric:${versions.robolectric}" testImplementation "junit:junit:${versions.junit}" testImplementation "com.google.truth:truth:${versions.truth}" Loading app/core/src/main/java/com/fsck/k9/K9.java +3 −3 Original line number Diff line number Diff line Loading @@ -354,7 +354,7 @@ public class K9 { * {@code SharedPreference}. * * <p> * If the stored version matches {@link LocalStore#DB_VERSION} we know that the databases are * If the stored version matches {@link LocalStore#getDbVersion()} we know that the databases are * up to date.<br> * Using {@code SharedPreferences} should be a lot faster than opening all SQLite databases to * get the current database version. Loading @@ -369,7 +369,7 @@ public class K9 { int cachedVersion = databaseVersionCache.getInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, 0); if (cachedVersion >= LocalStore.DB_VERSION) { if (cachedVersion >= LocalStore.getDbVersion()) { K9.setDatabasesUpToDate(false); } if (cachedVersion < VERSION_MIGRATE_OPENPGP_TO_ACCOUNTS) { Loading Loading @@ -1073,7 +1073,7 @@ public class K9 { if (save) { Editor editor = databaseVersionCache.edit(); editor.putInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, LocalStore.DB_VERSION); editor.putInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, LocalStore.getDbVersion()); editor.apply(); } } Loading app/core/src/main/java/com/fsck/k9/crypto/EncryptionExtractor.kt 0 → 100644 +17 −0 Original line number Diff line number Diff line package com.fsck.k9.crypto import android.content.ContentValues import com.fsck.k9.mail.Message import com.fsck.k9.message.extractors.PreviewResult interface EncryptionExtractor { fun extractEncryption(message: Message): EncryptionResult? } data class EncryptionResult( val encryptionType: String, val attachmentCount: Int, val previewResult: PreviewResult = PreviewResult.encrypted(), val textForSearchIndex: String? = null, val extraContentValues: ContentValues? = null ) app/core/src/main/java/com/fsck/k9/mailstore/LocalFolder.java +33 −8 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ import com.fsck.k9.DI; import com.fsck.k9.K9; import com.fsck.k9.controller.MessageReference; import com.fsck.k9.backend.api.MessageRemovalListener; import com.fsck.k9.crypto.EncryptionExtractor; import com.fsck.k9.crypto.EncryptionResult; import com.fsck.k9.helper.FileHelper; import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.Address; Loading Loading @@ -77,6 +79,7 @@ public class LocalFolder extends Folder<LocalMessage> { private final SearchStatusManager searchStatusManager = DI.get(SearchStatusManager.class); private final LocalStore localStore; private final AttachmentInfoExtractor attachmentInfoExtractor; private final EncryptionExtractor encryptionExtractor = DI.get(EncryptionExtractor.class); private String serverId = null; Loading Loading @@ -1379,16 +1382,33 @@ public class LocalFolder extends Folder<LocalMessage> { } try { MessagePreviewCreator previewCreator = localStore.getMessagePreviewCreator(); PreviewResult previewResult = previewCreator.createPreview(message); PreviewType previewType = previewResult.getPreviewType(); DatabasePreviewType databasePreviewType = DatabasePreviewType.fromPreviewType(previewType); String encryptionType; PreviewResult previewResult; int attachmentCount; String fulltext; ContentValues extraContentValues; EncryptionResult encryptionResult = encryptionExtractor.extractEncryption(message); if (encryptionResult != null) { encryptionType = encryptionResult.getEncryptionType(); previewResult = encryptionResult.getPreviewResult(); attachmentCount = encryptionResult.getAttachmentCount(); fulltext = encryptionResult.getTextForSearchIndex(); extraContentValues = encryptionResult.getExtraContentValues(); } else { MessagePreviewCreator previewCreator = localStore.getMessagePreviewCreator(); MessageFulltextCreator fulltextCreator = localStore.getMessageFulltextCreator(); String fulltext = fulltextCreator.createFulltext(message); AttachmentCounter attachmentCounter = localStore.getAttachmentCounter(); int attachmentCount = attachmentCounter.getAttachmentCount(message); encryptionType = null; previewResult = previewCreator.createPreview(message); attachmentCount = attachmentCounter.getAttachmentCount(message); fulltext = fulltextCreator.createFulltext(message); extraContentValues = null; } PreviewType previewType = previewResult.getPreviewType(); DatabasePreviewType databasePreviewType = DatabasePreviewType.fromPreviewType(previewType); long rootMessagePartId = saveMessageParts(db, message); Loading @@ -1415,6 +1435,7 @@ public class LocalFolder extends Folder<LocalMessage> { ? System.currentTimeMillis() : message.getInternalDate().getTime()); cv.put("mime_type", message.getMimeType()); cv.put("empty", 0); cv.put("encryption_type", encryptionType); cv.put("preview_type", databasePreviewType.getDatabaseValue()); if (previewResult.isPreviewTextAvailable()) { Loading @@ -1428,6 +1449,10 @@ public class LocalFolder extends Folder<LocalMessage> { cv.put("message_id", messageId); } if (extraContentValues != null) { cv.putAll(extraContentValues); } if (oldMessageId == -1) { msgId = db.insert("messages", "uid", cv); Loading app/core/src/main/java/com/fsck/k9/mailstore/LocalMessage.java +1 −1 Original line number Diff line number Diff line Loading @@ -188,7 +188,7 @@ public class LocalMessage extends MimeMessage { return (attachmentCount > 0); } int getAttachmentCount() { public int getAttachmentCount() { return attachmentCount; } Loading Loading
app/core/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ dependencies { testImplementation project(':mail:testing') testImplementation project(":backend:imap") testImplementation project(":mail:protocols:smtp") testImplementation project(":app:storage") testImplementation "org.robolectric:robolectric:${versions.robolectric}" testImplementation "junit:junit:${versions.junit}" testImplementation "com.google.truth:truth:${versions.truth}" Loading
app/core/src/main/java/com/fsck/k9/K9.java +3 −3 Original line number Diff line number Diff line Loading @@ -354,7 +354,7 @@ public class K9 { * {@code SharedPreference}. * * <p> * If the stored version matches {@link LocalStore#DB_VERSION} we know that the databases are * If the stored version matches {@link LocalStore#getDbVersion()} we know that the databases are * up to date.<br> * Using {@code SharedPreferences} should be a lot faster than opening all SQLite databases to * get the current database version. Loading @@ -369,7 +369,7 @@ public class K9 { int cachedVersion = databaseVersionCache.getInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, 0); if (cachedVersion >= LocalStore.DB_VERSION) { if (cachedVersion >= LocalStore.getDbVersion()) { K9.setDatabasesUpToDate(false); } if (cachedVersion < VERSION_MIGRATE_OPENPGP_TO_ACCOUNTS) { Loading Loading @@ -1073,7 +1073,7 @@ public class K9 { if (save) { Editor editor = databaseVersionCache.edit(); editor.putInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, LocalStore.DB_VERSION); editor.putInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, LocalStore.getDbVersion()); editor.apply(); } } Loading
app/core/src/main/java/com/fsck/k9/crypto/EncryptionExtractor.kt 0 → 100644 +17 −0 Original line number Diff line number Diff line package com.fsck.k9.crypto import android.content.ContentValues import com.fsck.k9.mail.Message import com.fsck.k9.message.extractors.PreviewResult interface EncryptionExtractor { fun extractEncryption(message: Message): EncryptionResult? } data class EncryptionResult( val encryptionType: String, val attachmentCount: Int, val previewResult: PreviewResult = PreviewResult.encrypted(), val textForSearchIndex: String? = null, val extraContentValues: ContentValues? = null )
app/core/src/main/java/com/fsck/k9/mailstore/LocalFolder.java +33 −8 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ import com.fsck.k9.DI; import com.fsck.k9.K9; import com.fsck.k9.controller.MessageReference; import com.fsck.k9.backend.api.MessageRemovalListener; import com.fsck.k9.crypto.EncryptionExtractor; import com.fsck.k9.crypto.EncryptionResult; import com.fsck.k9.helper.FileHelper; import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.Address; Loading Loading @@ -77,6 +79,7 @@ public class LocalFolder extends Folder<LocalMessage> { private final SearchStatusManager searchStatusManager = DI.get(SearchStatusManager.class); private final LocalStore localStore; private final AttachmentInfoExtractor attachmentInfoExtractor; private final EncryptionExtractor encryptionExtractor = DI.get(EncryptionExtractor.class); private String serverId = null; Loading Loading @@ -1379,16 +1382,33 @@ public class LocalFolder extends Folder<LocalMessage> { } try { MessagePreviewCreator previewCreator = localStore.getMessagePreviewCreator(); PreviewResult previewResult = previewCreator.createPreview(message); PreviewType previewType = previewResult.getPreviewType(); DatabasePreviewType databasePreviewType = DatabasePreviewType.fromPreviewType(previewType); String encryptionType; PreviewResult previewResult; int attachmentCount; String fulltext; ContentValues extraContentValues; EncryptionResult encryptionResult = encryptionExtractor.extractEncryption(message); if (encryptionResult != null) { encryptionType = encryptionResult.getEncryptionType(); previewResult = encryptionResult.getPreviewResult(); attachmentCount = encryptionResult.getAttachmentCount(); fulltext = encryptionResult.getTextForSearchIndex(); extraContentValues = encryptionResult.getExtraContentValues(); } else { MessagePreviewCreator previewCreator = localStore.getMessagePreviewCreator(); MessageFulltextCreator fulltextCreator = localStore.getMessageFulltextCreator(); String fulltext = fulltextCreator.createFulltext(message); AttachmentCounter attachmentCounter = localStore.getAttachmentCounter(); int attachmentCount = attachmentCounter.getAttachmentCount(message); encryptionType = null; previewResult = previewCreator.createPreview(message); attachmentCount = attachmentCounter.getAttachmentCount(message); fulltext = fulltextCreator.createFulltext(message); extraContentValues = null; } PreviewType previewType = previewResult.getPreviewType(); DatabasePreviewType databasePreviewType = DatabasePreviewType.fromPreviewType(previewType); long rootMessagePartId = saveMessageParts(db, message); Loading @@ -1415,6 +1435,7 @@ public class LocalFolder extends Folder<LocalMessage> { ? System.currentTimeMillis() : message.getInternalDate().getTime()); cv.put("mime_type", message.getMimeType()); cv.put("empty", 0); cv.put("encryption_type", encryptionType); cv.put("preview_type", databasePreviewType.getDatabaseValue()); if (previewResult.isPreviewTextAvailable()) { Loading @@ -1428,6 +1449,10 @@ public class LocalFolder extends Folder<LocalMessage> { cv.put("message_id", messageId); } if (extraContentValues != null) { cv.putAll(extraContentValues); } if (oldMessageId == -1) { msgId = db.insert("messages", "uid", cv); Loading
app/core/src/main/java/com/fsck/k9/mailstore/LocalMessage.java +1 −1 Original line number Diff line number Diff line Loading @@ -188,7 +188,7 @@ public class LocalMessage extends MimeMessage { return (attachmentCount > 0); } int getAttachmentCount() { public int getAttachmentCount() { return attachmentCount; } Loading