use of javax.microedition.lcdui.pointer.VirtualKeyboard in project J2ME-Loader by nikita36078.
the class ConfigActivity method setVirtualKeyboard.
private void setVirtualKeyboard() {
int vkAlpha = sbVKAlpha.getProgress();
int vkDelay = Integer.parseInt(tfVKHideDelay.getText().toString());
int vkColorBackground = Integer.parseInt(tfVKBack.getText().toString(), 16);
int vkColorForeground = Integer.parseInt(tfVKFore.getText().toString(), 16);
int vkColorBackgroundSelected = Integer.parseInt(tfVKSelBack.getText().toString(), 16);
int vkColorForegroundSelected = Integer.parseInt(tfVKSelFore.getText().toString(), 16);
int vkColorOutline = Integer.parseInt(tfVKOutline.getText().toString(), 16);
boolean vkFeedback = cxVKFeedback.isChecked();
VirtualKeyboard vk = new VirtualKeyboard();
vk.setOverlayAlpha(vkAlpha);
vk.setHideDelay(vkDelay);
vk.setHasHapticFeedback(vkFeedback);
if (keylayoutFile.exists()) {
try {
FileInputStream fis = new FileInputStream(keylayoutFile);
DataInputStream dis = new DataInputStream(fis);
vk.readLayout(dis);
fis.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
vk.setColor(VirtualKeyboard.BACKGROUND, vkColorBackground);
vk.setColor(VirtualKeyboard.FOREGROUND, vkColorForeground);
vk.setColor(VirtualKeyboard.BACKGROUND_SELECTED, vkColorBackgroundSelected);
vk.setColor(VirtualKeyboard.FOREGROUND_SELECTED, vkColorForegroundSelected);
vk.setColor(VirtualKeyboard.OUTLINE, vkColorOutline);
VirtualKeyboard.LayoutListener listener = vk1 -> {
try {
FileOutputStream fos = new FileOutputStream(keylayoutFile);
DataOutputStream dos = new DataOutputStream(fos);
vk1.writeLayout(dos);
fos.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
};
vk.setLayoutListener(listener);
ContextHolder.setVk(vk);
}
use of javax.microedition.lcdui.pointer.VirtualKeyboard 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);
}
Aggregations