diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index c6e2139..7e8a9bf 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -5,4 +5,19 @@
- azerty
- qwerty
+
+ 1
+
+
+ - @string/pref_accents_e_all_installed
+ - @string/pref_accents_e_selected
+ - @string/pref_accents_e_all
+ - @string/pref_accents_e_none
+
+
+ - 1
+ - 2
+ - 3
+ - 4
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 04c3b57..a15fc5b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -16,8 +16,13 @@
- Azerty
- Qwerty
- Toggle accent keys
- Whether to remove the accent keys from the keyboard
+
+ Accents
+ %s
+ Show accents for all the installed languages
+ Show accents for the selected language
+ Show every accents
+ Hide accents
Typing
Precision
diff --git a/res/xml/method.xml b/res/xml/method.xml
index 5a515cd..a84df7c 100644
--- a/res/xml/method.xml
+++ b/res/xml/method.xml
@@ -14,6 +14,6 @@
android:imeSubtypeLocale="fr_FR"
android:imeSubtypeMode="keyboard"
android:isAsciiCapable="true"
- android:imeSubtypeExtraValue="default_layout=azerty"
+ android:imeSubtypeExtraValue="default_layout=azerty,accents=grave|aigu|circonflexe|tilde|cedille|trema"
/>
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index f943557..2366d4e 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -9,12 +9,13 @@
android:entries="@array/pref_layout_entries"
android:entryValues="@array/pref_layout_values" />
/>
-
+
getEnabledSubtypes(InputMethodManager imm)
+ {
+ String pkg = getPackageName();
+ for (InputMethodInfo imi : imm.getEnabledInputMethodList())
+ if (imi.getPackageName().equals(pkg))
+ return imm.getEnabledInputMethodSubtypeList(imi, true);
+ return null;
+ }
+
+ private void refreshSubtypeLayout(InputMethodSubtype subtype)
{
- int l;
if (_config.layout == -1)
- l = Config.layoutId_of_string(subtype.getExtraValueOf("default_layout"));
+ _currentTextLayout = Config.layoutId_of_string(subtype.getExtraValueOf("default_layout"));
else
- l = _config.layout;
- if (_currentTextLayout != l)
+ _currentTextLayout = _config.layout;
+ }
+
+ 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)
{
- _currentTextLayout = l;
- _keyboardView.setKeyboard(getLayout(l));
+ 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 refreshSubtypeImm()
{
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
_config.shouldOfferSwitchingToNextInputMethod = imm.shouldOfferSwitchingToNextInputMethod(getConnectionToken());
- refreshSubtype(imm.getCurrentInputMethodSubtype());
+ InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype();
+ refreshSubtypeLayout(subtype);
+ refreshAccentsOption(imm, subtype);
}
@Override
@@ -103,13 +139,16 @@ public class Keyboard2 extends InputMethodService
refreshSubtypeImm();
if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0)
_keyboardView.setKeyboard(getLayout(R.xml.numeric));
+ else
+ _keyboardView.setKeyboard(getLayout(_currentTextLayout));
_keyboardView.reset(); // Layout might need to change due to rotation
}
@Override
public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype)
{
- refreshSubtype(subtype);
+ refreshSubtypeImm();
+ _keyboardView.setKeyboard(getLayout(_currentTextLayout));
}
@Override
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java
index 546ebca..03d58a7 100644
--- a/srcs/juloo.keyboard2/Keyboard2View.java
+++ b/srcs/juloo.keyboard2/Keyboard2View.java
@@ -92,15 +92,15 @@ public class Keyboard2View extends View
return (paint);
}
- public void setKeyboard(KeyboardData kw)
- {
+ public void setKeyboard(KeyboardData kw)
+ {
if (!_config.shouldOfferSwitchingToNextInputMethod)
kw = kw.removeKeys(new KeyboardData.RemoveKeysByEvent(KeyValue.EVENT_CHANGE_METHOD));
- if (_config.disableAccentKeys)
- kw = kw.removeKeys(new KeyboardData.RemoveKeysByFlags(KeyValue.FLAGS_ACCENTS));
+ if (_config.accent_flags_to_remove != 0)
+ kw = kw.removeKeys(new KeyboardData.RemoveKeysByFlags(_config.accent_flags_to_remove));
_keyboard = kw;
- reset();
- }
+ reset();
+ }
public void reset()
{