2015-07-30 20:14:55 +02:00
|
|
|
package juloo.keyboard2;
|
|
|
|
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
2015-08-01 00:49:09 +02:00
|
|
|
class KeyValue
|
2015-07-30 20:14:55 +02:00
|
|
|
{
|
2015-08-01 21:36:40 +02:00
|
|
|
public static final int EVENT_NONE = -1;
|
|
|
|
public static final int EVENT_BACKSPACE = -2;
|
|
|
|
public static final int EVENT_DELETE = -3;
|
|
|
|
|
2015-08-01 23:54:38 +02:00
|
|
|
public static final int FLAG_KEEP_ON = 1;
|
2015-08-02 20:21:53 +02:00
|
|
|
public static final int FLAG_LOCK = (1 << 1);
|
|
|
|
public static final int FLAG_CTRL = (1 << 2);
|
|
|
|
public static final int FLAG_SHIFT = (1 << 3);
|
|
|
|
public static final int FLAG_ALT = (1 << 4);
|
|
|
|
public static final int FLAG_NOCHAR = (1 << 5);
|
|
|
|
public static final int FLAG_LOCKED = (1 << 8);
|
2015-08-01 23:54:38 +02:00
|
|
|
|
2015-07-30 20:14:55 +02:00
|
|
|
private String _name;
|
2015-08-01 16:33:30 +02:00
|
|
|
private String _symbol;
|
2015-07-30 20:14:55 +02:00
|
|
|
private char _char;
|
2015-08-01 21:36:40 +02:00
|
|
|
private int _eventCode;
|
2015-08-01 23:54:38 +02:00
|
|
|
private int _flags;
|
2015-07-30 20:14:55 +02:00
|
|
|
|
2015-08-01 16:33:30 +02:00
|
|
|
public String getName()
|
2015-07-30 20:14:55 +02:00
|
|
|
{
|
2015-08-01 16:33:30 +02:00
|
|
|
return (_name);
|
2015-07-30 20:14:55 +02:00
|
|
|
}
|
|
|
|
|
2015-08-01 23:54:38 +02:00
|
|
|
public String getSymbol(boolean upperCase)
|
2015-07-30 20:14:55 +02:00
|
|
|
{
|
2015-08-01 23:54:38 +02:00
|
|
|
if (upperCase)
|
|
|
|
return (_symbol.toUpperCase());
|
2015-08-01 16:33:30 +02:00
|
|
|
return (_symbol);
|
2015-07-30 20:14:55 +02:00
|
|
|
}
|
|
|
|
|
2015-08-01 23:54:38 +02:00
|
|
|
public char getChar(boolean upperCase)
|
2015-07-30 20:14:55 +02:00
|
|
|
{
|
2015-08-01 23:54:38 +02:00
|
|
|
if (upperCase)
|
|
|
|
return (Character.toUpperCase(_char));
|
2015-07-30 20:14:55 +02:00
|
|
|
return (_char);
|
|
|
|
}
|
|
|
|
|
2015-08-01 21:36:40 +02:00
|
|
|
public int getEventCode()
|
|
|
|
{
|
|
|
|
return (_eventCode);
|
|
|
|
}
|
|
|
|
|
2015-08-01 23:54:38 +02:00
|
|
|
public int getFlags()
|
|
|
|
{
|
|
|
|
return (_flags);
|
|
|
|
}
|
|
|
|
|
2015-08-01 16:33:30 +02:00
|
|
|
private static HashMap<String, KeyValue> keys = new HashMap<String, KeyValue>();
|
2015-07-30 20:14:55 +02:00
|
|
|
|
2015-08-01 21:36:40 +02:00
|
|
|
private KeyValue(String name)
|
|
|
|
{
|
2015-08-01 23:54:38 +02:00
|
|
|
this(name, name, name.charAt(0), EVENT_NONE, 0);
|
2015-08-01 21:36:40 +02:00
|
|
|
}
|
|
|
|
|
2015-08-01 16:33:30 +02:00
|
|
|
private KeyValue(String name, String symbol, char c)
|
2015-08-01 21:36:40 +02:00
|
|
|
{
|
2015-08-01 23:54:38 +02:00
|
|
|
this(name, symbol, c, EVENT_NONE, 0);
|
2015-08-01 21:36:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private KeyValue(String name, String symbol, int eventCode)
|
|
|
|
{
|
2015-08-01 23:54:38 +02:00
|
|
|
this(name, symbol, '\0', eventCode, 0);
|
2015-08-01 21:36:40 +02:00
|
|
|
}
|
|
|
|
|
2015-08-01 23:54:38 +02:00
|
|
|
private KeyValue(String name, String symbol, char c, int eventCode, int flags)
|
2015-08-01 16:33:30 +02:00
|
|
|
{
|
|
|
|
_name = name;
|
|
|
|
_symbol = symbol;
|
|
|
|
_char = c;
|
2015-08-01 21:36:40 +02:00
|
|
|
_eventCode = eventCode;
|
2015-08-01 23:54:38 +02:00
|
|
|
_flags = flags;
|
2015-08-01 21:36:40 +02:00
|
|
|
KeyValue.keys.put(name, this);
|
2015-08-01 16:33:30 +02:00
|
|
|
}
|
2015-07-30 20:14:55 +02:00
|
|
|
|
|
|
|
public static KeyValue getKeyByName(String name)
|
|
|
|
{
|
2015-08-01 16:33:30 +02:00
|
|
|
return (KeyValue.keys.get(name));
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
{
|
|
|
|
String chars = "abcdefghijklmnopqrstuvwxyz"
|
|
|
|
+ "àçéèêë"
|
|
|
|
+ "0123456789<>"
|
|
|
|
+ "&é\"'(-_)=°+"
|
|
|
|
+ "~#{[|`\\^@]}"
|
|
|
|
+ "^$ù*,;:!¨£%µ?./§";
|
|
|
|
for (int i = 0; i < chars.length(); i++)
|
2015-08-01 21:36:40 +02:00
|
|
|
new KeyValue(chars.substring(i, i + 1));
|
|
|
|
|
2015-08-02 20:21:53 +02:00
|
|
|
new KeyValue("shift", "⇧", 'S', EVENT_NONE, FLAG_KEEP_ON | FLAG_NOCHAR | FLAG_LOCK | FLAG_SHIFT);
|
|
|
|
new KeyValue("ctrl", "Ctrl", 'C', EVENT_NONE, FLAG_KEEP_ON | FLAG_NOCHAR | FLAG_CTRL);
|
|
|
|
new KeyValue("alt", "Alt", 'A', EVENT_NONE, FLAG_KEEP_ON | FLAG_NOCHAR | FLAG_ALT);
|
2015-08-01 21:36:40 +02:00
|
|
|
|
|
|
|
new KeyValue("backspace", "⌫", EVENT_BACKSPACE);
|
|
|
|
new KeyValue("delete", "⌦", EVENT_DELETE);
|
|
|
|
|
|
|
|
new KeyValue("enter", "↵", KeyEvent.KEYCODE_ENTER);
|
|
|
|
new KeyValue("up", "↑", KeyEvent.KEYCODE_DPAD_UP);
|
|
|
|
new KeyValue("right", "→", KeyEvent.KEYCODE_DPAD_RIGHT);
|
|
|
|
new KeyValue("down", "↓", KeyEvent.KEYCODE_DPAD_DOWN);
|
|
|
|
new KeyValue("left", "←", KeyEvent.KEYCODE_DPAD_LEFT);
|
|
|
|
new KeyValue("page_up", "⇞", KeyEvent.KEYCODE_PAGE_DOWN);
|
|
|
|
new KeyValue("page_down", "⇟", KeyEvent.KEYCODE_PAGE_UP);
|
|
|
|
new KeyValue("home", "↖", KeyEvent.KEYCODE_HOME);
|
|
|
|
new KeyValue("end", "↗", KeyEvent.KEYCODE_MOVE_END);
|
|
|
|
|
|
|
|
new KeyValue("tab", "↹", '\t');
|
|
|
|
new KeyValue("space", " ", ' ');
|
2015-07-30 20:14:55 +02:00
|
|
|
}
|
|
|
|
}
|