From 197ab2fa3bebf9d28fbf0ee31888cfbeb8f06126 Mon Sep 17 00:00:00 2001 From: Evgenii Kozlov Date: Wed, 18 Sep 2024 16:07:40 +0200 Subject: [PATCH] DROID-2219 App | Tech | Release 6 stabilisation (#1570) --- .../anytype/ui/editor/EditorFragment.kt | 6 +++- .../ui/editor/sheets/ObjectMenuFragment.kt | 1 - .../widgets/text/CodeTextInputWidget.kt | 30 ++++++++++++------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt index 14933a9364..1fbdba9976 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt @@ -968,7 +968,11 @@ open class EditorFragment : NavigationFragment(R.layout.f isTemplate = command.isTemplate ) if (!fr.isAdded) { - fr.showChildFragment() + runCatching { + fr.showChildFragment() + }.onFailure { + Timber.e(it, "Error while opening object menu from editor") + } } else { Timber.d("Ignoring, fragment already added.") } diff --git a/app/src/main/java/com/anytypeio/anytype/ui/editor/sheets/ObjectMenuFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/editor/sheets/ObjectMenuFragment.kt index 5887d0d6ca..ca23c2de88 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/editor/sheets/ObjectMenuFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/editor/sheets/ObjectMenuFragment.kt @@ -46,7 +46,6 @@ class ObjectMenuFragment : ObjectMenuBaseFragment() { } companion object { - fun new( ctx: Id, space: Id, diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt index c3cb9bcabf..e1a1a8fa93 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/text/CodeTextInputWidget.kt @@ -61,8 +61,12 @@ class CodeTextInputWidget : AppCompatEditText, SyntaxHighlighter { } private fun setupSyntaxHighlighter() { - addRules(context.obtainSyntaxRules(Syntaxes.KOTLIN)) - highlight() + runCatching { + addRules(context.obtainSyntaxRules(Syntaxes.KOTLIN)) + highlight() + }.onFailure { + Timber.e(it, "Error while setting up syntax highlighter") + } super.addTextChangedListener(syntaxTextWatcher) } @@ -129,17 +133,21 @@ class CodeTextInputWidget : AppCompatEditText, SyntaxHighlighter { } override fun setupSyntax(lang: String?) { - if (lang == null) { - rules.clear() - clearHighlights() - } else { - val result = context.obtainSyntaxRules(lang) - if (result.isEmpty()) { - addRules(context.obtainGenericSyntaxRules()) + runCatching { + if (lang == null) { + rules.clear() + clearHighlights() } else { - addRules(result) + val result = context.obtainSyntaxRules(lang) + if (result.isEmpty()) { + addRules(context.obtainGenericSyntaxRules()) + } else { + addRules(result) + } + highlight() } - highlight() + }.onFailure { + Timber.e(it, "Error while setting syntax rules.") } }