Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27990] Android: Ti.UI.ShortcutItem has lot of issues

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionDuplicate
Resolution Date2020-07-17T21:18:29.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.1.0
ComponentsAndroid
Labelsandroid, api, defect
ReporterPrashant Saini
AssigneeGary Mathews
Created2020-06-27T04:20:44.000+0000
Updated2020-07-17T21:18:29.000+0000

Description

Ti.UI.ShortcutItem class needs lot of refactoring and improvements as listed below: *Issues:*

_icon_ property does not accept _Ti.File.nativePath_ string to create downloaded remote icons, it supports only the bundled icons as of now in the form of drawable which limits its usage.

While adding two shortcut items with same icon, one of the item does not shown icon (shown in attached screenshot)

Adding multiple shortcuts (out of maximum allowed) throw error. It should check and provide a support for knowing maximum shortcuts allowed as described [HERE](https://developer.android.com/reference/android/content/pm/ShortcutManager#getMaxShortcutCountPerActivity()) (shown in attached screenshot)

Before creating icon in proxy-class, it should be checked for their maximum dimension allowed as per [getIconMaxWidth() and getIconMaxHeight()](https://developer.android.com/reference/android/content/pm/ShortcutManager#getIconMaxWidth()).

*Feature Request:*

Add feature to remove shortcut by just passing the ID since the current way to remove shortcut is to first create it & then calling its hide() method which seems odd.

Add feature to remove all shortcuts with a single call using [removeAllDynamicShortcuts() method](https://developer.android.com/reference/android/content/pm/ShortcutManager#removeAllDynamicShortcuts()) from native side. A common method for Titanium can be used for this point and the one above.

Return a list of all shortcuts added so we don't need to keep a track in app. Refer [getShortcuts()](https://developer.android.com/reference/android/content/pm/ShortcutManager#getShortcuts(int)) or the [getDynamicShortcuts()](https://developer.android.com/reference/android/content/pm/ShortcutManager#getDynamicShortcuts()) method.

#

Attachments

FileDateSize
shortcut-2.png2020-06-27T04:19:59.000+0000821843
shortcut-max.png2020-06-27T04:19:57.000+0000218421

Comments

  1. Michael Gangolf 2020-06-27

    Issue 3 can be fixed like this: https://github.com/appcelerator/titanium_mobile/pull/11798 It would be nicer to have ShortcutManager and not just the items. Then you could expose the other parts (like the maxLimit, catch errors, get existing shortcuts)
  2. Prashant Saini 2020-06-27

    Using try-catch is not an ideal fix, rather checking about maximum allowed shortcuts is.
  3. Michael Gangolf 2020-06-27

    Tried that: max returned 10 for me but I was only able to create 5! Not sure why there was a difference. That's why I went with the try/catch one
  4. Prashant Saini 2020-06-27

    Perhaps that's because the count is a sum of STATIC & DYNAMIC shortcuts. It is recommended on [Android Docs](https://developer.android.com/guide/topics/ui/shortcuts/best-practices) to use only upto 4 shortcuts due to the device's launcher's restrictions. Maybe we should log a warning not to create more than 4 shortcuts as it's also not visually appealing.
  5. Gary Mathews 2020-06-29

    This will be fixed by https://github.com/appcelerator/titanium_mobile/pull/11759

JSON Source