improve the default rendering for all elements

This commit is contained in:
dece 2021-12-11 01:26:12 +01:00
parent 3cba46ad5d
commit 5cb3af8d12
13 changed files with 62 additions and 36 deletions

View file

@ -55,11 +55,12 @@ class ContentAdapter(private var content: List<Line>, private val listener: Cont
} }
} }
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: ContentViewHolder, position: Int) { override fun onBindViewHolder(holder: ContentViewHolder, position: Int) {
val line = content[position] val line = content[position]
when (holder) { when (holder) {
is ContentViewHolder.Paragraph -> holder.binding.textView.text = is ContentViewHolder.Paragraph ->
(line as ParagraphLine).text holder.binding.textView.text = (line as ParagraphLine).text
is ContentViewHolder.Title1 -> holder.binding.textView.text = (line as TitleLine).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.Title2 -> holder.binding.textView.text = (line as TitleLine).text
is ContentViewHolder.Title3 -> 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<Line>, private val listener: Cont
holder.binding.textView.text = underlined holder.binding.textView.text = underlined
holder.binding.root.setOnClickListener { listener.onLinkClick(line.url) } 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 -> {} else -> {}
} }
} }

View file

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_view" android:id="@+id/text_view"
android:textSize="16sp"
android:textColor="@color/text"
android:textStyle="italic"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/teal_200" /> android:paddingStart="32dp"
android:paddingEnd="16dp"
android:paddingTop="4dp"
android:paddingBottom="4dp" />

View file

@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Space xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="8dp" android:layout_height="4dp" />
android:background="@color/black"
android:orientation="vertical"></Space>

View file

@ -2,11 +2,11 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_view" android:id="@+id/text_view"
android:textSize="16sp" android:textSize="16sp"
android:textColor="@color/teal_700"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="8dp" android:paddingStart="16dp"
android:paddingEnd="8dp" android:paddingEnd="16dp"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingBottom="4dp" android:paddingBottom="4dp"
android:background="@color/teal_200"
android:textIsSelectable="false" /> android:textIsSelectable="false" />

View file

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_view" android:id="@+id/text_view"
android:textSize="16sp"
android:textColor="@color/text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/teal_200" /> android:paddingStart="32dp"
android:paddingEnd="16dp"
android:paddingTop="2dp"
android:paddingBottom="2dp" />

View file

@ -2,10 +2,10 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_view" android:id="@+id/text_view"
android:textSize="16sp" android:textSize="16sp"
android:textColor="@color/text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="8dp" android:paddingStart="16dp"
android:paddingEnd="8dp" android:paddingEnd="16dp"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingBottom="4dp" android:paddingBottom="4dp" />
android:background="@color/teal_200" />

View file

@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_view" android:id="@+id/text_view"
android:textSize="14sp"
android:textColor="@color/text"
android:typeface="monospace"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/teal_200" /> android:paddingStart="16dp"
android:paddingEnd="8dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:background="@color/purple_200" />

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_view" android:id="@+id/text_view"
android:textSize="30sp"
android:textColor="@color/text"
android:textStyle="bold"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="30sp" android:paddingStart="16dp"
android:textStyle="bold" android:paddingEnd="16dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingTop="16dp" android:paddingTop="16dp"
android:paddingBottom="4dp" android:paddingBottom="4dp" />
android:background="@color/teal_700" />

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_view" android:id="@+id/text_view"
android:textSize="24sp"
android:textColor="@color/text"
android:textStyle="bold"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="24sp" android:paddingStart="16dp"
android:textStyle="bold" android:paddingEnd="16dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingTop="8dp" android:paddingTop="8dp"
android:paddingBottom="4dp" android:paddingBottom="4dp" />
android:background="@color/teal_700" />

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_view" android:id="@+id/text_view"
android:textSize="18sp"
android:textColor="@color/text"
android:textStyle="bold"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="18sp" android:paddingStart="16dp"
android:textStyle="bold" android:paddingEnd="16dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingTop="8dp" android:paddingTop="8dp"
android:paddingBottom="4dp" android:paddingBottom="4dp" />
android:background="@color/teal_700" />

View file

@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Theme.Comet" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <style name="Theme.Comet" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. --> <!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item> <item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorPrimaryVariant">@color/purple_700</item>

View file

@ -7,4 +7,5 @@
<color name="teal_700">#FF018786</color> <color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="text">#222222</color>
</resources> </resources>

View file

@ -9,6 +9,8 @@
<item name="colorSecondary">@color/teal_200</item> <item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item> <item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item> <item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
</style> </style>
</resources> </resources>