mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2025-08-19 17:25:29 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1951448f9e | ||
|
ff01678ba6 | ||
|
d74e8f3b08 | ||
|
ab987c776c | ||
|
6e5be63e25 | ||
|
402bf4990e |
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="juloo.keyboard2" android:versionCode="23" android:versionName="1.16.0" android:hardwareAccelerated="false">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="juloo.keyboard2" android:versionCode="24" android:versionName="1.16.1" android:hardwareAccelerated="false">
|
||||
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="30"/>
|
||||
<application android:label="@string/app_name" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:hardwareAccelerated="false">
|
||||
<service android:name="juloo.keyboard2.Keyboard2" android:label="@string/app_name" android:permission="android.permission.BIND_INPUT_METHOD">
|
||||
|
5
metadata/android/en-US/changelogs/24.txt
Normal file
5
metadata/android/en-US/changelogs/24.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Add back the vibration option.
|
||||
Fix localized keys not in predefined positions.
|
||||
Improvements to layouts.
|
||||
|
||||
Thanks to the contributors: @Thunder-Squirrel
|
@@ -15,6 +15,8 @@
|
||||
<string name="pref_swipe_dist_summary">Abstand der Zeichen in den Ecken der Tasten (%s)</string>
|
||||
<string name="pref_long_timeout_title">Zeitüberschreitung bei Tastenwiederholung</string>
|
||||
<string name="pref_long_interval_title">Intervall der Tastenwiederholung</string>
|
||||
<string name="pref_vibrate_title">Vibration</string>
|
||||
<string name="pref_vibrate_summary">Vibration bei Tastendruck ein-/ausschalten</string>
|
||||
<string name="pref_precise_repeat_title">Präzise Cursorsteuerung</string>
|
||||
<string name="pref_precise_repeat_summary">Geschwindigkeit der Tastenwiederholung durch weniger oder mehr Wischen anpassen</string>
|
||||
<string name="pref_lockable_keys_title">Sperrbare Hilfstasten</string>
|
||||
|
@@ -13,6 +13,8 @@
|
||||
<string name="pref_swipe_dist_summary">Distancia de caracteres en las esquinas de las letras (%s)</string>
|
||||
<string name="pref_long_timeout_title">Tiempo de espera de repetición de tecla</string>
|
||||
<string name="pref_long_interval_title">Intervalo de repetición de tecla</string>
|
||||
<string name="pref_vibrate_title">Vibración</string>
|
||||
<string name="pref_vibrate_summary">Habilitar/deshabilitar vibración al presionar una tecla</string>
|
||||
<string name="pref_precise_repeat_title">Movimientos de cursor preciso</string>
|
||||
<string name="pref_precise_repeat_summary">Modular la velocidad de repetición de teclas según si se desliza más o menos</string>
|
||||
<string name="pref_lockable_keys_title">Bloqueo de teclas modificadoras</string>
|
||||
|
@@ -13,6 +13,8 @@
|
||||
<string name="pref_swipe_dist_summary">La distance des caractères dans les coins (%s)</string>
|
||||
<string name="pref_long_timeout_title">Délai avant répétition</string>
|
||||
<string name="pref_long_interval_title">Écart entre répétitions</string>
|
||||
<string name="pref_vibrate_title">Vibreur</string>
|
||||
<string name="pref_vibrate_summary">Vibration a chaque touche</string>
|
||||
<string name="pref_precise_repeat_title">Mouvement précis du curseur</string>
|
||||
<string name="pref_precise_repeat_summary">Modifier la vitesse de répétition en bougeant le doigt</string>
|
||||
<string name="pref_category_style">Style</string>
|
||||
|
@@ -13,6 +13,8 @@
|
||||
<string name="pref_swipe_dist_summary">키 모서리 문자의 입력 범위 (%s)</string>
|
||||
<string name="pref_long_timeout_title">키 길게 누르기 지연</string>
|
||||
<string name="pref_long_interval_title">키 반복 간격</string>
|
||||
<string name="pref_vibrate_title">진동</string>
|
||||
<string name="pref_vibrate_summary">키 누를 때 진동 키거/끄기</string>
|
||||
<string name="pref_precise_repeat_title">정확한 커서 움직임</string>
|
||||
<string name="pref_precise_repeat_summary">더 많거나 적은 스와이프로 키 반복 조절</string>
|
||||
<string name="pref_category_style">스타일</string>
|
||||
|
@@ -17,6 +17,8 @@
|
||||
<string name="pref_swipe_dist_summary">Taustiņu stūros esošo rakstzīmju attālums (%s)</string>
|
||||
<string name="pref_long_timeout_title">Taustiņa atkārtošanās ātrums</string>
|
||||
<string name="pref_long_interval_title">Taustiņa atkārtošanās aizture</string>
|
||||
<string name="pref_vibrate_title">Trīcēšana</string>
|
||||
<string name="pref_vibrate_summary">Iespējot/atspējot taustiņa piespiešanas trīcēšanu</string>
|
||||
<string name="pref_precise_repeat_title">Pielāgojama kursora kustība</string>
|
||||
<string name="pref_precise_repeat_summary">Mainīt taustiņa atkārtošanās ātrumu ar pavilkšanas attālumu</string>
|
||||
<string name="pref_lockable_keys_title">Slēdzami pārveidotājtaustiņi</string>
|
||||
|
@@ -17,6 +17,8 @@
|
||||
<string name="pref_swipe_dist_summary">Distância até acionar os cantos das teclas (%s)</string>
|
||||
<string name="pref_long_timeout_title">Tempo até repetir tecla</string>
|
||||
<string name="pref_long_interval_title">Intervalo de repetição de tecla</string>
|
||||
<string name="pref_vibrate_title">Vibração</string>
|
||||
<string name="pref_vibrate_summary">Ativar/desativar vibração ao digitar</string>
|
||||
<string name="pref_precise_repeat_title">Precisão nos movimentos do cursor</string>
|
||||
<string name="pref_precise_repeat_summary">Varia a velocidade de repetição a depender do quanto deslizar</string>
|
||||
<string name="pref_lockable_keys_title">Teclas traváveis</string>
|
||||
|
@@ -17,6 +17,8 @@
|
||||
<string name="pref_swipe_dist_summary">Tuşların köşelerindeki karakterlerin uzaklıkları (%s)</string>
|
||||
<string name="pref_long_timeout_title">Tuş tekrarlama beklemesi</string>
|
||||
<string name="pref_long_interval_title">Tuş tekrarlama aralığı</string>
|
||||
<string name="pref_vibrate_title">Titreşim</string>
|
||||
<string name="pref_vibrate_summary">Tuşa basıldığında titreşimi etkinleştir</string>
|
||||
<string name="pref_precise_repeat_title">İmleç hareketini ayarla</string>
|
||||
<string name="pref_precise_repeat_summary">Tuş tekrar hızını az ya da çok kaydırarak ayarla</string>
|
||||
<string name="pref_lockable_keys_title">Sabitlenebilir değiştiriciler</string>
|
||||
|
@@ -15,6 +15,8 @@
|
||||
<string name="pref_swipe_dist_summary">输入按键四角的符号需要滑动的距离 (%s)</string>
|
||||
<string name="pref_long_timeout_title">长按到开始重复输入的时间</string>
|
||||
<string name="pref_long_interval_title">长按后每次重复输入的时间间隔</string>
|
||||
<string name="pref_vibrate_title">振动</string>
|
||||
<string name="pref_vibrate_summary">启用或者禁用按下按键时振动</string>
|
||||
<string name="pref_precise_repeat_title">精确控制光标移速</string>
|
||||
<string name="pref_precise_repeat_summary">按键重复按下速度由手指滑动的距离决定</string>
|
||||
<string name="pref_lockable_keys_title">组合键锁定</string>
|
||||
|
@@ -17,6 +17,8 @@
|
||||
<string name="pref_swipe_dist_summary">Distance of characters in the corners of the keys (%s)</string>
|
||||
<string name="pref_long_timeout_title">Key repeat timeout</string>
|
||||
<string name="pref_long_interval_title">Key repeat interval</string>
|
||||
<string name="pref_vibrate_title">Vibration</string>
|
||||
<string name="pref_vibrate_summary">Enable/disable vibration on keypress</string>
|
||||
<string name="pref_precise_repeat_title">Precise cursor movements</string>
|
||||
<string name="pref_precise_repeat_summary">Modulate key repeat speed by swiping more or less</string>
|
||||
<string name="pref_lockable_keys_title">Lockable modifiers</string>
|
||||
|
@@ -10,12 +10,12 @@
|
||||
<key key0="г" key2="7" key3="&"/>
|
||||
<key key0="ш" key2="8" key3="*"/>
|
||||
<key key0="щ" key2="9" key3="(" key4=")"/>
|
||||
<key key0="з" key2="0"/>
|
||||
<key key0="х" key1="{" key2="}" key4="f11_placeholder"/>
|
||||
<key key0="ъ" key1="[" key2="]" key4="f12_placeholder"/>
|
||||
<key key0="з" key2="0" key3="{" key4="}" />
|
||||
<key key0="х" key3="[" key4="]" key1="f11_placeholder" key2="f12_placeholder"/>
|
||||
|
||||
</row>
|
||||
<row>
|
||||
<key shift="0.5" key0="ф" key1="tab" key2="`"/>
|
||||
<key key0="ф" key1="tab" key2="`"/>
|
||||
<key key0="ы"/>
|
||||
<key key0="в"/>
|
||||
<key key0="а"/>
|
||||
@@ -28,16 +28,16 @@
|
||||
<key key0="э" key2="|" key3="\\"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift"/>
|
||||
<key key0="я"/>
|
||||
<key key0="ч"/>
|
||||
<key key0="с"/>
|
||||
<key key0="м"/>
|
||||
<key key0="и" key2="<" key3="."/>
|
||||
<key key0="т" key2=">" key3=","/>
|
||||
<key key0="ь" key2="\?" key3="/"/>
|
||||
<key key0="б" key2=":" key3=";"/>
|
||||
<key key0="ю" key2=""" key3="'"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.18" key0="shift"/>
|
||||
<key width="0.96" key0="я"/>
|
||||
<key width="0.96" key0="ч"/>
|
||||
<key width="0.96" key0="с"/>
|
||||
<key width="0.96" key0="м"/>
|
||||
<key width="0.96" key0="и" key2="<" key3="."/>
|
||||
<key width="0.96" key0="т" key2=">" key3=","/>
|
||||
<key width="0.96" key0="ь" key1="ъ" key2="\?" key3="/"/>
|
||||
<key width="0.96" key0="б" key2=":" key3=";"/>
|
||||
<key width="0.96" key0="ю" key2=""" key3="'"/>
|
||||
<key width="1.18" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
@@ -20,6 +20,7 @@
|
||||
<CheckBoxPreference android:key="lockable_sub" android:title="Sub" android:defaultValue="false"/>
|
||||
<CheckBoxPreference android:key="lockable_box" android:title="Box" android:defaultValue="false"/>
|
||||
</PreferenceScreen>
|
||||
<CheckBoxPreference android:key="vibrate_enabled" android:title="@string/pref_vibrate_title" android:summary="@string/pref_vibrate_summary" android:defaultValue="true"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_category_style">
|
||||
<ListPreference android:key="theme" android:title="@string/pref_theme" android:summary="%s" android:defaultValue="system" android:entries="@array/pref_theme_entries" android:entryValues="@array/pref_theme_values"/>
|
||||
|
@@ -26,6 +26,7 @@ final class Config
|
||||
public int layout; // Or '-1' for the system defaults
|
||||
public int programming_layout; // Or '-1' for none
|
||||
public float swipe_dist_px;
|
||||
public boolean vibrateEnabled;
|
||||
public long longPressTimeout;
|
||||
public long longPressInterval;
|
||||
public float marginBottom;
|
||||
@@ -60,6 +61,7 @@ final class Config
|
||||
// default values
|
||||
layout = -1;
|
||||
programming_layout = -1;
|
||||
vibrateEnabled = true;
|
||||
longPressTimeout = 600;
|
||||
longPressInterval = 65;
|
||||
marginBottom = res.getDimension(R.dimen.margin_bottom);
|
||||
@@ -115,6 +117,7 @@ final class Config
|
||||
// Take the mean of both dimensions as an approximation of the diagonal.
|
||||
float physical_scaling = (dm.widthPixels + dm.heightPixels) / (dm.xdpi + dm.ydpi);
|
||||
swipe_dist_px = Float.valueOf(prefs.getString("swipe_dist", "15")) * physical_scaling;;
|
||||
vibrateEnabled = prefs.getBoolean("vibrate_enabled", vibrateEnabled);
|
||||
longPressTimeout = prefs.getInt("longpress_timeout", (int)longPressTimeout);
|
||||
longPressInterval = prefs.getInt("longpress_interval", (int)longPressInterval);
|
||||
marginBottom = getDipPref(dm, prefs, "margin_bottom", marginBottom);
|
||||
@@ -160,15 +163,12 @@ final class Config
|
||||
// first iteration then automatically added.
|
||||
final Set<KeyValue> extra_keys = new HashSet<KeyValue>(this.extra_keys);
|
||||
KeyboardData kw = original_kw.mapKeys(new KeyboardData.MapKeyValues() {
|
||||
public KeyValue apply(KeyValue key)
|
||||
public KeyValue apply(KeyValue key, boolean localized)
|
||||
{
|
||||
if (key == null)
|
||||
return null;
|
||||
boolean is_extra_key = extra_keys.contains(key);
|
||||
if (is_extra_key)
|
||||
extra_keys.remove(key);
|
||||
int flags = key.getFlags();
|
||||
if ((flags & KeyValue.FLAG_LOCALIZED) != 0 && !is_extra_key)
|
||||
if (localized && !is_extra_key)
|
||||
return null;
|
||||
switch (key.getKind())
|
||||
{
|
||||
@@ -193,7 +193,7 @@ final class Config
|
||||
break;
|
||||
case Modifier:
|
||||
if (lockable_modifiers.contains(key.getModifier()))
|
||||
return key.withFlags(flags | KeyValue.FLAG_LOCK);
|
||||
return key.withFlags(key.getFlags() | KeyValue.FLAG_LOCK);
|
||||
break;
|
||||
}
|
||||
return key;
|
||||
|
@@ -14,7 +14,8 @@ public class EmojiKeyButton extends Button
|
||||
{
|
||||
super(context, attrs);
|
||||
setOnClickListener(this);
|
||||
_key = KeyValue.getKeyByName(attrs.getAttributeValue(null, "key"));
|
||||
String key_name = attrs.getAttributeValue(null, "key");
|
||||
_key = (key_name == null) ? null : KeyValue.getKeyByName(key_name);
|
||||
setText(_key.getString());
|
||||
if (_key.hasFlags(KeyValue.FLAG_KEY_FONT))
|
||||
setTypeface(Theme.getSpecialKeyFont(context));
|
||||
|
@@ -58,8 +58,6 @@ final class KeyValue
|
||||
public static final int FLAG_SMALLER_FONT = (1 << 25);
|
||||
// Used by [Pointers].
|
||||
public static final int FLAG_LOCKED = (1 << 26);
|
||||
// Language specific keys that are removed from the keyboard by default.
|
||||
public static final int FLAG_LOCALIZED = (1 << 27);
|
||||
|
||||
// Kinds
|
||||
public static final int KIND_CHAR = (0 << 29);
|
||||
@@ -196,27 +194,11 @@ final class KeyValue
|
||||
_code = kind | flags | value;
|
||||
}
|
||||
|
||||
private static String stripPrefix(String s, String prefix)
|
||||
{
|
||||
if (s.startsWith(prefix))
|
||||
return s.substring(prefix.length());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static KeyValue getKeyByName(String name)
|
||||
{
|
||||
if (name == null)
|
||||
return null;
|
||||
KeyValue kv = KeyValue.keys.get(name);
|
||||
KeyValue kv = keys.get(name);
|
||||
if (kv != null)
|
||||
return kv;
|
||||
String localized = stripPrefix(name, "loc ");
|
||||
if (localized != null)
|
||||
{
|
||||
kv = getKeyByName(localized);
|
||||
return kv.withFlags(kv.getFlags() | FLAG_LOCALIZED);
|
||||
}
|
||||
if (name.length() == 1)
|
||||
return new KeyValue(name, KIND_CHAR, name.charAt(0), 0);
|
||||
else
|
||||
@@ -249,9 +231,14 @@ final class KeyValue
|
||||
addKey(name, symbol, KIND_KEYEVENT, code, flags);
|
||||
}
|
||||
|
||||
// Within VALUE_BITS
|
||||
private static int placeholder_unique_id = 0;
|
||||
|
||||
/** Use a unique id as the value because the symbol is shared between every
|
||||
placeholders (it is the empty string). */
|
||||
private static void addPlaceholderKey(String name)
|
||||
{
|
||||
addKey(name, "", KIND_STRING, 0, 0);
|
||||
addKey(name, "", KIND_STRING, placeholder_unique_id++, 0);
|
||||
}
|
||||
|
||||
static
|
||||
|
@@ -296,10 +296,9 @@ public class Keyboard2 extends InputMethodService
|
||||
return;
|
||||
KeyboardData layout =
|
||||
getLayout(_config.programming_layout).mapKeys(new KeyboardData.MapKeyValues() {
|
||||
public KeyValue apply(KeyValue key)
|
||||
public KeyValue apply(KeyValue key, boolean localized)
|
||||
{
|
||||
if (key != null
|
||||
&& key.getKind() == KeyValue.Kind.Event
|
||||
if (key.getKind() == KeyValue.Kind.Event
|
||||
&& key.getEvent() == KeyValue.Event.SWITCH_PROGRAMMING)
|
||||
return KeyValue.getKeyByName("switch_text");
|
||||
return key;
|
||||
|
@@ -18,16 +18,12 @@ import android.view.Window;
|
||||
public class Keyboard2View extends View
|
||||
implements View.OnTouchListener, Pointers.IPointerEventHandler
|
||||
{
|
||||
private static final long VIBRATE_MIN_INTERVAL = 100;
|
||||
|
||||
private KeyboardData _keyboard;
|
||||
|
||||
private Pointers _pointers;
|
||||
|
||||
private Pointers.Modifiers _mods;
|
||||
|
||||
private long _lastVibration = 0;
|
||||
|
||||
private static int _currentWhat = 0;
|
||||
|
||||
private Config _config;
|
||||
@@ -189,15 +185,12 @@ public class Keyboard2View extends View
|
||||
|
||||
private void vibrate()
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
if ((now - _lastVibration) > VIBRATE_MIN_INTERVAL)
|
||||
if (!_config.vibrateEnabled)
|
||||
return ;
|
||||
if (VERSION.SDK_INT >= 5)
|
||||
{
|
||||
_lastVibration = now;
|
||||
if (VERSION.SDK_INT >= 5)
|
||||
{
|
||||
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
|
||||
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
|
||||
}
|
||||
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
|
||||
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,26 +268,30 @@ public class Keyboard2View extends View
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
private void drawLabel(Canvas canvas, KeyValue k, float x, float y, float keyH, boolean isKeyDown)
|
||||
private void drawLabel(Canvas canvas, KeyboardData.Corner k, float x, float y, float keyH, boolean isKeyDown)
|
||||
{
|
||||
k = KeyModifier.modify(k, _mods);
|
||||
if (k == null)
|
||||
return;
|
||||
float textSize = scaleTextSize(k, _config.labelTextSize, keyH);
|
||||
Paint p = _theme.labelPaint(k.hasFlags(KeyValue.FLAG_KEY_FONT));
|
||||
p.setColor(labelColor(k, isKeyDown, _theme.labelColor));
|
||||
KeyValue kv = KeyModifier.modify(k.kv, _mods);
|
||||
if (kv == null)
|
||||
return;
|
||||
float textSize = scaleTextSize(kv, _config.labelTextSize, keyH);
|
||||
Paint p = _theme.labelPaint(kv.hasFlags(KeyValue.FLAG_KEY_FONT));
|
||||
p.setColor(labelColor(kv, isKeyDown, _theme.labelColor));
|
||||
p.setTextSize(textSize);
|
||||
canvas.drawText(k.getString(), x, (keyH - p.ascent() - p.descent()) / 2f + y, p);
|
||||
canvas.drawText(kv.getString(), x, (keyH - p.ascent() - p.descent()) / 2f + y, p);
|
||||
}
|
||||
|
||||
private void drawSubLabel(Canvas canvas, KeyValue k, float x, float y, float keyW, float keyH, Paint.Align a, Vertical v, boolean isKeyDown)
|
||||
private void drawSubLabel(Canvas canvas, KeyboardData.Corner k, float x, float y, float keyW, float keyH, Paint.Align a, Vertical v, boolean isKeyDown)
|
||||
{
|
||||
k = KeyModifier.modify(k, _mods);
|
||||
if (k == null)
|
||||
return;
|
||||
float textSize = scaleTextSize(k, _config.sublabelTextSize, keyH);
|
||||
Paint p = _theme.subLabelPaint(k.hasFlags(KeyValue.FLAG_KEY_FONT), a);
|
||||
p.setColor(labelColor(k, isKeyDown, _theme.subLabelColor));
|
||||
KeyValue kv = KeyModifier.modify(k.kv, _mods);
|
||||
if (kv == null)
|
||||
return;
|
||||
float textSize = scaleTextSize(kv, _config.sublabelTextSize, keyH);
|
||||
Paint p = _theme.subLabelPaint(kv.hasFlags(KeyValue.FLAG_KEY_FONT), a);
|
||||
p.setColor(labelColor(kv, isKeyDown, _theme.subLabelColor));
|
||||
p.setTextSize(textSize);
|
||||
float subPadding = _config.keyPadding;
|
||||
if (v == Vertical.CENTER)
|
||||
@@ -305,7 +302,7 @@ public class Keyboard2View extends View
|
||||
x += keyW / 2f;
|
||||
else
|
||||
x += (a == Paint.Align.LEFT) ? subPadding : keyW - subPadding;
|
||||
canvas.drawText(k.getString(), x, y, p);
|
||||
canvas.drawText(kv.getString(), x, y, p);
|
||||
}
|
||||
|
||||
private float scaleTextSize(KeyValue k, float rel_size, float keyH)
|
||||
|
@@ -177,11 +177,11 @@ class KeyboardData
|
||||
** 0
|
||||
** 3 4
|
||||
*/
|
||||
public final KeyValue key0;
|
||||
public final KeyValue key1;
|
||||
public final KeyValue key2;
|
||||
public final KeyValue key3;
|
||||
public final KeyValue key4;
|
||||
public final Corner key0;
|
||||
public final Corner key1;
|
||||
public final Corner key2;
|
||||
public final Corner key3;
|
||||
public final Corner key4;
|
||||
|
||||
/** Key width in relative unit. */
|
||||
public final float width;
|
||||
@@ -190,7 +190,7 @@ class KeyboardData
|
||||
/** Put keys 1 to 4 on the edges instead of the corners. */
|
||||
public final boolean edgekeys;
|
||||
|
||||
protected Key(KeyValue k0, KeyValue k1, KeyValue k2, KeyValue k3, KeyValue k4, float w, float s, boolean e)
|
||||
protected Key(Corner k0, Corner k1, Corner k2, Corner k3, Corner k4, float w, float s, boolean e)
|
||||
{
|
||||
key0 = k0;
|
||||
key1 = k1;
|
||||
@@ -204,11 +204,11 @@ class KeyboardData
|
||||
|
||||
public static Key parse(XmlResourceParser parser) throws Exception
|
||||
{
|
||||
KeyValue k0 = KeyValue.getKeyByName(parser.getAttributeValue(null, "key0"));
|
||||
KeyValue k1 = KeyValue.getKeyByName(parser.getAttributeValue(null, "key1"));
|
||||
KeyValue k2 = KeyValue.getKeyByName(parser.getAttributeValue(null, "key2"));
|
||||
KeyValue k3 = KeyValue.getKeyByName(parser.getAttributeValue(null, "key3"));
|
||||
KeyValue k4 = KeyValue.getKeyByName(parser.getAttributeValue(null, "key4"));
|
||||
Corner k0 = Corner.parse_of_attr(parser, "key0");
|
||||
Corner k1 = Corner.parse_of_attr(parser, "key1");
|
||||
Corner k2 = Corner.parse_of_attr(parser, "key2");
|
||||
Corner k3 = Corner.parse_of_attr(parser, "key3");
|
||||
Corner k4 = Corner.parse_of_attr(parser, "key4");
|
||||
float width = parser.getAttributeFloatValue(null, "width", 1f);
|
||||
float shift = parser.getAttributeFloatValue(null, "shift", 0.f);
|
||||
boolean edgekeys = parser.getAttributeBooleanValue(null, "edgekeys", false);
|
||||
@@ -225,27 +225,30 @@ class KeyboardData
|
||||
|
||||
public KeyValue getKeyValue(int i)
|
||||
{
|
||||
Corner c;
|
||||
switch (i)
|
||||
{
|
||||
case 0: return key0;
|
||||
case 1: return key1;
|
||||
case 2: return key2;
|
||||
case 3: return key3;
|
||||
case 4: return key4;
|
||||
default: return null;
|
||||
case 0: c = key0; break;
|
||||
case 1: c = key1; break;
|
||||
case 2: c = key2; break;
|
||||
case 3: c = key3; break;
|
||||
case 4: c = key4; break;
|
||||
default: c = null; break;
|
||||
}
|
||||
return (c == null) ? null : c.kv;
|
||||
}
|
||||
|
||||
public Key withKeyValue(int i, KeyValue kv)
|
||||
{
|
||||
KeyValue k0 = key0, k1 = key1, k2 = key2, k3 = key3, k4 = key4;
|
||||
Corner k0 = key0, k1 = key1, k2 = key2, k3 = key3, k4 = key4;
|
||||
Corner k = Corner.of_kv(kv);
|
||||
switch (i)
|
||||
{
|
||||
case 0: k0 = kv; break;
|
||||
case 1: k1 = kv; break;
|
||||
case 2: k2 = kv; break;
|
||||
case 3: k3 = kv; break;
|
||||
case 4: k4 = kv; break;
|
||||
case 0: k0 = k; break;
|
||||
case 1: k1 = k; break;
|
||||
case 2: k2 = k; break;
|
||||
case 3: k3 = k; break;
|
||||
case 4: k4 = k; break;
|
||||
}
|
||||
return new Key(k0, k1, k2, k3, k4, width, shift, edgekeys);
|
||||
}
|
||||
@@ -255,6 +258,7 @@ class KeyboardData
|
||||
*/
|
||||
public KeyValue getAtDirection(int direction)
|
||||
{
|
||||
Corner c = null;
|
||||
if (edgekeys)
|
||||
{
|
||||
// \ 1 /
|
||||
@@ -264,10 +268,10 @@ class KeyboardData
|
||||
// / 4 \
|
||||
switch (direction)
|
||||
{
|
||||
case 2: case 3: return key1;
|
||||
case 4: case 5: return key2;
|
||||
case 6: case 7: return key4;
|
||||
case 8: case 1: return key3;
|
||||
case 2: case 3: c = key1; break;
|
||||
case 4: case 5: c = key2; break;
|
||||
case 6: case 7: c = key4; break;
|
||||
case 8: case 1: c = key3; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -279,13 +283,56 @@ class KeyboardData
|
||||
// 3 | 4
|
||||
switch (direction)
|
||||
{
|
||||
case 1: case 2: return key1;
|
||||
case 3: case 4: return key2;
|
||||
case 5: case 6: return key4;
|
||||
case 7: case 8: return key3;
|
||||
case 1: case 2: c = key1; break;
|
||||
case 3: case 4: c = key2; break;
|
||||
case 5: case 6: c = key4; break;
|
||||
case 7: case 8: c = key3; break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return (c == null) ? null : c.kv;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Corner
|
||||
{
|
||||
public final KeyValue kv;
|
||||
/** Whether the kv is marked with the "loc " prefix. To be removed if not
|
||||
specified in the [extra_keys]. */
|
||||
public final boolean localized;
|
||||
|
||||
protected Corner(KeyValue k, boolean l)
|
||||
{
|
||||
kv = k;
|
||||
localized = l;
|
||||
}
|
||||
|
||||
public static Corner parse_of_attr(XmlResourceParser parser, String attr) throws Exception
|
||||
{
|
||||
String name = parser.getAttributeValue(null, attr);
|
||||
boolean localized = false;
|
||||
|
||||
if (name == null)
|
||||
return null;
|
||||
String name_loc = stripPrefix(name, "loc ");
|
||||
if (name_loc != null)
|
||||
{
|
||||
localized = true;
|
||||
name = name_loc;
|
||||
}
|
||||
return new Corner(KeyValue.getKeyByName(name), localized);
|
||||
}
|
||||
|
||||
public static Corner of_kv(KeyValue kv)
|
||||
{
|
||||
return new Corner(kv, false);
|
||||
}
|
||||
|
||||
private static String stripPrefix(String s, String prefix)
|
||||
{
|
||||
if (s.startsWith(prefix))
|
||||
return s.substring(prefix.length());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,13 +342,23 @@ class KeyboardData
|
||||
}
|
||||
|
||||
public static abstract class MapKeyValues implements MapKey {
|
||||
abstract public KeyValue apply(KeyValue kv);
|
||||
abstract public KeyValue apply(KeyValue c, boolean localized);
|
||||
|
||||
public Key apply(Key k)
|
||||
{
|
||||
return new Key(apply(k.key0), apply(k.key1), apply(k.key2),
|
||||
apply(k.key3), apply(k.key4), k.width, k.shift, k.edgekeys);
|
||||
}
|
||||
|
||||
private Corner apply(Corner c)
|
||||
{
|
||||
if (c == null)
|
||||
return null;
|
||||
KeyValue kv = apply(c.kv, c.localized);
|
||||
if (kv == null)
|
||||
return null;
|
||||
return Corner.of_kv(kv);
|
||||
}
|
||||
}
|
||||
|
||||
/** Parsing utils */
|
||||
|
@@ -140,7 +140,7 @@ public final class Pointers implements Handler.Callback
|
||||
// Don't take latched modifiers into account if an other key is pressed.
|
||||
// The other key already "own" the latched modifiers and will clear them.
|
||||
Modifiers mods = getModifiers(isOtherPointerDown());
|
||||
KeyValue value = _handler.modifyKey(key.key0, mods);
|
||||
KeyValue value = handleKV(key.key0, mods);
|
||||
Pointer ptr = new Pointer(pointerId, key, value, x, y, mods);
|
||||
_ptrs.add(ptr);
|
||||
if (value != null && !value.hasFlags(KeyValue.FLAG_SPECIAL))
|
||||
@@ -159,7 +159,7 @@ public final class Pointers implements Handler.Callback
|
||||
private KeyValue getKeyAtDirection(Pointer ptr, int direction)
|
||||
{
|
||||
if (direction == 0)
|
||||
return _handler.modifyKey(ptr.key.key0, ptr.modifiers);
|
||||
return handleKV(ptr.key.key0, ptr.modifiers);
|
||||
KeyValue k;
|
||||
for (int i = 0; i > -3; i = (~i>>31) - i)
|
||||
{
|
||||
@@ -173,6 +173,13 @@ public final class Pointers implements Handler.Callback
|
||||
return null;
|
||||
}
|
||||
|
||||
private KeyValue handleKV(KeyboardData.Corner c, Modifiers modifiers)
|
||||
{
|
||||
if (c == null)
|
||||
return null;
|
||||
return _handler.modifyKey(c.kv, modifiers);
|
||||
}
|
||||
|
||||
public void onTouchMove(float x, float y, int pointerId)
|
||||
{
|
||||
Pointer ptr = getPtr(pointerId);
|
||||
|
Reference in New Issue
Block a user