Revision: 2628
http://sourceforge.net/p/swingme/code/2628
Author: yuranet
Date: 2021-12-29 00:24:44 +0000 (Wed, 29 Dec 2021)
Log Message:
-----------
main class rename to Application
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/DesktopPane.java
SwingME/src/net/yura/mobile/gui/Font.java
SwingME/src/net/yura/mobile/gui/Graphics2D.java
SwingME/src/net/yura/mobile/gui/Icon.java
SwingME/src/net/yura/mobile/gui/KeyEvent.java
SwingME/src/net/yura/mobile/gui/border/MatteBorder.java
SwingME/src/net/yura/mobile/gui/components/Camera.java
SwingME/src/net/yura/mobile/gui/components/FileChooser.java
SwingME/src/net/yura/mobile/gui/components/Menu.java
SwingME/src/net/yura/mobile/gui/components/TextComponent.java
SwingME/src/net/yura/mobile/gui/components/Window.java
SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java
SwingME/src/net/yura/mobile/io/ClipboardManager.java
SwingME/src/net/yura/mobile/util/RemoteTest.java
Added Paths:
-----------
SwingME/src/net/yura/mobile/gui/Application.java
Removed Paths:
-------------
SwingME/src/net/yura/mobile/gui/Midlet.java
Copied: SwingME/src/net/yura/mobile/gui/Application.java (from rev 2627, SwingME/src/net/yura/mobile/gui/Midlet.java)
===================================================================
--- SwingME/src/net/yura/mobile/gui/Application.java (rev 0)
+++ SwingME/src/net/yura/mobile/gui/Application.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -0,0 +1,403 @@
+/*
+ * This file is part of 'yura.net Swing ME'.
+ *
+ * 'yura.net Swing ME' is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 'yura.net Swing ME' is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with 'yura.net Swing ME'. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.yura.mobile.gui;
+
+import java.io.InputStream;
+import java.util.Hashtable;
+import javax.microedition.lcdui.Display;
+import javax.microedition.lcdui.Image;
+import javax.microedition.midlet.MIDlet;
+import javax.microedition.midlet.MIDletStateChangeException;
+import net.yura.mobile.logging.DesktopLogger;
+import net.yura.mobile.logging.Logger;
+import net.yura.mobile.util.QueueProcessorThread;
+import net.yura.mobile.util.Url;
+
+/**
+ * @author Yura Mamyrin
+ * @see org.jdesktop.application.Application
+ */
+public abstract class Application extends MIDlet {
+
+ public static final int PLATFORM_NOT_DEFINED = 0;
+ public static final int PLATFORM_NOKIA_S40 = 1;
+ public static final int PLATFORM_NOKIA_S60 = 2;
+ public static final int PLATFORM_SONY_ERICSSON = 3;
+ public static final int PLATFORM_SAMSUNG = 4;
+ public static final int PLATFORM_MOTOROLA = 5;
+ public static final int PLATFORM_SIEMENS = 6;
+ public static final int PLATFORM_LG = 7;
+ public static final int PLATFORM_ME4SE = 8;
+ public static final int PLATFORM_WTK = 9;
+ public static final int PLATFORM_ANDROID = 10;
+ public static final int PLATFORM_BLACKBERRY = 11;
+ public static final int PLATFORM_IOS = 12;
+
+ private static int platform = detectPlatform();
+
+ //#mdebug info
+ static {
+ // on me4se we do not care about the popup as we have the console anyway
+ if (getPlatform() != PLATFORM_ME4SE) {
+ Logger.setLogger( new DesktopLogger(Logger.WARN) );
+ }
+ }
+ //#enddebug
+
+ private DesktopPane rootpane;
+ private Hashtable platformReqParams;
+
+ public Application() {
+
+ // Changing thread priority should only be done in platforms
+ // were actually improve performance.
+ QueueProcessorThread.CHANGE_PRIORITY =
+ Application.getPlatform() != Application.PLATFORM_IOS &&
+ Application.getPlatform() != Application.PLATFORM_ME4SE &&
+ Application.getPlatform() != Application.PLATFORM_ANDROID &&
+ Application.getPlatform() != Application.PLATFORM_BLACKBERRY;
+
+ rootpane = makeNewRootPane();
+
+ // now we set this as the main display
+ Display.getDisplay(this).setCurrent(rootpane);
+
+ // this repaint will mean the paint will be called
+ // this will then kick of the run method of this class
+ // and that will in tern call initialise of the midlet
+ rootpane.repaint();
+ }
+
+ /**
+ * @see org.jdesktop.application.Application#getInstance()
+ */
+ public static Application getInstance() {
+ DesktopPane dp = DesktopPane.getDesktopPane();
+ // dp can be null if the app is in the process of shutting down.
+ return dp == null ? null : dp.application;
+ }
+
+ /**
+ * This method should only be used to config the splash screen
+ * nothing else can be set up here as things like getHeight wont work
+ *
+ * Responsible for initializations that must occur before the GUI is constructed by {@link #initialize(DesktopPane)}.
+ *
+ * @see org.jdesktop.application.Application#initialize(java.lang.String[])
+ *
+ * @return THIS METHOD WILL MAKE A NEW ROOTPANE
+ */
+ protected DesktopPane makeNewRootPane() {
+ return new DesktopPane(this, 0xFF000000, null);
+ }
+
+ /**
+ * this will set up everything needed to start the app like the size and stuff
+ *
+ * Responsible for starting the application; for creating and showing the initial GUI.
+ *
+ * @see org.jdesktop.application.Application#startup()
+ */
+ protected abstract void initialize(DesktopPane rootpane);
+
+ /**
+ * @see org.jdesktop.application.Application#exit(java.util.EventObject)
+ * @see org.jdesktop.application.Application#shutdown()
+ * @param unconditional - If true when this method is called, the MIDlet must cleanup and release all resources. If false the MIDlet may throw
+ */
+ protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
+ rootpane.kill();
+ }
+
+ /**
+ * Gracefully shutdown the application, calls destroyApp(true)
+ *
+ * @see java.lang.System#exit(int) System.exit
+ * @see org.jdesktop.application.Application#exit()
+ */
+ public static void exit() {
+ try {
+ Application application = getInstance();
+ application.destroyApp(false);
+ application.notifyDestroyed();
+ }
+ catch (Exception ex) {
+ // as you called this yourself, you should not be throwing here
+ Logger.warn(null, ex);
+ throw new RuntimeException();
+ }
+ }
+
+ /**
+ * frame.setState(Frame.ICONIFIED);
+ * frame.setExtendedState(JFrame.ICONIFIED);
+ * @see java.awt.Frame#ICONIFIED
+ */
+ public static void hide() {
+ Display.getDisplay(getInstance()).setCurrent(null);
+ }
+
+ /**
+ * called when app is paused
+ */
+ protected void pauseApp() {
+ //Logger.debug("pauseApp");
+ }
+
+ /**
+ * called when comes out of pause
+ */
+ protected void startApp() {
+ //Logger.debug("startApp");
+ }
+
+ public static void call(String number) {
+ try {
+ // TODO remove spaces from number
+ getInstance().platformRequest("tel:" + number);
+ }
+ catch (Exception e) {
+ //#debug warn
+ Logger.warn("can not call: " + number, e);
+ }
+ }
+
+ public static void openURL(String url) {
+ try {
+ Application application = getInstance();
+ // midlet is null if the app is shutting down
+ if (application != null) {
+ application.platformRequest(url);
+ }
+ }
+ catch (Exception e) {
+ //#debug warn
+ Logger.warn("can not open url: " + url, e);
+ }
+ }
+
+ public static void vibration(int duration) {
+ try {
+ Display.getDisplay(getInstance()).vibrate(duration);
+ }
+ catch (Exception e) {
+ //#debug warn
+ Logger.warn("can not vibration", e);
+ }
+ }
+
+ /**
+ * @see org.jdesktop.application.Application#isMacOSX()
+ */
+ public static int getPlatform() {
+ return platform;
+ }
+
+ private static int detectPlatform() {
+
+ // detecting BLACKBERRY
+ if (hasClass("net.rim.device.api.ui.UiApplication")) {
+ return PLATFORM_BLACKBERRY;
+ }
+
+ // detecting ME4SE
+ if (hasClass("org.me4se.MIDletRunner")) {
+ return PLATFORM_ME4SE;
+ }
+
+ // detect ios before android as it has a few android classes in it
+ if (hasClass("apple.uikit.UIView")) {
+ return PLATFORM_IOS;
+ }
+
+ // detecting Android BEFORE Nokia platform as Nokia X is both android+nokia
+ if (hasClass("android.app.Activity")) { // or android.content.Context ?
+ return PLATFORM_ANDROID;
+ }
+
+ String currentPlatform = System.getProperty("microedition.platform");
+ if (currentPlatform == null) {
+ currentPlatform = ""; // Avoid null pointer exceptions
+ }
+
+ // detecting NOKIA
+ if (currentPlatform.indexOf("Nokia") >= 0) {
+ // detecting S40 vs S60
+ if (hasClass("com.nokia.mid.impl.isa.ui.gdi.Pixmap")) {
+ return PLATFORM_NOKIA_S40;
+ }
+ return PLATFORM_NOKIA_S60;
+ }
+
+ // detecting SONY ERICSSON
+ if (currentPlatform.indexOf("SonyEricsson") >= 0 ||
+ System.getProperty("com.sonyericsson.java.platform") != null) {
+ return PLATFORM_SONY_ERICSSON;
+ }
+
+ // detecting SAMSUNG
+ if (hasClass("com.samsung.util.Vibration")) {
+ return PLATFORM_SAMSUNG;
+ }
+
+ // detecting MOTOROLA
+ if (hasClass("com.motorola.multimedia.Vibrator") ||
+ hasClass("com.motorola.graphics.j3d.Effect3D") ||
+ hasClass("com.motorola.multimedia.Lighting") ||
+ hasClass("com.motorola.multimedia.FunLight") ||
+ hasClass("com.motorola.phonebook.PhoneBookRecord")) {
+ return PLATFORM_MOTOROLA;
+ }
+
+ // detecting SIEMENS
+ if (hasClass("com.siemens.mp.io.File")) {
+ return PLATFORM_SIEMENS;
+ }
+
+ // detecting LG
+ if (hasClass("mmpp.media.MediaPlayer") ||
+ hasClass("mmpp.phone.Phone") ||
+ hasClass("mmpp.lang.MathFP") ||
+ hasClass("mmpp.media.BackLight")) {
+ return PLATFORM_LG;
+ }
+
+ // detecting WTK
+ if (currentPlatform.indexOf("wtk") >= 0) {
+ return PLATFORM_WTK;
+ }
+
+ return PLATFORM_NOT_DEFINED;
+ }
+
+ // Utility method. Finds if a class is available to the class Loader
+ private static boolean hasClass(String className) {
+ try {
+ Class.forName(className);
+ return true;
+ }
+ catch (Throwable ex) {
+ return false;
+ }
+ }
+
+ //,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,
+ //==== Resources ===========================================================
+ //\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0
+
+ /**
+ * name MUST start with a "/"
+ * @see java.lang.Class#getResourceAsStream(java.lang.String) Class.getResourceAsStream
+ */
+ public static Image createImage(String name) {
+ try {
+ InputStream is = getInstance().getResourceAsStreamImpl(name);
+ if (is != null) {
+ return Image.createImage(is);
+ }
+ }
+ catch (Throwable th) {
+ //#debug warn
+ Logger.warn("cant createImage " + name, th);
+ }
+
+ try {
+ return Image.createImage(name);
+ }
+ catch (Exception ex) {
+ return null;
+ }
+ }
+
+ /**
+ * name MUST start with a "/"
+ * @see java.lang.Class#getResourceAsStream(java.lang.String) Class.getResourceAsStream
+ */
+ public static InputStream getResourceAsStream(String name) {
+ InputStream is = getInstance().getResourceAsStreamImpl(name);
+ if (is != null) {
+ return is;
+ }
+ return Application.class.getResourceAsStream(name);
+ }
+
+ public static String resdir;
+ static {
+ try {
+ // when running as a me4se applet, this can throw a SecurityException
+ String rd = System.getProperty("resdir");
+ if (rd != null) {
+ resdir = rd;
+ }
+ }
+ catch (Throwable th) { }
+ }
+
+ /**
+ * To be overwritten by sub-classes for specific implementation.
+ * This default implementation looks for a system property "resdir"
+ * and if it finds it, tries to load the resource from that folder
+ */
+ protected InputStream getResourceAsStreamImpl(String name) {
+ if (resdir != null) {
+ InputStream is = Application.class.getResourceAsStream(resdir + name);
+ if (is != null) {
+ return is;
+ }
+ }
+ return null;
+ }
+
+ //,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,
+ //==== platform Requests ===================================================
+ //\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0
+
+ // This will only be called on Android.
+ public void platformRequestForResult(String url, Object arg, int requestCode) {
+ Url u = new Url(url);
+ u.addQueryParameter("requestCode", String.valueOf(requestCode));
+ platformRequest(u.toString(), arg);
+ }
+
+ // This will only be called on Android.
+ public void platformRequest(String url, Object arg) {
+ try {
+ if (platformReqParams == null) {
+ platformReqParams = new Hashtable();
+ }
+
+ if (arg != null) {
+ platformReqParams.put(url, arg);
+ }
+
+ platformRequest(url);
+ }
+ catch (Exception e) {
+ Logger.warn("cant make request " + url + " " + arg, e);
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ // This will only be called on Android. By the "Android" side
+ public Object retrievePlatformRequestParam(String url) {
+ Object res = platformReqParams.remove(url);
+ return res;
+ }
+
+ public void onResult(int requestCode, int resultCode, Object obj) { }
+
+}
Modified: SwingME/src/net/yura/mobile/gui/DesktopPane.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/DesktopPane.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/DesktopPane.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -88,7 +88,7 @@
* @see javax.swing.SwingUtilities#invokeLater(java.lang.Runnable) SwingUtilities.invokeLater
*/
public static void invokeLater(Runnable runner) {
- Display.getDisplay(Midlet.getMidlet()).callSerially(runner);
+ Display.getDisplay(Application.getInstance()).callSerially(runner);
}
/**
@@ -151,7 +151,7 @@
private int menuHeight; // (soft key area) comes from the renderer, so depends on the theme
// object variables
- protected Midlet midlet;
+ protected Application application;
private LookAndFeel theme;
final private Vector windows = new Vector();
@@ -192,22 +192,22 @@
* @param back the background color
* @param sph the splash screen image
*/
- public DesktopPane(Midlet m, int back, Image sph) {
+ public DesktopPane(Application m, int back, Image sph) {
- int platform = Midlet.getPlatform();
+ int platform = Application.getPlatform();
- SOFT_KEYS = platform != Midlet.PLATFORM_ME4SE && platform != Midlet.PLATFORM_ANDROID && platform != Midlet.PLATFORM_IOS && platform != Midlet.PLATFORM_BLACKBERRY;
- HIDDEN_MENU = platform == Midlet.PLATFORM_BLACKBERRY;
- HIDDEN_BACK = platform == Midlet.PLATFORM_BLACKBERRY;
+ SOFT_KEYS = platform != Application.PLATFORM_ME4SE && platform != Application.PLATFORM_ANDROID && platform != Application.PLATFORM_IOS && platform != Application.PLATFORM_BLACKBERRY;
+ HIDDEN_MENU = platform == Application.PLATFORM_BLACKBERRY;
+ HIDDEN_BACK = platform == Application.PLATFORM_BLACKBERRY;
- VERY_BIG_SCREEN = platform == Midlet.PLATFORM_ME4SE;
- MAX_CLOSE_BUTTONS = platform == Midlet.PLATFORM_ME4SE;
- IPHONE_SCROLL = platform != Midlet.PLATFORM_ME4SE;
- DEFAULT_NO_FOCUS = platform == Midlet.PLATFORM_ANDROID || platform == Midlet.PLATFORM_IOS;
+ VERY_BIG_SCREEN = platform == Application.PLATFORM_ME4SE;
+ MAX_CLOSE_BUTTONS = platform == Application.PLATFORM_ME4SE;
+ IPHONE_SCROLL = platform != Application.PLATFORM_ME4SE;
+ DEFAULT_NO_FOCUS = platform == Application.PLATFORM_ANDROID || platform == Application.PLATFORM_IOS;
- QWERTY_KAYPAD = platform == Midlet.PLATFORM_ME4SE || platform == Midlet.PLATFORM_ANDROID || platform == Midlet.PLATFORM_IOS || (platform == Midlet.PLATFORM_BLACKBERRY && !KeyEvent.BLACKBERRY_ITUT);
+ QWERTY_KAYPAD = platform == Application.PLATFORM_ME4SE || platform == Application.PLATFORM_ANDROID || platform == Application.PLATFORM_IOS || (platform == Application.PLATFORM_BLACKBERRY && !KeyEvent.BLACKBERRY_ITUT);
- USE_SOFT_KEY_CLEAR = platform == Midlet.PLATFORM_NOKIA_S40;
+ USE_SOFT_KEY_CLEAR = platform == Application.PLATFORM_NOKIA_S40;
desktop = this;
@@ -216,7 +216,7 @@
setFullScreenMode(true);
- midlet = m;
+ application = m;
keypad = new KeyEvent(this);
@@ -253,7 +253,7 @@
public final void run() {
try {
- midlet.initialize(this);
+ application.initialize(this);
}
catch (Throwable th) {
//#debug warn
@@ -393,7 +393,7 @@
defaultSpace = (maxSize <= 128) ? 3 : (maxSize <= 208) ? 5 : 7;
}
- minimumTouchTarget = (Midlet.getPlatform() == Midlet.PLATFORM_IOS || Midlet.getPlatform() == Midlet.PLATFORM_ANDROID) ? XULLoader.adjustSizeToDensity(44) : 0;
+ minimumTouchTarget = (Application.getPlatform() == Application.PLATFORM_IOS || Application.getPlatform() == Application.PLATFORM_ANDROID) ? XULLoader.adjustSizeToDensity(44) : 0;
// this is only needed for if SOFT_KEYS is true,
// but we may wish to set it to true after we set the look and feel
@@ -756,7 +756,7 @@
}
static Thread dummyThread;
static {
- if (Midlet.getPlatform()==Midlet.PLATFORM_BLACKBERRY) {
+ if (Application.getPlatform() == Application.PLATFORM_BLACKBERRY) {
dummyThread=new Thread();
}
}
@@ -764,7 +764,7 @@
// there is a bug on blackberry that if it is processing a repaint and it is the last thing on the event queue
// and in that repaint we call repaint again, the 2nd repaint will never get called, even though it does get put on the queue
// we want the queue to have something more on it, so we put a empty task if we know we need another repaint
- if (Midlet.getPlatform()==Midlet.PLATFORM_BLACKBERRY && (fullrepaint || !repaintComponent.isEmpty())) {
+ if (Application.getPlatform() == Application.PLATFORM_BLACKBERRY && (fullrepaint || !repaintComponent.isEmpty())) {
invokeLater(dummyThread);
}
}
@@ -1260,7 +1260,7 @@
int key = keyevent.getJustPressedKey();
if (key != 0) {
if ( key==KeyEvent.KEY_MENU || key==KeyEvent.KEY_END ) {
- if (Midlet.getPlatform() != Midlet.PLATFORM_NOKIA_S60) {
+ if (Application.getPlatform() != Application.PLATFORM_NOKIA_S60) {
mneonicButton = currentWindow.findMnemonicButton(key);
if ( mneonicButton==null ) {
if ( key==KeyEvent.KEY_MENU ) {
@@ -1338,7 +1338,6 @@
//#debug warn
Logger.warn("Error in KeyEvent: " + keyevent, th);
}
-
}
// if no command listener is used key events fall though to this method
@@ -1597,7 +1596,7 @@
indicator.setBounds(0, getHeight() - h, w, h);
}
else {
- indicator.setBounds( (Midlet.getPlatform() == Midlet.PLATFORM_SONY_ERICSSON) ?0:(getWidth()-w), 0, w, h);
+ indicator.setBounds( (Application.getPlatform() == Application.PLATFORM_SONY_ERICSSON) ?0:(getWidth()-w), 0, w, h);
}
}
}
Modified: SwingME/src/net/yura/mobile/gui/Font.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/Font.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/Font.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -109,12 +109,12 @@
try {
- InputStream is = Midlet.getResourceAsStream(descriptor);
+ InputStream is = Application.getResourceAsStream(descriptor);
Image[] characterImage = new Image[imagePaths.length];
for (int c=0;c<imagePaths.length;c++) {
- Image image = Midlet.createImage( imagePaths[c] );
+ Image image = Application.createImage( imagePaths[c] );
// Set loaded character set images as default
characterImage[c] = image;
@@ -277,7 +277,7 @@
Properties newfont = new Properties();
- newfont.load( Midlet.getResourceAsStream(name) );
+ newfont.load( Application.getResourceAsStream(name) );
String baseDir = name.substring(0, name.lastIndexOf('/') + 1);
String[] offsetsText = StringUtil.split(newfont.getProperty("offsets"), ',');
@@ -322,7 +322,7 @@
imageName = "/"+imageName;
}
- Image fontimage = Midlet.createImage(imageName);
+ Image fontimage = Application.createImage(imageName);
f.colors[c] = Integer.parseInt(colorsText[c],16) | 0xFF000000;
Modified: SwingME/src/net/yura/mobile/gui/Graphics2D.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/Graphics2D.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/Graphics2D.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -174,7 +174,7 @@
setClip(c);
//#mdebug info
- if (Midlet.getPlatform() != Midlet.PLATFORM_ME4SE) {
+ if (Application.getPlatform() != Application.PLATFORM_ME4SE) {
int tile = (( (end_x-start_x) /src_w)*( (end_y-start_y) /src_h));
if ( tile>15 ) {
Logger.info("going to tile a very small image "+tile+" times: src_w=" +src_w+" src_h="+src_h+" dest_w="+ dest_w +" dest_h="+dest_h );
Modified: SwingME/src/net/yura/mobile/gui/Icon.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/Icon.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/Icon.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -49,7 +49,7 @@
* @see java.lang.Class#getResourceAsStream(java.lang.String) Class.getResourceAsStream
*/
public Icon(String imageName) {
- initImage( Midlet.createImage( imageName ) );
+ initImage( Application.createImage( imageName ) );
}
private void initImage(Image img) {
Modified: SwingME/src/net/yura/mobile/gui/KeyEvent.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/KeyEvent.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/KeyEvent.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -140,7 +140,7 @@
return 0;
}
- if (code == '0' && Midlet.getPlatform() == Midlet.PLATFORM_SONY_ERICSSON) {
+ if (code == '0' && Application.getPlatform() == Application.PLATFORM_SONY_ERICSSON) {
// Hack: Jane - For SE, the "+" is entered on "0", using a long key press...
acc = (pos == -1);
old = (pos >= 0);
@@ -197,7 +197,7 @@
private static final String CHARS_57 = "wxyz9";
static {
- if (Midlet.getPlatform() == Midlet.PLATFORM_SONY_ERICSSON) {
+ if (Application.getPlatform() == Application.PLATFORM_SONY_ERICSSON) {
CHARS_48 = "0+";
}
else {
@@ -452,7 +452,7 @@
private int check(int keyCode) {
- if (Midlet.getPlatform()==Midlet.PLATFORM_BLACKBERRY) {
+ if (Application.getPlatform()== Application.PLATFORM_BLACKBERRY) {
if (keyCode==-8) return KEY_SOFTKEY3;
}
@@ -472,7 +472,7 @@
}
private int checkBack(int code) {
- if (Midlet.getPlatform()==Midlet.PLATFORM_BLACKBERRY) {
+ if (Application.getPlatform() == Application.PLATFORM_BLACKBERRY) {
switch (code) {
case KEY_SOFTKEY3: code=-8; break;
case KEY_CLEAR: code=8; break;
@@ -502,5 +502,4 @@
return string.toString();
}
//#enddebug
-
}
Deleted: SwingME/src/net/yura/mobile/gui/Midlet.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/Midlet.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/Midlet.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -1,403 +0,0 @@
-/*
- * This file is part of 'yura.net Swing ME'.
- *
- * 'yura.net Swing ME' is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * 'yura.net Swing ME' is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with 'yura.net Swing ME'. If not, see <http://www.gnu.org/licenses/>.
- */
-package net.yura.mobile.gui;
-
-import java.io.InputStream;
-import java.util.Hashtable;
-import javax.microedition.lcdui.Display;
-import javax.microedition.lcdui.Image;
-import javax.microedition.midlet.MIDlet;
-import javax.microedition.midlet.MIDletStateChangeException;
-import net.yura.mobile.logging.DesktopLogger;
-import net.yura.mobile.logging.Logger;
-import net.yura.mobile.util.QueueProcessorThread;
-import net.yura.mobile.util.Url;
-
-/**
- * @author Yura Mamyrin
- * @see org.jdesktop.application.Application
- */
-public abstract class Midlet extends MIDlet {
-
- public static final int PLATFORM_NOT_DEFINED = 0;
- public static final int PLATFORM_NOKIA_S40 = 1;
- public static final int PLATFORM_NOKIA_S60 = 2;
- public static final int PLATFORM_SONY_ERICSSON = 3;
- public static final int PLATFORM_SAMSUNG = 4;
- public static final int PLATFORM_MOTOROLA = 5;
- public static final int PLATFORM_SIEMENS = 6;
- public static final int PLATFORM_LG = 7;
- public static final int PLATFORM_ME4SE = 8;
- public static final int PLATFORM_WTK = 9;
- public static final int PLATFORM_ANDROID = 10;
- public static final int PLATFORM_BLACKBERRY = 11;
- public static final int PLATFORM_IOS = 12;
-
- private static int platform = detectPlatform();
-
- //#mdebug info
- static {
- // on me4se we do not care about the popup as we have the console anyway
- if (getPlatform() != PLATFORM_ME4SE) {
- Logger.setLogger( new DesktopLogger(Logger.WARN) );
- }
- }
- //#enddebug
-
- private DesktopPane rootpane;
- private Hashtable platformReqParams;
-
- public Midlet() {
-
- // Changing thread priority should only be done in platforms
- // were actually improve performance.
- QueueProcessorThread.CHANGE_PRIORITY =
- Midlet.getPlatform() != Midlet.PLATFORM_IOS &&
- Midlet.getPlatform() != Midlet.PLATFORM_ME4SE &&
- Midlet.getPlatform() != Midlet.PLATFORM_ANDROID &&
- Midlet.getPlatform() != Midlet.PLATFORM_BLACKBERRY;
-
- rootpane = makeNewRootPane();
-
- // now we set this as the main display
- Display.getDisplay(this).setCurrent(rootpane);
-
- // this repaint will mean the paint will be called
- // this will then kick of the run method of this class
- // and that will in tern call initialise of the midlet
- rootpane.repaint();
- }
-
- /**
- * @see org.jdesktop.application.Application#getInstance()
- */
- public static Midlet getMidlet() {
- DesktopPane dp = DesktopPane.getDesktopPane();
- // dp can be null if the app is in the process of shutting down.
- return dp == null ? null : dp.midlet;
- }
-
- /**
- * This method should only be used to config the splash screen
- * nothing else can be set up here as things like getHeight wont work
- *
- * Responsible for initializations that must occur before the GUI is constructed by {@link #initialize(DesktopPane)}.
- *
- * @see org.jdesktop.application.Application#initialize(java.lang.String[])
- *
- * @return THIS METHOD WILL MAKE A NEW ROOTPANE
- */
- protected DesktopPane makeNewRootPane() {
- return new DesktopPane(this, 0xFF000000, null);
- }
-
- /**
- * this will set up everything needed to start the app like the size and stuff
- *
- * Responsible for starting the application; for creating and showing the initial GUI.
- *
- * @see org.jdesktop.application.Application#startup()
- */
- protected abstract void initialize(DesktopPane rootpane);
-
- /**
- * @see org.jdesktop.application.Application#exit(java.util.EventObject)
- * @see org.jdesktop.application.Application#shutdown()
- * @param unconditional - If true when this method is called, the MIDlet must cleanup and release all resources. If false the MIDlet may throw
- */
- protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
- rootpane.kill();
- }
-
- /**
- * Gracefully shutdown the application, calls destroyApp(true)
- *
- * @see java.lang.System#exit(int) System.exit
- * @see org.jdesktop.application.Application#exit()
- */
- public static void exit() {
- try {
- Midlet midlet = getMidlet();
- midlet.destroyApp(false);
- midlet.notifyDestroyed();
- }
- catch (Exception ex) {
- // as you called this yourself, you should not be throwing here
- Logger.warn(null, ex);
- throw new RuntimeException();
- }
- }
-
- /**
- * frame.setState(Frame.ICONIFIED);
- * frame.setExtendedState(JFrame.ICONIFIED);
- * @see java.awt.Frame#ICONIFIED
- */
- public static void hide() {
- Display.getDisplay(getMidlet()).setCurrent(null);
- }
-
- /**
- * called when app is paused
- */
- protected void pauseApp() {
- //Logger.debug("pauseApp");
- }
-
- /**
- * called when comes out of pause
- */
- protected void startApp() {
- //Logger.debug("startApp");
- }
-
- public static void call(String number) {
- try {
- // TODO remove spaces from number
- getMidlet().platformRequest("tel:" + number);
- }
- catch (Exception e) {
- //#debug warn
- Logger.warn("can not call: " + number, e);
- }
- }
-
- public static void openURL(String url) {
- try {
- Midlet midlet = getMidlet();
- // midlet is null if the app is shutting down
- if (midlet != null) {
- midlet.platformRequest(url);
- }
- }
- catch (Exception e) {
- //#debug warn
- Logger.warn("can not open url: " + url, e);
- }
- }
-
- public static void vibration(int duration) {
- try {
- Display.getDisplay(getMidlet()).vibrate(duration);
- }
- catch (Exception e) {
- //#debug warn
- Logger.warn("can not vibration", e);
- }
- }
-
- /**
- * @see org.jdesktop.application.Application#isMacOSX()
- */
- public static int getPlatform() {
- return platform;
- }
-
- private static int detectPlatform() {
-
- // detecting BLACKBERRY
- if (hasClass("net.rim.device.api.ui.UiApplication")) {
- return PLATFORM_BLACKBERRY;
- }
-
- // detecting ME4SE
- if (hasClass("org.me4se.MIDletRunner")) {
- return PLATFORM_ME4SE;
- }
-
- // detect ios before android as it has a few android classes in it
- if (hasClass("apple.uikit.UIView")) {
- return PLATFORM_IOS;
- }
-
- // detecting Android BEFORE Nokia platform as Nokia X is both android+nokia
- if (hasClass("android.app.Activity")) { // or android.content.Context ?
- return PLATFORM_ANDROID;
- }
-
- String currentPlatform = System.getProperty("microedition.platform");
- if (currentPlatform == null) {
- currentPlatform = ""; // Avoid null pointer exceptions
- }
-
- // detecting NOKIA
- if (currentPlatform.indexOf("Nokia") >= 0) {
- // detecting S40 vs S60
- if (hasClass("com.nokia.mid.impl.isa.ui.gdi.Pixmap")) {
- return PLATFORM_NOKIA_S40;
- }
- return PLATFORM_NOKIA_S60;
- }
-
- // detecting SONY ERICSSON
- if (currentPlatform.indexOf("SonyEricsson") >= 0 ||
- System.getProperty("com.sonyericsson.java.platform") != null) {
- return PLATFORM_SONY_ERICSSON;
- }
-
- // detecting SAMSUNG
- if (hasClass("com.samsung.util.Vibration")) {
- return PLATFORM_SAMSUNG;
- }
-
- // detecting MOTOROLA
- if (hasClass("com.motorola.multimedia.Vibrator") ||
- hasClass("com.motorola.graphics.j3d.Effect3D") ||
- hasClass("com.motorola.multimedia.Lighting") ||
- hasClass("com.motorola.multimedia.FunLight") ||
- hasClass("com.motorola.phonebook.PhoneBookRecord")) {
- return PLATFORM_MOTOROLA;
- }
-
- // detecting SIEMENS
- if (hasClass("com.siemens.mp.io.File")) {
- return PLATFORM_SIEMENS;
- }
-
- // detecting LG
- if (hasClass("mmpp.media.MediaPlayer") ||
- hasClass("mmpp.phone.Phone") ||
- hasClass("mmpp.lang.MathFP") ||
- hasClass("mmpp.media.BackLight")) {
- return PLATFORM_LG;
- }
-
- // detecting WTK
- if (currentPlatform.indexOf("wtk") >= 0) {
- return PLATFORM_WTK;
- }
-
- return PLATFORM_NOT_DEFINED;
- }
-
- // Utility method. Finds if a class is available to the class Loader
- private static boolean hasClass(String className) {
- try {
- Class.forName(className);
- return true;
- }
- catch (Throwable ex) {
- return false;
- }
- }
-
- //,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,
- //==== Resources ===========================================================
- //\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0
-
- /**
- * name MUST start with a "/"
- * @see java.lang.Class#getResourceAsStream(java.lang.String) Class.getResourceAsStream
- */
- public static Image createImage(String name) {
- try {
- InputStream is = getMidlet().getResourceAsStreamImpl(name);
- if (is != null) {
- return Image.createImage(is);
- }
- }
- catch (Throwable th) {
- //#debug warn
- Logger.warn("cant createImage " + name, th);
- }
-
- try {
- return Image.createImage(name);
- }
- catch (Exception ex) {
- return null;
- }
- }
-
- /**
- * name MUST start with a "/"
- * @see java.lang.Class#getResourceAsStream(java.lang.String) Class.getResourceAsStream
- */
- public static InputStream getResourceAsStream(String name) {
- InputStream is = getMidlet().getResourceAsStreamImpl(name);
- if (is != null) {
- return is;
- }
- return Midlet.class.getResourceAsStream(name);
- }
-
- public static String resdir;
- static {
- try {
- // when running as a me4se applet, this can throw a SecurityException
- String rd = System.getProperty("resdir");
- if (rd != null) {
- resdir = rd;
- }
- }
- catch (Throwable th) { }
- }
-
- /**
- * To be overwritten by sub-classes for specific implementation.
- * This default implementation looks for a system property "resdir"
- * and if it finds it, tries to load the resource from that folder
- */
- protected InputStream getResourceAsStreamImpl(String name) {
- if (resdir != null) {
- InputStream is = Midlet.class.getResourceAsStream(resdir + name);
- if (is != null) {
- return is;
- }
- }
- return null;
- }
-
- //,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,
- //==== platform Requests ===================================================
- //\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0\xBA\xA4\xF8,\xB8\xB8,\xF8\xA4\xBA\xB0``\xB0
-
- // This will only be called on Android.
- public void platformRequestForResult(String url, Object arg, int requestCode) {
- Url u = new Url(url);
- u.addQueryParameter("requestCode", String.valueOf(requestCode));
- platformRequest(u.toString(), arg);
- }
-
- // This will only be called on Android.
- public void platformRequest(String url, Object arg) {
- try {
- if (platformReqParams == null) {
- platformReqParams = new Hashtable();
- }
-
- if (arg != null) {
- platformReqParams.put(url, arg);
- }
-
- platformRequest(url);
- }
- catch (Exception e) {
- Logger.warn("cant make request " + url + " " + arg, e);
- throw new RuntimeException(e.toString());
- }
- }
-
- // This will only be called on Android. By the "Android" side
- public Object retrievePlatformRequestParam(String url) {
- Object res = platformReqParams.remove(url);
- return res;
- }
-
- public void onResult(int requestCode, int resultCode, Object obj) { }
-
-}
Modified: SwingME/src/net/yura/mobile/gui/border/MatteBorder.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/border/MatteBorder.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/border/MatteBorder.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -22,7 +22,7 @@
import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Graphics2D;
import net.yura.mobile.gui.Icon;
-import net.yura.mobile.gui.Midlet;
+import net.yura.mobile.gui.Application;
import net.yura.mobile.gui.components.Component;
import net.yura.mobile.gui.plaf.Style;
import net.yura.mobile.logging.Logger;
@@ -172,7 +172,7 @@
Properties newborder = new Properties();
- newborder.load( Midlet.getResourceAsStream(name) );
+ newborder.load( Application.getResourceAsStream(name) );
String imageName = newborder.getProperty("active");
Modified: SwingME/src/net/yura/mobile/gui/components/Camera.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/Camera.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/components/Camera.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -30,11 +30,11 @@
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;
import net.yura.mobile.gui.ActionListener;
+import net.yura.mobile.gui.Application;
import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Font;
import net.yura.mobile.gui.Graphics2D;
import net.yura.mobile.gui.KeyEvent;
-import net.yura.mobile.gui.Midlet;
import net.yura.mobile.gui.plaf.Style;
import net.yura.mobile.logging.Logger;
import net.yura.mobile.util.StringUtil;
@@ -259,8 +259,8 @@
// WORK-AROUND: WTK don't display the view
// finder, if there is no "Canvas transition"
- if (Midlet.getPlatform() == Midlet.PLATFORM_WTK) {
- Display.getDisplay(Midlet.getMidlet()).setCurrent(new DummyCanvas());
+ if (Application.getPlatform() == Application.PLATFORM_WTK) {
+ Display.getDisplay(Application.getInstance()).setCurrent(new DummyCanvas());
}
}
@@ -345,7 +345,7 @@
private int getCameraPermission() {
- MIDlet midlet = Midlet.getMidlet();
+ MIDlet midlet = Application.getInstance();
int perm = midlet.checkPermission("javax.microedition.media.control.VideoControl.getSnapshot");
return perm;
@@ -599,7 +599,7 @@
protected void paint(Graphics arg0) {
Canvas playerCanvas = DesktopPane.getDesktopPane();
- Display.getDisplay(Midlet.getMidlet()).setCurrent(playerCanvas);
+ Display.getDisplay(Application.getInstance()).setCurrent(playerCanvas);
}
}
Modified: SwingME/src/net/yura/mobile/gui/components/FileChooser.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/FileChooser.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/components/FileChooser.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -27,7 +27,7 @@
import net.yura.mobile.gui.Graphics2D;
import net.yura.mobile.gui.Icon;
import net.yura.mobile.gui.KeyEvent;
-import net.yura.mobile.gui.Midlet;
+import net.yura.mobile.gui.Application;
import net.yura.mobile.gui.celleditor.TableCellEditor;
import net.yura.mobile.gui.cellrenderer.ListCellRenderer;
import net.yura.mobile.gui.layout.BorderLayout;
@@ -137,7 +137,7 @@
// we need to add it to the window before we add the buttons so they get
// auto softkey assigned
- if (Midlet.getPlatform() == Midlet.PLATFORM_IOS || Midlet.getPlatform() == Midlet.PLATFORM_ANDROID) {
+ if (Application.getPlatform() == Application.PLATFORM_IOS || Application.getPlatform() == Application.PLATFORM_ANDROID) {
bar.add(close);
bar.addGlue();
bar.add(popupMenu);
@@ -301,7 +301,7 @@
fileList.setCellRenderer(thumbOptionRenderer);
fileList.setActionCommand("listSelect");
fileList.addActionListener(this);
- if (Midlet.getPlatform()==Midlet.PLATFORM_ME4SE) {
+ if (Application.getPlatform() == Application.PLATFORM_ME4SE) {
fileList.setDoubleClick(true);
}
}
Modified: SwingME/src/net/yura/mobile/gui/components/Menu.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/Menu.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/components/Menu.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -19,11 +19,11 @@
import java.util.Vector;
import javax.microedition.lcdui.Graphics;
+import net.yura.mobile.gui.Application;
import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Graphics2D;
import net.yura.mobile.gui.Icon;
import net.yura.mobile.gui.KeyEvent;
-import net.yura.mobile.gui.Midlet;
import net.yura.mobile.gui.border.Border;
import net.yura.mobile.gui.cellrenderer.ListCellRenderer;
import net.yura.mobile.gui.plaf.Style;
@@ -197,7 +197,7 @@
// SETUP LEFT/MENU SOFT KEY
- if (Midlet.getPlatform()==Midlet.PLATFORM_ANDROID) {
+ if (Application.getPlatform()== Application.PLATFORM_ANDROID) {
Button cancel2 = new Button( (String)DesktopPane.get("menuText") );
cancel2.setActionCommand(Frame.CMD_CLOSE);
cancel2.addActionListener(menuItems);
@@ -275,7 +275,6 @@
Border insets=window.getInsets();
window.setSize(w-insets.getLeft()-insets.getRight(), h-insets.getTop()-insets.getBottom() );
-
}
public static void positionMenuRelativeTo(Window window,int x, int y, int width, int height,int direction) {
@@ -316,7 +315,6 @@
// will adjust the location to make sure it is on screen
window.makeVisible();
-
}
private static int extraWidth(Panel p) {
@@ -347,7 +345,6 @@
//System.out.println("left="+left+" top="+top+" right="+right+" bottom="+bottom);
popup.snap = (left?Graphics.LEFT:0) | (top?Graphics.TOP:0) | (right?Graphics.RIGHT:0) | (bottom?Graphics.BOTTOM:0);
-
}
/**
@@ -467,15 +464,10 @@
if(pY==destY && pX == destX) {
break;
}
-
-
-
}
wait(50);
-
}
-
}
finally {
if(open) {
@@ -493,7 +485,5 @@
popup.repaint();
}
}
-
}
-
}
Modified: SwingME/src/net/yura/mobile/gui/components/TextComponent.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/TextComponent.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/components/TextComponent.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -25,12 +25,12 @@
import javax.microedition.lcdui.TextBox;
import net.yura.mobile.gui.ActionListener;
+import net.yura.mobile.gui.Application;
import net.yura.mobile.gui.ChangeListener;
import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Font;
import net.yura.mobile.gui.Graphics2D;
import net.yura.mobile.gui.KeyEvent;
-import net.yura.mobile.gui.Midlet;
import net.yura.mobile.gui.plaf.Style;
import net.yura.mobile.io.ClipboardManager;
import net.yura.mobile.logging.Logger;
@@ -81,7 +81,7 @@
// }
private static final int cursorBlinkWait = 500;
- private static final int changeModeChar = (Midlet.getPlatform() == Midlet.PLATFORM_SONY_ERICSSON) ? '*' : '#';
+ private static final int changeModeChar = (Application.getPlatform() == Application.PLATFORM_SONY_ERICSSON) ? '*' : '#';
private static int autoAcceptTimeout = 1000; // MUST be more then blink time
protected int padding = 2;
@@ -148,7 +148,7 @@
public boolean allowChar(char ch) {
// TODO somehow open the blackberry symbol dialog
- if (Midlet.getPlatform()==Midlet.PLATFORM_BLACKBERRY && ch==128) {
+ if (Application.getPlatform() == Application.PLATFORM_BLACKBERRY && ch==128) {
openNativeEditor();
return false;
}
@@ -461,7 +461,7 @@
textbox.setCommandListener(this); // replaces old one
- Display.getDisplay(Midlet.getMidlet()).setCurrent(textbox);
+ Display.getDisplay(Application.getInstance()).setCurrent(textbox);
}
public static void closeNativeEditor() {
@@ -468,7 +468,7 @@
// go back to normal
if (textbox!=null) {
DesktopPane rp = DesktopPane.getDesktopPane(); // will this always be the correct DesktopPane??
- Display.getDisplay(Midlet.getMidlet()).setCurrent(rp);
+ Display.getDisplay(Application.getInstance()).setCurrent(rp);
rp.setFullScreenMode(true);
textbox = null;
}
@@ -914,7 +914,7 @@
Window popup = Menu.makePopup();
MenuBar menu = Menu.getPopupMenu(popup);
- if (Midlet.getPlatform() == Midlet.PLATFORM_IOS || Midlet.getPlatform() == Midlet.PLATFORM_ANDROID) {
+ if (Application.getPlatform() == Application.PLATFORM_IOS || Application.getPlatform() == Application.PLATFORM_ANDROID) {
menu.setLayoutOrientation(List.HORIZONTAL);
}
Modified: SwingME/src/net/yura/mobile/gui/components/Window.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/Window.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/components/Window.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -23,7 +23,6 @@
import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Graphics2D;
import net.yura.mobile.gui.KeyEvent;
-import net.yura.mobile.gui.Midlet;
import net.yura.mobile.gui.border.Border;
import net.yura.mobile.gui.layout.BorderLayout;
import net.yura.mobile.logging.Logger;
Modified: SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/gui/plaf/SynthLookAndFeel.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -22,10 +22,10 @@
import java.util.Vector;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
+import net.yura.mobile.gui.Application;
import net.yura.mobile.gui.Font;
import net.yura.mobile.gui.Graphics2D;
import net.yura.mobile.gui.Icon;
-import net.yura.mobile.gui.Midlet;
import net.yura.mobile.gui.border.Border;
import net.yura.mobile.gui.border.EmptyBorder;
import net.yura.mobile.gui.border.MatteBorder;
@@ -75,7 +75,7 @@
* @see Image#createImage(String)
*/
protected Image createImage(String path) {
- Image in = Midlet.createImage(path);
+ Image in = Application.createImage(path);
if (in==null) {
//#debug warn
Logger.warn("can not load image: "+path);
@@ -84,7 +84,7 @@
}
protected InputStream getResourceAsStream(String path) {
- InputStream in = Midlet.getResourceAsStream(path);
+ InputStream in = Application.getResourceAsStream(path);
if (in==null) {
//#debug warn
Logger.warn("can not load resource: "+path);
Modified: SwingME/src/net/yura/mobile/io/ClipboardManager.java
===================================================================
--- SwingME/src/net/yura/mobile/io/ClipboardManager.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/io/ClipboardManager.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -1,21 +1,16 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package net.yura.mobile.io;
-import net.yura.mobile.gui.Midlet;
+import net.yura.mobile.gui.Application;
import net.yura.mobile.io.ServiceLink.Task;
import net.yura.mobile.logging.Logger;
/**
- *
* @author AP
*/
public class ClipboardManager implements ServiceLink.TaskHandler {
/** Creates a new instance of LocationMonitor */
private ClipboardManager() {
- if (Midlet.getPlatform()==Midlet.PLATFORM_NOKIA_S60) {
+ if (Application.getPlatform() == Application.PLATFORM_NOKIA_S60) {
ServiceLink link = ServiceLink.getInstance();
link.registerForTask("GetClipboardTextError", this);
link.registerForTask("PutClipboardText", this);
@@ -44,7 +39,7 @@
public String getText() {
- if (Midlet.getPlatform()==Midlet.PLATFORM_NOKIA_S60) {
+ if (Application.getPlatform() == Application.PLATFORM_NOKIA_S60) {
ServiceLink link = ServiceLink.getInstance();
if (link.isConnected()) {
link.sendTask(new ServiceLink.Task("GetClipboardText", null));
@@ -53,9 +48,9 @@
}
}
else { // for me4se and will be for android
- Midlet midlet = Midlet.getMidlet();
+ Application application = Application.getInstance();
- midlet.platformRequest("clipboard://get",null);
+ application.platformRequest("clipboard://get",null);
return System.getProperty("clipboard.text");
}
@@ -65,7 +60,7 @@
public void setText(String text) {
- if (Midlet.getPlatform()==Midlet.PLATFORM_NOKIA_S60) {
+ if (Application.getPlatform() == Application.PLATFORM_NOKIA_S60) {
ServiceLink link = ServiceLink.getInstance();
if (link.isConnected()) {
link.sendTask(new ServiceLink.Task("PutClipboardText", text));
@@ -72,10 +67,10 @@
}
}
else {
- Midlet midlet = Midlet.getMidlet();
+ Application application = Application.getInstance();
//midlet.platformRequest("clipboard://put",text);
try {
- midlet.platformRequest("clipboard://put/"+text);
+ application.platformRequest("clipboard://put/"+text);
}
catch(Exception ex) {
Logger.warn("cant put " + text, ex);
@@ -82,5 +77,4 @@
}
}
}
-
}
Modified: SwingME/src/net/yura/mobile/util/RemoteTest.java
===================================================================
--- SwingME/src/net/yura/mobile/util/RemoteTest.java 2021-12-28 22:36:45 UTC (rev 2627)
+++ SwingME/src/net/yura/mobile/util/RemoteTest.java 2021-12-29 00:24:44 UTC (rev 2628)
@@ -7,13 +7,11 @@
import java.io.Reader;
import java.io.Writer;
import java.util.Vector;
-
import javax.microedition.io.Connector;
import javax.microedition.io.ServerSocketConnection;
import javax.microedition.io.StreamConnection;
-
+import net.yura.mobile.gui.Application;
import net.yura.mobile.gui.DesktopPane;
-import net.yura.mobile.gui.Midlet;
import net.yura.mobile.gui.components.Button;
import net.yura.mobile.gui.components.Component;
import net.yura.mobile.gui.components.List;
@@ -32,7 +30,7 @@
public static void open() {
try {
- if (Midlet.getPlatform() == Midlet.PLATFORM_ANDROID) {
+ if (Application.getPlatform() == Application.PLATFORM_ANDROID) {
RemoteTest remoteTest = (RemoteTest)Class.forName("net.yura.android.AndroidRemoteTest").newInstance();
remoteTest.start();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|