Rename loadIconAsync to loadIcon as it's no longer guaranteed to be called off the main thread
This commit is contained in:
parent
2273a0912a
commit
c388b01fe8
@ -38,7 +38,7 @@ class AppInstallation(
|
|||||||
foregroundScale = 0.5f)
|
foregroundScale = 0.5f)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||||
val icon = session.appIcon ?: return getPlaceholderIcon(context)
|
val icon = session.appIcon ?: return getPlaceholderIcon(context)
|
||||||
val foreground = BitmapDrawable(context.resources, icon)
|
val foreground = BitmapDrawable(context.resources, icon)
|
||||||
foreground.colorFilter = ColorMatrixColorFilter(ColorMatrix().apply {
|
foreground.colorFilter = ColorMatrixColorFilter(ColorMatrix().apply {
|
||||||
|
|||||||
@ -79,7 +79,7 @@ class AppShortcut(
|
|||||||
foregroundScale = 0.5f)
|
foregroundScale = 0.5f)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||||
val launcherApps = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
val launcherApps = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||||
val icon = launcherApps.getShortcutIconDrawable(launcherShortcut, context.resources.displayMetrics.densityDpi)
|
val icon = launcherApps.getShortcutIconDrawable(launcherShortcut, context.resources.displayMetrics.densityDpi)
|
||||||
icon ?: return null
|
icon ?: return null
|
||||||
|
|||||||
@ -68,7 +68,7 @@ class LauncherApp(
|
|||||||
return launcherActivityInfo.user
|
return launcherActivityInfo.user
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||||
try {
|
try {
|
||||||
val icon =
|
val icon =
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ class Contact(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||||
val contentResolver = context.contentResolver
|
val contentResolver = context.contentResolver
|
||||||
val uri = ContactsContract.Contacts.getLookupUri(id, lookupKey) ?: return null
|
val uri = ContactsContract.Contacts.getLookupUri(id, lookupKey) ?: return null
|
||||||
val bmp = ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri, false)
|
val bmp = ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri, false)
|
||||||
|
|||||||
@ -51,7 +51,7 @@ open class File(
|
|||||||
|
|
||||||
open val isStoredInCloud = false
|
open val isStoredInCloud = false
|
||||||
|
|
||||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||||
if (!JavaIOFile(path).exists()) return null
|
if (!JavaIOFile(path).exists()) return null
|
||||||
when {
|
when {
|
||||||
mimeType.startsWith("image/") -> {
|
mimeType.startsWith("image/") -> {
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class GDriveFile(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class OneDriveFile(
|
|||||||
|
|
||||||
override val isStoredInCloud = true
|
override val isStoredInCloud = true
|
||||||
|
|
||||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ abstract class Searchable : Comparable<Searchable> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? = null
|
open suspend fun loadIcon(context: Context, size: Int): LauncherIcon? = null
|
||||||
abstract fun getPlaceholderIcon(context: Context): LauncherIcon
|
abstract fun getPlaceholderIcon(context: Context): LauncherIcon
|
||||||
|
|
||||||
override fun compareTo(other: Searchable): Int {
|
override fun compareTo(other: Searchable): Int {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ fun ShapedLauncherIcon(
|
|||||||
|
|
||||||
LaunchedEffect(item) {
|
LaunchedEffect(item) {
|
||||||
icon = withContext(Dispatchers.IO) {
|
icon = withContext(Dispatchers.IO) {
|
||||||
item.loadIconAsync(context, iconSize)
|
item.loadIcon(context, iconSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ class Website(
|
|||||||
) : Searchable() {
|
) : Searchable() {
|
||||||
|
|
||||||
override val key = "web://$url"
|
override val key = "web://$url"
|
||||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||||
if (favicon.isEmpty()) return null
|
if (favicon.isEmpty()) return null
|
||||||
try {
|
try {
|
||||||
return withContext(Dispatchers.IO) {
|
return withContext(Dispatchers.IO) {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class Wikipedia(
|
|||||||
) : Searchable() {
|
) : Searchable() {
|
||||||
override val key = "wikipedia://$id"
|
override val key = "wikipedia://$id"
|
||||||
|
|
||||||
override suspend fun loadIconAsync(context: Context, size: Int): LauncherIcon? {
|
override suspend fun loadIcon(context: Context, size: Int): LauncherIcon? {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user