Loading app/ui/src/main/java/com/fsck/k9/UiKoinModules.kt +3 −1 Original line number Diff line number Diff line package com.fsck.k9 import com.fsck.k9.activity.activityModule import com.fsck.k9.contacts.contactsModule import com.fsck.k9.fragment.fragmentModule import com.fsck.k9.ui.endtoend.endToEndUiModule import com.fsck.k9.ui.settings.settingsUiModule Loading @@ -11,5 +12,6 @@ val uiModules = listOf( uiModule, settingsUiModule, endToEndUiModule, fragmentModule fragmentModule, contactsModule ) app/ui/src/main/java/com/fsck/k9/activity/misc/ContactPicture.java +5 −14 Original line number Diff line number Diff line package com.fsck.k9.activity.misc; import android.content.Context; import android.util.TypedValue; import com.fsck.k9.K9; import com.fsck.k9.ui.R; import com.fsck.k9.DI; import com.fsck.k9.contacts.ContactLetterBitmapCreator; public class ContactPicture { public static ContactPictureLoader getContactPictureLoader(Context context) { final int defaultBgColor; if (!K9.isColorizeMissingContactPictures()) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.contactPictureFallbackDefaultBackgroundColor, outValue, true); defaultBgColor = outValue.data; } else { defaultBgColor = 0; } return new ContactPictureLoader(context, defaultBgColor); ContactLetterBitmapCreator contactLetterBitmapCreator = DI.get(ContactLetterBitmapCreator.class); return new ContactPictureLoader(context, contactLetterBitmapCreator); } } app/ui/src/main/java/com/fsck/k9/activity/misc/ContactPictureLoader.java +2 −14 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import com.bumptech.glide.request.FutureTarget; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.Target; import com.fsck.k9.contacts.ContactLetterBitmapCreator; import com.fsck.k9.contacts.ContactLetterExtractor; import com.fsck.k9.helper.Contacts; import com.fsck.k9.mail.Address; import com.fsck.k9.view.RecipientSelectView.Recipient; Loading @@ -50,25 +49,14 @@ public class ContactPictureLoader { private int mPictureSizeInPx; /** * Constructor. * * @param context * A {@link Context} instance. * @param defaultBackgroundColor * The ARGB value to be used as background color for the fallback picture. {@code 0} to * use a dynamically calculated background color. */ public ContactPictureLoader(Context context, int defaultBackgroundColor) { public ContactPictureLoader(Context context, ContactLetterBitmapCreator contactLetterBitmapCreator) { this.context = context.getApplicationContext(); this.contactLetterBitmapCreator = contactLetterBitmapCreator; mContactsHelper = Contacts.getInstance(this.context); Resources resources = context.getResources(); float scale = resources.getDisplayMetrics().density; mPictureSizeInPx = (int) (PICTURE_SIZE * scale); ContactLetterExtractor contactLetterExtractor = new ContactLetterExtractor(); contactLetterBitmapCreator = new ContactLetterBitmapCreator(contactLetterExtractor, defaultBackgroundColor); } public void loadContactPicture(final Address address, final ImageView imageView) { Loading app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterBitmapConfig.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line package com.fsck.k9.contacts import android.content.Context import android.util.TypedValue import android.view.ContextThemeWrapper import com.fsck.k9.K9 import com.fsck.k9.activity.K9ActivityCommon import com.fsck.k9.ui.R class ContactLetterBitmapConfig(context: Context) { val hasDefaultBackgroundColor: Boolean = !K9.isColorizeMissingContactPictures() val defaultBackgroundColor: Int init { defaultBackgroundColor = if (hasDefaultBackgroundColor) { val outValue = TypedValue() val themedContext = ContextThemeWrapper(context, K9ActivityCommon.getK9ThemeResourceId()) themedContext.theme.resolveAttribute(R.attr.contactPictureFallbackDefaultBackgroundColor, outValue, true) outValue.data } else { 0 } } } app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterBitmapCreator.kt +3 −6 Original line number Diff line number Diff line Loading @@ -8,13 +8,10 @@ import com.fsck.k9.mail.Address /** * Draw a `Bitmap` containing the "contact letter" obtained by [ContactLetterExtractor]. * * @param defaultBackgroundColor The ARGB value to be used as background color for the fallback picture. `0` to use a * dynamically calculated background color. */ class ContactLetterBitmapCreator( private val letterExtractor: ContactLetterExtractor, private val defaultBackgroundColor: Int private val config: ContactLetterBitmapConfig ) { fun drawBitmap(bitmap: Bitmap, pictureSizeInPx: Int, address: Address): Bitmap { val canvas = Canvas(bitmap) Loading Loading @@ -43,8 +40,8 @@ class ContactLetterBitmapCreator( } private fun calcUnknownContactColor(address: Address): Int { if (defaultBackgroundColor != 0) { return defaultBackgroundColor if (config.hasDefaultBackgroundColor) { return config.defaultBackgroundColor } val hash = address.hashCode() Loading Loading
app/ui/src/main/java/com/fsck/k9/UiKoinModules.kt +3 −1 Original line number Diff line number Diff line package com.fsck.k9 import com.fsck.k9.activity.activityModule import com.fsck.k9.contacts.contactsModule import com.fsck.k9.fragment.fragmentModule import com.fsck.k9.ui.endtoend.endToEndUiModule import com.fsck.k9.ui.settings.settingsUiModule Loading @@ -11,5 +12,6 @@ val uiModules = listOf( uiModule, settingsUiModule, endToEndUiModule, fragmentModule fragmentModule, contactsModule )
app/ui/src/main/java/com/fsck/k9/activity/misc/ContactPicture.java +5 −14 Original line number Diff line number Diff line package com.fsck.k9.activity.misc; import android.content.Context; import android.util.TypedValue; import com.fsck.k9.K9; import com.fsck.k9.ui.R; import com.fsck.k9.DI; import com.fsck.k9.contacts.ContactLetterBitmapCreator; public class ContactPicture { public static ContactPictureLoader getContactPictureLoader(Context context) { final int defaultBgColor; if (!K9.isColorizeMissingContactPictures()) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.contactPictureFallbackDefaultBackgroundColor, outValue, true); defaultBgColor = outValue.data; } else { defaultBgColor = 0; } return new ContactPictureLoader(context, defaultBgColor); ContactLetterBitmapCreator contactLetterBitmapCreator = DI.get(ContactLetterBitmapCreator.class); return new ContactPictureLoader(context, contactLetterBitmapCreator); } }
app/ui/src/main/java/com/fsck/k9/activity/misc/ContactPictureLoader.java +2 −14 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import com.bumptech.glide.request.FutureTarget; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.Target; import com.fsck.k9.contacts.ContactLetterBitmapCreator; import com.fsck.k9.contacts.ContactLetterExtractor; import com.fsck.k9.helper.Contacts; import com.fsck.k9.mail.Address; import com.fsck.k9.view.RecipientSelectView.Recipient; Loading @@ -50,25 +49,14 @@ public class ContactPictureLoader { private int mPictureSizeInPx; /** * Constructor. * * @param context * A {@link Context} instance. * @param defaultBackgroundColor * The ARGB value to be used as background color for the fallback picture. {@code 0} to * use a dynamically calculated background color. */ public ContactPictureLoader(Context context, int defaultBackgroundColor) { public ContactPictureLoader(Context context, ContactLetterBitmapCreator contactLetterBitmapCreator) { this.context = context.getApplicationContext(); this.contactLetterBitmapCreator = contactLetterBitmapCreator; mContactsHelper = Contacts.getInstance(this.context); Resources resources = context.getResources(); float scale = resources.getDisplayMetrics().density; mPictureSizeInPx = (int) (PICTURE_SIZE * scale); ContactLetterExtractor contactLetterExtractor = new ContactLetterExtractor(); contactLetterBitmapCreator = new ContactLetterBitmapCreator(contactLetterExtractor, defaultBackgroundColor); } public void loadContactPicture(final Address address, final ImageView imageView) { Loading
app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterBitmapConfig.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line package com.fsck.k9.contacts import android.content.Context import android.util.TypedValue import android.view.ContextThemeWrapper import com.fsck.k9.K9 import com.fsck.k9.activity.K9ActivityCommon import com.fsck.k9.ui.R class ContactLetterBitmapConfig(context: Context) { val hasDefaultBackgroundColor: Boolean = !K9.isColorizeMissingContactPictures() val defaultBackgroundColor: Int init { defaultBackgroundColor = if (hasDefaultBackgroundColor) { val outValue = TypedValue() val themedContext = ContextThemeWrapper(context, K9ActivityCommon.getK9ThemeResourceId()) themedContext.theme.resolveAttribute(R.attr.contactPictureFallbackDefaultBackgroundColor, outValue, true) outValue.data } else { 0 } } }
app/ui/src/main/java/com/fsck/k9/contacts/ContactLetterBitmapCreator.kt +3 −6 Original line number Diff line number Diff line Loading @@ -8,13 +8,10 @@ import com.fsck.k9.mail.Address /** * Draw a `Bitmap` containing the "contact letter" obtained by [ContactLetterExtractor]. * * @param defaultBackgroundColor The ARGB value to be used as background color for the fallback picture. `0` to use a * dynamically calculated background color. */ class ContactLetterBitmapCreator( private val letterExtractor: ContactLetterExtractor, private val defaultBackgroundColor: Int private val config: ContactLetterBitmapConfig ) { fun drawBitmap(bitmap: Bitmap, pictureSizeInPx: Int, address: Address): Bitmap { val canvas = Canvas(bitmap) Loading Loading @@ -43,8 +40,8 @@ class ContactLetterBitmapCreator( } private fun calcUnknownContactColor(address: Address): Int { if (defaultBackgroundColor != 0) { return defaultBackgroundColor if (config.hasDefaultBackgroundColor) { return config.defaultBackgroundColor } val hash = address.hashCode() Loading