mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2025-08-18 20:55:14 +02:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
dd5fce6cae | ||
|
1a18ea56ca | ||
|
68945ff227 | ||
|
5e01198500 | ||
|
7a3312fd01 | ||
|
ebfb8f3b39 | ||
|
6a19c7a56d | ||
|
b5edcbeb20 | ||
|
41dfa844f1 | ||
|
8fb89c5c71 | ||
|
3fbc35135e | ||
|
1e6e3ab22a |
@@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="juloo.keyboard2"
|
package="juloo.keyboard2"
|
||||||
android:versionCode="9"
|
android:versionCode="10"
|
||||||
android:versionName="1.8"
|
android:versionName="1.9"
|
||||||
android:hardwareAccelerated="false">
|
android:hardwareAccelerated="false">
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="3"
|
<uses-sdk android:minSdkVersion="4"
|
||||||
android:targetSdkVersion="29" />
|
android:targetSdkVersion="29" />
|
||||||
|
|
||||||
<application android:label="@string/app_name"
|
<application android:label="@string/app_name"
|
||||||
|
@@ -5,4 +5,19 @@
|
|||||||
<item>azerty</item>
|
<item>azerty</item>
|
||||||
<item>qwerty</item>
|
<item>qwerty</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string name="pref_accents_default">1</string>
|
||||||
|
|
||||||
|
<string-array name="pref_accents_entries">
|
||||||
|
<item>@string/pref_accents_e_all_installed</item>
|
||||||
|
<item>@string/pref_accents_e_selected</item>
|
||||||
|
<item>@string/pref_accents_e_all</item>
|
||||||
|
<item>@string/pref_accents_e_none</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="pref_accents_values">
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
<item>3</item>
|
||||||
|
<item>4</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
<string name="settings_activity_label">Unexpected Keyboard Settings</string>
|
<string name="settings_activity_label">Unexpected Keyboard Settings</string>
|
||||||
|
|
||||||
<string name="subtype_label_azerty">%s</string>
|
<string name="subtype_label">%s</string>
|
||||||
<string name="subtype_label_qwerty">%s</string>
|
|
||||||
|
|
||||||
<string name="pref_category_layout">Layout</string>
|
<string name="pref_category_layout">Layout</string>
|
||||||
<string name="pref_layout_title">Change keyboard layout</string>
|
<string name="pref_layout_title">Change keyboard layout</string>
|
||||||
@@ -16,8 +15,13 @@
|
|||||||
<item>Azerty</item>
|
<item>Azerty</item>
|
||||||
<item>Qwerty</item>
|
<item>Qwerty</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string name="pref_disable_accent_keys_title">Toggle accent keys</string>
|
|
||||||
<string name="pref_disable_accent_keys_summary">Whether to remove the accent keys from the keyboard</string>
|
<string name="pref_accents_title">Accents</string>
|
||||||
|
<string name="pref_accents_summary">%s</string>
|
||||||
|
<string name="pref_accents_e_all_installed">Show accents for all the installed languages</string>
|
||||||
|
<string name="pref_accents_e_selected">Show accents for the selected language</string>
|
||||||
|
<string name="pref_accents_e_all">Show every accents</string>
|
||||||
|
<string name="pref_accents_e_none">Hide accents</string>
|
||||||
|
|
||||||
<string name="pref_category_typing">Typing</string>
|
<string name="pref_category_typing">Typing</string>
|
||||||
<string name="pref_preci_title">Precision</string>
|
<string name="pref_preci_title">Precision</string>
|
||||||
|
@@ -3,23 +3,23 @@
|
|||||||
<row>
|
<row>
|
||||||
<key key0="a" key1="esc" key2="1" key3="&" />
|
<key key0="a" key1="esc" key2="1" key3="&" />
|
||||||
<key key0="z" key2="2" key4="~" />
|
<key key0="z" key2="2" key4="~" />
|
||||||
<key key0="e" key1="accent_aigu" key2="3" key3=""" key4="\#" />
|
<key key0="e" key2="3" key3=""" key4="\#" />
|
||||||
<key key0="r" key2="4" key3="'" />
|
<key key0="r" key2="4" key3="'" />
|
||||||
<key key0="t" key2="5" key3="(" key4=")" />
|
<key key0="t" key2="5" key3="(" key4=")" />
|
||||||
<key key0="y" key2="6" key3="-" key4="|" />
|
<key key0="y" key2="6" key3="-" key4="|" />
|
||||||
<key key0="u" key1="accent_grave" key2="7" key4="`" />
|
<key key0="u" key2="7" key4="`" />
|
||||||
<key key0="i" key1="accent_trema" key2="8" key3="_" key4="\\" />
|
<key key0="i" key2="8" key3="_" key4="\\" />
|
||||||
<key key0="o" key1="accent_circonflexe" key2="9" />
|
<key key0="o" key2="9" />
|
||||||
<key key0="p" key1="insert" key2="0" key4="\@" />
|
<key key0="p" key2="0" key4="\@" />
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<key key0="q" key1="tab" />
|
<key key0="q" key1="tab" />
|
||||||
<key key0="s" />
|
<key key0="s" />
|
||||||
<key key0="d" />
|
<key key0="d" key1="accent_grave" key3="accent_aigu" />
|
||||||
<key key0="f" key3="{" key4="}" />
|
<key key0="f" key3="{" key4="}" />
|
||||||
<key key0="g" key3="[" key4="]" />
|
<key key0="g" key3="[" key4="]" />
|
||||||
<key key0="h" key3="=" key4="+" />
|
<key key0="h" key3="=" key4="+" />
|
||||||
<key key0="j" key3="^" />
|
<key key0="j" key1="accent_trema" key2="accent_circonflexe" key3="^" />
|
||||||
<key key0="k" key2="€" key3="$" key4="£" />
|
<key key0="k" key2="€" key3="$" key4="£" />
|
||||||
<key key0="l" key2="%" />
|
<key key0="l" key2="%" />
|
||||||
<key key0="m" key4="*" />
|
<key key0="m" key4="*" />
|
||||||
|
@@ -2,18 +2,32 @@
|
|||||||
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
|
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:settingsActivity="juloo.keyboard2.SettingsActivity"
|
android:settingsActivity="juloo.keyboard2.SettingsActivity"
|
||||||
android:supportsSwitchingToNextInputMethod="true">
|
android:supportsSwitchingToNextInputMethod="true">
|
||||||
<subtype android:label="@string/subtype_label_qwerty"
|
<subtype android:label="@string/subtype_label"
|
||||||
android:languageTag="en"
|
android:languageTag="en"
|
||||||
android:imeSubtypeLocale="en_US"
|
android:imeSubtypeLocale="en_US"
|
||||||
android:imeSubtypeMode="keyboard"
|
android:imeSubtypeMode="keyboard"
|
||||||
android:isAsciiCapable="true"
|
android:isAsciiCapable="true"
|
||||||
android:imeSubtypeExtraValue="default_layout=qwerty"
|
android:imeSubtypeExtraValue="default_layout=qwerty"
|
||||||
/>
|
/>
|
||||||
<subtype android:label="@string/subtype_label_azerty"
|
<subtype android:label="@string/subtype_label"
|
||||||
android:languageTag="fr"
|
android:languageTag="fr"
|
||||||
android:imeSubtypeLocale="fr_FR"
|
android:imeSubtypeLocale="fr_FR"
|
||||||
android:imeSubtypeMode="keyboard"
|
android:imeSubtypeMode="keyboard"
|
||||||
android:isAsciiCapable="true"
|
android:isAsciiCapable="true"
|
||||||
android:imeSubtypeExtraValue="default_layout=azerty"
|
android:imeSubtypeExtraValue="default_layout=azerty,accents=grave|aigu|circonflexe|cedille|trema"
|
||||||
|
/>
|
||||||
|
<subtype android:label="@string/subtype_label"
|
||||||
|
android:languageTag="es"
|
||||||
|
android:imeSubtypeLocale="es_ES"
|
||||||
|
android:imeSubtypeMode="keyboard"
|
||||||
|
android:isAsciiCapable="true"
|
||||||
|
android:imeSubtypeExtraValue="default_layout=qwerty,accents=aigu|tilde|trema"
|
||||||
|
/>
|
||||||
|
<subtype android:label="@string/subtype_label"
|
||||||
|
android:languageTag="it"
|
||||||
|
android:imeSubtypeLocale="it_IT"
|
||||||
|
android:imeSubtypeMode="keyboard"
|
||||||
|
android:isAsciiCapable="true"
|
||||||
|
android:imeSubtypeExtraValue="default_layout=qwerty,accents=grave|aigu"
|
||||||
/>
|
/>
|
||||||
</input-method>
|
</input-method>
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
<row>
|
<row>
|
||||||
<key width="0.75" key0="esc" key2="~" key4="!" />
|
<key width="0.75" key0="esc" key2="~" key4="!" />
|
||||||
<key width="0.75" key0="(" key2="[" key4="{" />
|
<key width="0.75" key0="(" key2="[" key4="{" />
|
||||||
<key key0="7" key2="<" key3="home" />
|
<key key0="7" key3="<" key4=">" />
|
||||||
<key key0="8" />
|
<key key0="8" key2="∞" />
|
||||||
<key key0="9" key2="page_up" key3=">" />
|
<key key0="9" key2="π" />
|
||||||
<key width="0.75" key0="*" />
|
<key width="0.75" key0="*" key1="√" key2="×" />
|
||||||
<key width="0.75" key0="/" key1="%" key3=":" />
|
<key width="0.75" key0="/" key1="%" key3="÷" />
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<key width="0.75" key0="tab" key1=";" key2="|" key4="\\" />
|
<key width="0.75" key0="tab" key1=";" key2="|" key4="\\" />
|
||||||
@@ -15,14 +15,14 @@
|
|||||||
<key key0="4" />
|
<key key0="4" />
|
||||||
<key key0="5" key1="up" key2="right" key3="left" key4="down" />
|
<key key0="5" key1="up" key2="right" key3="left" key4="down" />
|
||||||
<key key0="6" />
|
<key key0="6" />
|
||||||
<key width="0.75" key0="+" key2="$" />
|
<key width="0.75" key0="+" key1="Σ" key2="$" />
|
||||||
<key width="0.75" key0="-" key2="^" />
|
<key width="0.75" key0="-" key2="^" />
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<key shift="0.35" width="1.15" key0="shift" key4="alt" />
|
<key shift="0.35" width="1.15" key0="shift" key2="fn" key4="alt" />
|
||||||
<key key0="1" key3="end" />
|
<key key0="1" key1="superscript" key3="subscript" />
|
||||||
<key key0="2" />
|
<key key0="2" />
|
||||||
<key key0="3" key4="page_down" />
|
<key key0="3" />
|
||||||
<key width="1.15" key0="backspace" key2="delete" />
|
<key width="1.15" key0="backspace" key2="delete" />
|
||||||
</row>
|
</row>
|
||||||
<row height="0.95">
|
<row height="0.95">
|
||||||
@@ -30,6 +30,6 @@
|
|||||||
<key width="1.5" key0="0" />
|
<key width="1.5" key0="0" />
|
||||||
<key width="0.75" key0="." key2="," />
|
<key width="0.75" key0="." key2="," />
|
||||||
<key width="0.75" key0="space" key1=""" key2="'" key4="_" />
|
<key width="0.75" key0="space" key1=""" key2="'" key4="_" />
|
||||||
<key width="1.5" key0="enter" key3="=" />
|
<key width="1.5" key0="enter" key2="±" key3="=" />
|
||||||
</row>
|
</row>
|
||||||
</keyboard>
|
</keyboard>
|
||||||
|
@@ -3,23 +3,23 @@
|
|||||||
<row>
|
<row>
|
||||||
<key key0="q" key1="esc" key2="1" key3="~" key4="!" />
|
<key key0="q" key1="esc" key2="1" key3="~" key4="!" />
|
||||||
<key key0="w" key2="2" key3="\@" />
|
<key key0="w" key2="2" key3="\@" />
|
||||||
<key key0="e" key1="accent_aigu" key2="3" key3="\#" />
|
<key key0="e" key2="3" key3="\#" />
|
||||||
<key key0="r" key2="4" key3="$" />
|
<key key0="r" key2="4" key3="$" />
|
||||||
<key key0="t" key2="5" key3="%" />
|
<key key0="t" key2="5" key3="%" />
|
||||||
<key key0="y" key2="6" key3="^" />
|
<key key0="y" key2="6" key3="^" />
|
||||||
<key key0="u" key1="accent_grave" key2="7" key3="&" />
|
<key key0="u" key2="7" key3="&" />
|
||||||
<key key0="i" key1="accent_trema" key2="8" key3="*" />
|
<key key0="i" key2="8" key3="*" />
|
||||||
<key key0="o" key1="accent_circonflexe" key2="9" key3="(" key4=")" />
|
<key key0="o" key2="9" key3="(" key4=")" />
|
||||||
<key key0="p" key1="insert" key2="0" />
|
<key key0="p" key2="0" />
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<key shift="0.5" key0="a" key1="tab" key2="`" />
|
<key shift="0.5" key0="a" key1="tab" key2="`" />
|
||||||
<key key0="s" />
|
<key key0="s" />
|
||||||
<key key0="d" />
|
<key key0="d" key1="accent_grave" key3="accent_aigu" />
|
||||||
<key key0="f" />
|
<key key0="f" />
|
||||||
<key key0="g" key2="-" key3="_" />
|
<key key0="g" key2="-" key3="_" />
|
||||||
<key key0="h" key2="=" key3="+" />
|
<key key0="h" key2="=" key3="+" />
|
||||||
<key key0="j" key4="}" key3="{" />
|
<key key0="j" key1="accent_trema" key2="accent_circonflexe" key4="}" key3="{" />
|
||||||
<key key0="k" key4="]" key3="[" />
|
<key key0="k" key4="]" key3="[" />
|
||||||
<key key0="l" key2="|" key3="\\" />
|
<key key0="l" key2="|" key3="\\" />
|
||||||
</row>
|
</row>
|
||||||
|
@@ -9,12 +9,13 @@
|
|||||||
android:entries="@array/pref_layout_entries"
|
android:entries="@array/pref_layout_entries"
|
||||||
android:entryValues="@array/pref_layout_values" />
|
android:entryValues="@array/pref_layout_values" />
|
||||||
/>
|
/>
|
||||||
<CheckBoxPreference
|
<ListPreference
|
||||||
android:key="disable_accent_keys"
|
android:key="accents"
|
||||||
android:title="@string/pref_disable_accent_keys_title"
|
android:title="@string/pref_accents_title"
|
||||||
android:summary="@string/pref_disable_accent_keys_summary"
|
android:summary="@string/pref_accents_summary"
|
||||||
android:defaultValue="false"
|
android:defaultValue="@string/pref_accents_default"
|
||||||
/>
|
android:entries="@array/pref_accents_entries"
|
||||||
|
android:entryValues="@array/pref_accents_values" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/pref_category_typing">
|
<PreferenceCategory android:title="@string/pref_category_typing">
|
||||||
<juloo.common.SlideBarPreference
|
<juloo.common.SlideBarPreference
|
||||||
|
@@ -9,12 +9,14 @@ class Config
|
|||||||
{
|
{
|
||||||
private Keyboard2 _context;
|
private Keyboard2 _context;
|
||||||
|
|
||||||
|
// From resources
|
||||||
public final float marginTop;
|
public final float marginTop;
|
||||||
public final float keyPadding;
|
public final float keyPadding;
|
||||||
public final float keyVerticalInterval;
|
public final float keyVerticalInterval;
|
||||||
public final float keyHorizontalInterval;
|
public final float keyHorizontalInterval;
|
||||||
public final float keyRound;
|
public final float keyRound;
|
||||||
|
|
||||||
|
// From preferences
|
||||||
public int layout; // Or '-1' for the system defaults
|
public int layout; // Or '-1' for the system defaults
|
||||||
public float subValueDist;
|
public float subValueDist;
|
||||||
public boolean vibrateEnabled;
|
public boolean vibrateEnabled;
|
||||||
@@ -24,11 +26,13 @@ class Config
|
|||||||
public float marginBottom;
|
public float marginBottom;
|
||||||
public float keyHeight;
|
public float keyHeight;
|
||||||
public float horizontalMargin;
|
public float horizontalMargin;
|
||||||
public boolean disableAccentKeys;
|
|
||||||
public boolean preciseRepeat;
|
public boolean preciseRepeat;
|
||||||
public float characterSize; // Ratio
|
public float characterSize; // Ratio
|
||||||
|
public int accents; // Values are R.values.pref_accents_v_*
|
||||||
|
|
||||||
|
// Dynamically set
|
||||||
public boolean shouldOfferSwitchingToNextInputMethod;
|
public boolean shouldOfferSwitchingToNextInputMethod;
|
||||||
|
public int accent_flags_to_remove;
|
||||||
|
|
||||||
public Config(Keyboard2 context)
|
public Config(Keyboard2 context)
|
||||||
{
|
{
|
||||||
@@ -51,13 +55,14 @@ class Config
|
|||||||
marginBottom = res.getDimension(R.dimen.margin_bottom);
|
marginBottom = res.getDimension(R.dimen.margin_bottom);
|
||||||
keyHeight = res.getDimension(R.dimen.key_height);
|
keyHeight = res.getDimension(R.dimen.key_height);
|
||||||
horizontalMargin = res.getDimension(R.dimen.horizontal_margin);
|
horizontalMargin = res.getDimension(R.dimen.horizontal_margin);
|
||||||
disableAccentKeys = false;
|
|
||||||
preciseRepeat = true;
|
preciseRepeat = true;
|
||||||
characterSize = 1.f;
|
characterSize = 1.f;
|
||||||
|
accents = 0;
|
||||||
// from prefs
|
// from prefs
|
||||||
refresh();
|
refresh();
|
||||||
// initialized later
|
// initialized later
|
||||||
shouldOfferSwitchingToNextInputMethod = false;
|
shouldOfferSwitchingToNextInputMethod = false;
|
||||||
|
accent_flags_to_remove = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -76,9 +81,9 @@ class Config
|
|||||||
marginBottom = getDipPref(prefs, "margin_bottom", marginBottom);
|
marginBottom = getDipPref(prefs, "margin_bottom", marginBottom);
|
||||||
keyHeight = getDipPref(prefs, "key_height", keyHeight);
|
keyHeight = getDipPref(prefs, "key_height", keyHeight);
|
||||||
horizontalMargin = getDipPref(prefs, "horizontal_margin", horizontalMargin);
|
horizontalMargin = getDipPref(prefs, "horizontal_margin", horizontalMargin);
|
||||||
disableAccentKeys = prefs.getBoolean("disable_accent_keys", disableAccentKeys);
|
|
||||||
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
|
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
|
||||||
characterSize = prefs.getFloat("character_size", characterSize);
|
characterSize = prefs.getFloat("character_size", characterSize);
|
||||||
|
accents = Integer.valueOf(prefs.getString("accents", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getDipPref(SharedPreferences prefs, String pref_name, float def)
|
private float getDipPref(SharedPreferences prefs, String pref_name, float def)
|
||||||
@@ -102,4 +107,18 @@ class Config
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Used for the accents option. */
|
||||||
|
public static int accentFlag_of_name(String name)
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "grave": return KeyValue.FLAG_ACCENT1;
|
||||||
|
case "aigu": return KeyValue.FLAG_ACCENT2;
|
||||||
|
case "circonflexe": return KeyValue.FLAG_ACCENT3;
|
||||||
|
case "tilde": return KeyValue.FLAG_ACCENT4;
|
||||||
|
case "cedille": return KeyValue.FLAG_ACCENT5;
|
||||||
|
case "trema": return KeyValue.FLAG_ACCENT6;
|
||||||
|
default: throw new RuntimeException(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,31 +20,46 @@ class KeyModifier
|
|||||||
KeyValue r = ks.get(flags);
|
KeyValue r = ks.get(flags);
|
||||||
if (r != null) // Found in cache
|
if (r != null) // Found in cache
|
||||||
return r;
|
return r;
|
||||||
if ((r = handleChar(k, flags)) != null) ;
|
r = k;
|
||||||
else if ((r = handleFn(k, flags)) != null) ;
|
r = handleFn(r, flags);
|
||||||
else r = k;
|
r = handleShift(r, flags);
|
||||||
|
r = handleAccents(r, flags);
|
||||||
ks.put(flags, r);
|
ks.put(flags, r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns [null] if had no effect. */
|
private static KeyValue handleAccents(KeyValue k, int flags)
|
||||||
private static KeyValue handleChar(KeyValue k, int flags)
|
|
||||||
{
|
{
|
||||||
char c = k.char_;
|
if (k.char_ == KeyValue.CHAR_NONE || (flags & KeyValue.FLAGS_ACCENTS) == 0)
|
||||||
if (c == KeyValue.CHAR_NONE)
|
return k;
|
||||||
return null;
|
char c = handleAccentChar(k.char_, flags);
|
||||||
if ((flags & KeyValue.FLAG_SHIFT) != 0) // Shift
|
|
||||||
c = Character.toUpperCase(c);
|
|
||||||
if ((flags & KeyValue.FLAGS_ACCENTS) != 0) // Accents, after shift is applied
|
|
||||||
c = handleAccentChar(c, flags);
|
|
||||||
if (c == 0 || c == k.char_)
|
if (c == 0 || c == k.char_)
|
||||||
return null;
|
return k;
|
||||||
return k.withCharAndSymbol(String.valueOf(c), c);
|
return k.withCharAndSymbol(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static KeyValue handleShift(KeyValue k, int flags)
|
||||||
|
{
|
||||||
|
if ((flags & KeyValue.FLAG_SHIFT) == 0)
|
||||||
|
return k;
|
||||||
|
char c = k.char_;
|
||||||
|
if (k.char_ != KeyValue.CHAR_NONE)
|
||||||
|
c = Character.toUpperCase(c);
|
||||||
|
if (c == k.char_) // More rules if toUpperCase() did nothing
|
||||||
|
switch (k.symbol)
|
||||||
|
{
|
||||||
|
case "→": c = '⇒'; break;
|
||||||
|
case "←": c = '⇐'; break;
|
||||||
|
case "<": c = '«'; break;
|
||||||
|
case ">": c = '»'; break;
|
||||||
|
case "“": c = '”'; break;
|
||||||
|
default: return k;
|
||||||
|
}
|
||||||
|
return k.withCharAndSymbol(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static char handleAccentChar(char c, int flags)
|
private static char handleAccentChar(char c, int flags)
|
||||||
{
|
{
|
||||||
char accent;
|
|
||||||
switch ((flags & KeyValue.FLAGS_ACCENTS))
|
switch ((flags & KeyValue.FLAGS_ACCENTS))
|
||||||
{
|
{
|
||||||
case KeyValue.FLAG_ACCENT1:
|
case KeyValue.FLAG_ACCENT1:
|
||||||
@@ -58,6 +73,36 @@ class KeyModifier
|
|||||||
default: return (char)KeyCharacterMap.getDeadChar('\u00B4', c);
|
default: return (char)KeyCharacterMap.getDeadChar('\u00B4', c);
|
||||||
}
|
}
|
||||||
case KeyValue.FLAG_ACCENT3:
|
case KeyValue.FLAG_ACCENT3:
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case '*': return '°';
|
||||||
|
default: return (char)KeyCharacterMap.getDeadChar('\u02C6', c);
|
||||||
|
}
|
||||||
|
case KeyValue.FLAG_ACCENT4:
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case '?': return '¿';
|
||||||
|
case '!': return '¡';
|
||||||
|
default: return (char)KeyCharacterMap.getDeadChar('\u02DC', c);
|
||||||
|
}
|
||||||
|
case KeyValue.FLAG_ACCENT5:
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'u': return 'µ';
|
||||||
|
case '"': return '„';
|
||||||
|
case '\'': return '’';
|
||||||
|
case '-': return '¬';
|
||||||
|
case 'a': return 'æ';
|
||||||
|
case 'o': return 'œ';
|
||||||
|
default: return (char)KeyCharacterMap.getDeadChar('\u00B8', c);
|
||||||
|
}
|
||||||
|
case KeyValue.FLAG_ACCENT6:
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case '-': return '÷';
|
||||||
|
default: return (char)KeyCharacterMap.getDeadChar('\u00A8', c);
|
||||||
|
}
|
||||||
|
case KeyValue.FLAG_ACCENT_SUPERSCRIPT:
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '1': return '¹';
|
case '1': return '¹';
|
||||||
@@ -70,12 +115,16 @@ class KeyModifier
|
|||||||
case '8': return '⁸';
|
case '8': return '⁸';
|
||||||
case '9': return '⁹';
|
case '9': return '⁹';
|
||||||
case '0': return '⁰';
|
case '0': return '⁰';
|
||||||
case '*': return '°';
|
case 'i': return 'ⁱ';
|
||||||
default: return (char)KeyCharacterMap.getDeadChar('\u02C6', c);
|
case '+': return '⁺';
|
||||||
|
case '-': return '⁻';
|
||||||
|
case '=': return '⁼';
|
||||||
|
case '(': return '⁽';
|
||||||
|
case ')': return '⁾';
|
||||||
|
case 'n': return 'ⁿ';
|
||||||
|
default: return c;
|
||||||
}
|
}
|
||||||
case KeyValue.FLAG_ACCENT4:
|
case KeyValue.FLAG_ACCENT_SUBSCRIPT:
|
||||||
return (char)KeyCharacterMap.getDeadChar('\u02DC', c);
|
|
||||||
case KeyValue.FLAG_ACCENT5:
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '1': return '₁';
|
case '1': return '₁';
|
||||||
@@ -88,18 +137,16 @@ class KeyModifier
|
|||||||
case '8': return '₈';
|
case '8': return '₈';
|
||||||
case '9': return '₉';
|
case '9': return '₉';
|
||||||
case '0': return '₀';
|
case '0': return '₀';
|
||||||
case 'u': return 'µ';
|
case '+': return '₊';
|
||||||
case '"': return '„';
|
case '-': return '₋';
|
||||||
case '-': return '¬';
|
case '=': return '₌';
|
||||||
default: return (char)KeyCharacterMap.getDeadChar('\u00B8', c);
|
case '(': return '₍';
|
||||||
}
|
case ')': return '₎';
|
||||||
case KeyValue.FLAG_ACCENT6:
|
case 'e': return 'ₑ';
|
||||||
switch (c)
|
case 'a': return 'ₐ';
|
||||||
{
|
case 'x': return 'ₓ';
|
||||||
case '-': return '÷';
|
case 'o': return 'ₒ';
|
||||||
case '?': return '¿';
|
default: return c;
|
||||||
case '!': return '¡';
|
|
||||||
default: return (char)KeyCharacterMap.getDeadChar('\u00A8', c);
|
|
||||||
}
|
}
|
||||||
default: return c; // Can't happen
|
default: return c; // Can't happen
|
||||||
}
|
}
|
||||||
@@ -108,7 +155,7 @@ class KeyModifier
|
|||||||
private static KeyValue handleFn(KeyValue k, int flags)
|
private static KeyValue handleFn(KeyValue k, int flags)
|
||||||
{
|
{
|
||||||
if ((flags & KeyValue.FLAG_FN) == 0)
|
if ((flags & KeyValue.FLAG_FN) == 0)
|
||||||
return null;
|
return k;
|
||||||
String name;
|
String name;
|
||||||
switch (k.name)
|
switch (k.name)
|
||||||
{
|
{
|
||||||
@@ -126,7 +173,13 @@ class KeyModifier
|
|||||||
case "down": name = "page_down"; break;
|
case "down": name = "page_down"; break;
|
||||||
case "left": name = "home"; break;
|
case "left": name = "home"; break;
|
||||||
case "right": name = "end"; break;
|
case "right": name = "end"; break;
|
||||||
default: return null;
|
case ">": name = "→"; break;
|
||||||
|
case "<": name = "←"; break;
|
||||||
|
case "\"": name = "“"; break;
|
||||||
|
case "-": name = "–"; break;
|
||||||
|
case "_": name = "—"; break;
|
||||||
|
case "esc": name = "insert"; break;
|
||||||
|
default: return k;
|
||||||
}
|
}
|
||||||
return KeyValue.getKeyByName(name);
|
return KeyValue.getKeyByName(name);
|
||||||
}
|
}
|
||||||
|
@@ -39,9 +39,12 @@ class KeyValue
|
|||||||
public static final int FLAG_ACCENT4 = (1 << 19); // Tilde
|
public static final int FLAG_ACCENT4 = (1 << 19); // Tilde
|
||||||
public static final int FLAG_ACCENT5 = (1 << 20); // Cédille
|
public static final int FLAG_ACCENT5 = (1 << 20); // Cédille
|
||||||
public static final int FLAG_ACCENT6 = (1 << 21); // Tréma
|
public static final int FLAG_ACCENT6 = (1 << 21); // Tréma
|
||||||
|
public static final int FLAG_ACCENT_SUPERSCRIPT = (1 << 22);
|
||||||
|
public static final int FLAG_ACCENT_SUBSCRIPT = (1 << 23);
|
||||||
|
|
||||||
public static final int FLAGS_ACCENTS = FLAG_ACCENT1 | FLAG_ACCENT2 |
|
public static final int FLAGS_ACCENTS = FLAG_ACCENT1 | FLAG_ACCENT2 |
|
||||||
FLAG_ACCENT3 | FLAG_ACCENT4 | FLAG_ACCENT5 | FLAG_ACCENT6;
|
FLAG_ACCENT3 | FLAG_ACCENT4 | FLAG_ACCENT5 | FLAG_ACCENT6 |
|
||||||
|
FLAG_ACCENT_SUPERSCRIPT | FLAG_ACCENT_SUBSCRIPT;
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final String symbol;
|
public final String symbol;
|
||||||
@@ -49,6 +52,12 @@ class KeyValue
|
|||||||
public final int eventCode;
|
public final int eventCode;
|
||||||
public final int flags;
|
public final int flags;
|
||||||
|
|
||||||
|
/* Update the char and the symbol. */
|
||||||
|
public KeyValue withCharAndSymbol(char c)
|
||||||
|
{
|
||||||
|
return withCharAndSymbol(String.valueOf(c), c);
|
||||||
|
}
|
||||||
|
|
||||||
public KeyValue withCharAndSymbol(String s, char c)
|
public KeyValue withCharAndSymbol(String s, char c)
|
||||||
{
|
{
|
||||||
return new KeyValue(name, s, c, eventCode, flags);
|
return new KeyValue(name, s, c, eventCode, flags);
|
||||||
@@ -67,7 +76,12 @@ class KeyValue
|
|||||||
|
|
||||||
public static KeyValue getKeyByName(String name)
|
public static KeyValue getKeyByName(String name)
|
||||||
{
|
{
|
||||||
return (KeyValue.keys.get(name));
|
if (name == null)
|
||||||
|
return null;
|
||||||
|
KeyValue kv = KeyValue.keys.get(name);
|
||||||
|
if (kv != null)
|
||||||
|
return kv;
|
||||||
|
return new KeyValue(name, name, CHAR_NONE, EVENT_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addKey(String name, String symbol, char c, int event, int flags)
|
private static void addKey(String name, String symbol, char c, int event, int flags)
|
||||||
@@ -111,12 +125,14 @@ class KeyValue
|
|||||||
addModifierKey("shift", "⇧", FLAG_LOCK | FLAG_SHIFT);
|
addModifierKey("shift", "⇧", FLAG_LOCK | FLAG_SHIFT);
|
||||||
addModifierKey("ctrl", "Ctrl", FLAG_CTRL);
|
addModifierKey("ctrl", "Ctrl", FLAG_CTRL);
|
||||||
addModifierKey("alt", "Alt", FLAG_ALT);
|
addModifierKey("alt", "Alt", FLAG_ALT);
|
||||||
addModifierKey("accent_grave", "\u02CB", FLAG_ACCENT1);
|
addModifierKey("accent_grave", "◌̀", FLAG_ACCENT1);
|
||||||
addModifierKey("accent_aigu", "\u00B4", FLAG_ACCENT2);
|
addModifierKey("accent_aigu", "◌́", FLAG_ACCENT2);
|
||||||
addModifierKey("accent_circonflexe", "\u02C6", FLAG_ACCENT3);
|
addModifierKey("accent_circonflexe", "◌̂", FLAG_ACCENT3);
|
||||||
addModifierKey("accent_tilde", "\u02DC", FLAG_ACCENT4);
|
addModifierKey("accent_tilde", "◌̃", FLAG_ACCENT4);
|
||||||
addModifierKey("accent_cedille", "\u00B8", FLAG_ACCENT5);
|
addModifierKey("accent_cedille", "◌̧", FLAG_ACCENT5);
|
||||||
addModifierKey("accent_trema", "\u00A8", FLAG_ACCENT6);
|
addModifierKey("accent_trema", "◌̈", FLAG_ACCENT6);
|
||||||
|
addModifierKey("superscript", "◌͆", FLAG_ACCENT_SUPERSCRIPT);
|
||||||
|
addModifierKey("subscript", "◌̺", FLAG_ACCENT_SUBSCRIPT);
|
||||||
addModifierKey("fn", "Fn", FLAG_FN);
|
addModifierKey("fn", "Fn", FLAG_FN);
|
||||||
|
|
||||||
addCharKey('a', KeyEvent.KEYCODE_A);
|
addCharKey('a', KeyEvent.KEYCODE_A);
|
||||||
|
@@ -6,11 +6,13 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
|
import android.os.Build.VERSION;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.view.inputmethod.InputMethodInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -18,6 +20,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -66,25 +69,83 @@ public class Keyboard2 extends InputMethodService
|
|||||||
return (_specialKeyFont);
|
return (_specialKeyFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshSubtype(InputMethodSubtype subtype)
|
private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm)
|
||||||
{
|
{
|
||||||
int l;
|
String pkg = getPackageName();
|
||||||
if (_config.layout == -1)
|
for (InputMethodInfo imi : imm.getEnabledInputMethodList())
|
||||||
l = Config.layoutId_of_string(subtype.getExtraValueOf("default_layout"));
|
if (imi.getPackageName().equals(pkg))
|
||||||
else
|
return imm.getEnabledInputMethodSubtypeList(imi, true);
|
||||||
l = _config.layout;
|
return null;
|
||||||
if (_currentTextLayout != l)
|
}
|
||||||
|
|
||||||
|
private void refreshSubtypeLayout(InputMethodSubtype subtype)
|
||||||
|
{
|
||||||
|
int l = _config.layout;;
|
||||||
|
if (l == -1)
|
||||||
{
|
{
|
||||||
_currentTextLayout = l;
|
String s = subtype.getExtraValueOf("default_layout");
|
||||||
_keyboardView.setKeyboard(getLayout(l));
|
if (s != null)
|
||||||
|
l = Config.layoutId_of_string(s);
|
||||||
}
|
}
|
||||||
|
_currentTextLayout = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int accents_of_subtype(InputMethodSubtype subtype)
|
||||||
|
{
|
||||||
|
String accents_option = subtype.getExtraValueOf("accents");
|
||||||
|
int flags = 0;
|
||||||
|
if (accents_option != null)
|
||||||
|
for (String acc : accents_option.split("\\|"))
|
||||||
|
flags |= Config.accentFlag_of_name(acc);
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype)
|
||||||
|
{
|
||||||
|
final int DONT_REMOVE = KeyValue.FLAG_ACCENT_SUPERSCRIPT | KeyValue.FLAG_ACCENT_SUBSCRIPT;
|
||||||
|
int to_keep = DONT_REMOVE;
|
||||||
|
switch (_config.accents)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
to_keep |= accents_of_subtype(subtype);
|
||||||
|
for (InputMethodSubtype s : getEnabledSubtypes(imm))
|
||||||
|
to_keep |= accents_of_subtype(s);
|
||||||
|
break;
|
||||||
|
case 2: to_keep |= accents_of_subtype(subtype); break;
|
||||||
|
case 3: to_keep = KeyValue.FLAGS_ACCENTS; break;
|
||||||
|
case 4: break;
|
||||||
|
default: throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
_config.accent_flags_to_remove = ~to_keep & KeyValue.FLAGS_ACCENTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshSubtypeLegacyFallback()
|
||||||
|
{
|
||||||
|
// Fallback for the accents option: Only respect the "None" case
|
||||||
|
switch (_config.accents)
|
||||||
|
{
|
||||||
|
case 1: case 2: case 3: _config.accent_flags_to_remove = 0; break;
|
||||||
|
case 4: _config.accent_flags_to_remove = KeyValue.FLAGS_ACCENTS; break;
|
||||||
|
}
|
||||||
|
// Fallback for the layout option: Use qwerty in the "system settings" case
|
||||||
|
_currentTextLayout = (_config.layout == -1) ? R.xml.qwerty : _config.layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshSubtypeImm()
|
private void refreshSubtypeImm()
|
||||||
{
|
{
|
||||||
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
_config.shouldOfferSwitchingToNextInputMethod = imm.shouldOfferSwitchingToNextInputMethod(getConnectionToken());
|
_config.shouldOfferSwitchingToNextInputMethod = imm.shouldOfferSwitchingToNextInputMethod(getConnectionToken());
|
||||||
refreshSubtype(imm.getCurrentInputMethodSubtype());
|
if (VERSION.SDK_INT < 12)
|
||||||
|
{
|
||||||
|
// Subtypes won't work well under API level 12 (getExtraValueOf)
|
||||||
|
refreshSubtypeLegacyFallback();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype();
|
||||||
|
refreshSubtypeLayout(subtype);
|
||||||
|
refreshAccentsOption(imm, subtype);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -103,12 +164,16 @@ public class Keyboard2 extends InputMethodService
|
|||||||
refreshSubtypeImm();
|
refreshSubtypeImm();
|
||||||
if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0)
|
if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0)
|
||||||
_keyboardView.setKeyboard(getLayout(R.xml.numeric));
|
_keyboardView.setKeyboard(getLayout(R.xml.numeric));
|
||||||
|
else
|
||||||
|
_keyboardView.setKeyboard(getLayout(_currentTextLayout));
|
||||||
|
_keyboardView.reset(); // Layout might need to change due to rotation
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype)
|
public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype)
|
||||||
{
|
{
|
||||||
refreshSubtype(subtype);
|
refreshSubtypeImm();
|
||||||
|
_keyboardView.setKeyboard(getLayout(_currentTextLayout));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -92,15 +92,15 @@ public class Keyboard2View extends View
|
|||||||
return (paint);
|
return (paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyboard(KeyboardData kw)
|
public void setKeyboard(KeyboardData kw)
|
||||||
{
|
{
|
||||||
if (!_config.shouldOfferSwitchingToNextInputMethod)
|
if (!_config.shouldOfferSwitchingToNextInputMethod)
|
||||||
kw = kw.removeKeys(new KeyboardData.RemoveKeysByEvent(KeyValue.EVENT_CHANGE_METHOD));
|
kw = kw.removeKeys(new KeyboardData.RemoveKeysByEvent(KeyValue.EVENT_CHANGE_METHOD));
|
||||||
if (_config.disableAccentKeys)
|
if (_config.accent_flags_to_remove != 0)
|
||||||
kw = kw.removeKeys(new KeyboardData.RemoveKeysByFlags(KeyValue.FLAGS_ACCENTS));
|
kw = kw.removeKeys(new KeyboardData.RemoveKeysByFlags(_config.accent_flags_to_remove));
|
||||||
_keyboard = kw;
|
_keyboard = kw;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user