fixes #2
- Switched back to java 17 Tracking-Bug: A-4762 (F-Droid builds failing) So far, we don't depend on any JVM 19 features. This may change in the future and a different solution may be req'd - Properly fixed race condition Previously, we tried to unreliably check class name which doesn't work for minified builds - Migrate a couple things to kotlin - Refactor http class - fix chinese traditional Signed-off-by: androidacy-user <opensource@androidacy.com>pull/27/head
parent
0c1a3ce8d0
commit
860036014c
@ -0,0 +1,35 @@
|
||||
package com.fox2code.mmm.utils.io
|
||||
|
||||
import android.content.Context
|
||||
import com.fox2code.mmm.MainApplication
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.chromium.net.CronetEngine
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.net.URL
|
||||
|
||||
class FileUtils {
|
||||
private var urlFactoryInstalled = false
|
||||
|
||||
fun ensureCacheDirs() {
|
||||
try {
|
||||
FileUtils.forceMkdir(File((MainApplication.getINSTANCE().dataDir.toString() + "/cache/WebView/Default/HTTP Cache/Code Cache/wasm").replace("//".toRegex(), "/")))
|
||||
FileUtils.forceMkdir(File((MainApplication.getINSTANCE().dataDir.toString() + "/cache/WebView/Default/HTTP Cache/Code Cache/js").replace("//".toRegex(), "/")))
|
||||
FileUtils.forceMkdir(File((MainApplication.getINSTANCE().dataDir.toString() + "/cache/cronet").replace("//".toRegex(), "/")))
|
||||
} catch (e: IOException) {
|
||||
Timber.e("Could not create cache dirs")
|
||||
}
|
||||
}
|
||||
|
||||
fun ensureURLHandler(context: Context?) {
|
||||
if (!urlFactoryInstalled) {
|
||||
try {
|
||||
URL.setURLStreamHandlerFactory(CronetEngine.Builder(context).build().createURLStreamHandlerFactory())
|
||||
urlFactoryInstalled = true
|
||||
} catch (ignored: Error) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue