Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:56:56 +01:00
parent 75dc487a7a
commit 39c29d175b
6317 changed files with 388324 additions and 2 deletions

View file

@ -0,0 +1,13 @@
plugins {
id(ThunderbirdPlugins.Library.android)
}
android {
namespace = "net.thunderbird.core.ui.account"
}
dependencies {
implementation(projects.core.ui.legacy.designsystem)
implementation(libs.glide)
}

View file

@ -0,0 +1,35 @@
package net.thunderbird.core.ui.account
import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.InsetDrawable
import android.graphics.drawable.LayerDrawable
import android.util.TypedValue
import androidx.core.content.ContextCompat
import app.k9mail.core.ui.legacy.designsystem.atom.icon.Icons
private const val PADDING_DP = 8f
/**
* Provides a [Drawable] for the account using the account's color as background color.
*/
class AccountFallbackImageProvider(private val context: Context) {
fun getDrawable(color: Int): Drawable {
val drawable = ContextCompat.getDrawable(context, Icons.Outlined.Person)
?: error("Error loading drawable")
val inset = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
PADDING_DP,
context.resources.displayMetrics,
).toInt()
return LayerDrawable(
arrayOf(
ColorDrawable(color),
InsetDrawable(drawable, inset),
),
)
}
}

View file

@ -0,0 +1,10 @@
package net.thunderbird.core.ui.account
import com.bumptech.glide.load.Key
import java.security.MessageDigest
data class AccountImage(val email: String, val color: Int) : Key {
override fun updateDiskCacheKey(messageDigest: MessageDigest) {
messageDigest.update(toString().toByteArray(Key.CHARSET))
}
}