mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
#1659 Autoload next video - revert migration from legacy content prefix - reorder statement so output stream is definitely connected
This commit is contained in:
parent
957ecd7691
commit
f9f05b0a95
@ -31,7 +31,6 @@ import androidx.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import org.kiwix.kiwixmobile.core.CoreApp;
|
||||
import org.kiwix.kiwixmobile.core.R;
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimFileReader;
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer;
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil;
|
||||
|
||||
@ -145,17 +144,10 @@ public abstract class CoreWebViewClient extends WebViewClient {
|
||||
@Nullable
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
||||
final String migratedUrl = migrate(url);
|
||||
if (migratedUrl.startsWith(CONTENT_PREFIX)) {
|
||||
return zimReaderContainer.load(migratedUrl);
|
||||
if (url.startsWith(CONTENT_PREFIX)) {
|
||||
return zimReaderContainer.load(url);
|
||||
} else {
|
||||
return super.shouldInterceptRequest(view, migratedUrl);
|
||||
return super.shouldInterceptRequest(view, url);
|
||||
}
|
||||
}
|
||||
|
||||
private String migrate(String url) {
|
||||
return url.startsWith(ZimFileReader.LEGACY_PREFIX)
|
||||
? url.replace(ZimFileReader.LEGACY_PREFIX, CONTENT_PREFIX)
|
||||
: url;
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,8 @@ class ZimFileReader constructor(
|
||||
|
||||
private fun loadContent(uri: String) =
|
||||
try {
|
||||
PipedInputStream(PipedOutputStream().also { streamZimContentToPipe(uri, it) })
|
||||
val outputStream = PipedOutputStream()
|
||||
PipedInputStream(outputStream).also { streamZimContentToPipe(uri, outputStream) }
|
||||
} catch (ioException: IOException) {
|
||||
throw IOException("Could not open pipe for $uri", ioException)
|
||||
}
|
||||
@ -231,10 +232,9 @@ class ZimFileReader constructor(
|
||||
val UI_URI: Uri? = Uri.parse("content://org.kiwix.ui/")
|
||||
|
||||
@JvmField
|
||||
val LEGACY_PREFIX =
|
||||
val CONTENT_PREFIX =
|
||||
Uri.parse("content://${CoreApp.getInstance().packageName}.zim.base/").toString()
|
||||
|
||||
const val CONTENT_PREFIX: String = "zim://content/"
|
||||
private val INVERT_IMAGES_VIDEO =
|
||||
"""
|
||||
img, video, div[poster], div#header {
|
||||
|
Loading…
x
Reference in New Issue
Block a user