Remove Android resource references from MessageHelper

This commit is contained in:
cketti 2018-07-06 23:41:03 +02:00
parent c44bdfbb7b
commit 5393404513
3 changed files with 12 additions and 4 deletions

View file

@ -8,4 +8,6 @@ interface CoreResourceProvider {
fun internalStorageProviderName(): String
fun externalStorageProviderName(): String
fun contactDisplayNamePrefix(): String
}

View file

@ -9,8 +9,9 @@ import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import com.fsck.k9.Account;
import com.fsck.k9.CoreResourceProvider;
import com.fsck.k9.DI;
import com.fsck.k9.K9;
import com.fsck.k9.core.R;
import com.fsck.k9.mail.Address;
public class MessageHelper {
@ -31,15 +32,18 @@ public class MessageHelper {
public synchronized static MessageHelper getInstance(final Context context) {
if (sInstance == null) {
sInstance = new MessageHelper(context);
CoreResourceProvider resourceProvider = DI.get(CoreResourceProvider.class);
sInstance = new MessageHelper(context, resourceProvider);
}
return sInstance;
}
private final CoreResourceProvider resourceProvider;
private Context mContext;
private MessageHelper(final Context context) {
private MessageHelper(Context context, CoreResourceProvider resourceProvider) {
mContext = context;
this.resourceProvider = resourceProvider;
}
public CharSequence getDisplayName(Account account, Address[] fromAddrs, Address[] toAddrs) {
@ -49,7 +53,7 @@ public class MessageHelper {
if (fromAddrs.length > 0 && account.isAnIdentity(fromAddrs[0])) {
CharSequence to = toFriendly(toAddrs, contactHelper);
displayName = new SpannableStringBuilder(
mContext.getString(R.string.message_to_label)).append(to);
resourceProvider.contactDisplayNamePrefix()).append(to);
} else {
displayName = toFriendly(fromAddrs, contactHelper);
}

View file

@ -15,4 +15,6 @@ class K9CoreResourceProvider(private val context: Context) : CoreResourceProvide
override fun externalStorageProviderName(): String =
context.getString(R.string.local_storage_provider_external_label)
override fun contactDisplayNamePrefix(): String = context.getString(R.string.message_to_label)
}