diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/OfflineContents.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/OfflineContents.kt index cc350ae..956d956 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/OfflineContents.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/OfflineContents.kt @@ -5,7 +5,6 @@ import android.content.Intent import android.os.Environment import android.webkit.CookieManager import androidx.core.content.FileProvider -import bums.lunatic.launcher.utils.CompressStringUtil import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay @@ -67,38 +66,34 @@ class OfflineContents(val context: Context, val host : String, val cookie: Strin fun enofLoop() { if (onItEndof) return onItEndof = true - LogUtil.e("on it enofLoop before compressString ${htmlString.length}") + LogUtil.e("on it enofLoop") + urlPathMap.forEach { t, u -> + val file = File(u) + var contentsUriString = FileProvider.getUriForFile( + context, + "${context.packageName}.fileprovider", + file + ).toString() - CompressStringUtil.compressString(htmlString.toString())?.apply { - LogUtil.e("on it enofLoop 2 compressed String ${this.length}") + var targetString = t + var targetIdx = htmlString.indexOf(targetString) + if (targetIdx > 0) { + htmlString?.replace( + targetIdx, + targetIdx.plus(targetString.length), + contentsUriString + ) + } + targetString = t.replace("&", "&") + targetIdx = htmlString.indexOf(targetString) + if (targetIdx > 0) { + htmlString?.replace( + targetIdx, + targetIdx.plus(targetString.length), + contentsUriString + ) + } } -// urlPathMap.forEach { t, u -> -// val file = File(u) -// var contentsUriString = FileProvider.getUriForFile( -// context, -// "${context.packageName}.fileprovider", -// file -// ).toString() -// -// var targetString = t -// var targetIdx = htmlString.indexOf(targetString) -// if (targetIdx > 0) { -// htmlString?.replace( -// targetIdx, -// targetIdx.plus(targetString.length), -// contentsUriString -// ) -// } -// targetString = t.replace("&", "&") -// targetIdx = htmlString.indexOf(targetString) -// if (targetIdx > 0) { -// htmlString?.replace( -// targetIdx, -// targetIdx.plus(targetString.length), -// contentsUriString -// ) -// } -// } if (autoCheck) { LogUtil.e("on it enofLoop autoCheck ${autoCheck}")