Search in sources :

Example 1 with Command

use of javax.microedition.lcdui.Command in project J2ME-Loader by nikita36078.

the class MicroActivity method onPrepareOptionsMenu.

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuInflater inflater = getMenuInflater();
    if (current == null) {
        inflater.inflate(R.menu.midlet_displayable, menu);
        return true;
    }
    boolean hasCommands = current.countCommands() > 0;
    Menu group;
    if (hasCommands) {
        inflater.inflate(R.menu.midlet_common, menu);
        group = menu.getItem(0).getSubMenu();
    } else {
        group = menu;
    }
    inflater.inflate(R.menu.midlet_displayable, group);
    if (current instanceof Canvas) {
        if (actionBarEnabled) {
            inflater.inflate(R.menu.midlet_canvas, menu);
        } else {
            inflater.inflate(R.menu.midlet_canvas_no_bar, group);
        }
        if (inputMethodManager == null) {
            menu.findItem(R.id.action_ime_keyboard).setVisible(false);
        }
        VirtualKeyboard vk = ContextHolder.getVk();
        if (vk != null) {
            inflater.inflate(R.menu.midlet_vk, group);
            if (vk.getLayoutEditMode() == VirtualKeyboard.LAYOUT_EOF) {
                menu.findItem(R.id.action_layout_edit_finish).setVisible(false);
            }
        }
    }
    if (!hasCommands) {
        return true;
    }
    for (Command cmd : current.getCommands()) {
        menu.add(Menu.NONE, cmd.hashCode(), Menu.NONE, cmd.getAndroidLabel());
    }
    return true;
}
Also used : MenuInflater(android.view.MenuInflater) Command(javax.microedition.lcdui.Command) Canvas(javax.microedition.lcdui.Canvas) Menu(android.view.Menu) VirtualKeyboard(javax.microedition.lcdui.keyboard.VirtualKeyboard)

Example 2 with Command

use of javax.microedition.lcdui.Command in project J2ME-Loader by nikita36078.

the class MicroActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (current != null) {
        int id = item.getItemId();
        if (item.getGroupId() == R.id.action_group_common_settings) {
            if (id == R.id.action_exit_midlet) {
                showExitConfirmation();
            } else if (current instanceof Canvas && ContextHolder.getVk() != null) {
                VirtualKeyboard vk = ContextHolder.getVk();
                switch(id) {
                    case R.id.action_layout_edit_mode:
                        vk.switchLayoutEditMode(VirtualKeyboard.LAYOUT_KEYS);
                        break;
                    case R.id.action_layout_scale_mode:
                        vk.switchLayoutEditMode(VirtualKeyboard.LAYOUT_SCALES);
                        break;
                    case R.id.action_layout_edit_finish:
                        vk.switchLayoutEditMode(VirtualKeyboard.LAYOUT_EOF);
                        break;
                    case R.id.action_layout_switch:
                        vk.switchLayout();
                        break;
                    case R.id.action_hide_buttons:
                        showHideButtonDialog();
                        break;
                }
            }
            return true;
        }
        CommandListener listener = current.getCommandListener();
        if (listener == null) {
            return false;
        }
        for (Command cmd : current.getCommands()) {
            if (cmd.hashCode() == id) {
                current.postEvent(CommandActionEvent.getInstance(listener, cmd, current));
                return true;
            }
        }
    }
    return super.onOptionsItemSelected(item);
}
Also used : CommandListener(javax.microedition.lcdui.CommandListener) Command(javax.microedition.lcdui.Command) Canvas(javax.microedition.lcdui.Canvas) VirtualKeyboard(javax.microedition.lcdui.pointer.VirtualKeyboard)

Example 3 with Command

use of javax.microedition.lcdui.Command in project CodenameOne by codenameone.

the class GameCanvasImplementation method editString.

/**
 * @inheritDoc
 */
public void editString(Component cmp, int maxSize, int constraint, String text, int keyCode) {
    UIManager m = UIManager.getInstance();
    CONFIRM_COMMAND = new Command(m.localize("ok", "OK"), Command.OK, 1);
    CANCEL_COMMAND = new Command(m.localize("cancel", "Cancel"), Command.CANCEL, 2);
    if (mid.getAppProperty("forceBackCommand") != null) {
        canvas.addCommand(MIDP_BACK_COMMAND);
    }
    currentTextBox = new TextBox("", "", maxSize, TextArea.ANY);
    currentTextBox.setCommandListener((CommandListener) canvas);
    currentTextBox.addCommand(CONFIRM_COMMAND);
    currentTextBox.addCommand(CANCEL_COMMAND);
    currentTextComponent = cmp;
    currentTextBox.setMaxSize(maxSize);
    currentTextBox.setString(text);
    currentTextBox.setConstraints(constraint);
    display.setCurrent(currentTextBox);
    ((C) canvas).setDone(false);
    Display.getInstance().invokeAndBlock(((C) canvas));
}
Also used : Command(javax.microedition.lcdui.Command) UIManager(com.codename1.ui.plaf.UIManager) TextBox(javax.microedition.lcdui.TextBox)

Example 4 with Command

use of javax.microedition.lcdui.Command in project qrcode by yanbe.

the class J2MEImage method addViewDecodedStringCommand.

void addViewDecodedStringCommand() {
    if (viewDecodedStringCommand == null) {
        viewDecodedStringCommand = new Command("Result", Command.SCREEN, 1);
        addCommand(viewDecodedStringCommand);
    }
}
Also used : Command(javax.microedition.lcdui.Command)

Aggregations

Command (javax.microedition.lcdui.Command)4 Canvas (javax.microedition.lcdui.Canvas)2 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1 UIManager (com.codename1.ui.plaf.UIManager)1 CommandListener (javax.microedition.lcdui.CommandListener)1 TextBox (javax.microedition.lcdui.TextBox)1 VirtualKeyboard (javax.microedition.lcdui.keyboard.VirtualKeyboard)1 VirtualKeyboard (javax.microedition.lcdui.pointer.VirtualKeyboard)1