Compare commits

..

No commits in common. "6b96eb358de41884b9bf3aae64dbac25b8f2cee2" and "b173664ff0506a9ced6350db1b9b7d2e45a8363c" have entirely different histories.

View File

@ -193,13 +193,14 @@ class ArticleFragment :
fab.mainFabClosedIconColor = colorOnSurface
fab.mainFabOpenedIconColor = colorOnSurface
maybeIfContext { handleFloatingToolbarActionItems(it) }
maybeIfContext { context -> handleFloatingToolbarActionItems(context) }
fab.setOnActionSelectedListener { actionItem ->
when (actionItem.id) {
R.id.share_action -> requireActivity().shareLink(url, contentTitle)
R.id.open_action -> requireActivity().openItemUrlInBrowserAsNewTask(this@ArticleFragment.item)
R.id.unread_action ->
try {
if (this@ArticleFragment.item.unread) {
CoroutineScope(Dispatchers.IO).launch {
repository.markAsRead(this@ArticleFragment.item)
@ -218,14 +219,15 @@ class ArticleFragment :
repository.unmarkAsRead(this@ArticleFragment.item)
}
this@ArticleFragment.item.unread = true
maybeIfContext {
Toast
.makeText(
it,
context,
R.string.marked_as_unread,
Toast.LENGTH_LONG,
).show()
}
} catch (e: IllegalStateException) {
e.sendSilentlyWithAcraWithName("Toolbar context required is null")
}
else -> Unit
@ -311,8 +313,8 @@ class ArticleFragment :
private fun handleLeadImage(leadImageUrl: String?) {
if (!leadImageUrl.isNullOrEmpty()) {
maybeIfContext {
binding.imageView.visibility = View.VISIBLE
maybeIfContext {
it.bitmapFitCenter(leadImageUrl, binding.imageView, appSettingsService)
}
} else {
@ -395,12 +397,13 @@ class ArticleFragment :
WHITE_COLOR_HEX and (if (colorOnSurface != DATA_NULL_UNDEFINED) colorOnSurface else 0),
)
try {
binding.webcontent.settings.useWideViewPort = true
binding.webcontent.settings.loadWithOverviewMode = true
binding.webcontent.settings.javaScriptEnabled = false
handleImageLoading()
try {
val gestureDetector =
GestureDetector(
activity,
@ -414,14 +417,15 @@ class ArticleFragment :
event,
)
}
} catch (e: IllegalStateException) {
e.sendSilentlyWithAcraWithName("Gesture detector issue ?")
return
}
binding.webcontent.settings.layoutAlgorithm =
WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING
} catch (e: IllegalStateException) {
e.sendSilentlyWithAcraWithName("Context is null but wasn't, and that's causing issues with webview config")
return
}
try {
var baseUrl: String? = null
try {
val itemUrl = URL(url)
@ -430,18 +434,16 @@ class ArticleFragment :
e.sendSilentlyWithAcraWithName("htmlToWebview > $url")
}
val fontName: String =
maybeIfContext {
val fontName =
when (font) {
it.getString(R.string.open_sans_font_id) -> "Open Sans"
it.getString(R.string.roboto_font_id) -> "Roboto"
it.getString(R.string.source_code_pro_font_id) -> "Source Code Pro"
getString(R.string.open_sans_font_id) -> "Open Sans"
getString(R.string.roboto_font_id) -> "Roboto"
getString(R.string.source_code_pro_font_id) -> "Source Code Pro"
else -> ""
}
}?.toString().orEmpty()
val fontLinkAndStyle =
if (fontName.isNotEmpty()) {
if (font.isNotEmpty()) {
"""<link href="https://fonts.googleapis.com/css?family=${
fontName.replace(
" ",
@ -457,7 +459,7 @@ class ArticleFragment :
} else {
""
}
try {
binding.webcontent.loadDataWithBaseURL(
baseUrl,
"""<html>