swingme-svn Mailing List for Swing ME
Java UI Framework for Desktop/iOS/Android
Brought to you by:
nathansudell,
yuranet
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(54) |
Aug
(33) |
Sep
(27) |
Oct
(10) |
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(7) |
Feb
(5) |
Mar
(7) |
Apr
(1) |
May
(1) |
Jun
(1) |
Jul
(25) |
Aug
(41) |
Sep
(89) |
Oct
(99) |
Nov
(161) |
Dec
(85) |
| 2010 |
Jan
(10) |
Feb
(35) |
Mar
(44) |
Apr
(115) |
May
(98) |
Jun
(87) |
Jul
(23) |
Aug
(27) |
Sep
(63) |
Oct
(57) |
Nov
(97) |
Dec
(62) |
| 2011 |
Jan
(67) |
Feb
(83) |
Mar
(43) |
Apr
(14) |
May
(43) |
Jun
(52) |
Jul
(55) |
Aug
(97) |
Sep
(65) |
Oct
(36) |
Nov
(67) |
Dec
(46) |
| 2012 |
Jan
(29) |
Feb
(24) |
Mar
(10) |
Apr
(2) |
May
(10) |
Jun
(34) |
Jul
(31) |
Aug
(9) |
Sep
(10) |
Oct
(10) |
Nov
(6) |
Dec
(7) |
| 2013 |
Jan
(1) |
Feb
(1) |
Mar
(5) |
Apr
(2) |
May
(17) |
Jun
(10) |
Jul
(8) |
Aug
(17) |
Sep
|
Oct
(3) |
Nov
(4) |
Dec
(1) |
| 2014 |
Jan
(2) |
Feb
(8) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(2) |
Sep
(1) |
Oct
(1) |
Nov
(5) |
Dec
(8) |
| 2015 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
|
May
(2) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
| 2016 |
Jan
|
Feb
(1) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(2) |
| 2018 |
Jan
|
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
(4) |
| 2019 |
Jan
(2) |
Feb
|
Mar
(4) |
Apr
(4) |
May
(2) |
Jun
(1) |
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
(4) |
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(1) |
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2021 |
Jan
|
Feb
(7) |
Mar
(29) |
Apr
(8) |
May
(7) |
Jun
(45) |
Jul
(66) |
Aug
|
Sep
|
Oct
(2) |
Nov
(37) |
Dec
(34) |
| 2022 |
Jan
(15) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(10) |
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
(1) |
Dec
(7) |
| 2023 |
Jan
(23) |
Feb
(18) |
Mar
(18) |
Apr
(6) |
May
(10) |
Jun
(7) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2024 |
Jan
(11) |
Feb
(3) |
Mar
|
Apr
(6) |
May
(3) |
Jun
|
Jul
|
Aug
(2) |
Sep
(16) |
Oct
(6) |
Nov
(7) |
Dec
(6) |
| 2025 |
Jan
(8) |
Feb
(3) |
Mar
(7) |
Apr
(5) |
May
(21) |
Jun
(10) |
Jul
(16) |
Aug
(5) |
Sep
(19) |
Oct
(19) |
Nov
(19) |
Dec
(25) |
|
From: <yu...@us...> - 2025-12-13 22:00:26
|
Revision: 2975
http://sourceforge.net/p/swingme/code/2975
Author: yuranet
Date: 2025-12-13 22:00:24 +0000 (Sat, 13 Dec 2025)
Log Message:
-----------
fix for fallback for safe areas
Modified Paths:
--------------
iOSME/src/net/yura/ios/CanvasView.java
Modified: iOSME/src/net/yura/ios/CanvasView.java
===================================================================
--- iOSME/src/net/yura/ios/CanvasView.java 2025-12-13 14:43:25 UTC (rev 2974)
+++ iOSME/src/net/yura/ios/CanvasView.java 2025-12-13 22:00:24 UTC (rev 2975)
@@ -14,6 +14,7 @@
import apple.coregraphics.c.CoreGraphics;
import apple.foundation.NSEnumerator;
import apple.foundation.NSSet;
+import apple.uikit.UIApplication;
import apple.uikit.UIBezierPath;
import apple.uikit.UIColor;
import apple.uikit.UIEvent;
@@ -333,7 +334,8 @@
return safeAreaInsets(); // API-11 (first OS on the very first notch iPhone X)
}
catch (Throwable th) {
- return new UIEdgeInsets();
+ // on old devices do we need space for the status bar?
+ return new UIEdgeInsets(UIApplication.sharedApplication().statusBarFrame().size().height(), 0d, 0d, 0d);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-13 14:43:27
|
Revision: 2974
http://sourceforge.net/p/swingme/code/2974
Author: yuranet
Date: 2025-12-13 14:43:25 +0000 (Sat, 13 Dec 2025)
Log Message:
-----------
hide unpremultiply
Modified Paths:
--------------
iOSME/src/javax/microedition/lcdui/Image.java
Modified: iOSME/src/javax/microedition/lcdui/Image.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Image.java 2025-12-13 14:40:04 UTC (rev 2973)
+++ iOSME/src/javax/microedition/lcdui/Image.java 2025-12-13 14:43:25 UTC (rev 2974)
@@ -496,7 +496,7 @@
if (alphaMode == CGImageAlphaInfo.PremultipliedFirst || alphaMode == CGImageAlphaInfo.PremultipliedLast) {
for (int a = 0; a < height; a++) {
for (int b = 0; b < width; b++) {
- rgb[offset + a * distScanLength + b] = unpremultiply(rgb[offset + a * distScanLength + b]);
+ rgb[offset + a * distScanLength + b] = unpremultiplyAlpha(rgb[offset + a * distScanLength + b]);
}
}
}
@@ -554,7 +554,7 @@
* TODO maybe we can use a system apple function to do this
* @see apple.accelerate.c.Accelerate#vImageUnpremultiplyData_ARGB8888(apple.accelerate.struct.vImage_Buffer, apple.accelerate.struct.vImage_Buffer, int)
*/
- public static int unpremultiply(int argb) {
+ private static int unpremultiplyAlpha(int argb) {
int a = argb >>> 24; // alpha 0..255
if (a == 0 || a == 255) return argb; // fully transparent or opaque, no change needed
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-13 14:40:06
|
Revision: 2973
http://sourceforge.net/p/swingme/code/2973
Author: yuranet
Date: 2025-12-13 14:40:04 +0000 (Sat, 13 Dec 2025)
Log Message:
-----------
unpremultiply also done
Modified Paths:
--------------
iOSME/src/javax/microedition/lcdui/Image.java
Modified: iOSME/src/javax/microedition/lcdui/Image.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Image.java 2025-12-13 13:56:43 UTC (rev 2972)
+++ iOSME/src/javax/microedition/lcdui/Image.java 2025-12-13 14:40:04 UTC (rev 2973)
@@ -297,7 +297,7 @@
return context;
}
- public static final Image createRGBImage(int[] rgb, int width, int height, boolean processAlpha) {
+ public static Image createRGBImage(int[] rgb, int width, int height, boolean processAlpha) {
// TODO not optimum as we first create white image
Image img = createImage(width, height);
img.setRGB(rgb, 0, width, width, height, processAlpha);
@@ -491,6 +491,15 @@
for (int c = 0; c < height; c++) {
intPtr.copyTo((y+c) * srcScanLenght + x, rgb, offset + c * distScanLength, width);
}
+
+ int alphaMode = CoreGraphics.CGBitmapContextGetBitmapInfo(context) & CGBitmapInfo.AlphaInfoMask;
+ if (alphaMode == CGImageAlphaInfo.PremultipliedFirst || alphaMode == CGImageAlphaInfo.PremultipliedLast) {
+ for (int a = 0; a < height; a++) {
+ for (int b = 0; b < width; b++) {
+ rgb[offset + a * distScanLength + b] = unpremultiply(rgb[offset + a * distScanLength + b]);
+ }
+ }
+ }
}
public void setRGB(int[] rgbData, int offset, int srcScanLength, int width, int height, boolean processAlpha) {
@@ -524,6 +533,10 @@
}
}
+ /**
+ * TODO maybe we can use a system apple function to do this
+ * @see apple.accelerate.c.Accelerate#vImagePremultiplyData_ARGB8888(apple.accelerate.struct.vImage_Buffer, apple.accelerate.struct.vImage_Buffer, int)
+ */
private static int premultiplyAlpha(int argb) {
int a = argb >>> 24;
if (a == 255) return argb;
@@ -537,11 +550,35 @@
return (a << 24) | (r << 16) | (g << 8) | b;
}
+ /**
+ * TODO maybe we can use a system apple function to do this
+ * @see apple.accelerate.c.Accelerate#vImageUnpremultiplyData_ARGB8888(apple.accelerate.struct.vImage_Buffer, apple.accelerate.struct.vImage_Buffer, int)
+ */
+ public static int unpremultiply(int argb) {
+ int a = argb >>> 24; // alpha 0..255
+ if (a == 0 || a == 255) return argb; // fully transparent or opaque, no change needed
+
+ int r = (argb >> 16) & 0xFF;
+ int g = (argb >> 8) & 0xFF;
+ int b = argb & 0xFF;
+
+ // reverse premultiply with rounding
+ r = (r * 255 + a / 2) / a;
+ g = (g * 255 + a / 2) / a;
+ b = (b * 255 + a / 2) / a;
+
+ return (a << 24) | (r << 16) | (g << 8) | b;
+ }
+
public void setRGB(int x, int y, int color) {
Graphics g = getGraphics();
+ CGContextRef context = g.getContext();
int srcScanLenght = getIntsPerRow();
- IntPtr intPtr = CoreGraphics.CGBitmapContextGetData(g.getContext()).getIntPtr();
- intPtr.setValue(y * srcScanLenght + x, color);
+ int alphaMode = CoreGraphics.CGBitmapContextGetBitmapInfo(context) & CGBitmapInfo.AlphaInfoMask;
+ IntPtr intPtr = CoreGraphics.CGBitmapContextGetData(context).getIntPtr();
+ intPtr.setValue(y * srcScanLenght + x,
+ alphaMode == CGImageAlphaInfo.PremultipliedFirst || alphaMode == CGImageAlphaInfo.PremultipliedLast ?
+ premultiplyAlpha(color) : color);
}
public static void filter(Image source, Image bm, ColorMatrix cm) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-13 13:56:44
|
Revision: 2972
http://sourceforge.net/p/swingme/code/2972
Author: yuranet
Date: 2025-12-13 13:56:43 +0000 (Sat, 13 Dec 2025)
Log Message:
-----------
better test order to actually get valid alpha
Modified Paths:
--------------
SwingMETest/src/net/yura/mobile/test/GraphicsTest.java
Modified: SwingMETest/src/net/yura/mobile/test/GraphicsTest.java
===================================================================
--- SwingMETest/src/net/yura/mobile/test/GraphicsTest.java 2025-12-13 13:50:49 UTC (rev 2971)
+++ SwingMETest/src/net/yura/mobile/test/GraphicsTest.java 2025-12-13 13:56:43 UTC (rev 2972)
@@ -103,9 +103,29 @@
g.setColor(0xFFFF0000); // red
g.drawLine(0, 0, 50, 50);
+ // test saving file to disk
+ try {
+ //OutputStream out=FileUtil.getWriteFileConnection("file:///root1/img.jpg").openOutputStream();
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ ImageUtil.saveImage(img,out);
+ out.close();
+
+ img = Image.createImage(out.toByteArray(), 0, out.size());
+ }
+ catch(Exception ex) {
+ ex.printStackTrace();
+ }
+
+
+ // testing Nokia DirectGraphics
+ //com.nokia.mid.ui.DirectGraphics g2 = com.nokia.mid.ui.DirectUtils.getDirectGraphics(g);
+ //g2.fillPolygon(new int[] { 25,35,45,25,5},0,new int[] { 25,5,25,45,35},0,5,0xAA115599);
+
+ // test getting and setting pixel data from int array
int[] rgb = new int[img.getWidth() * img.getHeight()];
img.getRGB(rgb, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight());
-
for (int a = 0; a < 15 * img.getWidth(); a++) {
int x = a % img.getWidth();
int y = a / img.getWidth();
@@ -120,33 +140,13 @@
else {
newColor = 0x000000FF | alpha;
}
-
+ // test also modifying some of the values
rgb[a + 17 * img.getWidth()] = newColor;
}
-
img = Image.createRGBImage(rgb, img.getWidth(), img.getHeight(), true);
- rgb = null;
- // test saving file to disk
- try {
- //OutputStream out=FileUtil.getWriteFileConnection("file:///root1/img.jpg").openOutputStream();
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ImageUtil.saveImage(img,out);
- out.close();
-
- img = Image.createImage(out.toByteArray(), 0, out.size());
- }
- catch(Exception ex) {
- ex.printStackTrace();
- }
-
-
- // testing Nokia DirectGraphics
- //com.nokia.mid.ui.DirectGraphics g2 = com.nokia.mid.ui.DirectUtils.getDirectGraphics(g);
- //g2.fillPolygon(new int[] { 25,35,45,25,5},0,new int[] { 25,5,25,45,35},0,5,0xAA115599);
-
Label drawRegionPanel = new Label(new Icon(img));
addToScrollPane(drawRegionPanel, null);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-13 13:50:52
|
Revision: 2971
http://sourceforge.net/p/swingme/code/2971
Author: yuranet
Date: 2025-12-13 13:50:49 +0000 (Sat, 13 Dec 2025)
Log Message:
-----------
fix creating image with alpha from int[]
Modified Paths:
--------------
iOSME/src/javax/microedition/lcdui/Image.java
Modified: iOSME/src/javax/microedition/lcdui/Image.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Image.java 2025-12-13 12:22:31 UTC (rev 2970)
+++ iOSME/src/javax/microedition/lcdui/Image.java 2025-12-13 13:50:49 UTC (rev 2971)
@@ -230,7 +230,7 @@
int size = Math.max(available, 8 * 1024);
BufferedInputStream buffInput = new BufferedInputStream(stream, size);
- //byte[] bytes = stream.readAllBytes?(); // added in java 9
+ //byte[] bytes = stream.readAllBytes(); // added in java 9
byte[] bytes = Streams.readFullyNoClose(buffInput);
return createImage(bytes, 0, bytes.length);
@@ -495,12 +495,25 @@
public void setRGB(int[] rgbData, int offset, int srcScanLength, int width, int height, boolean processAlpha) {
Graphics g = getGraphics();
+ CGContextRef context = g.getContext();
+
int distScanLength = getIntsPerRow();
- IntPtr intPtr = CoreGraphics.CGBitmapContextGetData(g.getContext()).getIntPtr();
+ int info = CoreGraphics.CGBitmapContextGetBitmapInfo(context);
+ //int order = info & CGBitmapInfo.ByteOrderMask; // CGBitmapInfo.ByteOrder32Little
+ int alpha = info & CGBitmapInfo.AlphaInfoMask; // CGImageAlphaInfo.PremultipliedFirst
+
+ IntPtr intPtr = CoreGraphics.CGBitmapContextGetData(context).getIntPtr();
for (int y = 0; y < height; y++) {
if (processAlpha) {
- intPtr.copyFrom(rgbData, offset+ y * srcScanLength, y * distScanLength, width);
+ if (alpha == CGImageAlphaInfo.PremultipliedFirst || alpha == CGImageAlphaInfo.PremultipliedLast) {
+ for (int x = 0; x < width; x++) {
+ intPtr.setValue(y * distScanLength + x, premultiplyAlpha(rgbData[offset + y * srcScanLength + x]));
+ }
+ }
+ else {
+ intPtr.copyFrom(rgbData, offset + y * srcScanLength, y * distScanLength, width);
+ }
}
else {
// TODO this could be better
@@ -511,6 +524,19 @@
}
}
+ private static int premultiplyAlpha(int argb) {
+ int a = argb >>> 24;
+ if (a == 255) return argb;
+ int r = (argb >> 16) & 0xFF;
+ int g = (argb >> 8) & 0xFF;
+ int b = argb & 0xFF;
+ // + 127 is half of 255, and is added so we do not round down the result
+ r = (r * a + 127) / 255;
+ g = (g * a + 127) / 255;
+ b = (b * a + 127) / 255;
+ return (a << 24) | (r << 16) | (g << 8) | b;
+ }
+
public void setRGB(int x, int y, int color) {
Graphics g = getGraphics();
int srcScanLenght = getIntsPerRow();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-13 12:22:33
|
Revision: 2970
http://sourceforge.net/p/swingme/code/2970
Author: yuranet
Date: 2025-12-13 12:22:31 +0000 (Sat, 13 Dec 2025)
Log Message:
-----------
put more on the draw offscreen image
Modified Paths:
--------------
SwingMETest/src/net/yura/mobile/test/GraphicsTest.java
SwingMETest/src/net/yura/mobile/test/MainTest.java
Modified: SwingMETest/src/net/yura/mobile/test/GraphicsTest.java
===================================================================
--- SwingMETest/src/net/yura/mobile/test/GraphicsTest.java 2025-12-13 03:09:48 UTC (rev 2969)
+++ SwingMETest/src/net/yura/mobile/test/GraphicsTest.java 2025-12-13 12:22:31 UTC (rev 2970)
@@ -93,8 +93,6 @@
Graphics g = img.getGraphics();
g.drawImage(mainPane.image.getImage(), 5, 5, 0);
- g.setColor(0xFFFF0000); // red
- g.drawLine(0, 0, 50, 50);
g.setColor(0xFF00FF00); // green
g.fillRoundRect(1,1, 48, 48, 5, 5);
@@ -102,6 +100,33 @@
g.setColor(0xFF0000FF); // blue
g.fillArc(1, 1, 48, 48, 0, 360);
+ g.setColor(0xFFFF0000); // red
+ g.drawLine(0, 0, 50, 50);
+
+ int[] rgb = new int[img.getWidth() * img.getHeight()];
+ img.getRGB(rgb, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight());
+
+ for (int a = 0; a < 15 * img.getWidth(); a++) {
+ int x = a % img.getWidth();
+ int y = a / img.getWidth();
+ int newColor;
+ int alpha = (int)(((img.getWidth()-x) / (double)img.getWidth()) * 255) << 24;
+ if (y < 5) {
+ newColor = 0x00FF0000 | alpha;
+ }
+ else if (y < 10) {
+ newColor = 0x0000FF00 | alpha;
+ }
+ else {
+ newColor = 0x000000FF | alpha;
+ }
+
+ rgb[a + 17 * img.getWidth()] = newColor;
+ }
+
+ img = Image.createRGBImage(rgb, img.getWidth(), img.getHeight(), true);
+ rgb = null;
+
// test saving file to disk
try {
//OutputStream out=FileUtil.getWriteFileConnection("file:///root1/img.jpg").openOutputStream();
Modified: SwingMETest/src/net/yura/mobile/test/MainTest.java
===================================================================
--- SwingMETest/src/net/yura/mobile/test/MainTest.java 2025-12-13 03:09:48 UTC (rev 2969)
+++ SwingMETest/src/net/yura/mobile/test/MainTest.java 2025-12-13 12:22:31 UTC (rev 2970)
@@ -714,7 +714,7 @@
synth = new SynthLookAndFeel() {
- @Override
+
protected Image createImage(String path) {
return super.createImage(dir+size+path);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-13 03:09:49
|
Revision: 2969
http://sourceforge.net/p/swingme/code/2969
Author: yuranet
Date: 2025-12-13 03:09:48 +0000 (Sat, 13 Dec 2025)
Log Message:
-----------
load images correctly for size demo theme
Modified Paths:
--------------
SwingMETest/desktop/build.gradle
SwingMETest/src/net/yura/mobile/test/MainTest.java
Modified: SwingMETest/desktop/build.gradle
===================================================================
--- SwingMETest/desktop/build.gradle 2025-12-12 17:19:55 UTC (rev 2968)
+++ SwingMETest/desktop/build.gradle 2025-12-13 03:09:48 UTC (rev 2969)
@@ -29,5 +29,5 @@
dependencies {
implementation rootProject
- implementation fileTree(dir: '../lib', include: ['*.jar'])
+ implementation fileTree(dir: '../lib', include: ['midletrunner.jar','m3gbasic.jar','opt.jar'])
}
Modified: SwingMETest/src/net/yura/mobile/test/MainTest.java
===================================================================
--- SwingMETest/src/net/yura/mobile/test/MainTest.java 2025-12-12 17:19:55 UTC (rev 2968)
+++ SwingMETest/src/net/yura/mobile/test/MainTest.java 2025-12-13 03:09:48 UTC (rev 2969)
@@ -12,6 +12,7 @@
import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Font;
import net.yura.mobile.gui.Application;
+import net.yura.mobile.gui.Icon;
import net.yura.mobile.gui.border.CompoundBorder;
import net.yura.mobile.gui.border.LineBorder;
import net.yura.mobile.gui.KeyEvent;
@@ -713,6 +714,11 @@
synth = new SynthLookAndFeel() {
+ @Override
+ protected Image createImage(String path) {
+ return super.createImage(dir+size+path);
+ }
+
protected InputStream getResourceAsStream(String path) {
return getClass().getResourceAsStream(dir+size+path);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-12 17:19:57
|
Revision: 2968
http://sourceforge.net/p/swingme/code/2968
Author: yuranet
Date: 2025-12-12 17:19:55 +0000 (Fri, 12 Dec 2025)
Log Message:
-----------
edge-to-edge in all apps
Modified Paths:
--------------
AndroidME/src_Android/net/yura/android/AndroidMeActivity.java
Modified: AndroidME/src_Android/net/yura/android/AndroidMeActivity.java
===================================================================
--- AndroidME/src_Android/net/yura/android/AndroidMeActivity.java 2025-12-12 15:22:03 UTC (rev 2967)
+++ AndroidME/src_Android/net/yura/android/AndroidMeActivity.java 2025-12-12 17:19:55 UTC (rev 2968)
@@ -14,6 +14,7 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
+import android.graphics.Color;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.Bundle;
@@ -23,6 +24,7 @@
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
+import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
@@ -116,6 +118,15 @@
// PrintStream log = new PrintStream(new LogOutputStream("AndroidMe"));
// System.setErr(log);
// System.setOut(log);
+
+ // this section is ALSO needed to allow edge-to-edge drawing on android API-35+
+ // make the navigation bar BLACK (the default seems to be white on some phones, e.g Samsung Galaxy S9)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ // it seems this flag is ALSO needed for when we swap from normal to fullscreen mode
+ // otherwise the very first time we go into fullscreen we will get a black bar at the bottom
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ getWindow().setNavigationBarColor(Color.BLACK);
+ }
}
public void startMIDlet() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-12 15:22:06
|
Revision: 2967
http://sourceforge.net/p/swingme/code/2967
Author: yuranet
Date: 2025-12-12 15:22:03 +0000 (Fri, 12 Dec 2025)
Log Message:
-----------
fix scale both x and y when getting rgb from image
Modified Paths:
--------------
AndroidME/src_MIDP/javax/microedition/lcdui/Image.java
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Image.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Image.java 2025-12-11 18:29:42 UTC (rev 2966)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Image.java 2025-12-12 15:22:03 UTC (rev 2967)
@@ -457,7 +457,7 @@
int systemDensity = getTargetDensity();
if (bitmapDensity != Bitmap.DENSITY_NONE && bitmapDensity != systemDensity) {
if (scanlength < width) {
- throw new IllegalArgumentException("scanlength ("+scanHeight+") must be >= width ("+width+")");
+ throw new IllegalArgumentException("scanlength ("+scanlength+") must be >= width ("+width+")");
}
x = scaleFromDensity(x, systemDensity, bitmapDensity);
y = scaleFromDensity(y, systemDensity, bitmapDensity);
@@ -508,7 +508,7 @@
int systemDensity = getTargetDensity();
if (bitmapDensity != Bitmap.DENSITY_NONE && bitmapDensity != systemDensity) {
for (int c = scanlength * scanHeight - 1; c >= 0; c--) {
- rgb[offset + c] = rgb[offset + ((c / scanlength) * scanlength) + scaleFromDensity(c % scanlength, systemDensity, bitmapDensity)];
+ rgb[offset + c] = rgb[offset + scaleFromDensity(c / scanlength, systemDensity, bitmapDensity) * scanlength + scaleFromDensity(c % scanlength, systemDensity, bitmapDensity)];
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-11 18:29:45
|
Revision: 2966
http://sourceforge.net/p/swingme/code/2966
Author: yuranet
Date: 2025-12-11 18:29:42 +0000 (Thu, 11 Dec 2025)
Log Message:
-----------
scale bitmap fonts if needed
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/Font.java
Modified: SwingME/src/net/yura/mobile/gui/Font.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/Font.java 2025-12-11 11:46:31 UTC (rev 2965)
+++ SwingME/src/net/yura/mobile/gui/Font.java 2025-12-11 18:29:42 UTC (rev 2966)
@@ -129,6 +129,10 @@
}
}
+ /**
+ * read font bin format
+ * more info: <a href="https://www.angelcode.com/products/bmfont/doc/file_format.html#bin">here</a>.
+ */
public static Font getFont(InputStream is, Image[] imagesArray, int[] colorsArray) throws IOException {
Font f = new Font();
@@ -151,9 +155,17 @@
//Logger.debug("FONT: Reading common");
dis.skipBytes(1);
size = getLong(dis);
- f.height = getShortUnsigned(dis);
- dis.skipBytes(size - 2);
+ int height = getShortUnsigned(dis);
+ int base = getShortUnsigned(dis);
+ int scaleW = getShortUnsigned(dis);
+ int scaleH = getShortUnsigned(dis);
+
+ double scale = imagesArray[0].getWidth() / (double)scaleW;
+ f.height = (int)(height * scale);
+
+ dis.skipBytes(size - 8);
+
// block: page
//Logger.debug("FONT: Reading pages");
dis.skipBytes(1);
@@ -181,13 +193,13 @@
Character key = new Character((char) id);
f.characters.put(key, new Integer(i));
- f.startX[i] = getShortUnsigned(dis);
- f.startY[i] = getShortUnsigned(dis);
- f.characterWidth[i] = (byte)getShortUnsigned(dis);
- f.characterHeight[i] = (byte)getShortUnsigned(dis);
- f.offsetX[i] = getShortSigned(dis);
- f.offsetY[i] = getShortSigned(dis);
- f.advance[i] = getShortSigned(dis);
+ f.startX[i] = (int)(getShortUnsigned(dis) * scale);
+ f.startY[i] = (int)(getShortUnsigned(dis) * scale);
+ f.characterWidth[i] = (byte)(getShortUnsigned(dis) * scale);
+ f.characterHeight[i] = (byte)(getShortUnsigned(dis) * scale);
+ f.offsetX[i] = (int)(getShortSigned(dis) * scale);
+ f.offsetY[i] = (int)(getShortSigned(dis) * scale);
+ f.advance[i] = (int)(getShortSigned(dis) * scale);
glyphs[i] = null;
int page = dis.readByte();
int channel = dis.readByte();
@@ -212,7 +224,7 @@
char second = (char) getLong(dis);
Integer charPairIdentifier = getCharPairId(first,second);
- int amount = getShortSigned(dis);
+ int amount = (int)(getShortSigned(dis) * scale);
Integer kerningValue = getInteger(amount);
f.kerning.put(charPairIdentifier, kerningValue);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-11 11:46:33
|
Revision: 2965
http://sourceforge.net/p/swingme/code/2965
Author: yuranet
Date: 2025-12-11 11:46:31 +0000 (Thu, 11 Dec 2025)
Log Message:
-----------
fix metal combo arrow
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/plaf/MetalIcon.java
Modified: SwingME/src/net/yura/mobile/gui/plaf/MetalIcon.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/plaf/MetalIcon.java 2025-12-11 11:35:47 UTC (rev 2964)
+++ SwingME/src/net/yura/mobile/gui/plaf/MetalIcon.java 2025-12-11 11:46:31 UTC (rev 2965)
@@ -85,7 +85,7 @@
}
}
else if (type == LookAndFeel.ICON_COMBO) {
- g.drawLine(x, (c.getHeight()-height)/2, x , height);
+ g.drawLine(x, y, x , y + height);
drawSelectionArrow(c, g, x, y, Sprite.TRANS_NONE);
}
else if (type == LookAndFeel.ICON_SPINNER_LEFT || type == LookAndFeel.ICON_ARROW_LEFT) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-11 11:35:49
|
Revision: 2964
http://sourceforge.net/p/swingme/code/2964
Author: yuranet
Date: 2025-12-11 11:35:47 +0000 (Thu, 11 Dec 2025)
Log Message:
-----------
fix horizontal line drawing
Modified Paths:
--------------
AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java 2025-12-11 00:58:35 UTC (rev 2963)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Graphics.java 2025-12-11 11:35:47 UTC (rev 2964)
@@ -167,12 +167,12 @@
public void drawLine(int x1, int y1, int x2, int y2) {
if (x1 > x2) {
x1++;
- } else {
+ } else if (x1 < x2) {
x2++;
}
if (y1 > y2) {
y1++;
- } else {
+ } else if (y1 < y2) {
y2++;
}
canvas.drawLine(tx+x1, ty+y1, tx+x2, ty+y2, paint);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-11 00:58:36
|
Revision: 2963
http://sourceforge.net/p/swingme/code/2963
Author: yuranet
Date: 2025-12-11 00:58:35 +0000 (Thu, 11 Dec 2025)
Log Message:
-----------
account for android rounding errors
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/border/MatteBorder.java
Modified: SwingME/src/net/yura/mobile/gui/border/MatteBorder.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/border/MatteBorder.java 2025-12-10 23:26:06 UTC (rev 2962)
+++ SwingME/src/net/yura/mobile/gui/border/MatteBorder.java 2025-12-11 00:58:35 UTC (rev 2963)
@@ -328,8 +328,8 @@
}
}
else if (color!=Style.NO_COLOR) {
- boolean fillsides = (imageHeight-imageTop-imageBottom) == 0;
- boolean filltop = (imageWidth-imageRight-imageLeft) == 0;
+ boolean fillsides = (imageHeight-imageTop-imageBottom) <= 0;
+ boolean filltop = (imageWidth-imageRight-imageLeft) <= 0;
g.setColor(color);
g.fillRect(fillsides?-left:leftDiff,filltop?-top:topDiff,width-(fillsides?-(left+right):leftDiff+rightDiff),height-(filltop?-(top+bottom):topDiff+bottomDiff));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-10 23:26:07
|
Revision: 2962
http://sourceforge.net/p/swingme/code/2962
Author: yuranet
Date: 2025-12-10 23:26:06 +0000 (Wed, 10 Dec 2025)
Log Message:
-----------
fix default images from lib jars to load as mdpi
Modified Paths:
--------------
AndroidME/src_MIDP/javax/microedition/lcdui/Image.java
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Image.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Image.java 2025-12-10 22:33:52 UTC (rev 2961)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Image.java 2025-12-10 23:26:06 UTC (rev 2962)
@@ -278,7 +278,9 @@
if (in == null) {
throw new IOException("can not find: "+resource);
}
- return createImage(in);
+ Image img = createImage(in);
+ img = scaleToTargetDensity(img, DisplayMetrics.DENSITY_MEDIUM, ninePatch);
+ return img;
}
private static Image scaleToTargetDensity(Image img, int density, boolean ninePatch) {
@@ -292,7 +294,7 @@
return img;
}
double scale = (double) targetDensity / (double) density;
- return new Image(Bitmap.createScaledBitmap(img.bitmap, (int) (img.getWidth() * scale), (int) (img.getWidth() * scale), true));
+ return new Image(Bitmap.createScaledBitmap(img.bitmap, (int) (img.getWidth() * scale), (int) (img.getHeight() * scale), true));
}
double scale = (double) targetDensity / (double) density;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-10 22:33:54
|
Revision: 2961
http://sourceforge.net/p/swingme/code/2961
Author: yuranet
Date: 2025-12-10 22:33:52 +0000 (Wed, 10 Dec 2025)
Log Message:
-----------
gifs work when auto-scaled
Modified Paths:
--------------
me4se/src/javax/microedition/lcdui/Image.java
Modified: me4se/src/javax/microedition/lcdui/Image.java
===================================================================
--- me4se/src/javax/microedition/lcdui/Image.java 2025-12-10 21:52:40 UTC (rev 2960)
+++ me4se/src/javax/microedition/lcdui/Image.java 2025-12-10 22:33:52 UTC (rev 2961)
@@ -204,8 +204,18 @@
img=newImg;
}
else {
- BufferedImage newImg = new BufferedImage((int)(multiplier*img.getWidth()), (int)(multiplier*img.getHeight()), type);
- java.awt.Graphics g = newImg.getGraphics();
+ BufferedImage newImg;
+ if (type == BufferedImage.TYPE_BYTE_INDEXED) {
+ newImg = new BufferedImage((int)(multiplier*img.getWidth()), (int)(multiplier*img.getHeight()), type, (IndexColorModel)img.getColorModel());
+ }
+ else {
+ newImg = new BufferedImage((int)(multiplier*img.getWidth()), (int)(multiplier*img.getHeight()), type);
+ }
+ java.awt.Graphics2D g = newImg.createGraphics();
+ // for indexed images (gifs) we need to set this so that transparency is preserved
+ if (type == BufferedImage.TYPE_BYTE_INDEXED) {
+ g.setComposite(java.awt.AlphaComposite.Src);
+ }
g.drawImage(img, 0, 0, newImg.getWidth(), newImg.getHeight(), 0, 0, img.getWidth(), img.getHeight(), null);
g.dispose();
img=newImg;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-10 21:52:42
|
Revision: 2960
http://sourceforge.net/p/swingme/code/2960
Author: yuranet
Date: 2025-12-10 21:52:40 +0000 (Wed, 10 Dec 2025)
Log Message:
-----------
only hide menu on small screens
Modified Paths:
--------------
AndroidME/src_SwingME_plaf/net/yura/android/plaf/AndroidLookAndFeel.java
Modified: AndroidME/src_SwingME_plaf/net/yura/android/plaf/AndroidLookAndFeel.java
===================================================================
--- AndroidME/src_SwingME_plaf/net/yura/android/plaf/AndroidLookAndFeel.java 2025-12-08 22:02:05 UTC (rev 2959)
+++ AndroidME/src_SwingME_plaf/net/yura/android/plaf/AndroidLookAndFeel.java 2025-12-10 21:52:40 UTC (rev 2960)
@@ -761,10 +761,14 @@
error.printStackTrace(System.out);
}
- dp.HIDDEN_MENU = true;
+ dp.HIDDEN_MENU = false; // default is false since android 10.0 (api-29)
try {
- // API-14
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // API-14
+ // all old devices have a physical menu button
+ dp.HIDDEN_MENU = true;
+ }
+ else if ("small".equals(System.getProperty("display.size"))) {
+ // we want to have the option of a hidden menu ONLY on small screens
dp.HIDDEN_MENU = ViewConfiguration.get(AndroidMeActivity.DEFAULT_ACTIVITY).hasPermanentMenuKey();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-08 22:02:07
|
Revision: 2959
http://sourceforge.net/p/swingme/code/2959
Author: yuranet
Date: 2025-12-08 22:02:05 +0000 (Mon, 08 Dec 2025)
Log Message:
-----------
always open http/https
Modified Paths:
--------------
iOSME/src/javax/microedition/midlet/MIDlet.java
Modified: iOSME/src/javax/microedition/midlet/MIDlet.java
===================================================================
--- iOSME/src/javax/microedition/midlet/MIDlet.java 2025-12-07 19:15:34 UTC (rev 2958)
+++ iOSME/src/javax/microedition/midlet/MIDlet.java 2025-12-08 22:02:05 UTC (rev 2959)
@@ -327,7 +327,7 @@
else {
// on emulator this returns false correctly, but on real device this can return true, but then fail when open is called.
// e.g. mailto: url returns false on emulator, but true on device with no Mail app installed, resulting in open failing.
- if (!UIApplication.sharedApplication().canOpenURL(nsUrl)) {
+ if (!url.startsWith(PROTOCOL_HTTP) && !url.startsWith(PROTOCOL_HTTPS) && !UIApplication.sharedApplication().canOpenURL(nsUrl)) {
throw new Exception("canOpenURL false for url: " + nsUrl);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-07 19:15:37
|
Revision: 2958
http://sourceforge.net/p/swingme/code/2958
Author: yuranet
Date: 2025-12-07 19:15:34 +0000 (Sun, 07 Dec 2025)
Log Message:
-----------
edge-to-edge works on ios
Modified Paths:
--------------
iOSME/res/iOS_theme.xml
iOSME/src/javax/microedition/lcdui/Canvas.java
iOSME/src/javax/microedition/lcdui/Graphics.java
iOSME/src/net/yura/ios/AppController.java
iOSME/src/net/yura/ios/CanvasView.java
iOSME/src/net/yura/ios/plaf/IOSLookAndFeel.java
Modified: iOSME/res/iOS_theme.xml
===================================================================
--- iOSME/res/iOS_theme.xml 2025-12-07 17:46:07 UTC (rev 2957)
+++ iOSME/res/iOS_theme.xml 2025-12-07 19:15:34 UTC (rev 2958)
@@ -200,13 +200,6 @@
- <style id="titleBar">
- <state>
- <color type="BACKGROUND" value="#000000"/>
- <color type="FOREGROUND" value="#FFFFFF"/>
- </state>
- </style>
- <bind style="titleBar" key="TitleBar"/>
<style id="listRenderer">
<insets top="0" left="0" bottom="1" right="0"/>
Modified: iOSME/src/javax/microedition/lcdui/Canvas.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Canvas.java 2025-12-07 17:46:07 UTC (rev 2957)
+++ iOSME/src/javax/microedition/lcdui/Canvas.java 2025-12-07 19:15:34 UTC (rev 2958)
@@ -138,11 +138,11 @@
}
else {
for (CGRect rect : repaintsQueue) {
- canvasView.setNeedsDisplayInRect(rect);
+ canvasView.repaint(rect);
}
//#mdebug debug
- if (fpsRect != null) canvasView.setNeedsDisplayInRect(fpsRect);
+ if (fpsRect != null) canvasView.repaint(fpsRect);
//#enddebug
}
repaintsQueue.clear();
@@ -155,14 +155,14 @@
private boolean fullRepaint;
private final List<CGRect> repaintsQueue = new ArrayList();
- public void repaint(int x, int y, int w, int h) {
+ public final void repaint(int x, int y, int w, int h) {
CGRect rect = CoreGraphics.CGRectMake(x, y, w, h);
// we can only ever call setNeedsDisplay from main thread or it does nothing
if (NSThread.isMainThread_static() && !painting) {
- canvasView.setNeedsDisplayInRect(rect);
+ canvasView.repaint(rect);
//#mdebug debug
- if (fpsRect != null) canvasView.setNeedsDisplayInRect(fpsRect);
+ if (fpsRect != null) canvasView.repaint(fpsRect);
//#enddebug
}
else {
@@ -180,7 +180,7 @@
}
}
- public void repaint() {
+ public final void repaint() {
// we can only ever call setNeedsDisplay from main thread or it does nothing
if (canvasView != null) {
if (NSThread.isMainThread_static() && !painting) {
@@ -353,7 +353,7 @@
}
}
- public void serviceRepaints() {
+ public final void serviceRepaints() {
iOSUtil.MAIN_QUEUE.waitUntilAllOperationsAreFinished();
//CoreGraphics.CGContextFlush(canvasView.graphics.getContext());
}
Modified: iOSME/src/javax/microedition/lcdui/Graphics.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Graphics.java 2025-12-07 17:46:07 UTC (rev 2957)
+++ iOSME/src/javax/microedition/lcdui/Graphics.java 2025-12-07 19:15:34 UTC (rev 2958)
@@ -66,10 +66,6 @@
public void setContext(CGContextRef context) {
this.context = context;
- reset();
- }
-
- public void reset() {
tx = 0;
ty = 0;
dirtyClip = true;
Modified: iOSME/src/net/yura/ios/AppController.java
===================================================================
--- iOSME/src/net/yura/ios/AppController.java 2025-12-07 17:46:07 UTC (rev 2957)
+++ iOSME/src/net/yura/ios/AppController.java 2025-12-07 19:15:34 UTC (rev 2958)
@@ -75,6 +75,14 @@
*/
}
+ /**
+ * @see #dealloc()
+ */
+ @Selector("dealloc")
+ private void mydealloc() {
+ NSNotificationCenter.defaultCenter().removeObserver(this);
+ }
+
@Override
public boolean prefersStatusBarHidden() {
// we could also use isiOSAppOnMac, but that was added in iOS 14 as opposed to iOS 13
@@ -217,10 +225,10 @@
try {
// safeAreaLayoutGuide was added in iOS 11
// TODO when running on M1 mac there is a bug: https://github.com/th3rdwave/react-native-safe-area-context/issues/210
- renderer.bottomAnchor().constraintEqualToAnchor(view().safeAreaLayoutGuide().bottomAnchor()).setActive(true);
- renderer.topAnchor().constraintEqualToAnchor(view().safeAreaLayoutGuide().topAnchor()).setActive(true);
- renderer.rightAnchor().constraintEqualToAnchor(view().safeAreaLayoutGuide().rightAnchor()).setActive(true);
- renderer.leftAnchor().constraintEqualToAnchor(view().safeAreaLayoutGuide().leftAnchor()).setActive(true);
+ renderer.bottomAnchor().constraintEqualToAnchor(view().bottomAnchor()).setActive(true);
+ renderer.topAnchor().constraintEqualToAnchor(view().topAnchor()).setActive(true);
+ renderer.rightAnchor().constraintEqualToAnchor(view().rightAnchor()).setActive(true);
+ renderer.leftAnchor().constraintEqualToAnchor(view().leftAnchor()).setActive(true);
}
catch (Throwable th) {
/*
Modified: iOSME/src/net/yura/ios/CanvasView.java
===================================================================
--- iOSME/src/net/yura/ios/CanvasView.java 2025-12-07 17:46:07 UTC (rev 2957)
+++ iOSME/src/net/yura/ios/CanvasView.java 2025-12-07 19:15:34 UTC (rev 2958)
@@ -11,6 +11,7 @@
import apple.corefoundation.struct.CGPoint;
import apple.corefoundation.struct.CGRect;
import apple.corefoundation.struct.CGSize;
+import apple.coregraphics.c.CoreGraphics;
import apple.foundation.NSEnumerator;
import apple.foundation.NSSet;
import apple.uikit.UIBezierPath;
@@ -23,6 +24,7 @@
import apple.uikit.enums.UITextAutocapitalizationType;
import apple.uikit.enums.UIViewContentMode;
import apple.uikit.protocol.UIKeyInput;
+import apple.uikit.struct.UIEdgeInsets;
/**
* from: https://discuss.multi-os-engine.org/t/cpu-usage-profiling/1326/2
@@ -85,7 +87,8 @@
return;
}
- CGRect bounds = bounds();
+ CGRect bounds = UIKit.UIEdgeInsetsInsetRect(bounds(), getSafeAreaInsets());
+ CGPoint origin = bounds.origin();
CGSize size = bounds.size();
// Check for size changes...
@@ -95,10 +98,36 @@
}
graphics.setContext(UIKit.UIGraphicsGetCurrentContext());
+ graphics.translate((int)origin.x(), (int)origin.y());
canvas.doPaint(graphics);
}
@Override
+ public void safeAreaInsetsDidChange() {
+ super.safeAreaInsetsDidChange();
+
+ UIEdgeInsets insets = getSafeAreaInsets();
+ System.setProperty("safeArea.left", String.valueOf((int)insets.left()));
+ System.setProperty("safeArea.top", String.valueOf((int)insets.top()));
+ System.setProperty("safeArea.right", String.valueOf((int)insets.right()));
+ System.setProperty("safeArea.bottom", String.valueOf((int)insets.bottom()));
+ }
+
+ public void repaint(CGRect rect) {
+ UIEdgeInsets insets = getSafeAreaInsets();
+ CGPoint origin = rect.origin();
+ CGSize size = rect.size();
+
+ rect = CoreGraphics.CGRectMake(
+ insets.left() + origin.x(),
+ insets.top() + origin.y(),
+ size.width(),
+ size.height());
+
+ setNeedsDisplayInRect(rect);
+ }
+
+ @Override
public boolean isMultipleTouchEnabled() {
return true;
}
@@ -116,7 +145,7 @@
*/
private static final int POINTER_RELEASED = 2;
- private void fireMultitouchEvent(NSSet<? extends UITouch> touches, int type) {
+ private void fireMultitouchEvent(NSSet<? extends UITouch> touches, int type, double leftOffset, double topOffset) {
try {
int count = (int) touches.count();
int[] xs = new int[count];
@@ -128,8 +157,8 @@
UITouch touch = it.nextObject();
while (touch != null) {
CGPoint point = touch.locationInView(this);
- xs[c] = (int) point.x();
- ys[c] = (int) point.y();
+ xs[c] = (int) (point.x() - leftOffset);
+ ys[c] = (int) (point.y() - topOffset);
types[c] = type;
touch = it.nextObject();
@@ -149,15 +178,17 @@
public void touchesBeganWithEvent(NSSet<? extends UITouch> touches, UIEvent event) {
super.touchesBeganWithEvent(touches, event);
+ UIEdgeInsets insets = getSafeAreaInsets();
+
UITouch touch = touches.anyObject();
touches = event.allTouches(); // this gives us ALL current touches, even ones that are not involved in this current event, (fingers that are being still)
CGPoint point = touch.locationInView(this);
- //System.out.println("firePointerPressed(1) " + (int) point.x() + " " + (int) point.y());
- canvas.firePointerPressed((int) point.x(), (int) point.y());
+ //System.out.println("firePointerPressed(1) " + (int) point.x() + " (insets.left=" + insets.left() + ") " + (int) point.y() +" (insets.top="+insets.top()+")");
+ canvas.firePointerPressed((int) (point.x() - insets.left()), (int) (point.y() - insets.top()));
if (touches.count() > 1) {
- fireMultitouchEvent(touches, POINTER_PRESSED);
+ fireMultitouchEvent(touches, POINTER_PRESSED, insets.left(), insets.top());
}
}
@@ -165,15 +196,17 @@
public void touchesMovedWithEvent(NSSet<? extends UITouch> touches, UIEvent event) {
super.touchesMovedWithEvent(touches, event);
+ UIEdgeInsets insets = getSafeAreaInsets();
+
UITouch touch = touches.anyObject();
touches = event.allTouches();
CGPoint point = touch.locationInView(this);
//System.out.println("firePointerDragged(0) " + (int) point.x() + " " + (int) point.y());
- canvas.firePointerDragged((int)point.x(), (int)point.y());
+ canvas.firePointerDragged((int) (point.x() - insets.left()), (int) (point.y() - insets.top()));
if (touches.count() > 1) {
- fireMultitouchEvent(touches, POINTER_DRAGGED);
+ fireMultitouchEvent(touches, POINTER_DRAGGED, insets.left(), insets.top());
}
}
@@ -181,16 +214,18 @@
public void touchesEndedWithEvent(NSSet<? extends UITouch> touches, UIEvent event) {
super.touchesEndedWithEvent(touches, event);
+ UIEdgeInsets insets = getSafeAreaInsets();
+
UITouch touch = touches.anyObject();
touches = event.allTouches();
CGPoint point = touch.locationInView(this);
if (touches.count() > 1) {
- fireMultitouchEvent(touches, POINTER_RELEASED);
+ fireMultitouchEvent(touches, POINTER_RELEASED, insets.left(), insets.top());
}
//System.out.println("firePointerReleased(2) " + (int) point.x() + " " + (int) point.y());
- canvas.firePointerReleased((int) point.x(), (int) point.y());
+ canvas.firePointerReleased((int) (point.x() - insets.left()), (int) (point.y() - insets.top()));
// we only want to hide the keyboard if the user has clicked on something that is not a text field
if (textField != null && !textField.isFocusOwner()) {
@@ -292,4 +327,13 @@
return UITextAutocapitalizationType.Sentences;
}
}
-}
\ No newline at end of file
+
+ private UIEdgeInsets getSafeAreaInsets() {
+ try {
+ return safeAreaInsets(); // API-11 (first OS on the very first notch iPhone X)
+ }
+ catch (Throwable th) {
+ return new UIEdgeInsets();
+ }
+ }
+}
Modified: iOSME/src/net/yura/ios/plaf/IOSLookAndFeel.java
===================================================================
--- iOSME/src/net/yura/ios/plaf/IOSLookAndFeel.java 2025-12-07 17:46:07 UTC (rev 2957)
+++ iOSME/src/net/yura/ios/plaf/IOSLookAndFeel.java 2025-12-07 19:15:34 UTC (rev 2958)
@@ -4,6 +4,7 @@
import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Icon;
import net.yura.mobile.gui.border.Border;
+import net.yura.mobile.gui.border.EdgeToEdgeBorder;
import net.yura.mobile.gui.border.EmptyBorder;
import net.yura.mobile.gui.border.MatteBorder;
import net.yura.mobile.gui.plaf.Style;
@@ -103,6 +104,10 @@
//spinner.addProperty(getSystemImage("plus.square.fill", gray), "iconRight", Style.DISABLED);
setStyleFor("Spinner", spinner);
+ Style titleBar = makeStyleFor("TitleBar");
+ titleBar.addForeground(0xFFFFFFFF, Style.ALL);
+ titleBar.addBorder(new EdgeToEdgeBorder(0xFF000000), Style.ALL);
+ setStyleFor("TitleBar", titleBar);
//NSBundle bundle = NSBundle.bundleWithIdentifier("com.apple.UIKit");
NSBundle bundle = NSBundle.bundleForClass(org.moe.natj.objc.Class.fromJavaClass(UIButton.class));
@@ -138,6 +143,16 @@
long userInterfaceIdiom = UIDevice.currentDevice().userInterfaceIdiom();
DesktopPane.getDesktopPane().VERY_BIG_SCREEN = userInterfaceIdiom == UIUserInterfaceIdiom.Pad || userInterfaceIdiom == UIUserInterfaceIdiom.Mac;
+/*
+//this does not work at all, its not possible to get the default images from iOS, this only returns nulls
+ UISlider slider = UISlider.alloc().init();
+ UIImage normalThumb = slider.thumbImageForState(UIControlState.Normal);
+ UIImage focusedThumb = slider.thumbImageForState(UIControlState.Focused);
+ Style sliderThumb = makeStyleFor("SliderThumb");
+ sliderThumb.addBorder(new IOSBorder(normalThumb,0,0,0,0), Style.ALL);
+ sliderThumb.addBorder(new IOSBorder(focusedThumb,0,0,0,0), Style.FOCUSED);
+ setStyleFor("SliderThumb", sliderThumb);
+*/
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-07 17:46:10
|
Revision: 2957
http://sourceforge.net/p/swingme/code/2957
Author: yuranet
Date: 2025-12-07 17:46:07 +0000 (Sun, 07 Dec 2025)
Log Message:
-----------
clear bitmap on safe area change in android
Modified Paths:
--------------
AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java 2025-12-07 16:33:47 UTC (rev 2956)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java 2025-12-07 17:46:07 UTC (rev 2957)
@@ -686,6 +686,12 @@
System.setProperty("safeArea.right", String.valueOf(getPaddingRight()));
System.setProperty("safeArea.bottom", String.valueOf(getPaddingBottom()));
+ // only really needed in software mode as hardware mode seems to always repaint the full screen
+ // we clear at 90% black, we will see a faint ghost of unrepainted pixels
+ if (graphicsBitmap != null) {
+ graphicsBitmap.eraseColor(0xE5000000);
+ }
+
return result;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-07 16:33:50
|
Revision: 2956
http://sourceforge.net/p/swingme/code/2956
Author: yuranet
Date: 2025-12-07 16:33:47 +0000 (Sun, 07 Dec 2025)
Log Message:
-----------
fix edge-to-edge border
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java
Modified: SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java 2025-12-07 02:49:16 UTC (rev 2955)
+++ SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java 2025-12-07 16:33:47 UTC (rev 2956)
@@ -30,7 +30,7 @@
if (xOnScreen == 0) { // fillLeft
int safeAreaLeft = Integer.getInteger("safeArea.left", 0);
if (safeAreaLeft > 0) {
- startX = xOnScreen - safeAreaLeft + getLeft();
+ startX = - safeAreaLeft;
}
}
int startY = 0;
@@ -37,7 +37,7 @@
if (yOnScreen == 0) { // fillTop
int safeAreaTop = Integer.getInteger("safeArea.top", 0);
if (safeAreaTop > 0) {
- startY = yOnScreen - safeAreaTop + getTop();
+ startY = - safeAreaTop;
}
}
int width = w;
@@ -44,7 +44,7 @@
if (rOnScreen == dp.getWidth()) { // fillRight
int safeAreaRight = Integer.getInteger("safeArea.right", 0);
if (safeAreaRight > 0) {
- width = rOnScreen + safeAreaRight - xOnScreen - getRight();
+ width = w + safeAreaRight;
}
}
@@ -52,7 +52,7 @@
if (bOnScreen == dp.getHeight()) { // fillBottom
int safeAreaBottom = Integer.getInteger("safeArea.bottom", 0);
if (safeAreaBottom > 0) {
- height = bOnScreen + safeAreaBottom - yOnScreen - getBottom();
+ height = h + safeAreaBottom;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-07 02:49:19
|
Revision: 2955
http://sourceforge.net/p/swingme/code/2955
Author: yuranet
Date: 2025-12-07 02:49:16 +0000 (Sun, 07 Dec 2025)
Log Message:
-----------
set safeArea properties
Modified Paths:
--------------
AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java 2025-12-07 02:18:31 UTC (rev 2954)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java 2025-12-07 02:49:16 UTC (rev 2955)
@@ -23,6 +23,7 @@
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
+import android.view.WindowInsets;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
@@ -677,6 +678,17 @@
}
}
+ public WindowInsets onApplyWindowInsets(WindowInsets windowInsets) {
+ WindowInsets result = super.onApplyWindowInsets(windowInsets);
+
+ System.setProperty("safeArea.left", String.valueOf(getPaddingLeft()));
+ System.setProperty("safeArea.top", String.valueOf(getPaddingTop()));
+ System.setProperty("safeArea.right", String.valueOf(getPaddingRight()));
+ System.setProperty("safeArea.bottom", String.valueOf(getPaddingBottom()));
+
+ return result;
+ }
+
// Override > 2.1 only
public boolean isOpaque() {
return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-07 02:18:33
|
Revision: 2954
http://sourceforge.net/p/swingme/code/2954
Author: yuranet
Date: 2025-12-07 02:18:31 +0000 (Sun, 07 Dec 2025)
Log Message:
-----------
edge-to-edge also works in android software mode and iOS
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/DesktopPane.java
SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java
Modified: SwingME/src/net/yura/mobile/gui/DesktopPane.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/DesktopPane.java 2025-12-05 01:07:31 UTC (rev 2953)
+++ SwingME/src/net/yura/mobile/gui/DesktopPane.java 2025-12-07 02:18:31 UTC (rev 2954)
@@ -719,7 +719,7 @@
}
else {
graphics.setColor( ((Integer)fade).intValue() );
- graphics.fillRect(0, 0, w, h);
+ graphics.fillRect(graphics.getClipX(), graphics.getClipY(), graphics.getClipWidth(), graphics.getClipHeight());
}
}
/*
@@ -918,8 +918,7 @@
int ys = rc.getYOnScreen();
int[] v = rc.getVisibleRect();
- repaint(xs+v[0],ys+v[1],v[2],v[3]);
-
+ safeAreaRepaint(xs + v[0], ys + v[1], v[2], v[3]);
}
public void repaintHole(final Component rc) {
@@ -930,9 +929,40 @@
synchronized(uiLock) {
fullrepaint = true;
}
- repaint(x,y,width,height);
+ safeAreaRepaint(x, y, width, height);
}
+ private void safeAreaRepaint(int x, int y, int w, int h) {
+
+ if ((x + w) >= getWidth()) {
+ int safeAreaRight = Integer.getInteger("safeArea.right", 0);
+ if (safeAreaRight > 0) {
+ w = getWidth() - x + safeAreaRight;
+ }
+ }
+ if ((y + h) >= getHeight()) {
+ int safeAreaBottom = Integer.getInteger("safeArea.bottom", 0);
+ if (safeAreaBottom > 0) {
+ h = getHeight() - y + safeAreaBottom;
+ }
+ }
+ if (x <= 0) {
+ int safeAreaLeft = Integer.getInteger("safeArea.left", 0);
+ if (safeAreaLeft > 0) {
+ w = safeAreaLeft + x + w;
+ x = -safeAreaLeft;
+ }
+ }
+ if (y <= 0) {
+ int safeAreaTop = Integer.getInteger("safeArea.top", 0);
+ if (safeAreaTop > 0) {
+ h = safeAreaTop + y + h;
+ y = -safeAreaTop;
+ }
+ }
+ repaint(x, y, w, h);
+ }
+
private int validating=0;
public void revalidateComponent(Component rc) {
//#mdebug info
Modified: SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java 2025-12-05 01:07:31 UTC (rev 2953)
+++ SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java 2025-12-07 02:18:31 UTC (rev 2954)
@@ -26,23 +26,38 @@
int rOnScreen = xOnScreen + w + getLeft() + getRight();
int bOnScreen = yOnScreen + h + getTop() + getBottom();
- boolean fillLeft = xOnScreen == 0;
- boolean fillTop = yOnScreen == 0;
- boolean fillRight = rOnScreen == dp.getWidth();
- boolean fillBottom = bOnScreen == dp.getHeight();
+ int startX = 0;
+ if (xOnScreen == 0) { // fillLeft
+ int safeAreaLeft = Integer.getInteger("safeArea.left", 0);
+ if (safeAreaLeft > 0) {
+ startX = xOnScreen - safeAreaLeft + getLeft();
+ }
+ }
+ int startY = 0;
+ if (yOnScreen == 0) { // fillTop
+ int safeAreaTop = Integer.getInteger("safeArea.top", 0);
+ if (safeAreaTop > 0) {
+ startY = yOnScreen - safeAreaTop + getTop();
+ }
+ }
+ int width = w;
+ if (rOnScreen == dp.getWidth()) { // fillRight
+ int safeAreaRight = Integer.getInteger("safeArea.right", 0);
+ if (safeAreaRight > 0) {
+ width = rOnScreen + safeAreaRight - xOnScreen - getRight();
+ }
+ }
- int clipXOnScreen = xOnScreen + g.getClipX();
- int clipYOnScreen = yOnScreen + g.getClipY();
- int clipROnScreen = clipXOnScreen + g.getClipWidth();
- int clipBOnScreen = clipYOnScreen + g.getClipHeight();
+ int height = h;
+ if (bOnScreen == dp.getHeight()) { // fillBottom
+ int safeAreaBottom = Integer.getInteger("safeArea.bottom", 0);
+ if (safeAreaBottom > 0) {
+ height = bOnScreen + safeAreaBottom - yOnScreen - getBottom();
+ }
+ }
- int startX = ((fillLeft && clipXOnScreen < 0) ? clipXOnScreen + getLeft() : 0);
- int startY = ((fillTop && clipYOnScreen < 0) ? clipYOnScreen + getTop() : 0);
- int width = ((fillRight && clipROnScreen > rOnScreen) ? clipROnScreen - xOnScreen - getRight() : w) - startX;
- int height = ((fillBottom && clipBOnScreen > bOnScreen) ? clipBOnScreen - yOnScreen - getBottom() : h) - startY;
-
g.translate(startX, startY);
- border.paintBorder(cmpnt, g, width, height);
+ border.paintBorder(cmpnt, g, width - startX, height - startY);
g.translate(-startX, -startY);
// for debugging:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-05 01:07:33
|
Revision: 2953
http://sourceforge.net/p/swingme/code/2953
Author: yuranet
Date: 2025-12-05 01:07:31 +0000 (Fri, 05 Dec 2025)
Log Message:
-----------
call correct method
Modified Paths:
--------------
AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java 2025-12-04 23:28:23 UTC (rev 2952)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java 2025-12-05 01:07:31 UTC (rev 2953)
@@ -158,7 +158,7 @@
public void repaint(int x, int y, int w, int h) {
if (this.canvasView != null) {
- int graphicsY = canvasView.getHeight() - getHeight();
+ int graphicsY = canvasView.getHeight() - canvasView.viewHeight;
y = y+graphicsY;
// TODO do we want to extend what we repaint to the view edge?
@@ -168,7 +168,7 @@
//#mdebug debug
if (net.yura.mobile.BuildConfig.DEBUG) {
- this.canvasView.postInvalidate(left, top, left + 10, top + 10);
+ this.canvasView.postInvalidate(left, top + graphicsY, left + 10, top + graphicsY + 10);
}
//#enddebug
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-04 23:28:26
|
Revision: 2952
http://sourceforge.net/p/swingme/code/2952
Author: yuranet
Date: 2025-12-04 23:28:23 +0000 (Thu, 04 Dec 2025)
Log Message:
-----------
call correct method
Modified Paths:
--------------
AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java 2025-12-04 18:40:49 UTC (rev 2951)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java 2025-12-04 23:28:23 UTC (rev 2952)
@@ -162,13 +162,13 @@
y = y+graphicsY;
// TODO do we want to extend what we repaint to the view edge?
- int left = getView().getPaddingLeft();
- int top = getView().getPaddingTop();
+ int left = canvasView.getPaddingLeft();
+ int top = canvasView.getPaddingTop();
this.canvasView.postInvalidate(left + x, top + y, left + x+w, top + y+h);
//#mdebug debug
if (net.yura.mobile.BuildConfig.DEBUG) {
- this.canvasView.postInvalidate(0, 0, 10, 10);
+ this.canvasView.postInvalidate(left, top, left + 10, top + 10);
}
//#enddebug
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2025-12-04 18:40:51
|
Revision: 2951
http://sourceforge.net/p/swingme/code/2951
Author: yuranet
Date: 2025-12-04 18:40:49 +0000 (Thu, 04 Dec 2025)
Log Message:
-----------
better logging for audio errors
Modified Paths:
--------------
AndroidME/build.gradle
AndroidME/src_JSR135_Multimedia/javax/microedition/media/player/AudioPlayer.java
AndroidME/src_MIDP/javax/microedition/media/PlayerListener.java
Added Paths:
-----------
AndroidME/test/
AndroidME/test/javax/
AndroidME/test/javax/microedition/
AndroidME/test/javax/microedition/media/
AndroidME/test/javax/microedition/media/player/
AndroidME/test/javax/microedition/media/player/AudioPlayerTest.java
Modified: AndroidME/build.gradle
===================================================================
--- AndroidME/build.gradle 2025-11-30 17:01:55 UTC (rev 2950)
+++ AndroidME/build.gradle 2025-12-04 18:40:49 UTC (rev 2951)
@@ -31,6 +31,7 @@
encoding = 'cp1252'
}
// updating to 35 may require a update of the gradle plugin!!
+ // 31+ does not support gradle 6 at all, ONLY gradle 4 and 7+ is supported!
compileSdkVersion 34
buildToolsVersion '34.0.0'
@@ -40,16 +41,31 @@
java.srcDirs = ['src_Android','src_JSR120_SMS','src_JSR135_Multimedia','src_JSR179_Location','src_JSR184_3D','src_JSR234_Advanced_Multimedia','src_JSR82_Bluetooth','src_MIDP','src_SwingME_plaf']
res.srcDirs = ['res']
}
+ test {
+ java.srcDirs = ['test']
+ }
}
defaultConfig {
minSdkVersion 4
}
+ packagingOptions {
+ exclude 'META-INF/LICENSE.md'
+ exclude 'META-INF/LICENSE-notice.md'
+ }
}
dependencies {
api project(":SwingME")
+
+ // 5.11.4 is the last version that works with gradle 4
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.4'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.4'
}
+tasks.withType(Test).configureEach {
+ useJUnitPlatform()
+}
+
group = 'org.swingme'
version = '1.0.0'
Modified: AndroidME/src_JSR135_Multimedia/javax/microedition/media/player/AudioPlayer.java
===================================================================
--- AndroidME/src_JSR135_Multimedia/javax/microedition/media/player/AudioPlayer.java 2025-11-30 17:01:55 UTC (rev 2950)
+++ AndroidME/src_JSR135_Multimedia/javax/microedition/media/player/AudioPlayer.java 2025-12-04 18:40:49 UTC (rev 2951)
@@ -1,10 +1,13 @@
package javax.microedition.media.player;
import android.content.res.AssetFileDescriptor;
+import android.media.AudioTrack;
import android.media.MediaPlayer;
import net.yura.android.AndroidMeApp;
import net.yura.mobile.logging.Logger;
import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import javax.microedition.media.Control;
@@ -48,6 +51,19 @@
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
+
+ try {
+ String whatString = findConstantsByValueAndPrefix(MediaPlayer.class, "MEDIA_ERROR_", what);
+ String extraString = findConstantsByValueAndPrefix(MediaPlayer.class, "MEDIA_ERROR_", extra);
+ if (extraString == null) {
+ extraString = findConstantsByValueAndPrefix(AudioTrack.class, "ERROR_", extra);
+ }
+ System.out.println("AudioPlayer onError what " + whatString + " (" + what + ") extra " + extraString + " (" + extra + ")");
+ }
+ catch (Throwable ex) {
+ System.out.println("unable to print error string" + ex);
+ }
+
sendListenerEvent(PlayerListener.ERROR, what + " " + extra);
return false;
}
@@ -153,4 +169,26 @@
//return player.getTrackInfo()[0].getFormat().getString(MediaFormat.KEY_MIME);
return null;
}
+
+ public static String findConstantsByValueAndPrefix(Class<?> clazz, String prefix, int value) {
+ Field[] fields = clazz.getDeclaredFields();
+
+ for (Field field : fields) {
+ try {
+ if (Modifier.isStatic(field.getModifiers())
+ && Modifier.isFinal(field.getModifiers())
+ && field.getType() == int.class
+ && field.getName().startsWith(prefix)) {
+
+ field.setAccessible(true);
+ if (field.getInt(null) == value) {
+ return field.getName();
+ }
+ }
+ }
+ catch (Exception e) { }
+ }
+
+ return null;
+ }
}
Modified: AndroidME/src_MIDP/javax/microedition/media/PlayerListener.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/media/PlayerListener.java 2025-11-30 17:01:55 UTC (rev 2950)
+++ AndroidME/src_MIDP/javax/microedition/media/PlayerListener.java 2025-12-04 18:40:49 UTC (rev 2951)
@@ -10,6 +10,10 @@
* When looping: An END_OF_MEDIA event will be posted every time the Player reaches the end of media.
*/
static String END_OF_MEDIA = "endOfMedia";
+ /**
+ * it is common for eventData to be a String with a numerical error code.
+ * on Android its a string with 2 ints separated by a space
+ */
static String ERROR = "error";
static String STARTED = "started";
static String STOPPED = "stopped";
Added: AndroidME/test/javax/microedition/media/player/AudioPlayerTest.java
===================================================================
--- AndroidME/test/javax/microedition/media/player/AudioPlayerTest.java (rev 0)
+++ AndroidME/test/javax/microedition/media/player/AudioPlayerTest.java 2025-12-04 18:40:49 UTC (rev 2951)
@@ -0,0 +1,22 @@
+package javax.microedition.media.player;
+
+import android.media.MediaPlayer;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * @see AudioPlayer
+ */
+public class AudioPlayerTest {
+
+ @Test
+ public void findConstantsByValueAndPrefix() {
+
+ String error = AudioPlayer.findConstantsByValueAndPrefix(MediaPlayer.class, "MEDIA_ERROR_", 1);
+ assertEquals("MEDIA_ERROR_UNKNOWN", error);
+
+ String error2 = AudioPlayer.findConstantsByValueAndPrefix(MediaPlayer.class, "MEDIA_ERROR_", -19);
+ assertEquals(null, error2);
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|