Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27889] Android: Implement Ti.UI.Shortcut

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2020-08-11T11:08:25.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.1.0
ComponentsAndroid
Labelsparity, shortcut
ReporterVijay Singh
AssigneeGary Mathews
Created2020-05-08T17:36:29.000+0000
Updated2020-08-11T11:08:25.000+0000

Description

iOS has Ti.UI.iOS.ApplicationShortcuts and android has implemented Ti.UI.ShortcutItem for shortcut. To have parity on both platform , it is discussed to move Shortcut APIs under Ti.UI.Shortcut. Following are the decided APIs -
1. var shortcutItem = Ti.UI.createShortcutItem({
     id: String   // Unique identifier
     title: String
     description: String
     icon: String/Number
     data: Dictionary
    })

2. var shortcut = Ti.UI.createShortcut();

3. shortcut.add(Ti.UI.ShortcutItem);

4. shortcut.items -> Array<Ti.UI.ShortcutItem>

5. shortcut.getById(id) -> Ti.UI.ShortcutItem

6. shortcut.staticItems -> Array<Ti.UI.ShortcutItem>

7. shortcut.remove(Ti.UI.ShortcutItem);

8. shortcut.removeAll();

9. Event listener - Ti.UI.Shortcuts.addEventListener('click', listener);  -> Ti.UI.ShortcutItem

Comments

  1. Gary Mathews 2020-06-08

    master: https://github.com/appcelerator/titanium_mobile/pull/11759
  2. Satyam Sekhri 2020-07-07

    FR Passed
  3. Satyam Sekhri 2020-07-27

    Parity issue with eventListner. //Works on iOS //Does not work on android. On android it works with Ti.UI.Shortcut.addEventListner var shortcut = Ti.UI.createShortcut(); Shortcut.addEventListener('click', e => { // e should contain 'item' property console.log('shortcut: ' + JSON.stringify(e, null, 1)) });
  4. Gary Mathews 2020-07-28

    9_1_X: https://github.com/appcelerator/titanium_mobile/pull/11853
  5. Joshua Quick 2020-07-29

    Gary's PR will make it work like iOS. However... I don't think the Ti.UI.createShortcut(} method should exist on Android or iOS since it doesn't make sense to have multiple instances of it.
       var shortcut = Ti.UI.createShortcut();
       var item = Ti.UI.createShortcutItem();
       shortcut.add(item);
       
    We should be using it as a module like this...
       var item = Ti.UI.createShortcutItem();
       Ti.UI.Shortcut.add(item);
       
    ...and possible have shortcut item creation done via the Ti.UI.Shortcut module...
       var item = Ti.UI.Shortcut.createShortcutItem();
       Ti.UI.Shortcut.add(item);
       
    I apologize for not paying attention to the original design, but we might want to re-open this for both Android and iOS.
  6. Samir Mohammed 2020-08-11

    *Closing ticket*. Improvement verified in SDK version 9.1.0.v20200810120239, 9.2.0.v20200810085310 and 9.3.0.v20200810090511. *Test and other information can be found at:* https://github.com/appcelerator/titanium_mobile/pull/11856 *Test Environment*
       MacOS Big Sur: 11.0 Beta
       Xcode: 12.0 Beta 
       Java Version: 1.8.0_242
       Android NDK: 21.3.6528147
       Node.js: 12.18.1
       ""NPM":"5.0.0","CLI":"8.1.0-master.5""
       API29 Pixel XL emulator
       

JSON Source