Unexpected-Keyboard/srcs/juloo.keyboard2/KeyValue.java

75 lines
1.4 KiB
Java
Raw Normal View History

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
{
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 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 16:33:30 +02:00
public String getSymbol()
2015-07-30 20:14:55 +02:00
{
2015-08-01 16:33:30 +02:00
return (_symbol);
2015-07-30 20:14:55 +02:00
}
public char getChar()
{
return (_char);
}
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 16:33:30 +02:00
private KeyValue(String name, String symbol, char c)
{
_name = name;
_symbol = symbol;
_char = c;
}
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));
}
private static void add(String name, String symbol, char c)
{
keys.put(name, new KeyValue(name, symbol, c));
}
static
{
String chars = "abcdefghijklmnopqrstuvwxyz"
+ "àçéèêë"
+ "0123456789<>"
+ "\"'(-_)=°+"
+ "~#{[|`\\^@]}"
+ "^$ù*,;:!¨£%µ?./§";
for (int i = 0; i < chars.length(); i++)
add(chars.substring(i, i + 1), chars.substring(i, i + 1), chars.charAt(i));
add("shift", "Shift", 'S');
add("ctrl", "Ctrl", 'C');
add("alt", "Alt", 'A');
add("back", "", '\u007F');
add("up", "", 'U');
add("right", "", 'R');
add("down", "", 'D');
add("left", "", 'L');
add("page_up", "", 'U');
add("page_down", "", 'D');
add("home", "", 'H');
add("end", "", 'E');
add("tab", "", '\t');
add("return", "", '\n');
add("space", " ", ' ');
add("delete", "", 'D');
2015-07-30 20:14:55 +02:00
}
}