mirror of
https://github.com/FossifyOrg/Notes.git
synced 2025-12-23 23:59:34 -05:00
fix: only clear span when Spanned.SPAN_COMPOSING is not set (#181)
* fix: only clear span when `Spanned.SPAN_COMPOSING` is not set See: https://github.com/FossifyOrg/Notes/issues/178 * docs: update changelog
This commit is contained in:
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
- Fixed broken input when typing with certain keyboards ([#178])
|
||||
|
||||
## [1.3.0] - 2025-07-12
|
||||
### Changed
|
||||
- Updated translations
|
||||
@@ -55,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
[#99]: https://github.com/FossifyOrg/Notes/issues/99
|
||||
[#110]: https://github.com/FossifyOrg/Notes/issues/110
|
||||
[#164]: https://github.com/FossifyOrg/Notes/issues/164
|
||||
[#178]: https://github.com/FossifyOrg/Notes/issues/178
|
||||
|
||||
[Unreleased]: https://github.com/FossifyOrg/Notes/compare/v1.3.0...HEAD
|
||||
[1.3.0]: https://github.com/FossifyOrg/Notes/compare/v1.2.0...v1.3.0
|
||||
|
||||
@@ -6,8 +6,13 @@ import org.fossify.commons.views.MyEditText
|
||||
|
||||
fun MyEditText.enforcePlainText() {
|
||||
val stripSpans = InputFilter { source, start, end, _, _, _ ->
|
||||
val sub = source.subSequence(start, end)
|
||||
if (sub is Spanned) sub.toString() else sub
|
||||
if (source !is Spanned) return@InputFilter null
|
||||
val hasRealStyle = source.getSpans(start, end, Any::class.java)
|
||||
.any { span ->
|
||||
(source.getSpanFlags(span) and Spanned.SPAN_COMPOSING) == 0
|
||||
}
|
||||
|
||||
if (hasRealStyle) source.subSequence(start, end).toString() else null
|
||||
}
|
||||
filters = (filters ?: emptyArray()) + stripSpans
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user