PageAdapter: show URL schemes on links

Currently only show them on absolute URLs and if they are not Gemini
links (https, gopher, etc).
main
dece 2 years ago
parent 8c1bebf315
commit c4d0e66322

@ -154,10 +154,19 @@ class PageAdapter(private val listener: Listener) :
}
}
is ContentBlock.Link -> {
val uri = Uri.parse(block.url)
val label = block.label.ifBlank { block.url }
(holder as ContentViewHolder.Link).binding.textView.text = label
holder.binding.root.setOnClickListener { listener.onLinkClick(block.url) }
// Add the protocol on the right view if available and necessary (i.e. not Gemini).
if (uri.isAbsolute && uri.scheme != null && uri.scheme != "gemini") {
holder.binding.protocolView.text = uri.scheme
holder.binding.protocolView.visibility = View.VISIBLE
} else {
holder.binding.protocolView.visibility = View.GONE
}
// Color links differently if it has been already visited or not.
val resources = holder.binding.root.context.resources
holder.binding.textView.setTextColor(

@ -1,6 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_view"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/CometLink" />
android:layout_height="wrap_content">
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_toStartOf="@id/protocol_view"
style="@style/CometLink" />
<TextView
android:id="@+id/protocol_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/text_view"
android:layout_alignParentEnd="true"
style="@style/CometText"
android:textColor="@color/text_light"
android:textStyle="italic"
android:textIsSelectable="false" />
</RelativeLayout>

Loading…
Cancel
Save