diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/IdleSyncRunnable.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/IdleSyncRunnable.kt index a7ff5ec55c..ac0e67ca18 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/IdleSyncRunnable.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/IdleSyncRunnable.kt @@ -9,7 +9,6 @@ import com.flowcrypt.email.api.email.FoldersManager import com.flowcrypt.email.api.email.model.LocalFolder import com.flowcrypt.email.database.FlowCryptRoomDatabase import com.flowcrypt.email.database.dao.source.AccountDao -import com.flowcrypt.email.database.dao.source.imap.MessageDaoSource import com.flowcrypt.email.util.GeneralUtil import com.flowcrypt.email.util.LogsUtil import com.flowcrypt.email.util.exception.ExceptionUtil @@ -40,7 +39,6 @@ class IdleSyncRunnable constructor(account: AccountDao, syncListener: SyncListen BaseSyncRunnable(account, syncListener), MessageCountListener, MessageChangedListener { private var localFolder: LocalFolder? = null private var remoteFolder: IMAPFolder? = null - private val msgDaoSource: MessageDaoSource = MessageDaoSource() /** * here we can have a lot of checks which help us decide can we run idling(wifi, 3G, a battery level and etc.) */ diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/tasks/ChangeMsgsReadStateSyncTask.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/tasks/ChangeMsgsReadStateSyncTask.kt index 6389789d3b..d4e2b5823b 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/tasks/ChangeMsgsReadStateSyncTask.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/tasks/ChangeMsgsReadStateSyncTask.kt @@ -10,7 +10,6 @@ import com.flowcrypt.email.api.email.sync.SyncListener import com.flowcrypt.email.database.FlowCryptRoomDatabase import com.flowcrypt.email.database.MessageState import com.flowcrypt.email.database.dao.source.AccountDao -import com.flowcrypt.email.database.dao.source.imap.MessageDaoSource import com.flowcrypt.email.util.exception.ExceptionUtil import com.sun.mail.imap.IMAPFolder import javax.mail.Flags @@ -33,14 +32,12 @@ class ChangeMsgsReadStateSyncTask(ownerKey: String, requestCode: Int) : BaseSync override fun runIMAPAction(account: AccountDao, session: Session, store: Store, listener: SyncListener) { val context = listener.context - val msgDaoSource = MessageDaoSource() - changeMsgsReadState(context, account, msgDaoSource, store, MessageState.PENDING_MARK_UNREAD) - changeMsgsReadState(context, account, msgDaoSource, store, MessageState.PENDING_MARK_READ) + changeMsgsReadState(context, account, store, MessageState.PENDING_MARK_UNREAD) + changeMsgsReadState(context, account, store, MessageState.PENDING_MARK_READ) } - private fun changeMsgsReadState(context: Context, account: AccountDao, - msgDaoSource: MessageDaoSource, store: Store, state: MessageState) { + private fun changeMsgsReadState(context: Context, account: AccountDao, store: Store, state: MessageState) { val roomDatabase = FlowCryptRoomDatabase.getDatabase(context) val candidatesForMark = roomDatabase.msgDao().getMsgsWithState(account.email, state.value) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/broadcastreceivers/MarkMessagesAsOldBroadcastReceiver.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/broadcastreceivers/MarkMessagesAsOldBroadcastReceiver.kt index 592f50fdb6..2b1447da26 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/broadcastreceivers/MarkMessagesAsOldBroadcastReceiver.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/broadcastreceivers/MarkMessagesAsOldBroadcastReceiver.kt @@ -8,7 +8,6 @@ package com.flowcrypt.email.broadcastreceivers import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import com.flowcrypt.email.database.dao.source.imap.MessageDaoSource import com.flowcrypt.email.service.MessagesNotificationManager import com.flowcrypt.email.util.GeneralUtil import com.flowcrypt.email.util.LogsUtil @@ -36,9 +35,9 @@ class MarkMessagesAsOldBroadcastReceiver : BroadcastReceiver() { val step = 500 if (uidList.isNotEmpty()) { - val daoSource = MessageDaoSource() if (uidList.size <= step) { - daoSource.setOldStatus(context, email, label, uidList) + //todo-denbond7 #793 + //daoSource.setOldStatus(context, email, label, uidList) } else { var i = 0 while (i < uidList.size) { @@ -47,7 +46,8 @@ class MarkMessagesAsOldBroadcastReceiver : BroadcastReceiver() { } else { uidList.subList(i, uidList.size) } - daoSource.setOldStatus(context, email, label, tempList) + //todo-denbond7 #793 + //daoSource.setOldStatus(context, email, label, tempList) i += step } } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt index d55e71d7af..e163f0281c 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt @@ -23,7 +23,6 @@ import com.flowcrypt.email.database.dao.source.AccountDaoSource import com.flowcrypt.email.database.dao.source.ActionQueueDaoSource import com.flowcrypt.email.database.dao.source.UserIdEmailsKeysDaoSource import com.flowcrypt.email.database.dao.source.imap.AttachmentDaoSource -import com.flowcrypt.email.database.dao.source.imap.MessageDaoSource import com.flowcrypt.email.database.entity.AccountAliasesEntity import com.flowcrypt.email.database.entity.AccountEntity import com.flowcrypt.email.database.entity.ActionQueueEntity @@ -79,8 +78,7 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { override fun migrate(database: SupportSQLiteDatabase) { database.beginTransaction() try { - database.execSQL("ALTER TABLE " + MessageDaoSource.TABLE_NAME_MESSAGES + - " ADD COLUMN " + MessageDaoSource.COL_IS_MESSAGE_HAS_ATTACHMENTS + " INTEGER DEFAULT 0;") + database.execSQL("ALTER TABLE messages ADD COLUMN is_message_has_attachments INTEGER DEFAULT 0;") database.execSQL("ALTER TABLE " + AccountDaoSource.TABLE_NAME_ACCOUNTS + " ADD COLUMN " + AccountDaoSource.COL_IS_ENABLE + " INTEGER DEFAULT 1;") @@ -189,12 +187,9 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { override fun migrate(database: SupportSQLiteDatabase) { database.beginTransaction() try { - database.execSQL("ALTER TABLE " + MessageDaoSource.TABLE_NAME_MESSAGES + - " ADD COLUMN " + MessageDaoSource.COL_IS_ENCRYPTED + " INTEGER DEFAULT -1;") - database.execSQL("ALTER TABLE " + MessageDaoSource.TABLE_NAME_MESSAGES + - " ADD COLUMN " + MessageDaoSource.COL_CC_ADDRESSES + " TEXT DEFAULT NULL;") - database.execSQL("ALTER TABLE " + MessageDaoSource.TABLE_NAME_MESSAGES + - " ADD COLUMN " + MessageDaoSource.COL_IS_NEW + " INTEGER DEFAULT 0;") + database.execSQL("ALTER TABLE messages ADD COLUMN is_encrypted INTEGER DEFAULT -1;") + database.execSQL("ALTER TABLE messages ADD COLUMN cc_address TEXT DEFAULT NULL;") + database.execSQL("ALTER TABLE messages ADD COLUMN is_new INTEGER DEFAULT 0;") database.execSQL("ALTER TABLE " + AccountDaoSource.TABLE_NAME_ACCOUNTS + " ADD COLUMN " + AccountDaoSource.COL_IS_SHOW_ONLY_ENCRYPTED + " INTEGER DEFAULT 0;") @@ -214,8 +209,7 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { override fun migrate(database: SupportSQLiteDatabase) { database.beginTransaction() try { - database.execSQL("ALTER TABLE " + MessageDaoSource.TABLE_NAME_MESSAGES + - " ADD COLUMN " + MessageDaoSource.COL_STATE + " INTEGER DEFAULT -1;") + database.execSQL("ALTER TABLE messages ADD COLUMN state INTEGER DEFAULT -1;") database.setTransactionSuccessful() } finally { database.endTransaction() @@ -231,8 +225,7 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { " ADD COLUMN " + AttachmentDaoSource.COL_FORWARDED_FOLDER + " TEXT;") database.execSQL("ALTER TABLE " + AttachmentDaoSource.TABLE_NAME_ATTACHMENT + " ADD COLUMN " + AttachmentDaoSource.COL_FORWARDED_UID + " INTEGER DEFAULT -1;") - database.execSQL("ALTER TABLE " + MessageDaoSource.TABLE_NAME_MESSAGES + - " ADD COLUMN " + MessageDaoSource.COL_ATTACHMENTS_DIRECTORY + " TEXT;") + database.execSQL("ALTER TABLE messages ADD COLUMN attachments_directory TEXT;") database.setTransactionSuccessful() } finally { database.endTransaction() @@ -244,8 +237,7 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { override fun migrate(database: SupportSQLiteDatabase) { database.beginTransaction() try { - database.execSQL("ALTER TABLE " + MessageDaoSource.TABLE_NAME_MESSAGES + - " ADD COLUMN " + MessageDaoSource.COL_ERROR_MSG + " TEXT DEFAULT NULL;") + database.execSQL("ALTER TABLE messages ADD COLUMN error_msg TEXT DEFAULT NULL;") database.setTransactionSuccessful() } finally { database.endTransaction() @@ -290,15 +282,13 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { override fun migrate(database: SupportSQLiteDatabase) { database.beginTransaction() try { - database.delete(MessageDaoSource.TABLE_NAME_MESSAGES, - MessageDaoSource.COL_FOLDER + " NOT IN(?,?) ", arrayOf("INBOX", "Outbox")) + database.delete("messages", "folder NOT IN(?,?) ", arrayOf("INBOX", "Outbox")) database.delete(AttachmentDaoSource.TABLE_NAME_ATTACHMENT, AttachmentDaoSource.COL_FOLDER + " NOT IN(?,?) ", arrayOf("INBOX", "Outbox")) val contentValues = ContentValues() - contentValues.putNull(MessageDaoSource.COL_RAW_MESSAGE_WITHOUT_ATTACHMENTS) - database.update(MessageDaoSource.TABLE_NAME_MESSAGES, SQLiteDatabase.CONFLICT_NONE, - contentValues, MessageDaoSource.COL_FOLDER + " = ? ", arrayOf("INBOX")) + contentValues.putNull("raw_message_without_attachments") + database.update("messages", SQLiteDatabase.CONFLICT_NONE, contentValues, "folder = ? ", arrayOf("INBOX")) database.setTransactionSuccessful() } finally { database.endTransaction() @@ -310,8 +300,7 @@ abstract class FlowCryptRoomDatabase : RoomDatabase() { override fun migrate(database: SupportSQLiteDatabase) { database.beginTransaction() try { - database.execSQL("ALTER TABLE " + MessageDaoSource.TABLE_NAME_MESSAGES + - " ADD COLUMN " + MessageDaoSource.COL_REPLY_TO + " TEXT DEFAULT NULL;") + database.execSQL("ALTER TABLE messages ADD COLUMN reply_to TEXT DEFAULT NULL;") database.setTransactionSuccessful() } finally { database.endTransaction() diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/source/imap/MessageDaoSource.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/source/imap/MessageDaoSource.kt index 96066382c2..115bed2e4c 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/source/imap/MessageDaoSource.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/source/imap/MessageDaoSource.kt @@ -5,13 +5,7 @@ package com.flowcrypt.email.database.dao.source.imap -import android.content.ContentValues -import android.content.Context -import android.text.TextUtils import com.flowcrypt.email.api.email.model.GeneralMessageDetails -import com.flowcrypt.email.api.email.model.MessageFlag -import com.flowcrypt.email.database.dao.source.BaseDaoSource -import java.util.* /** * This class describes the dao source for [GeneralMessageDetails] class. @@ -22,104 +16,4 @@ import java.util.* * E-mail: DenBond7@gmail.com */ -class MessageDaoSource : BaseDaoSource() { - - override val tableName: String = TABLE_NAME_MESSAGES - - /** - * Mark message as seen in the local database. - * - * @param context Interface to global information about an application environment. - * @param email The email that the message linked. - * @param label The folder label. - * @param uid The message UID. - * @param isSeen true if seen - * @return The count of the updated row or -1 up. - */ - fun setSeenStatus(context: Context, email: String?, label: String?, uid: Long, - isSeen: Boolean = true): Int { - val resolver = context.contentResolver - return if (email != null && label != null && resolver != null) { - val values = ContentValues() - if (isSeen) { - values.put(COL_FLAGS, MessageFlag.SEEN.value) - } else { - values.put(COL_FLAGS, "")//todo-denbond7 maybe it is not a good idea to erase all flags - } - - val where = "$COL_EMAIL= ? AND $COL_FOLDER = ? AND $COL_UID = ? " - resolver.update(baseContentUri, values, where, arrayOf(email, label, uid.toString())) - } else - -1 - } - - /** - * Mark messages as old in the local database. - * - * @param context Interface to global information about an application environment. - * @param email The email that the message linked. - * @param label The folder label. - * @return The count of the updated row or -1 up. - */ - fun setOldStatus(context: Context, email: String?, label: String?): Int { - val contentResolver = context.contentResolver - return if (email != null && label != null && contentResolver != null) { - val contentValues = ContentValues() - contentValues.put(COL_IS_NEW, false) - val where = "$COL_EMAIL= ? AND $COL_FOLDER = ?" - contentResolver.update(baseContentUri, contentValues, where, arrayOf(email, label)) - } else - -1 - } - - /** - * Mark messages as old in the local database. - * - * @param context Interface to global information about an application environment. - * @param email The email that the message linked. - * @param label The folder label. - * @param uidList The list of the UIDs. - * @return The count of the updated row or -1 up. - */ - fun setOldStatus(context: Context, email: String?, label: String?, uidList: List?): Int { - val contentResolver = context.contentResolver - return if (contentResolver != null && email != null && label != null && uidList != null && uidList.isNotEmpty()) { - val contentValues = ContentValues() - contentValues.put(COL_IS_NEW, false) - - val args = ArrayList() - args.add(0, email) - args.add(1, label) - args.addAll(uidList) - - val where = "$COL_EMAIL= ? AND $COL_FOLDER = ? AND $COL_UID IN (" + TextUtils.join(",", - Collections.nCopies(uidList.size, "?")) + ")" - - contentResolver.update(baseContentUri, contentValues, where, args.toTypedArray()) - } else - -1 - } - - companion object { - const val TABLE_NAME_MESSAGES = "messages" - - const val COL_EMAIL = "email" - const val COL_FOLDER = "folder" - const val COL_UID = "uid" - const val COL_RECEIVED_DATE = "received_date" - const val COL_SENT_DATE = "sent_date" - const val COL_FROM_ADDRESSES = "from_address" - const val COL_TO_ADDRESSES = "to_address" - const val COL_CC_ADDRESSES = "cc_address" - const val COL_SUBJECT = "subject" - const val COL_FLAGS = "flags" - const val COL_RAW_MESSAGE_WITHOUT_ATTACHMENTS = "raw_message_without_attachments" - const val COL_IS_MESSAGE_HAS_ATTACHMENTS = "is_message_has_attachments" - const val COL_IS_ENCRYPTED = "is_encrypted" - const val COL_IS_NEW = "is_new" - const val COL_STATE = "state" - const val COL_ATTACHMENTS_DIRECTORY = "attachments_directory" - const val COL_ERROR_MSG = "error_msg" - const val COL_REPLY_TO = "reply_to" - } -} +class MessageDaoSource diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/database/provider/SecurityContentProvider.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/database/provider/SecurityContentProvider.kt index 63f512bde9..4f0d445dbc 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/database/provider/SecurityContentProvider.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/database/provider/SecurityContentProvider.kt @@ -16,7 +16,6 @@ import android.database.Cursor import android.database.sqlite.SQLiteDatabase import android.net.Uri import android.provider.BaseColumns -import androidx.sqlite.db.SupportSQLiteDatabase import androidx.sqlite.db.SupportSQLiteOpenHelper import androidx.sqlite.db.SupportSQLiteQueryBuilder import com.flowcrypt.email.database.FlowCryptRoomDatabase @@ -28,7 +27,6 @@ import com.flowcrypt.email.database.dao.source.KeysDaoSource import com.flowcrypt.email.database.dao.source.UserIdEmailsKeysDaoSource import com.flowcrypt.email.database.dao.source.imap.AttachmentDaoSource import com.flowcrypt.email.database.dao.source.imap.ImapLabelsDaoSource -import com.flowcrypt.email.database.dao.source.imap.MessageDaoSource import com.flowcrypt.email.util.LogsUtil import com.flowcrypt.email.util.exception.ExceptionUtil import java.util.* @@ -75,11 +73,6 @@ class SecurityContentProvider : ContentProvider() { result = Uri.parse(ImapLabelsDaoSource().baseContentUri.toString() + "/" + id) } - MATCHED_CODE_IMAP_MESSAGES_TABLE -> { - id = sqLiteDatabase.insert(MessageDaoSource().tableName, SQLiteDatabase.CONFLICT_NONE, values) - result = Uri.parse(MessageDaoSource().baseContentUri.toString() + "/" + id) - } - MATCHED_CODE_ACCOUNTS_TABLE -> { id = sqLiteDatabase.insert(AccountDaoSource().tableName, SQLiteDatabase.CONFLICT_NONE, values) result = Uri.parse(AccountDaoSource().baseContentUri.toString() + "/" + id) @@ -125,29 +118,12 @@ class SecurityContentProvider : ContentProvider() { val sqLiteDatabase = dbHelper.writableDatabase sqLiteDatabase.beginTransaction() try { - when (URI_MATCHER.match(uri)) { - MATCHED_CODE_IMAP_MESSAGES_TABLE -> for (contentValues in values) { - var id = sqLiteDatabase.insert(MessageDaoSource().tableName, SQLiteDatabase.CONFLICT_NONE, contentValues) - - //if message not inserted, try to update message with some UID - if (id <= 0) { - id = updateMsgInfo(sqLiteDatabase, contentValues) - } else { - insertedRowsCount++ - } - - if (id <= 0) { - LogsUtil.d(TAG, "Failed to insert row into $uri") - } - } - - else -> for (contentValues in values) { - val id = sqLiteDatabase.insert(getMatchedTableName(uri), SQLiteDatabase.CONFLICT_NONE, contentValues) - if (id <= 0) { - LogsUtil.d(TAG, "Failed to insert row into $uri") - } else { - insertedRowsCount++ - } + for (contentValues in values) { + val id = sqLiteDatabase.insert(getMatchedTableName(uri), SQLiteDatabase.CONFLICT_NONE, contentValues) + if (id <= 0) { + LogsUtil.d(TAG, "Failed to insert row into $uri") + } else { + insertedRowsCount++ } } @@ -187,8 +163,7 @@ class SecurityContentProvider : ContentProvider() { AccountDaoSource.COL_EMAIL + " = ?", selectionArgs) rowsCount += sqLiteDatabase.delete(ImapLabelsDaoSource().tableName, ImapLabelsDaoSource.COL_EMAIL + " = ?", selectionArgs) - rowsCount += sqLiteDatabase.delete(MessageDaoSource().tableName, - MessageDaoSource.COL_EMAIL + " = ?", selectionArgs) + rowsCount += sqLiteDatabase.delete("messages", "email = ?", selectionArgs) rowsCount += sqLiteDatabase.delete(AttachmentDaoSource().tableName, AttachmentDaoSource.COL_EMAIL + " = ?", selectionArgs) rowsCount += sqLiteDatabase.delete(AccountAliasesDaoSource().tableName, @@ -199,7 +174,7 @@ class SecurityContentProvider : ContentProvider() { rowsCount = sqLiteDatabase.delete(AccountDaoSource().tableName, null, null) rowsCount += sqLiteDatabase.delete(AccountAliasesDaoSource().tableName, null, null) rowsCount += sqLiteDatabase.delete(ImapLabelsDaoSource().tableName, null, null) - rowsCount += sqLiteDatabase.delete(MessageDaoSource().tableName, null, null) + rowsCount += sqLiteDatabase.delete("messages", null, null) rowsCount += sqLiteDatabase.delete(AttachmentDaoSource().tableName, null, null) rowsCount += sqLiteDatabase.delete(KeysDaoSource().tableName, null, null) rowsCount += sqLiteDatabase.delete(UserIdEmailsKeysDaoSource().tableName, null, null) @@ -268,10 +243,6 @@ class SecurityContentProvider : ContentProvider() { MATCHED_CODE_IMAP_LABELS_SINGLE_ROW -> return ImapLabelsDaoSource().singleRowContentType - MATCHED_CODE_IMAP_MESSAGES_TABLE -> return MessageDaoSource().rowsContentType - - MATCHED_CODE_IMAP_MESSAGES_SINGLE_ROW -> return MessageDaoSource().singleRowContentType - MATCHED_CODE_ACCOUNTS_TABLE -> return AccountDaoSource().rowsContentType MATCHED_CODE_ACCOUNTS_SINGLE_ROW -> return AccountDaoSource().singleRowContentType @@ -310,8 +281,6 @@ class SecurityContentProvider : ContentProvider() { MATCHED_CODE_IMAP_LABELS_TABLE -> ImapLabelsDaoSource.TABLE_NAME_IMAP_LABELS - MATCHED_CODE_IMAP_MESSAGES_TABLE -> MessageDaoSource.TABLE_NAME_MESSAGES - MATCHED_CODE_ACCOUNTS_TABLE -> AccountDaoSource.TABLE_NAME_ACCOUNTS MATCHED_CODE_ATTACHMENT_TABLE -> AttachmentDaoSource.TABLE_NAME_ATTACHMENT @@ -326,29 +295,6 @@ class SecurityContentProvider : ContentProvider() { } } - /** - * Try to update some message. - * - * @param sqLiteDatabase The [SQLiteDatabase] which will be used to update a message. - * @param contentValues The new information about some message. - * @return the number of rows affected - */ - private fun updateMsgInfo(sqLiteDatabase: SupportSQLiteDatabase, contentValues: ContentValues): Long { - val id: Long - val email = contentValues.getAsString(MessageDaoSource.COL_EMAIL) - val folder = contentValues.getAsString(MessageDaoSource.COL_FOLDER) - val uid = contentValues.getAsString(MessageDaoSource.COL_UID) - - val selection = (MessageDaoSource.COL_EMAIL + "= ? AND " + MessageDaoSource.COL_FOLDER + " = ? AND " - + MessageDaoSource.COL_UID + " = ? ") - val selectionArgs = arrayOf(email, folder, uid) - id = sqLiteDatabase.update(MessageDaoSource().tableName, SQLiteDatabase.CONFLICT_NONE, - contentValues, - selection, - selectionArgs).toLong() - return id - } - companion object { private val TAG = SecurityContentProvider::class.java.simpleName @@ -359,8 +305,6 @@ class SecurityContentProvider : ContentProvider() { private const val MATCHED_CODE_CONTACTS_TABLE_SINGLE_ROW = 5 private const val MATCHED_CODE_IMAP_LABELS_TABLE = 6 private const val MATCHED_CODE_IMAP_LABELS_SINGLE_ROW = 7 - private const val MATCHED_CODE_IMAP_MESSAGES_TABLE = 8 - private const val MATCHED_CODE_IMAP_MESSAGES_SINGLE_ROW = 9 private const val MATCHED_CODE_ACCOUNTS_TABLE = 10 private const val MATCHED_CODE_ACCOUNTS_SINGLE_ROW = 11 private const val MATCHED_CODE_ATTACHMENT_TABLE = 12 @@ -392,10 +336,6 @@ class SecurityContentProvider : ContentProvider() { MATCHED_CODE_IMAP_LABELS_TABLE) URI_MATCHER.addURI(FlowcryptContract.AUTHORITY, ImapLabelsDaoSource.TABLE_NAME_IMAP_LABELS + SINGLE_APPENDED_SUFFIX, MATCHED_CODE_IMAP_LABELS_SINGLE_ROW) - URI_MATCHER.addURI(FlowcryptContract.AUTHORITY, MessageDaoSource.TABLE_NAME_MESSAGES, - MATCHED_CODE_IMAP_MESSAGES_TABLE) - URI_MATCHER.addURI(FlowcryptContract.AUTHORITY, MessageDaoSource.TABLE_NAME_MESSAGES - + SINGLE_APPENDED_SUFFIX, MATCHED_CODE_IMAP_MESSAGES_SINGLE_ROW) URI_MATCHER.addURI(FlowcryptContract.AUTHORITY, AccountDaoSource.TABLE_NAME_ACCOUNTS, MATCHED_CODE_ACCOUNTS_TABLE) URI_MATCHER.addURI(FlowcryptContract.AUTHORITY, AccountDaoSource.TABLE_NAME_ACCOUNTS diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/service/MessagesNotificationManager.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/service/MessagesNotificationManager.kt index 07770442df..f4903feffd 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/service/MessagesNotificationManager.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/service/MessagesNotificationManager.kt @@ -25,7 +25,6 @@ import com.flowcrypt.email.api.email.FoldersManager import com.flowcrypt.email.api.email.model.LocalFolder import com.flowcrypt.email.broadcastreceivers.MarkMessagesAsOldBroadcastReceiver import com.flowcrypt.email.database.dao.source.AccountDao -import com.flowcrypt.email.database.dao.source.imap.MessageDaoSource import com.flowcrypt.email.database.entity.MessageEntity import com.flowcrypt.email.ui.activity.EmailManagerActivity import com.flowcrypt.email.ui.activity.MessageDetailsActivity @@ -91,7 +90,8 @@ class MessagesNotificationManager(context: Context) : CustomNotificationManager( val localFolder = foldersManager.findInboxFolder() if (localFolder != null) { - MessageDaoSource().setOldStatus(context, account.email, localFolder.fullName) + //todo-denbond7 #793 + // MessageDaoSource().setOldStatus(context, account.email, localFolder.fullName) } } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/MessageDetailsActivity.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/MessageDetailsActivity.kt index d071293836..59327f01f7 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/MessageDetailsActivity.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/MessageDetailsActivity.kt @@ -34,7 +34,6 @@ import com.flowcrypt.email.api.retrofit.response.node.NodeResponseWrapper import com.flowcrypt.email.api.retrofit.response.node.ParseDecryptedMsgResult import com.flowcrypt.email.database.MessageState import com.flowcrypt.email.database.dao.source.imap.AttachmentDaoSource -import com.flowcrypt.email.database.dao.source.imap.MessageDaoSource import com.flowcrypt.email.database.entity.MessageEntity import com.flowcrypt.email.jetpack.viewmodel.DecryptMessageViewModel import com.flowcrypt.email.service.EmailSyncService @@ -105,13 +104,13 @@ class MessageDetailsActivity : BaseBackStackSyncActivity(), LoaderManager.Loader override fun onCreateLoader(id: Int, args: Bundle?): Loader { when (id) { - R.id.loader_id_load_raw_mime_msg_from_db, R.id.loader_id_subscribe_to_message_changes -> { + //todo-denbond7 #793 + /*R.id.loader_id_load_raw_mime_msg_from_db, R.id.loader_id_subscribe_to_message_changes -> { val uri = MessageDaoSource().baseContentUri - val selection = (MessageDaoSource.COL_EMAIL + "= ? AND " + MessageDaoSource.COL_FOLDER + " = ? AND " - + MessageDaoSource.COL_UID + " = ? ") + val selection = ("email = ? AND folder = ? AND uid = ? ") val selectionArgs = arrayOf(details?.email ?: "", label, details?.uid?.toString() ?: "") return CursorLoader(this, uri, null, selection, selectionArgs, null) - } + }*/ R.id.loader_id_load_attachments -> { val uriAtt = AttachmentDaoSource().baseContentUri @@ -131,12 +130,10 @@ class MessageDetailsActivity : BaseBackStackSyncActivity(), LoaderManager.Loader } override fun onLoadFinished(loader: Loader, cursor: Cursor?) { - val msgDaoSource = MessageDaoSource() - when (loader.id) { R.id.loader_id_load_raw_mime_msg_from_db -> if (cursor?.moveToFirst() == true) { this.rawMimeBytes = if (JavaEmailConstants.FOLDER_OUTBOX.equals(details?.label, ignoreCase = true)) { - cursor.getBlob(cursor.getColumnIndex(MessageDaoSource.COL_RAW_MESSAGE_WITHOUT_ATTACHMENTS)) + cursor.getBlob(cursor.getColumnIndex("raw_message_without_attachments")) } else { MsgsCacheManager.getMsgAsByteArray(details!!.id.toString()) } @@ -150,7 +147,8 @@ class MessageDetailsActivity : BaseBackStackSyncActivity(), LoaderManager.Loader if (!JavaEmailConstants.FOLDER_OUTBOX.equals(details?.label, ignoreCase = true) && details?.isSeen() == false) { - msgDaoSource.setSeenStatus(this, details!!.email, label, details!!.uid.toLong()) + //todo-denbond7 #793 + //msgDaoSource.setSeenStatus(this, details!!.email, label, details!!.uid.toLong()) //todo-denbond7 #793 /*msgDaoSource.updateMsgState(this, details?.email ?: "", details?.label ?: "", details?.uid?.toLong() ?: 0, MessageState.PENDING_MARK_READ)*/ @@ -232,7 +230,8 @@ class MessageDetailsActivity : BaseBackStackSyncActivity(), LoaderManager.Loader isRequestMsgDetailsStarted = false when (resultCode) { EmailSyncService.REPLY_RESULT_CODE_ACTION_OK -> { - MessageDaoSource().setSeenStatus(this, details!!.email, label, details!!.uid.toLong()) + //todo-denbond7 #793 + //MessageDaoSource().setSeenStatus(this, details!!.email, label, details!!.uid.toLong()) setResult(RESULT_CODE_UPDATE_LIST, null) LoaderManager.getInstance(this).restartLoader(R.id.loader_id_load_raw_mime_msg_from_db, null, this) } diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt index a7ab3bb487..d5cfafdf13 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.kt @@ -52,7 +52,6 @@ import com.flowcrypt.email.database.MessageState import com.flowcrypt.email.database.dao.source.AccountDao import com.flowcrypt.email.database.dao.source.AccountDaoSource import com.flowcrypt.email.database.dao.source.ContactsDaoSource -import com.flowcrypt.email.database.dao.source.imap.MessageDaoSource import com.flowcrypt.email.model.MessageEncryptionType import com.flowcrypt.email.model.MessageType import com.flowcrypt.email.service.attachment.AttachmentDownloadManagerService @@ -115,7 +114,6 @@ class MessageDetailsFragment : BaseSyncFragment(), View.OnClickListener { private var lastClickedAtt: AttachmentInfo? = null private var msgEncryptType = MessageEncryptionType.STANDARD private var atts = mutableListOf() - private val msgDaoSource = MessageDaoSource() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -253,8 +251,8 @@ class MessageDetailsFragment : BaseSyncFragment(), View.OnClickListener { //todo-denbond7 #793 /*msgDaoSource.updateMsgState(context!!, details?.email ?: "", details?.label ?: "", details?.uid?.toLong() ?: 0, MessageState.PENDING_MARK_UNREAD)*/ - msgDaoSource.setSeenStatus(context!!, details?.email, details?.label, details?.uid?.toLong() - ?: 0L, false) + //todo-denbond7 #793 + //msgDaoSource.setSeenStatus(context!!, details?.email, details?.label, details?.uid? .toLong() ?: 0L, false) (activity as? BaseSyncActivity)?.changeMsgsReadState() activity?.finish() true