forked from extern/Unexpected-Keyboard
Allow to hide more keys than just accents
Add the "FLAGS_LANGS" set of flags, which will be used to hide individual keys that are not accents.
This commit is contained in:
parent
2764e96eb1
commit
23e59c6b09
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<input-method xmlns:android="http://schemas.android.com/apk/res/android" android:settingsActivity="juloo.keyboard2.SettingsActivity" android:supportsSwitchingToNextInputMethod="true">
|
<input-method xmlns:android="http://schemas.android.com/apk/res/android" android:settingsActivity="juloo.keyboard2.SettingsActivity" android:supportsSwitchingToNextInputMethod="true">
|
||||||
<subtype android:label="%s" android:languageTag="en" android:imeSubtypeLocale="en_US" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty"/>
|
<subtype android:label="%s" android:languageTag="en" android:imeSubtypeLocale="en_US" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty"/>
|
||||||
<subtype android:label="%s" android:languageTag="fr" android:imeSubtypeLocale="fr_FR" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=azerty,accents=grave|aigu|circonflexe|cedille|trema"/>
|
<subtype android:label="%s" android:languageTag="fr" android:imeSubtypeLocale="fr_FR" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=azerty,extra_keys=grave|aigu|circonflexe|cedille|trema"/>
|
||||||
<subtype android:label="%s" 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="%s" android:languageTag="es" android:imeSubtypeLocale="es_ES" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,extra_keys=aigu|tilde|trema"/>
|
||||||
<subtype android:label="%s" android:languageTag="it" android:imeSubtypeLocale="it_IT" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,accents=grave|aigu"/>
|
<subtype android:label="%s" android:languageTag="it" android:imeSubtypeLocale="it_IT" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,extra_keys=grave|aigu"/>
|
||||||
<subtype android:label="%s" android:languageTag="sv" android:imeSubtypeLocale="sv_SE" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,accents=aigu|trema|ring"/>
|
<subtype android:label="%s" android:languageTag="sv" android:imeSubtypeLocale="sv_SE" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,extra_keys=aigu|trema|ring"/>
|
||||||
</input-method>
|
</input-method>
|
||||||
|
@ -33,7 +33,7 @@ final class Config
|
|||||||
|
|
||||||
// Dynamically set
|
// Dynamically set
|
||||||
public boolean shouldOfferSwitchingToNextInputMethod;
|
public boolean shouldOfferSwitchingToNextInputMethod;
|
||||||
public int accent_flags_to_remove;
|
public int key_flags_to_remove;
|
||||||
|
|
||||||
public final IKeyEventHandler handler;
|
public final IKeyEventHandler handler;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ final class Config
|
|||||||
refresh(context);
|
refresh(context);
|
||||||
// initialized later
|
// initialized later
|
||||||
shouldOfferSwitchingToNextInputMethod = false;
|
shouldOfferSwitchingToNextInputMethod = false;
|
||||||
accent_flags_to_remove = 0;
|
key_flags_to_remove = 0;
|
||||||
handler = h;
|
handler = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ final class Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Used for the accents option. */
|
/* Used for the accents option. */
|
||||||
public static int accentFlag_of_name(String name)
|
public static int extra_key_flag_of_name(String name)
|
||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,15 @@ class KeyValue
|
|||||||
FLAG_ACCENT3 | FLAG_ACCENT4 | FLAG_ACCENT5 | FLAG_ACCENT6 |
|
FLAG_ACCENT3 | FLAG_ACCENT4 | FLAG_ACCENT5 | FLAG_ACCENT6 |
|
||||||
FLAG_ACCENT_SUPERSCRIPT | FLAG_ACCENT_SUBSCRIPT | FLAG_ACCENT_RING;
|
FLAG_ACCENT_SUPERSCRIPT | FLAG_ACCENT_SUBSCRIPT | FLAG_ACCENT_RING;
|
||||||
|
|
||||||
|
// Language specific keys
|
||||||
|
public static final int FLAGS_LANGS = 0;
|
||||||
|
|
||||||
|
public static final int FLAGS_NOT_HIDDEN_ACCENTS = FLAG_ACCENT_SUPERSCRIPT |
|
||||||
|
FLAG_ACCENT_SUBSCRIPT;
|
||||||
|
// Keys that have to be enabled per language
|
||||||
|
public static final int FLAGS_HIDDEN_KEYS =
|
||||||
|
(FLAGS_ACCENTS & ~FLAGS_NOT_HIDDEN_ACCENTS) | FLAGS_LANGS;
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final String symbol;
|
public final String symbol;
|
||||||
public final char char_;
|
public final char char_;
|
||||||
|
@ -81,33 +81,32 @@ public class Keyboard2 extends InputMethodService
|
|||||||
_currentTextLayout = l;
|
_currentTextLayout = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int accents_of_subtype(InputMethodSubtype subtype)
|
private int extra_keys_of_subtype(InputMethodSubtype subtype)
|
||||||
{
|
{
|
||||||
String accents_option = subtype.getExtraValueOf("accents");
|
String extra_keys = subtype.getExtraValueOf("extra_keys");
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if (accents_option != null)
|
if (extra_keys != null)
|
||||||
for (String acc : accents_option.split("\\|"))
|
for (String acc : extra_keys.split("\\|"))
|
||||||
flags |= Config.accentFlag_of_name(acc);
|
flags |= Config.extra_key_flag_of_name(acc);
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype)
|
private void refreshAccentsOption(InputMethodManager imm, InputMethodSubtype subtype)
|
||||||
{
|
{
|
||||||
final int DONT_REMOVE = KeyValue.FLAG_ACCENT_SUPERSCRIPT | KeyValue.FLAG_ACCENT_SUBSCRIPT;
|
int to_keep = 0;
|
||||||
int to_keep = DONT_REMOVE;
|
|
||||||
switch (_config.accents)
|
switch (_config.accents)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
to_keep |= accents_of_subtype(subtype);
|
to_keep |= extra_keys_of_subtype(subtype);
|
||||||
for (InputMethodSubtype s : getEnabledSubtypes(imm))
|
for (InputMethodSubtype s : getEnabledSubtypes(imm))
|
||||||
to_keep |= accents_of_subtype(s);
|
to_keep |= extra_keys_of_subtype(s);
|
||||||
break;
|
break;
|
||||||
case 2: to_keep |= accents_of_subtype(subtype); break;
|
case 2: to_keep |= extra_keys_of_subtype(subtype); break;
|
||||||
case 3: to_keep = KeyValue.FLAGS_ACCENTS; break;
|
case 3: to_keep = KeyValue.FLAGS_HIDDEN_KEYS; break;
|
||||||
case 4: break;
|
case 4: break;
|
||||||
default: throw new IllegalArgumentException();
|
default: throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
_config.accent_flags_to_remove = ~to_keep & KeyValue.FLAGS_ACCENTS;
|
_config.key_flags_to_remove = ~to_keep & KeyValue.FLAGS_HIDDEN_KEYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshSubtypeLegacyFallback()
|
private void refreshSubtypeLegacyFallback()
|
||||||
@ -115,8 +114,8 @@ public class Keyboard2 extends InputMethodService
|
|||||||
// Fallback for the accents option: Only respect the "None" case
|
// Fallback for the accents option: Only respect the "None" case
|
||||||
switch (_config.accents)
|
switch (_config.accents)
|
||||||
{
|
{
|
||||||
case 1: case 2: case 3: _config.accent_flags_to_remove = 0; break;
|
case 1: case 2: case 3: _config.key_flags_to_remove = 0; break;
|
||||||
case 4: _config.accent_flags_to_remove = KeyValue.FLAGS_ACCENTS; break;
|
case 4: _config.key_flags_to_remove = KeyValue.FLAGS_HIDDEN_KEYS; break;
|
||||||
}
|
}
|
||||||
// Fallback for the layout option: Use qwerty in the "system settings" case
|
// Fallback for the layout option: Use qwerty in the "system settings" case
|
||||||
_currentTextLayout = (_config.layout == -1) ? R.xml.qwerty : _config.layout;
|
_currentTextLayout = (_config.layout == -1) ? R.xml.qwerty : _config.layout;
|
||||||
|
@ -61,8 +61,8 @@ public class Keyboard2View extends View
|
|||||||
{
|
{
|
||||||
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.accent_flags_to_remove != 0)
|
if (_config.key_flags_to_remove != 0)
|
||||||
kw = kw.removeKeys(new KeyboardData.RemoveKeysByFlags(_config.accent_flags_to_remove));
|
kw = kw.removeKeys(new KeyboardData.RemoveKeysByFlags(_config.key_flags_to_remove));
|
||||||
_keyboard = kw;
|
_keyboard = kw;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user