Skip to content

Commit b89cc04

Browse files
authored
Merge pull request #196 from Merkost/capitalizing_refactoring
Sentences capitalization cursor improvements
2 parents 5e50fee + 9c57944 commit b89cc04

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.text.InputType.*
66
import android.text.TextUtils
77
import android.view.KeyEvent
88
import android.view.View
9+
import android.view.inputmethod.CursorAnchorInfo
910
import android.view.inputmethod.EditorInfo
1011
import android.view.inputmethod.EditorInfo.IME_ACTION_NONE
1112
import android.view.inputmethod.EditorInfo.IME_FLAG_NO_ENTER_ACTION
@@ -72,7 +73,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
7273
}
7374

7475
private fun updateShiftKeyState() {
75-
if (keyboard!!.mShiftState == ShiftState.ON_PERMANENT) {
76+
if (keyboard?.mShiftState == ShiftState.ON_PERMANENT) {
7677
return
7778
}
7879

@@ -258,6 +259,11 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
258259
updateShiftKeyState()
259260
}
260261

262+
override fun onUpdateCursorAnchorInfo(cursorAnchorInfo: CursorAnchorInfo?) {
263+
super.onUpdateCursorAnchorInfo(cursorAnchorInfo)
264+
updateShiftKeyState()
265+
}
266+
261267
private fun moveCursor(moveRight: Boolean) {
262268
val extractedText = currentInputConnection?.getExtractedText(ExtractedTextRequest(), 0) ?: return
263269
var newCursorPosition = extractedText.selectionStart

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
<com.simplemobiletools.commons.views.MyEditText
5151
android:id="@+id/text_edittext"
52+
android:inputType="textCapSentences"
5253
android:layout_width="match_parent"
5354
android:layout_height="wrap_content"
5455
android:layout_marginStart="@dimen/activity_margin"

0 commit comments

Comments
 (0)