Remove Android resource references from MessagingController

This commit is contained in:
cketti 2018-07-06 17:13:01 +02:00
parent a4e8046217
commit 63142f222a
4 changed files with 15 additions and 9 deletions

View file

@ -3,4 +3,6 @@ package com.fsck.k9
interface CoreResourceProvider {
fun defaultSignature(): String
fun defaultIdentityDescription(): String
fun sendAlternateChooserTitle(): String
}

View file

@ -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);
}
/**

View file

@ -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();

View file

@ -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)
}