pull/28/head
fengyuecanzhu 2 years ago
parent 0b739766fa
commit e8fb887912
No known key found for this signature in database
GPG Key ID: 04B78AD06A9D6E6C
  1. 2
      app/src/main/assets/updatelog.fy
  2. 10
      app/src/main/java/xyz/fycz/myreader/application/App.java
  3. 13
      app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java
  4. 3
      dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt
  5. 24
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App243Fix.kt
  6. 14
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App244Fix.kt
  7. 14
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App244Fix2.kt
  8. 13
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix.kt
  9. 13
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix2.kt
  10. 13
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix3.kt
  11. 13
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix4.kt
  12. 158
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix5.kt
  13. 16
      dynamic/src/main/java/xyz/fycz/dynamic/fix/AppFixHandle.kt
  14. 13
      dynamic/src/main/java/xyz/fycz/dynamic/fix/AppSubSourceFix.kt

@ -1,4 +1,6 @@
1、修复阅读界面概率性闪退的问题 1、修复阅读界面概率性闪退的问题
2、关于界面新增插件加载结果
3、修复书源订阅失败的问题
2022.05.28 2022.05.28
风月读书v2.4.6 风月读书v2.4.6

@ -282,15 +282,9 @@ public class App extends Application {
public static void checkVersionByServer(final AppCompatActivity activity, final boolean isManualCheck) { public static void checkVersionByServer(final AppCompatActivity activity, final boolean isManualCheck) {
App.getApplication().newThread(() -> { App.getApplication().newThread(() -> {
try { try {
String url = "https://shimo.im/docs/cqkgjPRRydYYhQKt/read"; String content = OkHttpUtils.getUpdateInfo();
if (debug) {
url = "https://shimo.im/docs/zfzpda7MUGskOC9v/read";
}
String html = OkHttpUtils.getHtml(url);
Document doc = Jsoup.parse(html);
String content = doc.getElementsByClass("ql-editor").text();
if (StringHelper.isEmpty(content)) { if (StringHelper.isEmpty(content)) {
content = OkHttpUtils.getUpdateInfo(); content = OkHttpUtils.getBakUpdateInfo();
if (StringHelper.isEmpty(content)) { if (StringHelper.isEmpty(content)) {
if (isManualCheck || NetworkUtils.isNetWorkAvailable()) { if (isManualCheck || NetworkUtils.isNetWorkAvailable()) {
ToastUtils.showError("检查更新失败!"); ToastUtils.showError("检查更新失败!");

@ -176,7 +176,7 @@ public class OkHttpUtils {
return response.body().byteStream(); return response.body().byteStream();
} }
public static String getUpdateInfo() throws IOException, JSONException { public static String getUpdateInfo() throws IOException {
String key = "ryvwiq"; String key = "ryvwiq";
if (App.isDebug()) { if (App.isDebug()) {
key = "sgak2h"; key = "sgak2h";
@ -197,6 +197,7 @@ public class OkHttpUtils {
if (body == null) { if (body == null) {
return ""; return "";
} else { } else {
try {
String bodyStr = new String(body.bytes(), StandardCharsets.UTF_8); String bodyStr = new String(body.bytes(), StandardCharsets.UTF_8);
JSONObject jsonObj = new JSONObject(bodyStr); JSONObject jsonObj = new JSONObject(bodyStr);
jsonObj = jsonObj.getJSONObject("data"); jsonObj = jsonObj.getJSONObject("data");
@ -205,9 +206,19 @@ public class OkHttpUtils {
content = doc.text(); content = doc.text();
Log.d("Http -> UpdateInfo", content); Log.d("Http -> UpdateInfo", content);
return content; return content;
}catch (JSONException e){
e.printStackTrace();
return "";
}
} }
} }
public static String getBakUpdateInfo() throws IOException {
return OkHttpUtils.getHtml("https://fyreader.coding.net/p/img/d/FYReader-Update/git/raw/master/" +
(App.isDebug() ? "debug" : "release") +
"/content.txt");
}
public static Observable<StrResponse> getStrResponse(AnalyzeUrl analyzeUrl) { public static Observable<StrResponse> getStrResponse(AnalyzeUrl analyzeUrl) {
return Observable.create(emitter -> { return Observable.create(emitter -> {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

@ -48,10 +48,11 @@ class AppLoadImpl : IAppLoader {
App244Fix::class.java, App244Fix::class.java,
App244Fix2::class.java, App244Fix2::class.java,
App246Fix::class.java, App246Fix::class.java,
//AppSubSourceFix::class.java, AppSubSourceFix::class.java,
App246Fix2::class.java, App246Fix2::class.java,
App246Fix3::class.java, App246Fix3::class.java,
App246Fix4::class.java, App246Fix4::class.java,
App246Fix5::class.java,
) )
override fun onLoad(appParam: AppParam) { override fun onLoad(appParam: AppParam) {

@ -39,25 +39,11 @@ import xyz.fycz.myreader.util.utils.AdUtils
class App243Fix : AppFixHandle { class App243Fix : AppFixHandle {
override fun onFix(key: String): BooleanArray { override fun onFix(key: String): BooleanArray {
var fx1 = false return handleFix(
var fx2 = false key,
try { "getAllNoLocalSource" to { fixGetAllNoLocalSource() },
fixGetAllNoLocalSource() "adTimeout" to { fixAdTimeout() },
fx1 = true )
fixResult(key, "getAllNoLocalSource", true)
} catch (e: Exception) {
MapleUtils.log(e)
fixResult(key, "getAllNoLocalSource", false)
}
try {
fixAdTimeout()
fx2 = true
fixResult(key, "adTimeout", true)
} catch (e: Exception) {
MapleUtils.log(e)
fixResult(key, "adTimeout", false)
}
return booleanArrayOf(fx1, fx2)
} }
private fun getAllNoLocalSource(): List<BookSource> { private fun getAllNoLocalSource(): List<BookSource> {

@ -36,16 +36,10 @@ import java.io.*
@AppFix([243, 244], ["修复书籍无法导出缓存的问题"], "2022-04-26") @AppFix([243, 244], ["修复书籍无法导出缓存的问题"], "2022-04-26")
class App244Fix: AppFixHandle { class App244Fix: AppFixHandle {
override fun onFix(key: String): BooleanArray { override fun onFix(key: String): BooleanArray {
var fx = false return handleFix(
try { key,
fixUnionChapterCathe() "unionChapterCathe" to { fixUnionChapterCathe() },
fx = true )
fixResult(key, "unionChapterCathe", true)
} catch (e: Exception) {
MapleUtils.log(e)
fixResult(key, "unionChapterCathe", false)
}
return booleanArrayOf(fx)
} }
private fun fixUnionChapterCathe() { private fun fixUnionChapterCathe() {

@ -32,16 +32,10 @@ import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler
@AppFix([243, 244], ["修复搜索时当前分组不存在时无法搜索的问题"], "2022-05-11") @AppFix([243, 244], ["修复搜索时当前分组不存在时无法搜索的问题"], "2022-05-11")
class App244Fix2 : AppFixHandle{ class App244Fix2 : AppFixHandle{
override fun onFix(key: String): BooleanArray { override fun onFix(key: String): BooleanArray {
var fx = false return handleFix(
try { key,
fixGetEnableReadCrawlers() "getEnableReadCrawlers" to { fixGetEnableReadCrawlers() },
fx = true )
fixResult(key, "getEnableReadCrawlers", true)
} catch (e: Exception) {
MapleUtils.log(e)
fixResult(key, "getEnableReadCrawlers", false)
}
return booleanArrayOf(fx)
} }
private fun fixGetEnableReadCrawlers() { private fun fixGetEnableReadCrawlers() {

@ -43,15 +43,10 @@ import xyz.fycz.myreader.util.utils.ScreenUtils
class App246Fix : AppFixHandle { class App246Fix : AppFixHandle {
override fun onFix(key: String): BooleanArray { override fun onFix(key: String): BooleanArray {
val result = try { return handleFix(
fxAdFile() key,
true "adFile" to { fxAdFile() },
} catch (e: Exception) { )
MapleUtils.log(e)
false
}
fixResult(key, "adFile", result)
return booleanArrayOf(result)
} }
fun fxAdFile() { fun fxAdFile() {

@ -30,15 +30,10 @@ import xyz.fycz.myreader.widget.page.PageView
@AppFix([], ["修复阅读界面概率性闪退的问题"], "2022-06-23") @AppFix([], ["修复阅读界面概率性闪退的问题"], "2022-06-23")
class App246Fix2 : AppFixHandle { class App246Fix2 : AppFixHandle {
override fun onFix(key: String): BooleanArray { override fun onFix(key: String): BooleanArray {
val result = try { return handleFix(
fxPageView() key,
true "pageView" to { fxPageView() },
} catch (e: Exception) { )
MapleUtils.log(e)
false
}
fixResult(key, "pageView", result)
return booleanArrayOf(result)
} }
private fun fxPageView() { private fun fxPageView() {

@ -51,15 +51,10 @@ import xyz.fycz.myreader.util.utils.fromJsonObject
class App246Fix3 : AppFixHandle { class App246Fix3 : AppFixHandle {
override fun onFix(key: String): BooleanArray { override fun onFix(key: String): BooleanArray {
val result = try { return handleFix(
fxPluginView() key,
true "pluginView" to { fxPluginView() },
} catch (e: Exception) { )
MapleUtils.log(e)
false
}
fixResult(key, "pluginView", result)
return booleanArrayOf(result)
} }
private fun fxPluginView() { private fun fxPluginView() {

@ -31,15 +31,10 @@ import xyz.fycz.myreader.webapi.LanZouApi
@AppFix([243, 244, 245, 246], ["修复书源订阅失败的问题"], "2022-06-30") @AppFix([243, 244, 245, 246], ["修复书源订阅失败的问题"], "2022-06-30")
class App246Fix4: AppFixHandle { class App246Fix4: AppFixHandle {
override fun onFix(key: String): BooleanArray { override fun onFix(key: String): BooleanArray {
val result = try { return handleFix(
fxLanZouApi() key,
true "lanZouApi" to { fxLanZouApi() },
} catch (e: Exception) { )
MapleUtils.log(e)
false
}
fixResult(key, "lanZouApi", result)
return booleanArrayOf(result)
} }
private fun fxLanZouApi() { private fun fxLanZouApi() {

@ -0,0 +1,158 @@
/*
* This file is part of FYReader.
* FYReader is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FYReader is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FYReader. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2020 - 2022 fengyuecanzhu
*/
package xyz.fycz.dynamic.fix
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import me.fycz.maple.MapleBridge
import me.fycz.maple.MapleUtils
import me.fycz.maple.MethodReplacement
import xyz.fycz.myreader.R
import xyz.fycz.myreader.application.App
import xyz.fycz.myreader.application.SysManager
import xyz.fycz.myreader.common.URLCONST
import xyz.fycz.myreader.util.SharedPreUtils
import xyz.fycz.myreader.util.ToastUtils
import xyz.fycz.myreader.util.help.StringHelper
import xyz.fycz.myreader.util.utils.NetworkUtils
import xyz.fycz.myreader.util.utils.OkHttpUtils
import java.io.IOException
/**
* @author fengyue
* @date 2022/7/1 15:45
*/
@AppFix([243, 244, 245, 246], ["修复检查更新失败的问题"], "2022-07-01")
class App246Fix5 : AppFixHandle {
override fun onFix(key: String): BooleanArray {
return handleFix(
key,
"checkUpdateUrl" to { fxCheckUpdateUrl() },
)
}
fun fxCheckUpdateUrl() {
MapleUtils.findAndHookMethod(
App::class.java,
"checkVersionByServer",
AppCompatActivity::class.java,
Boolean::class.java,
object : MethodReplacement() {
override fun replaceHookedMethod(param: MapleBridge.MethodHookParam) {
checkUpdate(param.args[0] as AppCompatActivity, param.args[1] as Boolean)
}
}
)
}
fun checkUpdate(activity: AppCompatActivity, isManualCheck: Boolean) {
App.getApplication().newThread {
try {
var content = OkHttpUtils.getUpdateInfo()
if (StringHelper.isEmpty(content)) {
content = getBakUpdateInfo()
if (StringHelper.isEmpty(content)) {
if (isManualCheck || NetworkUtils.isNetWorkAvailable()) {
ToastUtils.showError("检查更新失败!")
}
return@newThread
}
}
val contents = content.split(";".toRegex())
val newestVersion = contents[0].substring(contents[0].indexOf(":") + 1).toInt()
var isForceUpdate = contents[1].substring(contents[1].indexOf(":") + 1).toBoolean()
val downloadLink =
contents[2].substring(contents[2].indexOf(":") + 1).trim { it <= ' ' }
val updateContent = contents[3].substring(contents[3].indexOf(":") + 1)
SharedPreUtils.getInstance().putString(
App.getmContext().getString(R.string.lanzousKeyStart),
contents[4].substring(contents[4].indexOf(":") + 1)
)
val newSplashTime = contents[5].substring(contents[5].indexOf(":") + 1)
val oldSplashTime = SharedPreUtils.getInstance().getString("splashTime")
SharedPreUtils.getInstance()
.putBoolean("needUdSI", oldSplashTime != newSplashTime)
SharedPreUtils.getInstance().putString(
"splashTime",
contents[5].substring(contents[5].indexOf(":") + 1)
)
SharedPreUtils.getInstance().putString(
"splashImageUrl",
contents[6].substring(contents[6].indexOf(":") + 1)
)
SharedPreUtils.getInstance().putString(
"splashImageMD5",
contents[7].substring(contents[7].indexOf(":") + 1)
)
val forceUpdateVersion = contents[8].substring(contents[8].indexOf(":") + 1).toInt()
SharedPreUtils.getInstance().putInt("forceUpdateVersion", forceUpdateVersion)
val domain = contents[9].substring(contents[9].indexOf(":") + 1)
SharedPreUtils.getInstance().putString("domain", domain)
val pluginConfigUrl = contents[10].substring(contents[10].indexOf(":") + 1)
SharedPreUtils.getInstance().putString("pluginConfigUrl", pluginConfigUrl)
val versionCode = App.getVersionCode()
isForceUpdate = isForceUpdate && forceUpdateVersion > versionCode
if (!StringHelper.isEmpty(downloadLink)) {
SharedPreUtils.getInstance()
.putString(App.getmContext().getString(R.string.downloadLink), downloadLink)
} else {
SharedPreUtils.getInstance().putString(
App.getmContext().getString(R.string.downloadLink),
URLCONST.APP_DIR_URL
)
}
val updateContents = updateContent.split("/".toRegex())
val s = StringBuilder()
updateContents.forEach {
s.append(it)
s.append("<br>")
}
Log.i("检查更新,最新版本", newestVersion.toString() + "")
if (newestVersion > versionCode) {
val setting = SysManager.getSetting()
if (isManualCheck || setting.newestVersionCode < newestVersion || isForceUpdate) {
setting.newestVersionCode = newestVersion
SysManager.saveSetting(setting)
App.getApplication().updateApp2(
activity, downloadLink, newestVersion, s.toString(), isForceUpdate
)
}
} else if (isManualCheck) {
ToastUtils.showSuccess("已经是最新版本!")
}
} catch (e: Exception) {
e.printStackTrace()
Log.e("检查更新失败!", "" + e.localizedMessage)
if (isManualCheck || NetworkUtils.isNetWorkAvailable()) {
ToastUtils.showError("检查更新失败!")
}
}
}
}
@Throws(IOException::class)
fun getBakUpdateInfo(): String {
return OkHttpUtils.getHtml(
"https://fyreader.coding.net/p/img/d/FYReader-Update/git/raw/master/" +
(if (App.isDebug()) "debug" else "release") +
"/content.txt"
)
}
}

@ -36,6 +36,22 @@ interface AppFixHandle {
fun onFix(key: String): BooleanArray fun onFix(key: String): BooleanArray
fun handleFix(key: String, vararg fix: Pair<String, () -> Unit>): BooleanArray {
val results = mutableListOf<Boolean>()
fix.forEach {
val result = try {
it.second()
true
} catch (e: Exception) {
MapleUtils.log(e)
false
}
results.add(result)
fixResult(key, it.first, result)
}
return results.toBooleanArray()
}
fun fixResult(key: String, name: String, success: Boolean) { fun fixResult(key: String, name: String, success: Boolean) {
val res = if (success) "Success" else "Failed" val res = if (success) "Success" else "Failed"
if (!spu.getBoolean("$key-$name-$res", false)) { if (!spu.getBoolean("$key-$name-$res", false)) {

@ -31,15 +31,10 @@ import xyz.fycz.myreader.webapi.LanZouApi
@AppFix([], ["更新订阅书源链接,仅支持v2.4.3版本及以上版本"], "2022-06-21") @AppFix([], ["更新订阅书源链接,仅支持v2.4.3版本及以上版本"], "2022-06-21")
class AppSubSourceFix : AppFixHandle { class AppSubSourceFix : AppFixHandle {
override fun onFix(key: String): BooleanArray { override fun onFix(key: String): BooleanArray {
val result = try { return handleFix(
fxSubSource() key,
true "subSource" to { fxSubSource() },
} catch (e: Exception) { )
MapleUtils.log(e)
false
}
fixResult(key, "subSource", result)
return booleanArrayOf(result)
} }
private fun fxSubSource() { private fun fxSubSource() {

Loading…
Cancel
Save