mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-17 13:38:30 +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)
|
||||
.setShortLabel(context.getString(R.string.magisk))
|
||||
.setIntent(intent)
|
||||
.setIcon(IconCompat.createFromIcon(context, context.getIcon(R.drawable.ic_launcher)))
|
||||
.setIcon(context.getIconCompat(R.drawable.ic_launcher))
|
||||
.build()
|
||||
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)
|
||||
private fun getShortCuts(context: Context): List<ShortcutInfo> {
|
||||
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
||||
|
Loading…
x
Reference in New Issue
Block a user