yatsek / microemu

Automatically exported from code.google.com/p/microemu
0 stars 0 forks source link

Various problems in javax.microedition.lcdui functions on Android #87

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What version of the product are you using? On what operating system?
Android 1.5.  The version I downloaded from SVN on Dec. 16, 2010.

I have attached a zip file with code fixes for these problems.  I have tested 
the changes only on Android.

Problems:

1.  Display.setCurrentItem() does not work

2. itemStateChanged should not be called when item changed by API call

E.g. in a TextField, if I call setString, my itemStateChanged listener gets 
called.  This is not the correct behavior.

The official documentation for ItemStateListener.itemStateChanged says "The 
listener is not called if the application changes the value of an interactive 
item".  The only time that itemStateChanged should be called as the result of 
an API call is when notifyStateChanged is called.

3.  Item commands do not show up when I press the Menu button.

I only see the commands for the Form as a whole, not the commands that I set 
for specific items via Item.addCommand()
See my proposed changes to MicroEmulator.java

4. TextField.setLabel() causes crash

It must be wrapped in activity.post()

5. TextField UNEDITABLE option does not work

In setConstraints,
                m_isEditable = (constraints & TextField.UNEDITABLE) == 0;
                if ( !m_isEditable )
                    editView.setInputType(InputType.TYPE_NULL);
                            else if ....

and in onTextChanged, veto any user edits.

6.  In TextField and TextBox, infinite loop occurs if onTextChanged vetos the 
edit.

onTextChanged calls editView.setText(previousText), but calling setText() 
causes onTextChanged to be called again.

7. Exit command does not work

My commandListener that I registered with Command type EXIT does not get called.

When I register a Command with type EXIT and press the back button, the 
application gets moved to the back, instead of executing the commandAction for 
my command listener.  This is not the correct behavior according to the 
official MIDP documentation.

In MicroEmulator.java make this change
            CommandUI cmd = getFirstCommandOfType(commands, Command.BACK);
-           if (cmd != null) {
-               if (ui.getCommandListener() != null) {
-                   ignoreBackKeyUp = true;
-                   MIDletBridge.getMIDletAccess().getDisplayAccess().commandAction(cmd.getCom
mand(), da.getCurrent());
-               }
-               return true;
-           }
-
-           cmd = getFirstCommandOfType(commands, Command.EXIT);
-           if (cmd != null) {
-               moveTaskToBack(true);
-               return true;
-           }
-           
-           cmd = getFirstCommandOfType(commands, Command.CANCEL);
+           if ( cmd == null )
+               cmd = getFirstCommandOfType(commands, Command.EXIT);
+           if ( cmd == null )
+               cmd = getFirstCommandOfType(commands, Command.CANCEL);
            if (cmd != null) {
                if (ui.getCommandListener() != null) {
                    ignoreBackKeyUp = true;

8.  Form.insert(int, Item) is not implemented

9.  itemStateChanged does not get called for ChoiceGroup with type = POPUP

10.  Cannot enter negative numbers for TextField with NUMERIC option.

The documentation says that NUMERIC should accept integer values.  Integers 
include negative numbers.

In setConstraints, add InputType.TYPE_NUMBER_FLAG_SIGNED like this:
editView.setInputType(InputType.TYPE_CLASS_NUMBER | 
InputType.TYPE_NUMBER_FLAG_SIGNED);

11. List.insert(int, String, Image) does not work

12. List with type MULTIPLE does not work

This can be implemented as a Form with a ChoiceGroup MULTIPLE item

13. Various ChoiceGroup functions crash when called outside the activity thread

Original issue reported on code.google.com by VincentL...@gmail.com on 22 Dec 2010 at 10:09

Attachments:

GoogleCodeExporter commented 8 years ago
I haven't fixed #2 for Gauge or DateField.

Original comment by VincentL...@gmail.com on 22 Dec 2010 at 10:12

GoogleCodeExporter commented 8 years ago
Could you provide the patch file in a diff format?

According to the 7. Exit command does not work:
This has been disabled intentionally. Android guidelines encourage not to 
provide exit functionality, because application can be easily moved into 
background. All the default Android applications doesn't have Exit button.

Original comment by bar...@gmail.com on 23 Dec 2010 at 7:59