Skip to content

Commit 2c81907

Browse files
fix: keyboard hiding cursor on startup (#172)
* fix: keyboard hiding cursor on startup * update changelog * lint * hacky delayed scroll, has to be a better way * use window inset listener * Update app/src/main/kotlin/org/fossify/notes/fragments/TextFragment.kt Co-authored-by: Naveen Singh <[email protected]> * only run keyboard listener once and check config.placeCursorToEnd * fix: keyboard hiding cursor on startup * update changelog * lint * hacky delayed scroll, has to be a better way * use window inset listener * Update app/src/main/kotlin/org/fossify/notes/fragments/TextFragment.kt Co-authored-by: Naveen Singh <[email protected]> * only run keyboard listener once and check config.placeCursorToEnd * Update app/src/main/kotlin/org/fossify/notes/fragments/TextFragment.kt Co-authored-by: Naveen Singh <[email protected]> * add fits system windows * remove extra keyboard listener * remove unused imports * style: add empty line --------- Co-authored-by: Naveen Singh <[email protected]> Co-authored-by: Naveen Singh <[email protected]>
1 parent 80fc431 commit 2c81907

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Updated translations
1313

14+
### Fixed
15+
16+
- Fixed keyboard hiding cursor on long notes ([#164])
17+
1418
## [1.2.0] - 2025-05-07
1519

1620
### Added
@@ -71,3 +75,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7175
[#83]: https://github.com/FossifyOrg/Notes/issues/83
7276
[#99]: https://github.com/FossifyOrg/Notes/issues/99
7377
[#110]: https://github.com/FossifyOrg/Notes/issues/110
78+
[#164]: https://github.com/FossifyOrg/Notes/issues/164

app/src/main/kotlin/org/fossify/notes/fragments/TextFragment.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import android.view.ViewGroup
1717
import android.view.inputmethod.InputMethodManager
1818
import android.widget.ImageView
1919
import android.widget.TextView
20+
import androidx.core.view.ViewCompat
21+
import androidx.core.view.WindowInsetsCompat
2022
import androidx.viewbinding.ViewBinding
2123
import org.fossify.commons.extensions.*
2224
import org.fossify.commons.views.MyEditText
@@ -200,6 +202,22 @@ class TextFragment : NoteFragment() {
200202
setTextWatcher()
201203
}
202204

205+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
206+
super.onViewCreated(view, savedInstanceState)
207+
setupKeyboardListener()
208+
}
209+
210+
private fun setupKeyboardListener() {
211+
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view, insets ->
212+
if (insets.isVisible(WindowInsetsCompat.Type.ime())) {
213+
noteEditText.post {
214+
noteEditText.bringPointIntoView(noteEditText.selectionEnd)
215+
}
216+
}
217+
insets
218+
}
219+
}
220+
203221
fun setTextWatcher() {
204222
noteEditText.apply {
205223
removeTextChangedListener(textWatcher)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
android:id="@+id/main_coordinator"
5+
android:fitsSystemWindows="true"
56
android:layout_width="match_parent"
67
android:layout_height="match_parent">
78

0 commit comments

Comments
 (0)