Refactor icons
This commit is contained in:
@@ -6,23 +6,14 @@ import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.provider.CalendarContract
|
||||
import android.text.format.DateFormat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.graphics.blue
|
||||
import androidx.core.graphics.green
|
||||
import androidx.core.graphics.red
|
||||
import de.mm20.launcher2.calendar.R
|
||||
import de.mm20.launcher2.graphics.TextDrawable
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.icons.ColorLayer
|
||||
import de.mm20.launcher2.icons.StaticLauncherIcon
|
||||
import de.mm20.launcher2.icons.TextLayer
|
||||
import de.mm20.launcher2.ktx.dp
|
||||
import hct.Hct
|
||||
import palettes.TonalPalette
|
||||
import scheme.Scheme
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class CalendarEvent(
|
||||
override val label: String,
|
||||
@@ -41,21 +32,14 @@ class CalendarEvent(
|
||||
get() = "calendar://$id"
|
||||
|
||||
|
||||
override fun getPlaceholderIcon(context: Context): LauncherIcon {
|
||||
override fun getPlaceholderIcon(context: Context): StaticLauncherIcon {
|
||||
val df = SimpleDateFormat("dd")
|
||||
val s = (48 * context.dp).toInt()
|
||||
val foreground = TextDrawable(
|
||||
df.format(startTime),
|
||||
color = Color.WHITE,
|
||||
fontSize = 24 * context.dp,
|
||||
typeface = Typeface.DEFAULT_BOLD,
|
||||
height = s
|
||||
)
|
||||
val background = ColorDrawable(getDisplayColor())
|
||||
return LauncherIcon(
|
||||
foreground = foreground,
|
||||
background = background,
|
||||
foregroundScale = 0.74f
|
||||
return StaticLauncherIcon(
|
||||
foregroundLayer = TextLayer(
|
||||
text = df.format(startTime),
|
||||
color = Color.WHITE
|
||||
),
|
||||
backgroundLayer = ColorLayer(getDisplayColor())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user