diff --git a/src/java/KP2ASoftkeyboard_AS/app/src/main/java/keepass2android/softkeyboard/KeyboardSwitcher.java b/src/java/KP2ASoftkeyboard_AS/app/src/main/java/keepass2android/softkeyboard/KeyboardSwitcher.java index e6847814a..506cc493e 100644 --- a/src/java/KP2ASoftkeyboard_AS/app/src/main/java/keepass2android/softkeyboard/KeyboardSwitcher.java +++ b/src/java/KP2ASoftkeyboard_AS/app/src/main/java/keepass2android/softkeyboard/KeyboardSwitcher.java @@ -69,6 +69,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha public static final String DEFAULT_LAYOUT_ID = "4"; public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20100902"; + public static final String PREF_KEY_LAYOUT = "pref_key_layout"; + public static final String KEY_LAYOUT_QWERTY = "qwerty"; + public static final String KEY_LAYOUT_DVORAK = "dvorak"; private static final int[] THEMES = new int [] { R.layout.input_basic, R.layout.input_basic_highcontrast, R.layout.input_stone_normal, R.layout.input_stone_bold, R.layout.input_gingerbread}; @@ -86,6 +89,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private static final int[] KBD_SYMBOLS_SHIFT = new int[] { R.xml.kbd_symbols_shift, R.xml.kbd_symbols_shift_black}; private static final int[] KBD_QWERTY = new int[] {R.xml.kbd_qwerty, R.xml.kbd_qwerty_black}; + private static final int[] KBD_DVORAK = new int[] {R.xml.kbd_dvorak, R.xml.kbd_dvorak_black}; private static final int[] KBD_KP2A = new int[] {R.xml.kbd_kp2a, R.xml.kbd_kp2a_black}; @@ -141,6 +145,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private Locale mInputLocale; private int mLayoutId; + private String mKeyLayout; private static final KeyboardSwitcher sInstance = new KeyboardSwitcher(); @@ -158,6 +163,7 @@ public static void init(KP2AKeyboard ims) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ims); sInstance.mLayoutId = Integer.valueOf( prefs.getString(PREF_KEYBOARD_LAYOUT, DEFAULT_LAYOUT_ID)); + sInstance.mKeyLayout = prefs.getString(PREF_KEY_LAYOUT, KEY_LAYOUT_QWERTY); sInstance.updateSettingsKeyState(prefs); prefs.registerOnSharedPreferenceChangeListener(sInstance); @@ -321,7 +327,8 @@ private KeyboardId getKeyboardId(int mode, int imeOptions, boolean isSymbols) { } } // TODO: generalize for any KeyboardId - int keyboardRowsResId = KBD_QWERTY[charColorId]; + int[] alphaKbd = KEY_LAYOUT_DVORAK.equals(mKeyLayout) ? KBD_DVORAK : KBD_QWERTY; + int keyboardRowsResId = alphaKbd[charColorId]; switch (mode) { case MODE_KP2A: @@ -569,6 +576,9 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin if (PREF_KEYBOARD_LAYOUT.equals(key)) { changeLatinKeyboardView( Integer.valueOf(sharedPreferences.getString(key, DEFAULT_LAYOUT_ID)), false); + } else if (PREF_KEY_LAYOUT.equals(key)) { + mKeyLayout = sharedPreferences.getString(key, KEY_LAYOUT_QWERTY); + setKeyboardMode(mMode, mImeOptions, mPreferSymbols); } else if (LatinIMESettings.PREF_SETTINGS_KEY.equals(key)) { updateSettingsKeyState(sharedPreferences); recreateInputView(); diff --git a/src/java/KP2ASoftkeyboard_AS/app/src/main/java/keepass2android/softkeyboard/LatinKeyboard.java b/src/java/KP2ASoftkeyboard_AS/app/src/main/java/keepass2android/softkeyboard/LatinKeyboard.java index 45bc65d90..21396c02d 100644 --- a/src/java/KP2ASoftkeyboard_AS/app/src/main/java/keepass2android/softkeyboard/LatinKeyboard.java +++ b/src/java/KP2ASoftkeyboard_AS/app/src/main/java/keepass2android/softkeyboard/LatinKeyboard.java @@ -144,7 +144,9 @@ public LatinKeyboard(Context context, int xmlLayoutResId, int mode) { sSpacebarVerticalCorrection = res.getDimensionPixelOffset( R.dimen.spacebar_vertical_correction); mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty - || xmlLayoutResId == R.xml.kbd_qwerty_black; + || xmlLayoutResId == R.xml.kbd_qwerty_black + || xmlLayoutResId == R.xml.kbd_dvorak + || xmlLayoutResId == R.xml.kbd_dvorak_black; // The index of space key is available only after Keyboard constructor has finished. mSpaceKeyIndexArray = new int[] { indexOf(KP2AKeyboard.KEYCODE_SPACE) }; initializeNumberHintResources(context); diff --git a/src/java/KP2ASoftkeyboard_AS/app/src/main/res/values/donottranslate-altchars.xml b/src/java/KP2ASoftkeyboard_AS/app/src/main/res/values/donottranslate-altchars.xml index bba7282c9..d56fe5447 100644 --- a/src/java/KP2ASoftkeyboard_AS/app/src/main/res/values/donottranslate-altchars.xml +++ b/src/java/KP2ASoftkeyboard_AS/app/src/main/res/values/donottranslate-altchars.xml @@ -43,4 +43,6 @@ + \u2018\u2019\u201C\u201D\u0060\u00B4" + : diff --git a/src/java/KP2ASoftkeyboard_AS/app/src/main/res/values/strings.xml b/src/java/KP2ASoftkeyboard_AS/app/src/main/res/values/strings.xml index f4c674f20..b24489791 100644 --- a/src/java/KP2ASoftkeyboard_AS/app/src/main/res/values/strings.xml +++ b/src/java/KP2ASoftkeyboard_AS/app/src/main/res/values/strings.xml @@ -373,6 +373,19 @@ keyboard voice + + Key layout + QWERTY + Dvorak + + @string/pref_key_layout_qwerty + @string/pref_key_layout_dvorak + + + qwerty + dvorak + + Android keyboard Debug settings Debug Mode diff --git a/src/java/KP2ASoftkeyboard_AS/app/src/main/res/xml/kbd_dvorak.xml b/src/java/KP2ASoftkeyboard_AS/app/src/main/res/xml/kbd_dvorak.xml new file mode 100644 index 000000000..77599a31f --- /dev/null +++ b/src/java/KP2ASoftkeyboard_AS/app/src/main/res/xml/kbd_dvorak.xml @@ -0,0 +1,540 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/KP2ASoftkeyboard_AS/app/src/main/res/xml/kbd_dvorak_black.xml b/src/java/KP2ASoftkeyboard_AS/app/src/main/res/xml/kbd_dvorak_black.xml new file mode 100644 index 000000000..60c05d555 --- /dev/null +++ b/src/java/KP2ASoftkeyboard_AS/app/src/main/res/xml/kbd_dvorak_black.xml @@ -0,0 +1,480 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/KP2ASoftkeyboard_AS/app/src/main/res/xml/prefs.xml b/src/java/KP2ASoftkeyboard_AS/app/src/main/res/xml/prefs.xml index d748765e7..0bf54229e 100644 --- a/src/java/KP2ASoftkeyboard_AS/app/src/main/res/xml/prefs.xml +++ b/src/java/KP2ASoftkeyboard_AS/app/src/main/res/xml/prefs.xml @@ -61,6 +61,14 @@ android:action="keepass2android.softkeyboard.INPUT_LANGUAGE_SELECTION"/> + +