Skip to content

Commit

Permalink
disable auto-capitalization for certain keyboard layouts (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
wittmane authored Feb 7, 2021
1 parent 4f7c579 commit c049ca9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,8 @@ private void updateSoftInputWindowLayoutParameters() {
}

int getCurrentAutoCapsState() {
return mInputLogic.getCurrentAutoCapsState(mSettings.getCurrent());
return mInputLogic.getCurrentAutoCapsState(mSettings.getCurrent(),
mRichImm.getCurrentSubtype().getKeyboardLayoutSetName());
}

int getCurrentRecapitalizeState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(),
Expand Down

0 comments on commit c049ca9

Please sign in to comment.