use of javax.microedition.lcdui.keyboard.VirtualKeyboard 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.keyboard.VirtualKeyboard in project J2ME-Loader by nikita36078.
the class MicroLoader method applyConfiguration.
void applyConfiguration() {
try {
// Apply configuration to the launching MIDlet
if (params.showKeyboard) {
ContextHolder.setVk(new VirtualKeyboard(params));
} else {
ContextHolder.setVk(null);
}
setProperties();
final String[] propLines = params.systemProperties.split("\n");
for (String line : propLines) {
String[] prop = line.split(":[ ]*", 2);
if (prop.length == 2) {
System.setProperty(prop[0], prop[1]);
MidletSystem.setProperty(prop[0], prop[1]);
}
}
try {
Charset.forName(System.getProperty("microedition.encoding"));
} catch (Exception e) {
System.setProperty("microedition.encoding", "ISO-8859-1");
MidletSystem.setProperty("microedition.encoding", "ISO-8859-1");
}
int screenWidth = params.screenWidth;
int screenHeight = params.screenHeight;
Displayable.setVirtualSize(screenWidth, screenHeight);
Canvas.setBackgroundColor(params.screenBackgroundColor);
Canvas.setScale(params.screenGravity, params.screenScaleType, params.screenScaleRatio);
Canvas.setFilterBitmap(params.screenFilter);
EventQueue.setImmediate(params.immediateMode);
Canvas.setGraphicsMode(params.graphicsMode, params.parallelRedrawScreen);
ShaderInfo shader = params.shader;
if (shader != null) {
shader.dir = workDir + Config.SHADERS_DIR;
}
Canvas.setShaderFilter(shader);
Canvas.setForceFullscreen(params.forceFullscreen);
Canvas.setShowFps(params.showFps);
Canvas.setLimitFps(params.fpsLimit);
Font.applySettings(params);
KeyMapper.setKeyMapping(params);
Canvas.setHasTouchInput(params.touchInput);
} catch (Exception e) {
e.printStackTrace();
}
}
use of javax.microedition.lcdui.keyboard.VirtualKeyboard in project J2ME-Loader by nikita36078.
the class MicroActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme();
super.onCreate(savedInstanceState);
ContextHolder.setCurrentActivity(this);
setContentView(R.layout.activity_micro);
OverlayView overlayView = findViewById(R.id.vOverlay);
layout = findViewById(R.id.displayable_container);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
actionBarEnabled = sp.getBoolean(PREF_TOOLBAR, false);
statusBarEnabled = sp.getBoolean(PREF_STATUSBAR, false);
if (sp.getBoolean(PREF_KEEP_SCREEN, false)) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
ContextHolder.setVibration(sp.getBoolean(PREF_VIBRATION, true));
Intent intent = getIntent();
appName = intent.getStringExtra(KEY_MIDLET_NAME);
Uri data = intent.getData();
if (data == null) {
showErrorDialog("Invalid intent: app path is null");
return;
}
String appPath = data.toString();
microLoader = new MicroLoader(this, appPath);
if (!microLoader.init()) {
Config.startApp(this, appName, appPath, true);
finish();
return;
}
microLoader.applyConfiguration();
VirtualKeyboard vk = ContextHolder.getVk();
int orientation = microLoader.getOrientation();
if (vk != null) {
vk.setView(overlayView);
overlayView.addLayer(vk);
if (vk.isPhone()) {
orientation = ORIENTATION_PORTRAIT;
}
}
setOrientation(orientation);
menuKey = microLoader.getMenuKeyCode();
inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
try {
loadMIDlet();
} catch (Exception e) {
e.printStackTrace();
showErrorDialog(e.toString());
}
}
use of javax.microedition.lcdui.keyboard.VirtualKeyboard in project J2ME-Loader by nikita36078.
the class MicroActivity method handleVkOptions.
private void handleVkOptions(int id) {
VirtualKeyboard vk = ContextHolder.getVk();
if (id == R.id.action_layout_edit_mode) {
vk.setLayoutEditMode(VirtualKeyboard.LAYOUT_KEYS);
Toast.makeText(this, R.string.layout_edit_mode, Toast.LENGTH_SHORT).show();
} else if (id == R.id.action_layout_scale_mode) {
vk.setLayoutEditMode(VirtualKeyboard.LAYOUT_SCALES);
Toast.makeText(this, R.string.layout_scale_mode, Toast.LENGTH_SHORT).show();
} else if (id == R.id.action_layout_edit_finish) {
vk.setLayoutEditMode(VirtualKeyboard.LAYOUT_EOF);
Toast.makeText(this, R.string.layout_edit_finished, Toast.LENGTH_SHORT).show();
showSaveVkAlert(false);
} else if (id == R.id.action_layout_switch) {
showSetLayoutDialog();
} else if (id == R.id.action_hide_buttons) {
showHideButtonDialog();
}
}
use of javax.microedition.lcdui.keyboard.VirtualKeyboard in project J2ME-Loader by nikita36078.
the class MicroActivity method showSetLayoutDialog.
private void showSetLayoutDialog() {
final VirtualKeyboard vk = ContextHolder.getVk();
AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(R.string.layout_switch).setSingleChoiceItems(R.array.PREF_VK_TYPE_ENTRIES, vk.getLayout(), null).setPositiveButton(android.R.string.ok, (d, w) -> {
vk.setLayout(((AlertDialog) d).getListView().getCheckedItemPosition());
if (vk.isPhone()) {
setOrientation(ORIENTATION_PORTRAIT);
} else {
setOrientation(microLoader.getOrientation());
}
});
builder.show();
}
Aggregations