[TIMOB-27990] Android: Ti.UI.ShortcutItem has lot of issues
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2020-07-17T21:18:29.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.1.0 |
Components | Android |
Labels | android, api, defect |
Reporter | Prashant Saini |
Assignee | Gary Mathews |
Created | 2020-06-27T04:20:44.000+0000 |
Updated | 2020-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
File | Date | Size |
---|---|---|
shortcut-2.png | 2020-06-27T04:19:59.000+0000 | 821843 |
shortcut-max.png | 2020-06-27T04:19:57.000+0000 | 218421 |
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)
Using try-catch is not an ideal fix, rather checking about maximum allowed shortcuts is.
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
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.
This will be fixed by https://github.com/appcelerator/titanium_mobile/pull/11759