File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
webui/src/main/kotlin/com/dergoogler/mmrl/webui/interfaces Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,15 @@ class ModuleInterface(
220220 createShortcutInternal(title, icon)
221221 }
222222
223+ private val shortcutManager = context.getSystemService(ShortcutManager ::class .java)
224+
225+ @JavascriptInterface
226+ fun hasShortcut (): Boolean {
227+ val id = modId.id
228+ val shortcutId = " shortcut_$id "
229+ return shortcutManager.pinnedShortcuts.any { it.id == shortcutId }
230+ }
231+
223232 private fun createShortcutInternal (title : String , icon : String ) {
224233
225234 if (options.cls == null ) {
@@ -242,7 +251,6 @@ class ModuleInterface(
242251 return
243252 }
244253
245- val shortcutManager = context.getSystemService(ShortcutManager ::class .java)
246254
247255 if (! shortcutManager.isRequestPinShortcutSupported) {
248256 Toast .makeText(
@@ -252,7 +260,7 @@ class ModuleInterface(
252260 ).show()
253261 }
254262
255- if (shortcutManager.pinnedShortcuts.any { it.id == shortcutId } ) {
263+ if (hasShortcut() ) {
256264 Toast .makeText(
257265 context,
258266 context.getString(R .string.shortcut_already_exists),
You can’t perform that action at this time.
0 commit comments