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;
}
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);
}
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));
}
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);
}
}
Aggregations