matrix-org / matrix-rich-text-editor

Matrix Rich Text Editor
https://matrix-org.github.io/matrix-rich-text-editor/
Apache License 2.0
82 stars 19 forks source link

Android: reconcile UI text with editor text #948

Closed jmartinesp closed 3 months ago

jmartinesp commented 3 months ago

This should help in cases where the UI text is modified externally by the OS or some app.

Basically, what we do here is we intercept any change made outside of the editor by either the OS or the implementing app, pass them to the editor, apply them, then notify the text watchers of the result of these editor changes.

It seems to work well so far, the tests pass. We probably need to thoroughly test it with some day-to-day usage.

PS: this is heavily based on @ganfra 's work here. Thanks!

Video example

https://github.com/matrix-org/matrix-rich-text-editor/assets/480955/33234304-038f-40c5-bbd3-b00bd3ffc7f0

codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 65.11628% with 30 lines in your changes are missing coverage. Please review.

Project coverage is 87.13%. Comparing base (5d3e6c3) to head (cc9abf6).

Files Patch % Lines
.../wysiwyg/inputhandlers/InterceptInputConnection.kt 60.60% 8 Missing and 5 partials :warning:
...va/io/element/android/wysiwyg/EditorTextWatcher.kt 68.57% 6 Missing and 5 partials :warning:
.../java/io/element/android/wysiwyg/EditorEditText.kt 62.50% 2 Missing and 4 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #948 +/- ## ============================================ - Coverage 87.49% 87.13% -0.36% - Complexity 426 442 +16 ============================================ Files 167 136 -31 Lines 19229 17720 -1509 Branches 1068 443 -625 ============================================ - Hits 16824 15441 -1383 + Misses 2093 1981 -112 + Partials 312 298 -14 ``` | [Flag](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/948/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | Coverage Δ | | |---|---|---| | [uitests](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `64.34% <65.11%> (-6.28%)` | :arrow_down: | | [uitests-android](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `64.34% <65.11%> (-0.01%)` | :arrow_down: | | [uitests-ios](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `?` | | | [unittests](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `86.45% <0.00%> (+0.75%)` | :arrow_up: | | [unittests-android](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `42.16% <0.00%> (-1.37%)` | :arrow_down: | | [unittests-ios](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `?` | | | [unittests-rust](https://app.codecov.io/gh/matrix-org/matrix-rich-text-editor/pull/948/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org) | `89.64% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=matrix-org#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud