mirror of https://git.sr.ht/~oppen/ariane
inline images fixes
This commit is contained in:
parent
c5b4bd07b7
commit
05123fb9f1
|
@ -7,7 +7,8 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.android.synthetic.main.gemtext_code_block.view.*
|
||||
import kotlinx.android.synthetic.main.gemtext_link.view.*
|
||||
import kotlinx.android.synthetic.main.gemtext_image_link.view.*
|
||||
import kotlinx.android.synthetic.main.gemtext_link.view.gemtext_text_link
|
||||
import kotlinx.android.synthetic.main.gemtext_text.view.gemtext_text_textview
|
||||
import oppen.ariane.R
|
||||
import oppen.endsWithImage
|
||||
|
@ -35,7 +36,7 @@ class GemtextAdapter(val onLink: (adapter: GemtextAdapter, link: URI, longTap: B
|
|||
class H2(itemView: View): ViewHolder(itemView)
|
||||
class H3(itemView: View): ViewHolder(itemView)
|
||||
class ListItem(itemView: View): ViewHolder(itemView)
|
||||
class ImageLinkLink(itemView: View): ViewHolder(itemView)
|
||||
class ImageLink(itemView: View): ViewHolder(itemView)
|
||||
class Link(itemView: View): ViewHolder(itemView)
|
||||
class Code(itemView: View): ViewHolder(itemView)
|
||||
class Quote(itemView: View): ViewHolder(itemView)
|
||||
|
@ -55,7 +56,7 @@ class GemtextAdapter(val onLink: (adapter: GemtextAdapter, link: URI, longTap: B
|
|||
typeH2 -> ViewHolder.H2(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_h2, parent, false))
|
||||
typeH3 -> ViewHolder.H3(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_h3, parent, false))
|
||||
typeListItem -> ViewHolder.ListItem(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_text, parent, false))
|
||||
typeImageLink -> ViewHolder.Link(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_image_link, parent, false))
|
||||
typeImageLink -> ViewHolder.ImageLink(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_image_link, parent, false))
|
||||
typeLink -> ViewHolder.Link(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_link, parent, false))
|
||||
typeCodeBlock-> ViewHolder.Code(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_code_block, parent, false))
|
||||
typeQuote -> ViewHolder.Quote(LayoutInflater.from(parent.context).inflate(R.layout.gemtext_quote, parent, false))
|
||||
|
@ -71,7 +72,7 @@ class GemtextAdapter(val onLink: (adapter: GemtextAdapter, link: URI, longTap: B
|
|||
line.startsWith("##") -> typeH2
|
||||
line.startsWith("#") -> typeH1
|
||||
line.startsWith("*") -> typeListItem
|
||||
line.startsWith("=>") && line.endsWithImage() -> typeImageLink
|
||||
line.startsWith("=>") && getLink(line).endsWithImage() -> typeImageLink
|
||||
line.startsWith("=>") -> typeLink
|
||||
line.startsWith(">") -> typeQuote
|
||||
else -> typeText
|
||||
|
@ -129,7 +130,7 @@ class GemtextAdapter(val onLink: (adapter: GemtextAdapter, link: URI, longTap: B
|
|||
true
|
||||
}
|
||||
}
|
||||
is ViewHolder.ImageLinkLink -> {
|
||||
is ViewHolder.ImageLink -> {
|
||||
//todo - extract, largely duplicate of above
|
||||
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
|
||||
var linkName = linkParts[0]
|
||||
|
@ -162,6 +163,11 @@ class GemtextAdapter(val onLink: (adapter: GemtextAdapter, link: URI, longTap: B
|
|||
}
|
||||
}
|
||||
|
||||
private fun getLink(line: String): String{
|
||||
val linkParts = line.substring(2).trim().split("\\s+".toRegex(), 2)
|
||||
return linkParts[0]
|
||||
}
|
||||
|
||||
private fun getUri(linkLine: String): URI{
|
||||
val linkParts = linkLine.substring(2).trim().split("\\s+".toRegex(), 2)
|
||||
return URI.create(linkParts.first())
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="@dimen/screen_margin"
|
||||
android:paddingBottom="@dimen/default_margin"
|
||||
android:paddingBottom="@dimen/screen_margin"
|
||||
/>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
|
|
@ -3,26 +3,17 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gemtext_text_link"
|
||||
android:textColor="@color/stroke"
|
||||
android:textSize="@dimen/default_text_size"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:layout_marginLeft="@dimen/screen_margin"
|
||||
android:layout_marginRight="@dimen/screen_margin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/gemtext_inline_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/gemtext_text_link"
|
||||
android:textColor="@color/stroke"
|
||||
android:textSize="@dimen/default_text_size"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:layout_marginLeft="@dimen/screen_margin"
|
||||
android:layout_marginRight="@dimen/screen_margin"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:visibility="gone"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_below="@+id/gemtext_text_link"/>
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in New Issue