mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-18 22:01:28 +00:00
Avoid using IconCompat.createFromIcon() that doesn't support bitmap icon
This commit is contained in:
parent
7ad77a14ae
commit
d390ca2fdf
@ -31,7 +31,7 @@ object Shortcuts {
|
|||||||
val info = ShortcutInfoCompat.Builder(context, Const.Nav.HOME)
|
val info = ShortcutInfoCompat.Builder(context, Const.Nav.HOME)
|
||||||
.setShortLabel(context.getString(R.string.magisk))
|
.setShortLabel(context.getString(R.string.magisk))
|
||||||
.setIntent(intent)
|
.setIntent(intent)
|
||||||
.setIcon(IconCompat.createFromIcon(context, context.getIcon(R.drawable.ic_launcher)))
|
.setIcon(context.getIconCompat(R.drawable.ic_launcher))
|
||||||
.build()
|
.build()
|
||||||
ShortcutManagerCompat.requestPinShortcut(context, info, null)
|
ShortcutManagerCompat.requestPinShortcut(context, info, null)
|
||||||
}
|
}
|
||||||
@ -47,6 +47,18 @@ object Shortcuts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Context.getIconCompat(id: Int): IconCompat {
|
||||||
|
return if (isRunningAsStub) {
|
||||||
|
val bitmap = getBitmap(id)
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
|
IconCompat.createWithAdaptiveBitmap(bitmap)
|
||||||
|
else
|
||||||
|
IconCompat.createWithBitmap(bitmap)
|
||||||
|
} else {
|
||||||
|
IconCompat.createWithResource(this, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@RequiresApi(api = 25)
|
@RequiresApi(api = 25)
|
||||||
private fun getShortCuts(context: Context): List<ShortcutInfo> {
|
private fun getShortCuts(context: Context): List<ShortcutInfo> {
|
||||||
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user