Remove Android resource references from AutocryptTransferMessageCreator
This commit is contained in:
parent
548f908d7c
commit
a4e8046217
6 changed files with 36 additions and 12 deletions
|
@ -0,0 +1,6 @@
|
|||
package com.fsck.k9.autocrypt
|
||||
|
||||
interface AutocryptStringProvider {
|
||||
fun transferMessageSubject(): String
|
||||
fun transferMessageBody(): String
|
||||
}
|
|
@ -1,12 +1,7 @@
|
|||
package com.fsck.k9.autocrypt
|
||||
|
||||
|
||||
import java.util.Date
|
||||
|
||||
import android.content.res.Resources
|
||||
|
||||
import com.fsck.k9.K9
|
||||
import com.fsck.k9.core.R
|
||||
import com.fsck.k9.mail.Address
|
||||
import com.fsck.k9.mail.Flag
|
||||
import com.fsck.k9.mail.Message
|
||||
|
@ -19,13 +14,14 @@ import com.fsck.k9.mail.internet.MimeMessageHelper
|
|||
import com.fsck.k9.mail.internet.MimeMultipart
|
||||
import com.fsck.k9.mail.internet.TextBody
|
||||
import com.fsck.k9.mailstore.BinaryMemoryBody
|
||||
import java.util.Date
|
||||
|
||||
|
||||
class AutocryptTransferMessageCreator(val resources: Resources) {
|
||||
class AutocryptTransferMessageCreator(private val stringProvider: AutocryptStringProvider) {
|
||||
fun createAutocryptTransferMessage(data: ByteArray, address: Address): Message {
|
||||
try {
|
||||
val subjectText = resources.getString(R.string.ac_transfer_msg_subject)
|
||||
val messageText = resources.getString(R.string.ac_transfer_msg_body)
|
||||
val subjectText = stringProvider.transferMessageSubject()
|
||||
val messageText = stringProvider.transferMessageBody()
|
||||
|
||||
val textBodyPart = MimeBodyPart(TextBody(messageText))
|
||||
val dataBodyPart = MimeBodyPart(BinaryMemoryBody(data, "7bit"))
|
||||
|
@ -53,6 +49,5 @@ class AutocryptTransferMessageCreator(val resources: Resources) {
|
|||
} catch (e: MessagingException) {
|
||||
throw AssertionError(e)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.fsck.k9
|
|||
import com.fsck.k9.external.BroadcastSenderListener
|
||||
import com.fsck.k9.external.externalModule
|
||||
import com.fsck.k9.notification.notificationModule
|
||||
import com.fsck.k9.resources.resourcesModule
|
||||
import com.fsck.k9.widget.list.MessageListWidgetUpdateListener
|
||||
import com.fsck.k9.widget.list.messageListWidgetModule
|
||||
import com.fsck.k9.widget.unread.UnreadWidgetUpdateListener
|
||||
|
@ -18,7 +19,6 @@ private val mainAppModule = applicationContext {
|
|||
get<BroadcastSenderListener>()
|
||||
))
|
||||
}
|
||||
bean { K9CoreResourceProvider(get()) as CoreResourceProvider }
|
||||
}
|
||||
|
||||
val appModules = listOf(
|
||||
|
@ -26,5 +26,6 @@ val appModules = listOf(
|
|||
externalModule,
|
||||
messageListWidgetModule,
|
||||
unreadWidgetModule,
|
||||
notificationModule
|
||||
notificationModule,
|
||||
resourcesModule
|
||||
)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.fsck.k9.resources
|
||||
|
||||
import android.content.Context
|
||||
import com.fsck.k9.autocrypt.AutocryptStringProvider
|
||||
import com.fsck.k9.core.R
|
||||
|
||||
class K9AutocryptStringProvider(private val context: Context) : AutocryptStringProvider {
|
||||
override fun transferMessageSubject(): String = context.getString(R.string.ac_transfer_msg_subject)
|
||||
override fun transferMessageBody(): String = context.getString(R.string.ac_transfer_msg_body)
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package com.fsck.k9
|
||||
package com.fsck.k9.resources
|
||||
|
||||
import android.content.Context
|
||||
import com.fsck.k9.CoreResourceProvider
|
||||
import com.fsck.k9.R
|
||||
|
||||
class K9CoreResourceProvider(private val context: Context) : CoreResourceProvider {
|
||||
override fun defaultSignature(): String = context.getString(R.string.default_signature)
|
10
app/k9mail/src/main/java/com/fsck/k9/resources/KoinModule.kt
Normal file
10
app/k9mail/src/main/java/com/fsck/k9/resources/KoinModule.kt
Normal file
|
@ -0,0 +1,10 @@
|
|||
package com.fsck.k9.resources
|
||||
|
||||
import com.fsck.k9.CoreResourceProvider
|
||||
import com.fsck.k9.autocrypt.AutocryptStringProvider
|
||||
import org.koin.dsl.module.applicationContext
|
||||
|
||||
val resourcesModule = applicationContext {
|
||||
bean { K9CoreResourceProvider(get()) as CoreResourceProvider }
|
||||
bean { K9AutocryptStringProvider(get()) as AutocryptStringProvider}
|
||||
}
|
Loading…
Reference in a new issue