#1659 Autoload next video - revert migration from legacy content prefix - reorder statement so output stream is definitely connected

This commit is contained in:
Sean Mac Gillicuddy 2020-04-21 16:45:41 +01:00
parent 957ecd7691
commit f9f05b0a95
2 changed files with 6 additions and 14 deletions

View File

@ -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;
}
}

View File

@ -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 {