From bf110b4a604fa6bfc6584bd3839ff84cfdf2130a Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Thu, 13 Jun 2024 10:55:14 +0200 Subject: [PATCH] Clean code using constants and by removing useless new lines --- .../lib/richhtmleditor/RichHtmlEditorWebView.kt | 1 - .../lib/richhtmleditor/sample/EditorSampleFragment.kt | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rich-html-editor/src/main/java/com/infomaniak/lib/richhtmleditor/RichHtmlEditorWebView.kt b/rich-html-editor/src/main/java/com/infomaniak/lib/richhtmleditor/RichHtmlEditorWebView.kt index 9c62204..9b88978 100644 --- a/rich-html-editor/src/main/java/com/infomaniak/lib/richhtmleditor/RichHtmlEditorWebView.kt +++ b/rich-html-editor/src/main/java/com/infomaniak/lib/richhtmleditor/RichHtmlEditorWebView.kt @@ -119,7 +119,6 @@ class RichHtmlEditorWebView @JvmOverloads constructor( fun toggleUnderline() = jsBridge.toggleUnderline() fun removeFormat() = jsBridge.removeFormat() fun setTextColor(@ColorInt color: Int) = jsBridge.setTextColor(JsColor(color)) - fun setTextBackgroundColor(@ColorInt color: Int) = jsBridge.setTextBackgroundColor(JsColor(color)) fun setFontSize(@IntRange(from = 1, to = 7) fontSize: Int) = jsBridge.setFontSize(fontSize) fun createLink(displayText: String?, url: String) = jsBridge.createLink(displayText, url) diff --git a/sample/src/main/java/com/infomaniak/lib/richhtmleditor/sample/EditorSampleFragment.kt b/sample/src/main/java/com/infomaniak/lib/richhtmleditor/sample/EditorSampleFragment.kt index 70638c8..cdbb9cb 100644 --- a/sample/src/main/java/com/infomaniak/lib/richhtmleditor/sample/EditorSampleFragment.kt +++ b/sample/src/main/java/com/infomaniak/lib/richhtmleditor/sample/EditorSampleFragment.kt @@ -81,9 +81,9 @@ class EditorSampleFragment : Fragment() { textBackgroundColorRed.setOnClickListener { editor.setTextBackgroundColor(RED) } textBackgroundColorBlue.setOnClickListener { editor.setTextBackgroundColor(BLUE) } - fontSmallButton.setOnClickListener { editor.setFontSize(2) } - fontMediumButton.setOnClickListener { editor.setFontSize(4) } - fontBigButton.setOnClickListener { editor.setFontSize(6) } + fontSmallButton.setOnClickListener { editor.setFontSize(SMALL_FONT_SIZE) } + fontMediumButton.setOnClickListener { editor.setFontSize(MEDIUM_FONT_SIZE) } + fontBigButton.setOnClickListener { editor.setFontSize(BIG_FONT_SIZE) } } private fun observeEditorStatusUpdates() = with(binding) { @@ -148,5 +148,9 @@ class EditorSampleFragment : Fragment() { companion object { private val RED = Color.parseColor("#FF0000") private val BLUE = Color.parseColor("#0000FF") + + private const val SMALL_FONT_SIZE = 2 + private const val MEDIUM_FONT_SIZE = 4 + private const val BIG_FONT_SIZE = 6 } }