From 5cb3af8d12b8af2a04340a82d32f3c5c0c7499a8 Mon Sep 17 00:00:00 2001 From: dece Date: Sat, 11 Dec 2021 01:26:12 +0100 Subject: [PATCH] improve the default rendering for all elements --- .../java/dev/lowrespalmtree/comet/ContentRecycler.kt | 11 +++++++++-- app/src/main/res/layout/gemtext_blockquote.xml | 8 +++++++- app/src/main/res/layout/gemtext_empty.xml | 8 +++----- app/src/main/res/layout/gemtext_link.xml | 6 +++--- app/src/main/res/layout/gemtext_list_item.xml | 7 ++++++- app/src/main/res/layout/gemtext_paragraph.xml | 8 ++++---- app/src/main/res/layout/gemtext_preformatted.xml | 9 ++++++++- app/src/main/res/layout/gemtext_title1.xml | 12 ++++++------ app/src/main/res/layout/gemtext_title2.xml | 12 ++++++------ app/src/main/res/layout/gemtext_title3.xml | 12 ++++++------ app/src/main/res/values-night/themes.xml | 2 +- app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/themes.xml | 2 ++ 13 files changed, 62 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/dev/lowrespalmtree/comet/ContentRecycler.kt b/app/src/main/java/dev/lowrespalmtree/comet/ContentRecycler.kt index e64b97f..77996f7 100644 --- a/app/src/main/java/dev/lowrespalmtree/comet/ContentRecycler.kt +++ b/app/src/main/java/dev/lowrespalmtree/comet/ContentRecycler.kt @@ -55,11 +55,12 @@ class ContentAdapter(private var content: List, private val listener: Cont } } + @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: ContentViewHolder, position: Int) { val line = content[position] when (holder) { - is ContentViewHolder.Paragraph -> holder.binding.textView.text = - (line as ParagraphLine).text + is ContentViewHolder.Paragraph -> + holder.binding.textView.text = (line as ParagraphLine).text is ContentViewHolder.Title1 -> holder.binding.textView.text = (line as TitleLine).text is ContentViewHolder.Title2 -> holder.binding.textView.text = (line as TitleLine).text is ContentViewHolder.Title3 -> holder.binding.textView.text = (line as TitleLine).text @@ -70,6 +71,12 @@ class ContentAdapter(private var content: List, private val listener: Cont holder.binding.textView.text = underlined holder.binding.root.setOnClickListener { listener.onLinkClick(line.url) } } + is ContentViewHolder.PreText -> + holder.binding.textView.text = (line as PreTextLine).text + is ContentViewHolder.Blockquote -> + holder.binding.textView.text = (line as BlockquoteLine).text + is ContentViewHolder.ListItem -> + holder.binding.textView.text = "\u25CF ${(line as ListItemLine).text}" else -> {} } } diff --git a/app/src/main/res/layout/gemtext_blockquote.xml b/app/src/main/res/layout/gemtext_blockquote.xml index 2d46bbf..f43a280 100644 --- a/app/src/main/res/layout/gemtext_blockquote.xml +++ b/app/src/main/res/layout/gemtext_blockquote.xml @@ -1,6 +1,12 @@ \ No newline at end of file + android:paddingStart="32dp" + android:paddingEnd="16dp" + android:paddingTop="4dp" + android:paddingBottom="4dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_empty.xml b/app/src/main/res/layout/gemtext_empty.xml index b6998cf..70b62ee 100644 --- a/app/src/main/res/layout/gemtext_empty.xml +++ b/app/src/main/res/layout/gemtext_empty.xml @@ -1,6 +1,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_link.xml b/app/src/main/res/layout/gemtext_link.xml index bc27299..b89c227 100644 --- a/app/src/main/res/layout/gemtext_link.xml +++ b/app/src/main/res/layout/gemtext_link.xml @@ -2,11 +2,11 @@ \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_list_item.xml b/app/src/main/res/layout/gemtext_list_item.xml index 2d46bbf..1f133bb 100644 --- a/app/src/main/res/layout/gemtext_list_item.xml +++ b/app/src/main/res/layout/gemtext_list_item.xml @@ -1,6 +1,11 @@ \ No newline at end of file + android:paddingStart="32dp" + android:paddingEnd="16dp" + android:paddingTop="2dp" + android:paddingBottom="2dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_paragraph.xml b/app/src/main/res/layout/gemtext_paragraph.xml index 3868c58..18028b9 100644 --- a/app/src/main/res/layout/gemtext_paragraph.xml +++ b/app/src/main/res/layout/gemtext_paragraph.xml @@ -2,10 +2,10 @@ \ No newline at end of file + android:paddingBottom="4dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_preformatted.xml b/app/src/main/res/layout/gemtext_preformatted.xml index 2d46bbf..6c564a8 100644 --- a/app/src/main/res/layout/gemtext_preformatted.xml +++ b/app/src/main/res/layout/gemtext_preformatted.xml @@ -1,6 +1,13 @@ \ No newline at end of file + android:paddingStart="16dp" + android:paddingEnd="8dp" + android:paddingTop="2dp" + android:paddingBottom="2dp" + android:background="@color/purple_200" /> \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_title1.xml b/app/src/main/res/layout/gemtext_title1.xml index fc0095f..a9c1475 100644 --- a/app/src/main/res/layout/gemtext_title1.xml +++ b/app/src/main/res/layout/gemtext_title1.xml @@ -1,12 +1,12 @@ \ No newline at end of file + android:paddingBottom="4dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_title2.xml b/app/src/main/res/layout/gemtext_title2.xml index b02f206..06d5d36 100644 --- a/app/src/main/res/layout/gemtext_title2.xml +++ b/app/src/main/res/layout/gemtext_title2.xml @@ -1,12 +1,12 @@ \ No newline at end of file + android:paddingBottom="4dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/gemtext_title3.xml b/app/src/main/res/layout/gemtext_title3.xml index 0887625..77b6b63 100644 --- a/app/src/main/res/layout/gemtext_title3.xml +++ b/app/src/main/res/layout/gemtext_title3.xml @@ -1,12 +1,12 @@ \ No newline at end of file + android:paddingBottom="4dp" /> \ No newline at end of file diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 1621d5f..66c0579 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -1,6 +1,6 @@ - \ No newline at end of file