From c049ca9dee53f1792bfa56554a3534067877a4df Mon Sep 17 00:00:00 2001 From: wittmane Date: Sun, 7 Feb 2021 01:05:39 -0600 Subject: [PATCH] disable auto-capitalization for certain keyboard layouts (#242) --- .../inputmethod/latin/LatinIME.java | 3 +- .../latin/inputlogic/InputLogic.java | 35 +++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/LatinIME.java b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/LatinIME.java index cd674ba28..ef77f4c5c 100644 --- a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/LatinIME.java +++ b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/LatinIME.java @@ -726,7 +726,8 @@ private void updateSoftInputWindowLayoutParameters() { } int getCurrentAutoCapsState() { - return mInputLogic.getCurrentAutoCapsState(mSettings.getCurrent()); + return mInputLogic.getCurrentAutoCapsState(mSettings.getCurrent(), + mRichImm.getCurrentSubtype().getKeyboardLayoutSetName()); } int getCurrentRecapitalizeState() { diff --git a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/inputlogic/InputLogic.java b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/inputlogic/InputLogic.java index 66d7720f1..b26c2b200 100644 --- a/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/inputlogic/InputLogic.java +++ b/app/src/main/java/rkr/simplekeyboard/inputmethod/latin/inputlogic/InputLogic.java @@ -422,10 +422,14 @@ private void performRecapitalization(final SettingsValues settingsValues) { * needs to know auto caps state to display the right layout. * * @param settingsValues the relevant settings values + * @param layoutSetName the name of the current keyboard layout set * @return a caps mode from TextUtils.CAP_MODE_* or Constants.TextUtils.CAP_MODE_OFF. */ - public int getCurrentAutoCapsState(final SettingsValues settingsValues) { - if (!settingsValues.mAutoCap) return Constants.TextUtils.CAP_MODE_OFF; + public int getCurrentAutoCapsState(final SettingsValues settingsValues, + final String layoutSetName) { + if (!settingsValues.mAutoCap || !layoutUsesAutoCaps(layoutSetName)) { + return Constants.TextUtils.CAP_MODE_OFF; + } final EditorInfo ei = getCurrentInputEditorInfo(); if (ei == null) return Constants.TextUtils.CAP_MODE_OFF; @@ -435,6 +439,33 @@ public int getCurrentAutoCapsState(final SettingsValues settingsValues) { return mConnection.getCursorCapsMode(inputType, settingsValues.mSpacingAndPunctuations); } + private boolean layoutUsesAutoCaps(final String layoutSetName) { + switch (layoutSetName) { + case "arabic": + case "bengali": + case "bengali_akkhor": + case "farsi": + case "georgian": + case "hebrew": + case "hindi": + case "hindi_compact": + case "kannada": + case "khmer": + case "lao": + case "malayalam": + case "marathi": + case "nepali_romanized": + case "nepali_traditional": + case "tamil": + case "telugu": + case "thai": + case "urdu": + return false; + default: + return true; + } + } + public int getCurrentRecapitalizeState() { if (!mRecapitalizeStatus.isStarted() || !mRecapitalizeStatus.isSetAt(mConnection.getExpectedSelectionStart(),