Skip to content

Commit

Permalink
[TIMOB-24765] Implement shortcut pinning for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Oct 2, 2018
1 parent 30d22d7 commit 8c43088
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,26 @@ public void hide()
}
}

@Kroll.method
public void pin()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
shortcut != null) {
if (shortcutManager.isRequestPinShortcutSupported()) {
boolean shortcutExists = false;
for (ShortcutInfo shortcut : shortcutManager.getPinnedShortcuts()) {
if (shortcut.getId().equals(this.shortcut.getId())) {
shortcutExists = true;
break;
}
}
if (!shortcutExists) {
shortcutManager.requestPinShortcut(this.shortcut, null);
}
}
}
}

@Kroll.getProperty
public String getId()
{
Expand Down
5 changes: 5 additions & 0 deletions apidoc/Titanium/UI/ShortcutItem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ methods:
description: Hide the shortcut.
platforms: [android, iphone, ipad]

- name: pin
description: Pin shortcut to launcher.
platforms: [android]
osver: {android: {min: "8.0"}}

properties:
- name: id
summary: Determines shortcut id.
Expand Down

0 comments on commit 8c43088

Please sign in to comment.