1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-3003 Editor | Enhancement | Add 'Plain Text' option and align text color with desktop (#1815)

Co-authored-by: Evgenii Kozlov <ubuphobos@gmail.com>
This commit is contained in:
Nadezhda-Gurova 2024-11-19 14:24:39 +01:00 committed by GitHub
parent d15e709c93
commit d0f171a9d2
Signed by: github
GPG key ID: B5690EEEBB952194
21 changed files with 24 additions and 41 deletions

View file

@ -43,6 +43,7 @@
"pascal": "Pascal",
"perl": "Perl",
"php": "PHP",
"plain": "Plain Text",
"powershell": "Power Shell",
"prolog": "Prolog",
"python": "Python",

View file

@ -11,7 +11,6 @@ import android.widget.FrameLayout
import android.widget.TextView
import androidx.core.view.updateLayoutParams
import com.anytypeio.anytype.core_models.ThemeColor
import com.anytypeio.anytype.core_ui.BuildConfig
import com.anytypeio.anytype.core_ui.R
import com.anytypeio.anytype.core_ui.databinding.ItemBlockCodeSnippetBinding
import com.anytypeio.anytype.core_ui.extensions.veryLight
@ -22,9 +21,7 @@ import com.anytypeio.anytype.core_ui.features.editor.decoration.DecoratableViewH
import com.anytypeio.anytype.core_ui.features.editor.decoration.EditorDecorationContainer
import com.anytypeio.anytype.core_ui.tools.DefaultTextWatcher
import com.anytypeio.anytype.core_ui.widgets.text.CodeTextInputWidget
import com.anytypeio.anytype.core_utils.ext.dimen
import com.anytypeio.anytype.core_utils.ext.imm
import com.anytypeio.anytype.core_utils.text.BackspaceKeyDetector
import com.anytypeio.anytype.library_syntax_highlighter.Syntaxes
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
import com.anytypeio.anytype.presentation.editor.editor.model.BlockView
@ -116,12 +113,13 @@ class Code(
clicked(ListenerType.Code.SelectLanguage(item.id))
}
if (!item.lang.isNullOrEmpty()) {
if (item.lang.isNullOrEmpty() || item.lang.equals("plain", ignoreCase = true)) {
content.setupSyntax(Syntaxes.PLAIN)
menu.setText(R.string.block_code_plain_text)
} else {
content.setupSyntax(item.lang)
menu.text = item.lang!!.capitalize()
} else {
content.setupSyntax(Syntaxes.GENERIC)
menu.setText(R.string.block_code_menu_title)
}
}
@ -232,21 +230,6 @@ class Code(
}
}
fun enableBackspaceDetector(
onEmptyBlockBackspaceClicked: () -> Unit,
onNonEmptyBlockBackspaceClicked: () -> Unit
) {
content.setOnKeyListener(
BackspaceKeyDetector {
if (content.text.toString().isEmpty()) {
onEmptyBlockBackspaceClicked()
} else {
onNonEmptyBlockBackspaceClicked()
}
}
)
}
override fun applyDecorations(decorations: List<BlockView.Decoration>) {
decoratableContainer.decorate(decorations) { rect ->
binding.content.updateLayoutParams<FrameLayout.LayoutParams> {

View file

@ -134,7 +134,7 @@ class CodeTextInputWidget : AppCompatEditText, SyntaxHighlighter {
override fun setupSyntax(lang: String?) {
runCatching {
if (lang == null) {
if (lang == null || lang.equals("plain", ignoreCase = true)) {
rules.clear()
clearHighlights()
} else {

View file

@ -29,7 +29,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="13dp"
android:text="@string/block_code_menu_title" />
android:text="@string/block_code_plain_text" />
<HorizontalScrollView
android:layout_width="match_parent"

View file

@ -2,6 +2,6 @@ package com.anytypeio.anytype.library_syntax_highlighter
object Syntaxes {
const val KOTLIN = "kotlin"
const val PYTHON = "python"
const val GENERIC = "generic"
const val PLAIN = "plain"
}

View file

@ -2,7 +2,6 @@ package com.anytypeio.anytype.library_syntax_highlighter
import android.content.Context
import android.graphics.Color
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive

View file

@ -221,7 +221,7 @@
<string name="more">Больш</string>
<string name="done">Гатова</string>
<string name="select_scroll_and_move_blocks">Каб пачаць, выберыце блокі</string>
<string name="block_code_menu_title">Мова</string>
<string name="block_code_plain_text">Мова</string>
<string name="undo">Скасаваць</string>
<string name="redo">Вярнуць</string>
<string name="block_action_copy">Капіяваць</string>

View file

@ -221,7 +221,7 @@
<string name="more">Mehr</string>
<string name="done">Fertig</string>
<string name="select_scroll_and_move_blocks">Blöcke auswählen um zu starten</string>
<string name="block_code_menu_title">Sprache</string>
<string name="block_code_plain_text">Sprache</string>
<string name="undo">Rückgängig</string>
<string name="redo">Wiederholen</string>
<string name="block_action_copy">Kopieren</string>

View file

@ -221,7 +221,7 @@
<string name="more">Más</string>
<string name="done">Listo</string>
<string name="select_scroll_and_move_blocks">Para empezar, selecciona bloques</string>
<string name="block_code_menu_title">Idioma</string>
<string name="block_code_plain_text">Idioma</string>
<string name="undo">Deshacer</string>
<string name="redo">Rehacer</string>
<string name="block_action_copy">Copiar</string>

View file

@ -221,7 +221,7 @@
<string name="more">Plus</string>
<string name="done">Terminé</string>
<string name="select_scroll_and_move_blocks">Pour commencer, sélectionnez des blocs</string>
<string name="block_code_menu_title">Langue</string>
<string name="block_code_plain_text">Langue</string>
<string name="undo">Annuler</string>
<string name="redo">Rétablir</string>
<string name="block_action_copy">Copier</string>

View file

@ -221,7 +221,7 @@
<string name="more">Lainnya</string>
<string name="done">Selesai</string>
<string name="select_scroll_and_move_blocks">Untuk mulai, pilih balok</string>
<string name="block_code_menu_title">Bahasa</string>
<string name="block_code_plain_text">Bahasa</string>
<string name="undo">Urungkan</string>
<string name="redo">Ulangi</string>
<string name="block_action_copy">Salin</string>

View file

@ -221,7 +221,7 @@
<string name="more">Altro</string>
<string name="done">Fatto</string>
<string name="select_scroll_and_move_blocks">Per iniziare, seleziona blocchi</string>
<string name="block_code_menu_title">Lingua</string>
<string name="block_code_plain_text">Lingua</string>
<string name="undo">Annulla</string>
<string name="redo">Ripristina</string>
<string name="block_action_copy">Copia</string>

View file

@ -221,7 +221,7 @@
<string name="more">Meer</string>
<string name="done">Gereed</string>
<string name="select_scroll_and_move_blocks">Selecteer blokken om te starten</string>
<string name="block_code_menu_title">Taal</string>
<string name="block_code_plain_text">Taal</string>
<string name="undo">Ongedaan maken</string>
<string name="redo">Voer opnieuw uit</string>
<string name="block_action_copy">Kopieer</string>

View file

@ -221,7 +221,7 @@
<string name="more">Mer</string>
<string name="done">Ferdig</string>
<string name="select_scroll_and_move_blocks">To start, select blocks</string>
<string name="block_code_menu_title">Språk</string>
<string name="block_code_plain_text">Språk</string>
<string name="undo">Angre</string>
<string name="redo">Omgjør</string>
<string name="block_action_copy">Kopier</string>

View file

@ -221,7 +221,7 @@
<string name="more">Mais</string>
<string name="done">Concluído</string>
<string name="select_scroll_and_move_blocks">Para iniciar, selecione os blocos</string>
<string name="block_code_menu_title">Idioma</string>
<string name="block_code_plain_text">Idioma</string>
<string name="undo">Desfazer</string>
<string name="redo">Refazer</string>
<string name="block_action_copy">Copiar</string>

View file

@ -221,7 +221,7 @@
<string name="more">Ещё</string>
<string name="done">Готово</string>
<string name="select_scroll_and_move_blocks">Чтобы начать, выберите блоки</string>
<string name="block_code_menu_title">Язык</string>
<string name="block_code_plain_text">Язык</string>
<string name="undo">Отменить</string>
<string name="redo">Повторить</string>
<string name="block_action_copy">Копировать</string>

View file

@ -221,7 +221,7 @@
<string name="more">Daha fazla</string>
<string name="done">Bitti</string>
<string name="select_scroll_and_move_blocks">Başlamak için blokları seçin</string>
<string name="block_code_menu_title">Dil</string>
<string name="block_code_plain_text">Dil</string>
<string name="undo">Geri al</string>
<string name="redo">Yinele</string>
<string name="block_action_copy">Kopyala</string>

View file

@ -221,7 +221,7 @@
<string name="more">More</string>
<string name="done">Готово</string>
<string name="select_scroll_and_move_blocks">To start, select blocks</string>
<string name="block_code_menu_title">Language</string>
<string name="block_code_plain_text">Language</string>
<string name="undo">Повернути</string>
<string name="redo">Redo</string>
<string name="block_action_copy">Копіювати</string>

View file

@ -221,7 +221,7 @@
<string name="more">更多</string>
<string name="done">完成</string>
<string name="select_scroll_and_move_blocks">要开始, 请选择块</string>
<string name="block_code_menu_title">语言</string>
<string name="block_code_plain_text">语言</string>
<string name="undo">撤消</string>
<string name="redo">重做</string>
<string name="block_action_copy">拷贝</string>

View file

@ -221,7 +221,7 @@
<string name="more">更多</string>
<string name="done">完成</string>
<string name="select_scroll_and_move_blocks">選取區塊以開始</string>
<string name="block_code_menu_title">語言</string>
<string name="block_code_plain_text">語言</string>
<string name="undo">撤銷</string>
<string name="redo">重做</string>
<string name="block_action_copy">複製</string>

View file

@ -258,7 +258,7 @@
<string name="more">More</string>
<string name="done">Done</string>
<string name="select_scroll_and_move_blocks">To start, select blocks</string>
<string name="block_code_menu_title">Language</string>
<string name="block_code_plain_text">Plain text</string>
<string name="undo">Undo</string>
<string name="redo">Redo</string>