diff --git a/app/core/src/main/java/com/fsck/k9/CoreResourceProvider.kt b/app/core/src/main/java/com/fsck/k9/CoreResourceProvider.kt index 4b90e53a3..08c30f4f9 100644 --- a/app/core/src/main/java/com/fsck/k9/CoreResourceProvider.kt +++ b/app/core/src/main/java/com/fsck/k9/CoreResourceProvider.kt @@ -3,4 +3,6 @@ package com.fsck.k9 interface CoreResourceProvider { fun defaultSignature(): String fun defaultIdentityDescription(): String + + fun sendAlternateChooserTitle(): String } diff --git a/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java b/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java index 47521ab34..130eb544f 100644 --- a/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -36,12 +36,12 @@ import com.fsck.k9.Account; import com.fsck.k9.Account.DeletePolicy; import com.fsck.k9.Account.Expunge; import com.fsck.k9.AccountStats; +import com.fsck.k9.CoreResourceProvider; import com.fsck.k9.core.BuildConfig; import com.fsck.k9.DI; import com.fsck.k9.K9; import com.fsck.k9.K9.Intents; import com.fsck.k9.Preferences; -import com.fsck.k9.core.R; import com.fsck.k9.backend.BackendManager; import com.fsck.k9.backend.api.Backend; import com.fsck.k9.backend.api.FolderInfo; @@ -130,6 +130,7 @@ public class MessagingController { private final MemorizingMessagingListener memorizingMessagingListener = new MemorizingMessagingListener(); private final TransportProvider transportProvider; private final AccountStatsCollector accountStatsCollector; + private final CoreResourceProvider resourceProvider; private MessagingListener checkMailListener = null; @@ -143,8 +144,9 @@ public class MessagingController { Contacts contacts = Contacts.getInstance(context); TransportProvider transportProvider = TransportProvider.getInstance(); AccountStatsCollector accountStatsCollector = new DefaultAccountStatsCollector(context); + CoreResourceProvider resourceProvider = DI.get(CoreResourceProvider.class); inst = new MessagingController(appContext, notificationController, contacts, transportProvider, - accountStatsCollector); + accountStatsCollector, resourceProvider); } return inst; } @@ -152,12 +154,14 @@ public class MessagingController { @VisibleForTesting MessagingController(Context context, NotificationController notificationController, Contacts contacts, - TransportProvider transportProvider, AccountStatsCollector accountStatsCollector) { + TransportProvider transportProvider, AccountStatsCollector accountStatsCollector, + CoreResourceProvider resourceProvider) { this.context = context; this.notificationController = notificationController; this.contacts = contacts; this.transportProvider = transportProvider; this.accountStatsCollector = accountStatsCollector; + this.resourceProvider = resourceProvider; controllerThread = new Thread(new Runnable() { @Override @@ -2403,7 +2407,8 @@ public class MessagingController { msg.putExtra(Intent.EXTRA_CC, recipientsCc); msg.setType("text/plain"); - context.startActivity(Intent.createChooser(msg, context.getString(R.string.send_alternate_chooser_title))); + Intent chooserIntent = Intent.createChooser(msg, resourceProvider.sendAlternateChooserTitle()); + context.startActivity(chooserIntent); } /** diff --git a/app/core/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java b/app/core/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java index b8689d94d..846686a25 100644 --- a/app/core/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java +++ b/app/core/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java @@ -8,17 +8,14 @@ import java.util.List; import java.util.Map; import java.util.Set; -import android.app.Application; import android.content.Context; import com.fsck.k9.Account; import com.fsck.k9.AccountStats; -import com.fsck.k9.Core; -import com.fsck.k9.DI; +import com.fsck.k9.CoreResourceProvider; import com.fsck.k9.K9; import com.fsck.k9.K9RobolectricTest; import com.fsck.k9.Preferences; -import com.fsck.k9.RobolectricTest; import com.fsck.k9.backend.api.Backend; import com.fsck.k9.backend.api.FolderInfo; import com.fsck.k9.helper.Contacts; @@ -148,7 +145,7 @@ public class MessagingControllerTest extends K9RobolectricTest { MessagingControllerTestExtra.backendManagerProvides(backend); controller = new MessagingController(appContext, notificationController, contacts, transportProvider, - accountStatsCollector); + accountStatsCollector, mock(CoreResourceProvider.class)); configureAccount(); configureLocalStore(); diff --git a/app/k9mail/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt b/app/k9mail/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt index 0f17033fc..ee1a27eb8 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt @@ -7,4 +7,6 @@ import com.fsck.k9.R class K9CoreResourceProvider(private val context: Context) : CoreResourceProvider { override fun defaultSignature(): String = context.getString(R.string.default_signature) override fun defaultIdentityDescription(): String = context.getString(R.string.default_identity_description) + + override fun sendAlternateChooserTitle(): String = context.getString(R.string.send_alternate_chooser_title) }