mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Stop auto-switching-back to the main layout by quotes.
bug: 5314117 Change-Id: Idcd6a146665b93eabdc03875b98988f9fa049791
This commit is contained in:
parent
436a645ea8
commit
32cf5bb9f9
@ -31,6 +31,21 @@
|
|||||||
<!-- Word separator list is the union of all symbols except those that are not separators:
|
<!-- Word separator list is the union of all symbols except those that are not separators:
|
||||||
magic_space_swapping_symbols | magic_space_stripping_symbols |
|
magic_space_swapping_symbols | magic_space_stripping_symbols |
|
||||||
magic_space_neutral_symbols \ symbols_excluded_from_word_separators -->
|
magic_space_neutral_symbols \ symbols_excluded_from_word_separators -->
|
||||||
|
<!-- Symbol characters list that should switch back to the main layout -->
|
||||||
|
<!-- \u0022: Quotation mark (double quotation mark)
|
||||||
|
\u0027: Apostrophe (single quotation mark)
|
||||||
|
\u2018: Left single quotation mark
|
||||||
|
\u2019: Right single quotation mark
|
||||||
|
\u201a: Single low-9 quotation mark
|
||||||
|
\u201b: Single high-reversed-9 quotation mark
|
||||||
|
\u201c: Left double quotation mark
|
||||||
|
\u201d: Right double quotation mark
|
||||||
|
\u201e: Double low-9 quotation mark
|
||||||
|
\u201f: Double high-reversed-9 quotation mark
|
||||||
|
\u00ab: Left-pointing double angle quotation mark
|
||||||
|
\u00bb: Right-pointing double angle quotation mark -->
|
||||||
|
<!-- string name="layout_switch_back_symbols">\u0022\u0027\u2018\u2019\u201a\u201b\u201c\u201d\u201e\u201f\u00ab\u00bb</string> -->
|
||||||
|
<string name="layout_switch_back_symbols"></string>
|
||||||
|
|
||||||
<!-- Label for "switch to more symbol" modifier key. Must be short to fit on key! -->
|
<!-- Label for "switch to more symbol" modifier key. Must be short to fit on key! -->
|
||||||
<string name="label_to_more_symbol_key">= \\ <</string>
|
<string name="label_to_more_symbol_key">= \\ <</string>
|
||||||
|
@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
@ -97,6 +98,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||||||
private static final int SWITCH_STATE_CHORDING_SYMBOL = 6;
|
private static final int SWITCH_STATE_CHORDING_SYMBOL = 6;
|
||||||
private int mSwitchState = SWITCH_STATE_ALPHA;
|
private int mSwitchState = SWITCH_STATE_ALPHA;
|
||||||
|
|
||||||
|
private static String mLayoutSwitchBackSymbols;
|
||||||
|
|
||||||
private int mThemeIndex = -1;
|
private int mThemeIndex = -1;
|
||||||
private Context mThemeContext;
|
private Context mThemeContext;
|
||||||
|
|
||||||
@ -204,6 +207,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||||||
mMainKeyboardId = getKeyboardId(editorInfo, false, false, settingsValues);
|
mMainKeyboardId = getKeyboardId(editorInfo, false, false, settingsValues);
|
||||||
mSymbolsKeyboardId = getKeyboardId(editorInfo, true, false, settingsValues);
|
mSymbolsKeyboardId = getKeyboardId(editorInfo, true, false, settingsValues);
|
||||||
mSymbolsShiftedKeyboardId = getKeyboardId(editorInfo, true, true, settingsValues);
|
mSymbolsShiftedKeyboardId = getKeyboardId(editorInfo, true, true, settingsValues);
|
||||||
|
mLayoutSwitchBackSymbols = mResources.getString(R.string.layout_switch_back_symbols);
|
||||||
setKeyboard(getKeyboard(mSavedKeyboardState.getKeyboardId()));
|
setKeyboard(getKeyboard(mSavedKeyboardState.getKeyboardId()));
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
Log.w(TAG, "loading keyboard failed: " + mMainKeyboardId, e);
|
Log.w(TAG, "loading keyboard failed: " + mMainKeyboardId, e);
|
||||||
@ -661,24 +665,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||||||
return c == Keyboard.CODE_SPACE || c == Keyboard.CODE_ENTER;
|
return c == Keyboard.CODE_SPACE || c == Keyboard.CODE_ENTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isQuoteCharacter(int c) {
|
private static boolean isLayoutSwitchBackCharacter(int c) {
|
||||||
// Apostrophe, quotation mark.
|
if (TextUtils.isEmpty(mLayoutSwitchBackSymbols)) return false;
|
||||||
if (c == Keyboard.CODE_SINGLE_QUOTE || c == Keyboard.CODE_DOUBLE_QUOTE)
|
if (mLayoutSwitchBackSymbols.indexOf(c) >= 0) return true;
|
||||||
return true;
|
|
||||||
// \u2018: Left single quotation mark
|
|
||||||
// \u2019: Right single quotation mark
|
|
||||||
// \u201a: Single low-9 quotation mark
|
|
||||||
// \u201b: Single high-reversed-9 quotation mark
|
|
||||||
// \u201c: Left double quotation mark
|
|
||||||
// \u201d: Right double quotation mark
|
|
||||||
// \u201e: Double low-9 quotation mark
|
|
||||||
// \u201f: Double high-reversed-9 quotation mark
|
|
||||||
if (c >= '\u2018' && c <= '\u201f')
|
|
||||||
return true;
|
|
||||||
// \u00ab: Left-pointing double angle quotation mark
|
|
||||||
// \u00bb: Right-pointing double angle quotation mark
|
|
||||||
if (c == '\u00ab' || c == '\u00bb')
|
|
||||||
return true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,7 +725,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||||||
mSwitchState = SWITCH_STATE_SYMBOL;
|
mSwitchState = SWITCH_STATE_SYMBOL;
|
||||||
}
|
}
|
||||||
// Snap back to alpha keyboard mode immediately if user types a quote character.
|
// Snap back to alpha keyboard mode immediately if user types a quote character.
|
||||||
if (isQuoteCharacter(code)) {
|
if (isLayoutSwitchBackCharacter(code)) {
|
||||||
changeKeyboardMode();
|
changeKeyboardMode();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -744,7 +733,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||||||
case SWITCH_STATE_CHORDING_SYMBOL:
|
case SWITCH_STATE_CHORDING_SYMBOL:
|
||||||
// Snap back to alpha keyboard mode if user types one or more non-space/enter
|
// Snap back to alpha keyboard mode if user types one or more non-space/enter
|
||||||
// characters followed by a space/enter or a quote character.
|
// characters followed by a space/enter or a quote character.
|
||||||
if (isSpaceCharacter(code) || isQuoteCharacter(code)) {
|
if (isSpaceCharacter(code) || isLayoutSwitchBackCharacter(code)) {
|
||||||
changeKeyboardMode();
|
changeKeyboardMode();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user