From 615014447908fb950e0fd63a604a8272b91c42c8 Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Fri, 10 Jan 2020 17:34:06 +0200 Subject: [PATCH] Added progress for the search screen. Removed unused code.| #793 --- .../email/api/email/sync/ConnectionSyncRunnable.kt | 1 + .../api/email/sync/tasks/SearchMessagesSyncTask.kt | 4 ++++ .../email/ui/activity/base/BaseEmailListActivity.kt | 10 +--------- .../email/ui/activity/base/BaseSyncActivity.kt | 1 + FlowCrypt/src/main/res/values/ids.xml | 4 ---- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/ConnectionSyncRunnable.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/ConnectionSyncRunnable.kt index 2c729c7a3e..86fc76cb63 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/ConnectionSyncRunnable.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/ConnectionSyncRunnable.kt @@ -221,6 +221,7 @@ class ConnectionSyncRunnable(account: AccountDao, syncListener: SyncListener) fun searchMsgs(ownerKey: String, requestCode: Int, localFolder: LocalFolder, alreadyLoadedMsgsCount: Int) { try { + syncListener.onActionProgress(account, ownerKey, requestCode, R.id.progress_id_adding_task_to_queue) removeOldTasks(SearchMessagesSyncTask::class.java, tasksQueue) tasksQueue.put(SearchMessagesSyncTask(ownerKey, requestCode, localFolder, alreadyLoadedMsgsCount)) } catch (e: InterruptedException) { diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/tasks/SearchMessagesSyncTask.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/tasks/SearchMessagesSyncTask.kt index 03a11ef6d7..873affb7a0 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/tasks/SearchMessagesSyncTask.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/api/email/sync/tasks/SearchMessagesSyncTask.kt @@ -6,6 +6,7 @@ package com.flowcrypt.email.api.email.sync.tasks import android.content.Context +import com.flowcrypt.email.R import com.flowcrypt.email.api.email.EmailUtil import com.flowcrypt.email.api.email.JavaEmailConstants import com.flowcrypt.email.api.email.model.LocalFolder @@ -46,6 +47,7 @@ class SearchMessagesSyncTask(ownerKey: String, override fun runIMAPAction(account: AccountDao, session: Session, store: Store, listener: SyncListener) { super.runIMAPAction(account, session, store, listener) + listener.onActionProgress(account, ownerKey, requestCode, R.id.progress_id_opening_store) val imapFolder = store.getFolder(localFolder.fullName) as IMAPFolder imapFolder.open(Folder.READ_ONLY) @@ -66,6 +68,8 @@ class SearchMessagesSyncTask(ownerKey: String, else -> startCandidate } + listener.onActionProgress(account, ownerKey, requestCode, R.id.progress_id_getting_list_of_emails) + if (end < 1) { listener.onSearchMsgsReceived(account, localFolder, imapFolder, arrayOf(), ownerKey, requestCode) } else { diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/base/BaseEmailListActivity.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/base/BaseEmailListActivity.kt index 55a99814c1..c7b285d65e 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/base/BaseEmailListActivity.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/base/BaseEmailListActivity.kt @@ -64,19 +64,11 @@ abstract class BaseEmailListActivity : BaseSyncActivity(), EmailListFragment.OnM override fun onProgressReplyReceived(requestCode: Int, resultCode: Int, obj: Any?) { when (requestCode) { - R.id.syns_request_code_load_next_messages -> when (resultCode) { + R.id.syns_request_code_load_next_messages, R.id.sync_request_code_search_messages -> when (resultCode) { R.id.progress_id_start_of_loading_new_messages -> updateActionProgressState(0, "Starting") R.id.progress_id_adding_task_to_queue -> updateActionProgressState(10, "Queuing") - R.id.progress_id_queue_is_not_empty -> updateActionProgressState(15, "Queue is not empty") - - R.id.progress_id_thread_is_cancelled_and_done -> updateActionProgressState(15, "Thread is cancelled and done") - - R.id.progress_id_thread_is_done -> updateActionProgressState(15, "Thread is done") - - R.id.progress_id_thread_is_cancelled -> updateActionProgressState(15, "Thread is cancelled") - R.id.progress_id_running_task -> updateActionProgressState(20, "Running task") R.id.progress_id_resetting_connection -> updateActionProgressState(30, "Resetting connection") diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/base/BaseSyncActivity.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/base/BaseSyncActivity.kt index e9c074573e..3b682ebd29 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/base/BaseSyncActivity.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/base/BaseSyncActivity.kt @@ -183,6 +183,7 @@ abstract class BaseSyncActivity : BaseNodeActivity() { * @param alreadyLoadedMsgsCount The count of already loaded messages in the localFolder. */ fun searchNextMsgs(requestCode: Int, localFolder: LocalFolder, alreadyLoadedMsgsCount: Int) { + onProgressReplyReceived(requestCode, R.id.progress_id_start_of_loading_new_messages, Any()) if (checkServiceBound(isSyncServiceBound)) return val action = BaseService.Action(replyMessengerName, requestCode, localFolder) diff --git a/FlowCrypt/src/main/res/values/ids.xml b/FlowCrypt/src/main/res/values/ids.xml index 6ad4803d6e..82ab9f7d7e 100644 --- a/FlowCrypt/src/main/res/values/ids.xml +++ b/FlowCrypt/src/main/res/values/ids.xml @@ -54,10 +54,6 @@ - - - -