Repo created
This commit is contained in:
parent
75dc487a7a
commit
39c29d175b
6317 changed files with 388324 additions and 2 deletions
13
core/ui/account/build.gradle.kts
Normal file
13
core/ui/account/build.gradle.kts
Normal 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)
|
||||
}
|
||||
|
|
@ -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),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue