Making plugins for iShell.
For creating plugins there is a class UIBase. The plugin needs to extend that class, just like every application extends MIDlet. The constuctor of the class needs to be: protected UIBase() The class UIBase have methods for start and stop: public final void start() public final void stop() The method start() tells iShell to start the plugin. For ending the plugin work you need to use the method stop(). With stop we go back to iShell.Here are signal methods: public abstract void gainFocus(PrimaryDisplay d) public abstract void loseFocus(PrimaryDisplay d) public abstract void destroyed(PrimaryDisplay d) As you can see that methods are abstract. The method gainFocus(PrimaryDisplay d) is used when the app gets focus, e.g. the application will get on top and when you press keys - the focus will be on the app and you can control it. The method gainFocus(PrimaryDisplay d) is used when the app gets focus, e.g. the application will get on top and when you press keys - the focus will be on the app and you can control it.The method loseFocus(PrimaryDisplay d) as named you can see it's for loosing focus, e.g.. makes other object PrimaryView or UIBase, where you used start(). The method destroyed(PrimaryDisplay d) is used when the plugin is closed, for example when you used stop() or on red button press. The method destroyed(PrimaryDisplay d) is used when the plugin is closed, for example when you used stop() or on red button press.Method for rendering the plugin on the screen: public abstract void paint(UIGraphics g) It is also abstract. In this method you need to add everything printable. The painting is done by UIGraphics g, method which is identical with the method Graphics.Method for work with keys: public abstract void onKeyDown(int key) Started when you press a key. public abstract void onKeyLongPress(int key) Started when you press a key for longer time and release it Started when you press a key for longer time and release it public abstract void onKeyReleased(int key) Started when you release a key Started when you release a key public abstract void onKeyRepeated(int key) Started when you press and hold the key (it will make repeated key presses). public abstract void onKeyShortPress(int key); Started when you press a key shortly.Here is a list with the events which will be started when you press a key and release it fast: onKeyDown onKeyReleased onKeyShortPress (onKeyLongPress) Here is a list with events that will start when you press and hold a key: onKeyDown onKeyRepeated onKeyLongPress onKeyRepeated onKeyRepeated onKeyRepeated onKeyReleased Static method for accessing the iTunesPlayer: public static iTunesPlayer getiTunesPlayer() For example on plugin start you can start playing with iTunes, with the following gainFocus: For example on plugin start you can start playing with iTunes, with the following gainFocus: public void gainFocus(PrimaryDisplay d) { getiTunesPlayer().stop(); } To make iShell to know that there is a plugin, the plugin names need to be stored in ishell.plugin. This file needs to contain: To make iShell to know that there is a plugin, the plugin names need to be stored in ishell.plugin. This file needs to contain:[Plugin name] /icon icon plugin class plugin class For example the Phone Manager plugin will be: For example the Phone Manager plugin will be:[Phone Manager] /PMan/pm.png PMan Plugin example: import com.motorola.synerj.ui.PrimaryDisplay; import com.motorola.synerj.ui.UIGraphics; public class Plugin extends UIBase { private int x; private int y; public Plugin() { super(); x = 0; y = 0; } public void paint(UIGraphics g) { g.setColor(255, 255, 255);//make white color make white color g.fillRect(x, y, getWidth(), getHeight());//the usable area the usable area } public void loseFocus(PrimaryDisplay d) { } public void gainFocus(PrimaryDisplay d) { getiTunesPlayer().pause();//we start it on pause } public void destroyed(PrimaryDisplay d) { getiTunesPlayer().resume();//on end we continue playing } public void onKeyDown(int key) { } public void onKeyLongPress(int key) { } public void onKeyReleased(int key) { } public void onKeyRepeated(int key) { } public void onKeyShortPress(int key) { if (key == 48) stop();// the key 0 will be exit the key 0 will be exit } }
|