From acaed246cc2082e13b68f7ecc2df4145a18865a4 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Mon, 17 Jan 2022 09:25:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E4=B9=A6=E6=BA=90?= =?UTF-8?q?=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/gradle.xml | 3 +- app/build.gradle | 12 ++++ .../xyz/fycz/myreader/common/APPCONST.java | 1 + .../model/third2/analyzeRule/AnalyzeRule.java | 1 - .../model/third2/analyzeRule/AnalyzeUrl.java | 1 - .../third2/analyzeRule/JsExtensions.java | 5 +- .../fycz/myreader/model/third3/Exceptions.kt | 2 +- .../third3/analyzeRule/AnalyzeByJSonPath.kt | 12 ++-- .../third3/analyzeRule/AnalyzeByJSoup.kt | 2 +- .../third3/analyzeRule/AnalyzeByRegex.kt | 2 +- .../third3/analyzeRule/AnalyzeByXPath.kt | 2 +- .../model/third3/analyzeRule/AnalyzeRule.kt | 2 +- .../model/third3/analyzeRule/AnalyzeUrl.kt | 2 +- .../model/third3/analyzeRule/JsExtensions.kt | 67 +++++++++---------- .../model/third3/analyzeRule/QueryTTF.java | 2 +- .../model/third3/analyzeRule/RuleAnalyzer.kt | 2 +- .../model/third3/analyzeRule/RuleData.kt | 2 +- .../third3/analyzeRule/RuleDataInterface.kt | 2 +- .../model/third3/http/BackstageWebView.kt | 16 ++--- .../myreader/model/third3/http/SSLHelper.kt | 12 ++-- .../model/third3/webBook/BookChapterList.kt | 8 +-- .../model/third3/webBook/BookContent.kt | 6 +- .../myreader/model/third3/webBook/BookInfo.kt | 4 +- .../myreader/model/third3/webBook/BookList.kt | 6 +- .../model/third3/webBook/SearchModel.kt | 2 +- .../myreader/model/third3/webBook/WebBook.kt | 4 +- 26 files changed, 93 insertions(+), 87 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index bf2bb41..eb20a8e 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,7 +4,7 @@ diff --git a/app/build.gradle b/app/build.gradle index 98d12d4..99ba574 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -124,6 +124,10 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } + kotlinOptions { + jvmTarget = "1.8" + } + productFlavors { } packagingOptions { @@ -242,6 +246,14 @@ dependencies { // https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.9.1' + + //协程 + def coroutines_version = '1.5.1' + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version") + + //apache + implementation('org.apache.commons:commons-text:1.9') } greendao { diff --git a/app/src/main/java/xyz/fycz/myreader/common/APPCONST.java b/app/src/main/java/xyz/fycz/myreader/common/APPCONST.java index 5077c34..8ba6f3c 100644 --- a/app/src/main/java/xyz/fycz/myreader/common/APPCONST.java +++ b/app/src/main/java/xyz/fycz/myreader/common/APPCONST.java @@ -132,4 +132,5 @@ public class APPCONST { public static final String DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4168.3 Safari/537.36"; + public static final String UA_NAME = "User-Agent"; } diff --git a/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeRule.java b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeRule.java index 2cf42c8..982e878 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeRule.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeRule.java @@ -20,7 +20,6 @@ import javax.script.SimpleBindings; import xyz.fycz.myreader.greendao.entity.Book; import xyz.fycz.myreader.greendao.service.CookieStore; import xyz.fycz.myreader.util.help.StringHelper; -import xyz.fycz.myreader.util.help.JsExtensions; import xyz.fycz.myreader.util.utils.NetworkUtils; import xyz.fycz.myreader.util.utils.StringUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeUrl.java b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeUrl.java index 2bd7c25..bcbb28e 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeUrl.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/AnalyzeUrl.java @@ -20,7 +20,6 @@ import java.util.regex.Pattern; import javax.script.SimpleBindings; import xyz.fycz.myreader.util.help.StringHelper; -import xyz.fycz.myreader.util.help.JsExtensions; import xyz.fycz.myreader.util.utils.NetworkUtils; import xyz.fycz.myreader.util.utils.StringUtils; import xyz.fycz.myreader.util.utils.UrlEncoderUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/JsExtensions.java b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/JsExtensions.java index 7b8a674..e4f516d 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/JsExtensions.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third2/analyzeRule/JsExtensions.java @@ -1,4 +1,4 @@ -package xyz.fycz.myreader.util.help; +package xyz.fycz.myreader.model.third2.analyzeRule; import android.text.TextUtils; @@ -23,10 +23,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import xyz.fycz.myreader.greendao.service.CookieStore; -import xyz.fycz.myreader.model.third2.analyzeRule.AnalyzeUrl; import xyz.fycz.myreader.util.ZipUtils; +import xyz.fycz.myreader.util.help.SSLSocketClient; import xyz.fycz.myreader.util.utils.EncoderUtils; -import xyz.fycz.myreader.util.utils.EncodingDetect; import xyz.fycz.myreader.util.utils.FileUtils; import xyz.fycz.myreader.util.utils.MD5Utils; import xyz.fycz.myreader.util.utils.OkHttpUtils; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/Exceptions.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/Exceptions.kt index 01a0026..072be6c 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/Exceptions.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/Exceptions.kt @@ -1,6 +1,6 @@ @file:Suppress("unused") -package io.legado.app.model +package xyz.fycz.myreader.model.third3 class AppException(msg: String) : Exception(msg) diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByJSonPath.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByJSonPath.kt index 0846245..0f920b0 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByJSonPath.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByJSonPath.kt @@ -1,16 +1,18 @@ -package io.legado.app.model.analyzeRule +package xyz.fycz.myreader.model.third3.analyzeRule +import android.util.Log import androidx.annotation.Keep import com.jayway.jsonpath.JsonPath import com.jayway.jsonpath.ReadContext -import timber.log.Timber import java.util.* @Suppress("RegExpRedundantEscape") @Keep class AnalyzeByJSonPath(json: Any) { + private val TAG = AnalyzeByJSonPath::class.simpleName + companion object { fun parse(json: Any): ReadContext { @@ -50,7 +52,7 @@ class AnalyzeByJSonPath(json: Any) { ob.toString() } } catch (e: Exception) { - Timber.e(e) + Log.e(TAG, e.toString()) } } return result @@ -87,7 +89,7 @@ class AnalyzeByJSonPath(json: Any) { result.add(obj.toString()) } } catch (e: Exception) { - Timber.e(e) + Log.e(TAG, e.toString()) } } else { result.add(st) @@ -137,7 +139,7 @@ class AnalyzeByJSonPath(json: Any) { try { return it.read>(rules[0]) } catch (e: Exception) { - Timber.e(e) + Log.e(TAG, e.toString()) } } } else { diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByJSoup.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByJSoup.kt index 45ea15c..f17c06c 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByJSoup.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByJSoup.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.analyzeRule +package xyz.fycz.myreader.model.third3.analyzeRule import androidx.annotation.Keep import org.jsoup.Jsoup diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByRegex.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByRegex.kt index 05851b4..5a72958 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByRegex.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByRegex.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.analyzeRule +package xyz.fycz.myreader.model.third3.analyzeRule import androidx.annotation.Keep import java.util.* diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByXPath.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByXPath.kt index a67d934..e7b7ff2 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByXPath.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeByXPath.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.analyzeRule +package xyz.fycz.myreader.model.third3.analyzeRule import android.text.TextUtils import androidx.annotation.Keep diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeRule.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeRule.kt index 1e1b879..f884665 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeRule.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.analyzeRule +package xyz.fycz.myreader.model.third3.analyzeRule import android.text.TextUtils import androidx.annotation.Keep diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt index 81b11e5..b66afa6 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/AnalyzeUrl.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.analyzeRule +package xyz.fycz.myreader.model.third3.analyzeRule import android.annotation.SuppressLint import androidx.annotation.Keep diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/JsExtensions.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/JsExtensions.kt index 0897a59..83f0657 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/JsExtensions.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/JsExtensions.kt @@ -1,24 +1,20 @@ -package io.legado.app.help +package xyz.fycz.myreader.model.third3.analyzeRule import android.net.Uri import android.util.Base64 +import android.util.Log import androidx.annotation.Keep -import io.legado.app.BuildConfig -import io.legado.app.constant.AppConst -import io.legado.app.constant.AppConst.dateFormat -import io.legado.app.data.entities.BaseSource import io.legado.app.help.http.* -import io.legado.app.model.Debug -import io.legado.app.model.analyzeRule.AnalyzeUrl -import io.legado.app.model.analyzeRule.QueryTTF -import io.legado.app.utils.* import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking +import nl.siegmann.epublib.epub.PackageDocumentBase.dateFormat import org.jsoup.Connection import org.jsoup.Jsoup -import splitties.init.appCtx -import timber.log.Timber +import xyz.fycz.myreader.greendao.entity.rule.BookSource +import xyz.fycz.myreader.greendao.service.CookieStore +import xyz.fycz.myreader.util.ZipUtils +import xyz.fycz.myreader.util.utils.* import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.File @@ -38,7 +34,10 @@ import java.util.zip.ZipInputStream @Suppress("unused") interface JsExtensions { - fun getSource(): BaseSource? + private val TAG: String? + get() = JsExtensions::class.simpleName + + fun getSource(): BookSource? /** * 访问网络,返回String @@ -50,9 +49,9 @@ interface JsExtensions { analyzeUrl.getStrResponseAwait().body }.onFailure { log("ajax(${urlStr}) error\n${it.stackTraceToString()}") - Timber.e(it) + Log.e(TAG, it.toString()) }.getOrElse { - it.msg + it.message } } } @@ -86,7 +85,7 @@ interface JsExtensions { analyzeUrl.getStrResponseAwait() }.onFailure { log("connect(${urlStr}) error\n${it.stackTraceToString()}") - Timber.e(it) + Log.e(TAG, it.toString()) }.getOrElse { StrResponse(analyzeUrl.url, it.localizedMessage) } @@ -101,7 +100,7 @@ interface JsExtensions { analyzeUrl.getStrResponseAwait() }.onFailure { log("ajax($urlStr,$header) error\n${it.stackTraceToString()}") - Timber.e(it) + Log.e(TAG, it.toString()) }.getOrElse { StrResponse(analyzeUrl.url, it.localizedMessage) } @@ -134,11 +133,11 @@ interface JsExtensions { fun downloadFile(content: String, url: String): String { val type = AnalyzeUrl(url, source = getSource()).type ?: return "" val zipPath = FileUtils.getPath( - FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), + FileUtils.getFile(FileUtils.getCachePath()), "${MD5Utils.md5Encode16(url)}.${type}" ) FileUtils.deleteFile(zipPath) - val zipFile = FileUtils.createFileIfNotExist(zipPath) + val zipFile = FileUtils.getFile(zipPath) StringUtils.hexStringToByte(content).let { if (it.isNotEmpty()) { zipFile.writeBytes(it) @@ -303,7 +302,7 @@ interface JsExtensions { fun readTxtFile(path: String): String { val file = getFile(path) if (file.exists()) { - val charsetName = EncodingDetect.getEncode(file) + val charsetName = EncodingDetect.getJavaEncode(file) return String(file.readBytes(), charset(charsetName)) } return "" @@ -321,8 +320,7 @@ interface JsExtensions { * 删除本地文件 */ fun deleteFile(path: String) { - val file = getFile(path) - FileUtils.delete(file, true) + FileUtils.deleteFile(path) } /** @@ -332,16 +330,13 @@ interface JsExtensions { */ fun unzipFile(zipPath: String): String { if (zipPath.isEmpty()) return "" - val unzipPath = FileUtils.getPath( - FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), - FileUtils.getNameExcludeExtension(zipPath) - ) + val unzipPath = FileUtils.getCachePath() + File.separator + FileUtils.getNameExcludeExtension(zipPath) FileUtils.deleteFile(unzipPath) - val zipFile = getFile(zipPath) - val unzipFolder = FileUtils.createFolderIfNotExist(unzipPath) + val zipFile = FileUtils.getFile(zipPath) + val unzipFolder = FileUtils.getFolder(unzipPath) ZipUtils.unzipFile(zipFile, unzipFolder) - FileUtils.deleteFile(zipFile.absolutePath) - return unzipPath.substring(FileUtils.getCachePath().length) + FileUtils.deleteFile(zipPath) + return unzipPath } /** @@ -354,7 +349,7 @@ interface JsExtensions { unzipFolder.listFiles().let { if (it != null) { for (f in it) { - val charsetName = EncodingDetect.getEncode(f) + val charsetName = EncodingDetect.getJavaEncode(f) contents.append(String(f.readBytes(), charset(charsetName))) .append("\n") } @@ -373,7 +368,7 @@ interface JsExtensions { */ fun getZipStringContent(url: String, path: String): String { val byteArray = getZipByteArrayContent(url, path) ?: return "" - val charsetName = EncodingDetect.getEncode(byteArray) + val charsetName = EncodingDetect.getJavaEncode(byteArray) return String(byteArray, Charset.forName(charsetName)) } @@ -485,7 +480,7 @@ interface JsExtensions { Debug.log(it.getKey(), msg) } ?: Debug.log(msg) if (BuildConfig.DEBUG) { - Timber.d(msg) + Log.e(TAG, msg) } return msg } @@ -515,7 +510,7 @@ interface JsExtensions { iv.encodeToByteArray() ) } catch (e: Exception) { - Timber.e(e) + Log.e(TAG, e.toString()) log(e.localizedMessage ?: "aesDecodeToByteArrayERROR") null } @@ -554,7 +549,7 @@ interface JsExtensions { iv.encodeToByteArray() ) } catch (e: Exception) { - Timber.e(e) + Log.e(TAG, r.toString()) log(e.localizedMessage ?: "aesDecodeToByteArrayERROR") null } @@ -592,7 +587,7 @@ interface JsExtensions { iv.encodeToByteArray() ) } catch (e: Exception) { - Timber.e(e) + Log.e(TAG, e.toString()) log(e.localizedMessage ?: "aesEncodeToByteArrayERROR") null } @@ -629,7 +624,7 @@ interface JsExtensions { iv.encodeToByteArray() ) } catch (e: Exception) { - Timber.e(e) + Log.e(TAG, e.toString()) log(e.localizedMessage ?: "aesEncodeToBase64ByteArrayERROR") null } diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/QueryTTF.java b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/QueryTTF.java index dc35a78..3037e37 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/QueryTTF.java +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/QueryTTF.java @@ -1,4 +1,4 @@ -package io.legado.app.model.analyzeRule; +package xyz.fycz.myreader.model.third3.analyzeRule; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleAnalyzer.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleAnalyzer.kt index 5fd91e1..0392553 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleAnalyzer.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleAnalyzer.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.analyzeRule +package xyz.fycz.myreader.model.third3.analyzeRule //通用的规则切分处理 class RuleAnalyzer(data: String, code: Boolean = false) { diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleData.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleData.kt index 3752ac1..ac7e4ff 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleData.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleData.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.analyzeRule +package xyz.fycz.myreader.model.third3.analyzeRule class RuleData : RuleDataInterface { diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleDataInterface.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleDataInterface.kt index 8b87f94..e866cfa 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleDataInterface.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/analyzeRule/RuleDataInterface.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.analyzeRule +package xyz.fycz.myreader.model.third3.analyzeRule interface RuleDataInterface { diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/http/BackstageWebView.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/http/BackstageWebView.kt index 914b940..dc4ce1d 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/http/BackstageWebView.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/http/BackstageWebView.kt @@ -8,12 +8,12 @@ import android.webkit.CookieManager import android.webkit.WebSettings import android.webkit.WebView import android.webkit.WebViewClient -import io.legado.app.constant.AppConst -import io.legado.app.model.NoStackTraceException -import io.legado.app.utils.runOnUI import kotlinx.coroutines.* import org.apache.commons.text.StringEscapeUtils -import splitties.init.appCtx +import xyz.fycz.myreader.application.App +import xyz.fycz.myreader.common.APPCONST +import xyz.fycz.myreader.greendao.service.CookieStore +import xyz.fycz.myreader.model.third3.NoStackTraceException import java.lang.ref.WeakReference import kotlin.coroutines.resume @@ -36,7 +36,7 @@ class BackstageWebView( suspend fun getStrResponse(): StrResponse = suspendCancellableCoroutine { block -> block.invokeOnCancellation { - runOnUI { + App.getHandler().post { destroy() } } @@ -51,7 +51,7 @@ class BackstageWebView( block.cancel(error) } } - runOnUI { + App.getHandler().post { try { load() } catch (error: Throwable) { @@ -88,12 +88,12 @@ class BackstageWebView( @SuppressLint("SetJavaScriptEnabled", "JavascriptInterface") private fun createWebView(): WebView { - val webView = WebView(appCtx) + val webView = WebView(App.getmContext()) val settings = webView.settings settings.javaScriptEnabled = true settings.domStorageEnabled = true settings.blockNetworkImage = true - settings.userAgentString = headerMap?.get(AppConst.UA_NAME) + settings.userAgentString = headerMap?.get(APPCONST.UA_NAME) settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW if (sourceRegex.isNullOrEmpty()) { webView.webViewClient = HtmlWebViewClient() diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/http/SSLHelper.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/http/SSLHelper.kt index ecbcc1f..55624c6 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/http/SSLHelper.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/http/SSLHelper.kt @@ -1,8 +1,8 @@ package io.legado.app.help.http import android.annotation.SuppressLint +import android.util.Log -import timber.log.Timber import java.io.IOException import java.io.InputStream import java.security.KeyManagementException @@ -16,7 +16,7 @@ import javax.net.ssl.* @Suppress("unused") object SSLHelper { - + private val TAG = SSLHelper::class.simpleName /** * 为了解决客户端不信任服务器数字证书的问题, * 网络上大部分的解决方案都是让客户端不对证书做任何检查, @@ -127,9 +127,9 @@ object SSLHelper { sslParams.trustManager = manager return sslParams } catch (e: NoSuchAlgorithmException) { - Timber.e(e) + Log.e(TAG, e.toString()) } catch (e: KeyManagementException) { - Timber.e(e) + Log.e(TAG, e.toString()) } return null } @@ -143,7 +143,7 @@ object SSLHelper { kmf.init(clientKeyStore, password.toCharArray()) return kmf.keyManagers } catch (e: Exception) { - Timber.e(e) + Log.e(TAG, e.toString()) } return null } @@ -162,7 +162,7 @@ object SSLHelper { try { certStream.close() } catch (e: IOException) { - Timber.e(e) + Log.e(TAG, e.toString()) } } //我们创建一个默认类型的TrustManagerFactory diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookChapterList.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookChapterList.kt index db8a7c7..a413e38 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookChapterList.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookChapterList.kt @@ -1,16 +1,16 @@ -package io.legado.app.model.webBook +package xyz.fycz.myreader.model.third3.webBook import android.text.TextUtils import io.legado.app.R import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookSource -import io.legado.app.data.entities.rule.TocRule +import xyz.fycz.myreader.model.third3.rule.TocRule import io.legado.app.model.Debug import io.legado.app.model.NoStackTraceException import io.legado.app.model.TocEmptyException -import io.legado.app.model.analyzeRule.AnalyzeRule -import io.legado.app.model.analyzeRule.AnalyzeUrl +import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeRule +import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeUrl import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.async diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookContent.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookContent.kt index c51a4e4..6966017 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookContent.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookContent.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.webBook +package xyz.fycz.myreader.model.third3.webBook import io.legado.app.R import io.legado.app.data.appDb @@ -10,8 +10,8 @@ import io.legado.app.help.BookHelp import io.legado.app.model.ContentEmptyException import io.legado.app.model.Debug import io.legado.app.model.NoStackTraceException -import io.legado.app.model.analyzeRule.AnalyzeRule -import io.legado.app.model.analyzeRule.AnalyzeUrl +import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeRule +import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeUrl import io.legado.app.utils.HtmlFormatter import io.legado.app.utils.NetworkUtils import kotlinx.coroutines.CoroutineScope diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookInfo.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookInfo.kt index ceb1b3b..2b67b8d 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookInfo.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookInfo.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.webBook +package xyz.fycz.myreader.model.third3.webBook import io.legado.app.R import io.legado.app.data.entities.Book @@ -6,7 +6,7 @@ import io.legado.app.data.entities.BookSource import io.legado.app.help.BookHelp import io.legado.app.model.Debug import io.legado.app.model.NoStackTraceException -import io.legado.app.model.analyzeRule.AnalyzeRule +import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeRule import io.legado.app.utils.HtmlFormatter import io.legado.app.utils.NetworkUtils import io.legado.app.utils.StringUtils.wordCountFormat diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookList.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookList.kt index 8bc9dac..b8415ea 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookList.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/BookList.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.webBook +package xyz.fycz.myreader.model.third3.webBook import io.legado.app.R import io.legado.app.data.entities.Book @@ -8,8 +8,8 @@ import io.legado.app.data.entities.rule.BookListRule import io.legado.app.help.BookHelp import io.legado.app.model.Debug import io.legado.app.model.NoStackTraceException -import io.legado.app.model.analyzeRule.AnalyzeRule -import io.legado.app.model.analyzeRule.AnalyzeUrl +import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeRule +import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeUrl import io.legado.app.utils.HtmlFormatter import io.legado.app.utils.NetworkUtils import io.legado.app.utils.StringUtils.wordCountFormat diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/SearchModel.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/SearchModel.kt index 97d8977..961a383 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/SearchModel.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/SearchModel.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.webBook +package xyz.fycz.myreader.model.third3.webBook import io.legado.app.constant.AppConst import io.legado.app.constant.PreferKey diff --git a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/WebBook.kt b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/WebBook.kt index 373014f..65386d5 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/WebBook.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/third3/webBook/WebBook.kt @@ -1,4 +1,4 @@ -package io.legado.app.model.webBook +package xyz.fycz.myreader.model.third3.webBook import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter @@ -8,7 +8,7 @@ import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.http.StrResponse import io.legado.app.model.Debug import io.legado.app.model.NoStackTraceException -import io.legado.app.model.analyzeRule.AnalyzeUrl +import xyz.fycz.myreader.model.third3.analyzeRule.AnalyzeUrl import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.isActive