6.7.0 - Alpha3 - 修复启动器图标无法显示快捷方式菜单的问题

This commit is contained in:
SuperMonster003
2025-07-23 14:51:04 +08:00
parent 13369983bb
commit 21b6e413cc
3 changed files with 34 additions and 23 deletions

View File

@@ -231,6 +231,10 @@
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/app_shortcuts" />
</activity-alias>
<activity-alias
@@ -248,6 +252,10 @@
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/app_shortcuts" />
</activity-alias>
<activity

View File

@@ -160,29 +160,32 @@ class LauncherIconPreference : MaterialListPreference, SharedPreferences.OnShare
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
ctx.getSystemService(ShortcutManager::class.java)?.let { sm ->
sm.pinnedShortcuts.mapNotNull { shortcutInfo ->
ShortcutInfo.Builder(ctx, shortcutInfo.id).apply {
shortcutInfo.intent?.let {
it.component?.let { component ->
setActivity(ComponentName(component.packageName, component.className))
sm.pinnedShortcuts
.filterNot { it.isDeclaredInManifest }
.filterNot { Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && it.isImmutable }
.mapNotNull { shortcutInfo ->
ShortcutInfo.Builder(ctx, shortcutInfo.id).apply {
shortcutInfo.intent?.let {
it.component?.let { component ->
setActivity(ComponentName(component.packageName, component.className))
} ?: run {
setActivity(ComponentName(ctx, ShortcutActivity::class.java))
}
setIntent(it)
} ?: run {
setActivity(ComponentName(ctx, ShortcutActivity::class.java))
setIntent(Intent(ctx, ShortcutActivity::class.java))
}
setIntent(it)
} ?: run {
setActivity(ComponentName(ctx, ShortcutActivity::class.java))
setIntent(Intent(ctx, ShortcutActivity::class.java))
}
(shortcutInfo.shortLabel ?: shortcutInfo.longLabel)?.let {
setShortLabel(it)
}
(shortcutInfo.longLabel ?: shortcutInfo.shortLabel)?.let {
setLongLabel(it)
}
}.build()
}.takeUnless { it.isEmpty() }?.let { toUpdate ->
sm.updateShortcuts(toUpdate)
}
(shortcutInfo.shortLabel ?: shortcutInfo.longLabel)?.let {
setShortLabel(it)
}
(shortcutInfo.longLabel ?: shortcutInfo.shortLabel)?.let {
setLongLabel(it)
}
}.build()
}.takeUnless { it.isEmpty() }?.let { toUpdate ->
sm.updateShortcuts(toUpdate)
}
}
}