Skip to content

Commit 0de4a4b

Browse files
committed
Refactored code.| #1631
1 parent fc2f108 commit 0de4a4b

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/workmanager/ForwardedAttachmentsDownloaderWorker.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import org.apache.commons.io.FileUtils
3939
import java.io.File
4040
import java.io.FileOutputStream
4141
import java.io.InputStream
42-
import java.util.*
42+
import java.util.UUID
4343
import javax.mail.Folder
4444
import javax.mail.Store
4545

@@ -66,13 +66,13 @@ class ForwardedAttachmentsDownloaderWorker(context: Context, params: WorkerParam
6666
try {
6767
if (!attCacheDir.exists()) {
6868
if (!attCacheDir.mkdirs()) {
69-
throw IllegalStateException("Create cache directory " + attCacheDir.name + " filed!")
69+
throw IllegalStateException("Create cache directory " + attCacheDir.name + " failed!")
7070
}
7171
}
7272

7373
if (!fwdAttsCacheDir.exists()) {
7474
if (!fwdAttsCacheDir.mkdirs()) {
75-
throw IllegalStateException("Create cache directory " + fwdAttsCacheDir.name + " filed!")
75+
throw IllegalStateException("Create cache directory " + fwdAttsCacheDir.name + " failed!")
7676
}
7777
}
7878

FlowCrypt/src/main/java/com/flowcrypt/email/service/ProcessingOutgoingMessageInfoHelper.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ object ProcessingOutgoingMessageInfoHelper {
106106
if (hasAtts) {
107107
if (!msgAttsCacheDir.exists()) {
108108
if (!msgAttsCacheDir.mkdir()) {
109-
throw IOException("Create cache directory for outgoing attachments filed!")
109+
throw IOException("Create cache directory for outgoing attachments failed!")
110110
}
111111
}
112112

@@ -188,7 +188,7 @@ object ProcessingOutgoingMessageInfoHelper {
188188
val attsCacheDir = File(context.cacheDir, Constants.ATTACHMENTS_CACHE_DIR)
189189
if (!attsCacheDir.exists()) {
190190
if (!attsCacheDir.mkdirs()) {
191-
throw IllegalStateException("Create cache directory " + attsCacheDir.name + " filed!")
191+
throw IllegalStateException("Create cache directory " + attsCacheDir.name + " failed!")
192192
}
193193
}
194194
return attsCacheDir
@@ -224,15 +224,18 @@ object ProcessingOutgoingMessageInfoHelper {
224224

225225
val hasAtts = msgInfo.atts?.isNotEmpty() == true || msgInfo.forwardedAtts?.isNotEmpty() == true
226226
val isEncrypted = msgInfo.encryptionType === MessageEncryptionType.ENCRYPTED
227-
val msgStateValue =
228-
if (msgInfo.messageType == MessageType.FORWARD) MessageState.NEW_FORWARDED.value else MessageState.NEW.value
227+
val msgState = if (msgInfo.messageType == MessageType.FORWARD) {
228+
MessageState.NEW_FORWARDED
229+
} else {
230+
MessageState.NEW
231+
}
229232

230233
return messageEntity.copy(
231234
hasAttachments = hasAtts,
232235
rawMessageWithoutAttachments = rawMsg,
233236
flags = MessageFlag.SEEN.value,
234237
isEncrypted = isEncrypted,
235-
state = msgStateValue,
238+
state = msgState.value,
236239
attachmentsDirectory = attsCacheDir.name,
237240
password = msgInfo.password?.let { KeyStoreCryptoManager.encrypt(String(it)).toByteArray() }
238241
)

FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/CreateMessageFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ class CreateMessageFragment : BaseSyncFragment(), View.OnFocusChangeListener,
634634

635635
if (draftCacheDir.exists()) {
636636
if (!draftCacheDir.mkdir()) {
637-
Log.e(TAG, "Create cache directory " + draftCacheDir.name + " filed!")
637+
Log.e(TAG, "Create cache directory " + draftCacheDir.name + " failed!")
638638
}
639639
}
640640
}
@@ -686,7 +686,7 @@ class CreateMessageFragment : BaseSyncFragment(), View.OnFocusChangeListener,
686686
ExceptionUtil.handleError(e)
687687

688688
if (!draftAtt.delete()) {
689-
Log.e(TAG, "Delete " + draftAtt.name + " filed!")
689+
Log.e(TAG, "Delete " + draftAtt.name + " failed!")
690690
}
691691
}
692692

0 commit comments

Comments
 (0)