Fix auto-capitalization so that it works rather flawlessly
This commit is contained in:
+2
-2
@@ -11,8 +11,8 @@ android {
|
||||
minSdk 19
|
||||
//noinspection OldTargetApi
|
||||
targetSdk 34
|
||||
versionCode 30
|
||||
versionName "0.3"
|
||||
versionCode 29
|
||||
versionName "0.2.9"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -22,6 +22,7 @@ package cfpi_fpsi.eu.titanboard;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.os.Vibrator;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
@@ -83,9 +84,8 @@ public class InputMethod extends InputMethodService {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_DEL:
|
||||
case KeyEvent.KEYCODE_ENTER:
|
||||
mMetaKeyManager.adjustMetaStateAfterKeypress();
|
||||
case KeyEvent.KEYCODE_DEL:
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_SPACE:
|
||||
handleSpacebar(event);
|
||||
@@ -150,11 +150,6 @@ public class InputMethod extends InputMethodService {
|
||||
mInputView.updateSymbolsView(null, 0);
|
||||
}
|
||||
|
||||
// TODO: Not ideal. Should be handled on key down ideally.
|
||||
if (keyCode == KeyEvent.KEYCODE_DEL) {
|
||||
detectAutoCapitalization();
|
||||
}
|
||||
|
||||
getCurrentInputConnection().finishComposingText();
|
||||
mMetaKeyManager.updateMetaStateUp(keyCode, event);
|
||||
mInputView.updateStateText();
|
||||
@@ -178,19 +173,10 @@ public class InputMethod extends InputMethodService {
|
||||
if (!mSettings.isAutoCapsEnabled()) {
|
||||
return;
|
||||
}
|
||||
// Get a bunch of text, run a regex through it, and bam. Is there a better way to do this?
|
||||
String text = getTextBeforeCursor(16);
|
||||
if (text.isEmpty()) {
|
||||
|
||||
if (getCurrentInputConnection().getCursorCapsMode(TextUtils.CAP_MODE_SENTENCES) > 0) {
|
||||
mMetaKeyManager.getShift().setLatched(true);
|
||||
mInputView.updateStateText();
|
||||
} else {
|
||||
// If, on the other hand, we have some characters before the cursor, we scan.
|
||||
Pattern pattern = Pattern.compile("[\\.…\\!\\?] +$");
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
if (matcher.find()) {
|
||||
mMetaKeyManager.getShift().setLatched(true);
|
||||
mInputView.updateStateText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user