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. 29
      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. 18
      dynamic/src/main/java/xyz/fycz/dynamic/fix/AppFixHandle.kt
  14. 19
      dynamic/src/main/java/xyz/fycz/dynamic/fix/AppSubSourceFix.kt

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

@ -282,15 +282,9 @@ public class App extends Application {
public static void checkVersionByServer(final AppCompatActivity activity, final boolean isManualCheck) {
App.getApplication().newThread(() -> {
try {
String url = "https://shimo.im/docs/cqkgjPRRydYYhQKt/read";
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();
String content = OkHttpUtils.getUpdateInfo();
if (StringHelper.isEmpty(content)) {
content = OkHttpUtils.getUpdateInfo();
content = OkHttpUtils.getBakUpdateInfo();
if (StringHelper.isEmpty(content)) {
if (isManualCheck || NetworkUtils.isNetWorkAvailable()) {
ToastUtils.showError("检查更新失败!");

@ -176,7 +176,7 @@ public class OkHttpUtils {
return response.body().byteStream();
}
public static String getUpdateInfo() throws IOException, JSONException {
public static String getUpdateInfo() throws IOException {
String key = "ryvwiq";
if (App.isDebug()) {
key = "sgak2h";
@ -197,17 +197,28 @@ public class OkHttpUtils {
if (body == null) {
return "";
} else {
String bodyStr = new String(body.bytes(), StandardCharsets.UTF_8);
JSONObject jsonObj = new JSONObject(bodyStr);
jsonObj = jsonObj.getJSONObject("data");
String content = jsonObj.getString("content");
Document doc = Jsoup.parse(content);
content = doc.text();
Log.d("Http -> UpdateInfo", content);
return content;
try {
String bodyStr = new String(body.bytes(), StandardCharsets.UTF_8);
JSONObject jsonObj = new JSONObject(bodyStr);
jsonObj = jsonObj.getJSONObject("data");
String content = jsonObj.getString("content");
Document doc = Jsoup.parse(content);
content = doc.text();
Log.d("Http -> UpdateInfo", 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) {
return Observable.create(emitter -> {
StringBuilder sb = new StringBuilder();

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

@ -39,25 +39,11 @@ import xyz.fycz.myreader.util.utils.AdUtils
class App243Fix : AppFixHandle {
override fun onFix(key: String): BooleanArray {
var fx1 = false
var fx2 = false
try {
fixGetAllNoLocalSource()
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)
return handleFix(
key,
"getAllNoLocalSource" to { fixGetAllNoLocalSource() },
"adTimeout" to { fixAdTimeout() },
)
}
private fun getAllNoLocalSource(): List<BookSource> {

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

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

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

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

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

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

@ -33,9 +33,25 @@ import xyz.fycz.myreader.util.utils.AdUtils
* @date 2022/4/25 21:49
*/
interface AppFixHandle {
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) {
val res = if (success) "Success" else "Failed"
if (!spu.getBoolean("$key-$name-$res", false)) {

@ -29,17 +29,12 @@ import xyz.fycz.myreader.webapi.LanZouApi
* @date 2022/6/21 18:30
*/
@AppFix([], ["更新订阅书源链接,仅支持v2.4.3版本及以上版本"], "2022-06-21")
class AppSubSourceFix : AppFixHandle{
class AppSubSourceFix : AppFixHandle {
override fun onFix(key: String): BooleanArray {
val result = try {
fxSubSource()
true
} catch (e: Exception) {
MapleUtils.log(e)
false
}
fixResult(key, "subSource", result)
return booleanArrayOf(result)
return handleFix(
key,
"subSource" to { fxSubSource() },
)
}
private fun fxSubSource() {
@ -49,9 +44,9 @@ class AppSubSourceFix : AppFixHandle{
String::class.java,
Int::class.java,
String::class.java,
object : MethodHook(){
object : MethodHook() {
override fun beforeHookedMethod(param: MapleBridge.MethodHookParam) {
if (param.args[0] == URLCONST.SUB_SOURCE_URL){
if (param.args[0] == URLCONST.SUB_SOURCE_URL) {
param.args[0] = "https://fycz.lanzoum.com/b00pucrch"
param.args[2] = "b0ox"
}

Loading…
Cancel
Save