Skip to content

Commit

Permalink
Merge pull request #3870 from kiwix/Fixes#3869
Browse files Browse the repository at this point in the history
Fixed: Long clicking on Download button in epub ZIM files shows the `Open in new tab` dialog which leads to a blank page.
  • Loading branch information
kelson42 authored Jun 7, 2024
2 parents 694e76b + 630966d commit 8e08ace
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ open class CoreWebViewClient(
}

@Suppress("NestedBlockDepth")
private fun handleUnsupportedFiles(url: String): Boolean {
fun handleUnsupportedFiles(url: String): Boolean {
val extension = MimeTypeMap.getFileExtensionFromUrl(url)
if (DOCUMENT_TYPES.containsKey(extension)) {
callback.showSaveOrOpenUnsupportedFilesDialog(url, DOCUMENT_TYPES[extension])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ open class KiwixWebView @SuppressLint("SetJavaScriptEnabled") constructor(
attrs: AttributeSet,
nonVideoView: ViewGroup,
videoView: ViewGroup,
webViewClient: CoreWebViewClient,
private val webViewClient: CoreWebViewClient,
val sharedPreferenceUtil: SharedPreferenceUtil
) : VideoEnabledWebView(context, attrs) {

Expand Down Expand Up @@ -108,7 +108,11 @@ open class KiwixWebView @SuppressLint("SetJavaScriptEnabled") constructor(
override fun performLongClick(): Boolean {
val result = hitTestResult
if (result.type == HitTestResult.SRC_ANCHOR_TYPE) {
result.extra?.let(callback::webViewLongClick)
result.extra?.let {
if (!webViewClient.handleUnsupportedFiles(it)) {
callback.webViewLongClick(it)
}
}
return true
}
return super.performLongClick()
Expand Down

0 comments on commit 8e08ace

Please sign in to comment.