Cyberpunkish Launcher default script and api documentation.
The code runs in the device Android WebView. All JavaScript features supported by the device WebView are available. Additionally some methods where added to access phone functionality.
Prints text at the x y coordinates.
ap37.print(0, 0, 'text', '#666666');
Prints the entire screen line by line.
ap37.printLines(['line 1', 'line 2'], '#666666');
Prints text using different colors for each character.
ap37.printMultipleColors(0, 0, 'text', '#666666', ['#ff0000', '#000000', '#ffffff']);
Change font size.
ap37.setTextSize(11);
Returns the number of character that fit on the screen horizontally and vertically.
ap37.getScreenWidth(); // returns a number
ap37.getScreenHeight(); // returns a number
Returns the current date. Useful to avoid Android WebView timezone bug: https://bugs.chromium.org/p/chromium/issues/detail?id=520783
ap37.getDate(); // returns an object: {year: 2018, month: 7, day: 12, hour: 1, minute: 2, second: 49}
Returns the battery level in a number ranging from 0 to 100.
ap37.getBatteryLevel(); // returns a number
Returns the list of currently installed apps.
ap37.getApps(); // returns an array: [{id: 0, name: "Alarm", ...}]
Instructs the launcher to open the app with a given id.
ap37.openApp(apps[0].id);
Defines the callback function to be called every time an app is installed or removed.
ap37.setOnAppsListener(function() {
apps = ap37.getApps();
});
Launches the device default web browser with the given url.
ap37.openLink('http://google.com');
Returns a boolean indicating if the launcher has permissions to access the user notifications.
ap37.notificationsActive(); // returns a boolean
Instructs the launcher to request the user for permissions the notifications.
ap37.requestNotificationsPermission();
Retrieves the list of current notifications. This will fail if the user has not accepted the request to access the device notifications.
ap37.getNotifications(); // returns an array: [{id: 0, name: "New message", ...}]
Instructs the launcher to open the notification with a given id.
ap37.openNotification(notification[0].id);
Defines the callback function to be called every time an notification is created or removed.
ap37.setOnNotificationsListener(function() {
notifications = ap37.getNotifications();
});
Defines the callback function to be called every time the user touches the device screen.
ap37.setOnTouchListener(function(x, y) {
// handle screen touch at coordinates x y
});
Copyright (C) 2018 Apseren Industries
Licensed under the GPL v3 license.