mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Fixed: Long clicking on Download button in epub ZIM files shows the Open in new tab dialog which leads to a blank page.
* We didn't account for the scenario where a user long-clicks on an image that contains an anchor tag with a URL. For now, we only check when a link is loading(when user simply clicks on the image button), and if the link is unsupported by Kiwix, we show the save/open dialog. Now, we are also checking for this scenario on long clicks.
This commit is contained in:
parent
694e76bbb0
commit
630966d469
@ -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])
|
||||
|
@ -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) {
|
||||
|
||||
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user