diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b2c2c40..4858c3d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/src/main/kotlin/org/fossify/notes/fragments/TextFragment.kt b/app/src/main/kotlin/org/fossify/notes/fragments/TextFragment.kt index 5442651c..dc969ce5 100644 --- a/app/src/main/kotlin/org/fossify/notes/fragments/TextFragment.kt +++ b/app/src/main/kotlin/org/fossify/notes/fragments/TextFragment.kt @@ -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) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3091fed8..c69607d4 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -2,6 +2,7 @@