Search in sources :

Example 1 with VirtualKeyboard

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);
}
Also used : Context(android.content.Context) DataInputStream(java.io.DataInputStream) Bundle(android.os.Bundle) R(ru.playsoftware.j2meloader.R) SparseIntArray(android.util.SparseIntArray) Environment(android.os.Environment) VirtualKeyboard(javax.microedition.lcdui.pointer.VirtualKeyboard) Intent(android.content.Intent) DataContainer(javax.microedition.util.param.DataContainer) Editable(android.text.Editable) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) SeekBar(android.widget.SeekBar) AmbilWarnaDialog(yuku.ambilwarna.AmbilWarnaDialog) SuppressLint(android.annotation.SuppressLint) ContextHolder(javax.microedition.util.ContextHolder) CheckBox(android.widget.CheckBox) DataOutputStream(java.io.DataOutputStream) MenuInflater(android.view.MenuInflater) Locale(java.util.Locale) Menu(android.view.Menu) View(android.view.View) Build(android.os.Build) DialogInterface(android.content.DialogInterface) Canvas(javax.microedition.lcdui.Canvas) FileUtils(ru.playsoftware.j2meloader.util.FileUtils) Font(javax.microedition.lcdui.Font) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) AppCompatActivity(android.support.v7.app.AppCompatActivity) File(java.io.File) Spinner(android.widget.Spinner) AlertDialog(android.support.v7.app.AlertDialog) KeyMapper(ru.playsoftware.j2meloader.settings.KeyMapper) EventQueue(javax.microedition.lcdui.event.EventQueue) Configuration(android.content.res.Configuration) SharedPreferencesContainer(javax.microedition.util.param.SharedPreferencesContainer) EditText(android.widget.EditText) TextWatcher(android.text.TextWatcher) DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) VirtualKeyboard(javax.microedition.lcdui.pointer.VirtualKeyboard) DataInputStream(java.io.DataInputStream) SuppressLint(android.annotation.SuppressLint) FileInputStream(java.io.FileInputStream)

Example 2 with VirtualKeyboard

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);
}
Also used : CommandListener(javax.microedition.lcdui.CommandListener) Command(javax.microedition.lcdui.Command) Canvas(javax.microedition.lcdui.Canvas) VirtualKeyboard(javax.microedition.lcdui.pointer.VirtualKeyboard)

Aggregations

Canvas (javax.microedition.lcdui.Canvas)2 VirtualKeyboard (javax.microedition.lcdui.pointer.VirtualKeyboard)2 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 Configuration (android.content.res.Configuration)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Environment (android.os.Environment)1 AlertDialog (android.support.v7.app.AlertDialog)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 SparseIntArray (android.util.SparseIntArray)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 CheckBox (android.widget.CheckBox)1