Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): implement Shortcut proxy #11759

Merged
merged 19 commits into from Jul 7, 2020
Merged

Conversation

garymathews
Copy link
Contributor

@garymathews garymathews commented Jun 7, 2020

  • Implement Ti.UI.createShortcut for cross-platform shortcuts
TEST CASE
const window = Ti.UI.createWindow({ backgroundColor: 'grey', layout: 'vertical' });
const shortcut = Ti.UI.createShortcut();

let lastShortcutItem;

function test(title, callback) {
	const button = Ti.UI.createButton({ title, top: 50 });
	button.addEventListener('click', callback);
	window.add(button);
}

test('ADD RANDOM SHORTCUT', _ => {
	const rand = Math.floor(Math.random() * (999 - 1)) + 1;
	const item = Ti.UI.createShortcutItem({
    	id: `test_shortcut_${rand}`,
    	title: `SHORTCUT_${rand}`,
    	description: `DESCRIPTION_${rand}`
    });
	lastShortcutId = item;
	shortcut.add(item);
});

test('REMOVE LAST SHORTCUT', _ => {
	try {
		shortcut.remove(lastShortcutItem);
	} catch { }
});

test('REMOVE ALL SHORTCUTS', _ => {
	shortcut.removeAll();
});

test('NUMBER OF SHORTCUTS', _ => {
	alert(`staticItems: ${shortcut.staticItems.length}`);
	alert(`items: ${shortcut.items.length}`);
});

Ti.UI.Shortcut.addEventListener('click', e => {
	console.log('shortcut: ' + JSON.stringify(e, null, 1))
});

window.open();

JIRA Ticket

@build build requested a review from a team June 8, 2020 18:21
@build build added the docs label Jun 8, 2020
* `Ti.UI.createShortcut` is manually defined in `UIModule`.
*/
@Kroll.module(parentModule = UIModule.class)
public class ShortcutModule extends KrollModule
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels a bit odd to have this module stub so we can hang event listeners. Looks like we also always fire the event at the same time to Ti.App shortcutitemclick event - so you could probably hack this pretty easily in a js extension (basically add a dumb Ti.UI.Shortcut add/removeEventListener that registers for Ti.App event and forwards it)

@ssekhri
Copy link

ssekhri commented Jul 7, 2020

FR Passed
Verified on:
Mac OS: 10.15.4
SDK: 9.1.0.v20200706133155
Appc CLI: 8.0.0
JDK: 11.0.4
Node: 10.17.0
Studio: 6.0.0.202005141803
Device: MiA1(v9.0) device, Pixel3(v10.0) emulator

@ssekhri ssekhri merged commit 5432efc into tidev:master Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants