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 <36371707+naveensingh@users.noreply.github.com>

* 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 <36371707+naveensingh@users.noreply.github.com>

* 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 <36371707+naveensingh@users.noreply.github.com>

* add fits system windows

* remove extra keyboard listener

* remove unused imports

* style: add empty line

---------

Co-authored-by: Naveen Singh <36371707+naveensingh@users.noreply.github.com>
Co-authored-by: Naveen Singh <snaveen935@gmail.com>
This commit is contained in:
Ben Nguyen
2025-07-09 09:53:57 -05:00
committed by GitHub
parent 80fc43109e
commit 2c8190705b
3 changed files with 24 additions and 0 deletions

View File

@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated translations
### Fixed
- Fixed keyboard hiding cursor on long notes ([#164])
## [1.2.0] - 2025-05-07
### Added
@@ -71,3 +75,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#83]: https://github.com/FossifyOrg/Notes/issues/83
[#99]: https://github.com/FossifyOrg/Notes/issues/99
[#110]: https://github.com/FossifyOrg/Notes/issues/110
[#164]: https://github.com/FossifyOrg/Notes/issues/164

View File

@@ -17,6 +17,8 @@ import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.widget.ImageView
import android.widget.TextView
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.viewbinding.ViewBinding
import org.fossify.commons.extensions.*
import org.fossify.commons.views.MyEditText
@@ -200,6 +202,22 @@ class TextFragment : NoteFragment() {
setTextWatcher()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setupKeyboardListener()
}
private fun setupKeyboardListener() {
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { view, insets ->
if (insets.isVisible(WindowInsetsCompat.Type.ime())) {
noteEditText.post {
noteEditText.bringPointIntoView(noteEditText.selectionEnd)
}
}
insets
}
}
fun setTextWatcher() {
noteEditText.apply {
removeTextChangedListener(textWatcher)

View File

@@ -2,6 +2,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_coordinator"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">