Fix crash if adaptive icon foreground or background is null
This commit is contained in:
parent
3cf0038c70
commit
a303703d9e
@ -53,14 +53,18 @@ class LauncherApp(
|
|||||||
} ?: return null
|
} ?: return null
|
||||||
if (icon is AdaptiveIconDrawable) {
|
if (icon is AdaptiveIconDrawable) {
|
||||||
return StaticLauncherIcon(
|
return StaticLauncherIcon(
|
||||||
foregroundLayer = StaticIconLayer(
|
foregroundLayer = icon.foreground?.let {
|
||||||
icon = icon.foreground,
|
StaticIconLayer(
|
||||||
scale = 1.5f,
|
icon = it,
|
||||||
),
|
scale = 1.5f,
|
||||||
backgroundLayer = StaticIconLayer(
|
)
|
||||||
icon = icon.background,
|
} ?: TransparentLayer,
|
||||||
scale = 1.5f,
|
backgroundLayer = icon.background?.let {
|
||||||
)
|
StaticIconLayer(
|
||||||
|
icon = it,
|
||||||
|
scale = 1.5f,
|
||||||
|
)
|
||||||
|
} ?: TransparentLayer,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return StaticLauncherIcon(
|
return StaticLauncherIcon(
|
||||||
|
|||||||
@ -75,14 +75,18 @@ class AppShortcut(
|
|||||||
} ?: return null
|
} ?: return null
|
||||||
if (icon is AdaptiveIconDrawable) {
|
if (icon is AdaptiveIconDrawable) {
|
||||||
return StaticLauncherIcon(
|
return StaticLauncherIcon(
|
||||||
foregroundLayer = StaticIconLayer(
|
foregroundLayer = icon.foreground?.let {
|
||||||
icon = icon.foreground,
|
StaticIconLayer(
|
||||||
scale = 1.5f,
|
icon = it,
|
||||||
),
|
scale = 1.5f,
|
||||||
backgroundLayer = StaticIconLayer(
|
)
|
||||||
icon = icon.background,
|
} ?: TransparentLayer,
|
||||||
scale = 1.5f,
|
backgroundLayer = icon.background?.let {
|
||||||
)
|
StaticIconLayer(
|
||||||
|
icon = it,
|
||||||
|
scale = 1.5f,
|
||||||
|
)
|
||||||
|
} ?: TransparentLayer,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return StaticLauncherIcon(
|
return StaticLauncherIcon(
|
||||||
|
|||||||
@ -15,10 +15,7 @@ import android.util.Size
|
|||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.exifinterface.media.ExifInterface
|
import androidx.exifinterface.media.ExifInterface
|
||||||
import de.mm20.launcher2.files.R
|
import de.mm20.launcher2.files.R
|
||||||
import de.mm20.launcher2.icons.ColorLayer
|
import de.mm20.launcher2.icons.*
|
||||||
import de.mm20.launcher2.icons.LauncherIcon
|
|
||||||
import de.mm20.launcher2.icons.StaticIconLayer
|
|
||||||
import de.mm20.launcher2.icons.StaticLauncherIcon
|
|
||||||
import de.mm20.launcher2.ktx.formatToString
|
import de.mm20.launcher2.ktx.formatToString
|
||||||
import de.mm20.launcher2.media.ThumbnailUtilsCompat
|
import de.mm20.launcher2.media.ThumbnailUtilsCompat
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -120,14 +117,18 @@ open class LocalFile(
|
|||||||
when {
|
when {
|
||||||
icon is AdaptiveIconDrawable -> {
|
icon is AdaptiveIconDrawable -> {
|
||||||
return StaticLauncherIcon(
|
return StaticLauncherIcon(
|
||||||
foregroundLayer = StaticIconLayer(
|
foregroundLayer = icon.foreground?.let {
|
||||||
icon = icon.foreground,
|
StaticIconLayer(
|
||||||
scale = 1.5f,
|
icon = it,
|
||||||
),
|
scale = 1.5f,
|
||||||
backgroundLayer = StaticIconLayer(
|
)
|
||||||
icon = icon.background,
|
} ?: TransparentLayer,
|
||||||
scale = 1.5f,
|
backgroundLayer = icon.background?.let {
|
||||||
)
|
StaticIconLayer(
|
||||||
|
icon = it,
|
||||||
|
scale = 1.5f,
|
||||||
|
)
|
||||||
|
} ?: TransparentLayer,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
|
|||||||
@ -40,15 +40,19 @@ internal class DynamicCalendarIcon(
|
|||||||
backgroundLayer = ColorLayer()
|
backgroundLayer = ColorLayer()
|
||||||
)
|
)
|
||||||
} else if (drawable is AdaptiveIconDrawable) {
|
} else if (drawable is AdaptiveIconDrawable) {
|
||||||
StaticLauncherIcon(
|
return StaticLauncherIcon(
|
||||||
foregroundLayer = StaticIconLayer(
|
foregroundLayer = drawable.foreground?.let {
|
||||||
icon = drawable.foreground,
|
StaticIconLayer(
|
||||||
scale = 1.5f
|
icon = it,
|
||||||
),
|
scale = 1.5f,
|
||||||
backgroundLayer = StaticIconLayer(
|
)
|
||||||
icon = drawable.background,
|
} ?: TransparentLayer,
|
||||||
scale = 1.5f
|
backgroundLayer = drawable.background?.let {
|
||||||
)
|
StaticIconLayer(
|
||||||
|
icon = it,
|
||||||
|
scale = 1.5f,
|
||||||
|
)
|
||||||
|
} ?: TransparentLayer,
|
||||||
)
|
)
|
||||||
} else StaticLauncherIcon(
|
} else StaticLauncherIcon(
|
||||||
foregroundLayer = StaticIconLayer(
|
foregroundLayer = StaticIconLayer(
|
||||||
|
|||||||
@ -46,15 +46,19 @@ class IconPackIconProvider(
|
|||||||
val drawable = ResourcesCompat.getDrawable(res, resId, context.theme) ?: return null
|
val drawable = ResourcesCompat.getDrawable(res, resId, context.theme) ?: return null
|
||||||
return when {
|
return when {
|
||||||
drawable is AdaptiveIconDrawable -> {
|
drawable is AdaptiveIconDrawable -> {
|
||||||
StaticLauncherIcon(
|
return StaticLauncherIcon(
|
||||||
foregroundLayer = StaticIconLayer(
|
foregroundLayer = drawable.foreground?.let {
|
||||||
icon = drawable.foreground,
|
StaticIconLayer(
|
||||||
scale = 1.5f
|
icon = it,
|
||||||
),
|
scale = 1.5f,
|
||||||
backgroundLayer = StaticIconLayer(
|
)
|
||||||
icon = drawable.background,
|
} ?: TransparentLayer,
|
||||||
scale = 1.5f
|
backgroundLayer = drawable.background?.let {
|
||||||
)
|
StaticIconLayer(
|
||||||
|
icon = it,
|
||||||
|
scale = 1.5f,
|
||||||
|
)
|
||||||
|
} ?: TransparentLayer,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user