commit
d9963620a7
@ -1 +1,8 @@ |
|||||||
* 1、修复书源过多时搜索界面卡死的问题 |
* 1、修复阅读界面概率性闪退的问题 |
||||||
|
* 2、关于界面新增插件加载结果 |
||||||
|
* 3、修复书源订阅失败的问题 |
||||||
|
* 4、修复字体下载失败的问题 |
||||||
|
* 5、\[设置-缓存设置\]新增清除广告文件 |
||||||
|
* 6、修复检查更新失败的问题 |
||||||
|
* 7、修复获取更新链接失败的问题 |
||||||
|
* 8、更新订阅书源链接 |
@ -1,81 +0,0 @@ |
|||||||
/* |
|
||||||
* 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 me.fycz.maple.MapleBridge |
|
||||||
import me.fycz.maple.MapleUtils |
|
||||||
import me.fycz.maple.MethodReplacement |
|
||||||
import xyz.fycz.myreader.application.App |
|
||||||
import xyz.fycz.myreader.model.user.UserService |
|
||||||
import xyz.fycz.myreader.util.AppInfoUtils |
|
||||||
import xyz.fycz.myreader.util.utils.EncoderUtils |
|
||||||
|
|
||||||
/** |
|
||||||
* @author fengyue |
|
||||||
* @date 2022/5/23 18:20 |
|
||||||
*/ |
|
||||||
@AppFix([243, 244, 245], ["修改用户服务验证机制(beta)"], "2022-05-23") |
|
||||||
class App245Fix : AppFixHandle { |
|
||||||
|
|
||||||
override fun onFix(key: String): BooleanArray { |
|
||||||
val result = try { |
|
||||||
fixMakeAuth() |
|
||||||
true |
|
||||||
} catch (e: Exception) { |
|
||||||
MapleUtils.log(e) |
|
||||||
false |
|
||||||
} |
|
||||||
fixResult(key, "makeAuth", result) |
|
||||||
return booleanArrayOf(result) |
|
||||||
} |
|
||||||
|
|
||||||
private fun fixMakeAuth() { |
|
||||||
MapleUtils.findAndHookMethod( |
|
||||||
UserService::class.java, |
|
||||||
"makeAuth", |
|
||||||
object : MethodReplacement() { |
|
||||||
override fun replaceHookedMethod(param: MapleBridge.MethodHookParam): Any { |
|
||||||
return makeAuth() |
|
||||||
} |
|
||||||
} |
|
||||||
) |
|
||||||
} |
|
||||||
|
|
||||||
fun makeAuth(): String { |
|
||||||
var auth = "signal=" + AppInfoUtils.getSingInfo( |
|
||||||
App.getmContext(), |
|
||||||
App.getApplication().packageName, |
|
||||||
AppInfoUtils.SHA1 |
|
||||||
) + "&appVersion=" + App.getVersionCode() |
|
||||||
auth = try { |
|
||||||
EncoderUtils.encryptAES2Base64( |
|
||||||
auth.toByteArray(), DO_FILTER_KEY, |
|
||||||
"AES/ECB/PKCS5Padding" |
|
||||||
)?.let { String(it) }.toString() |
|
||||||
} catch (e: Exception) { |
|
||||||
"" |
|
||||||
} |
|
||||||
return "&auth=$auth" + |
|
||||||
"&deviceId=" + UserService.getUUID() + |
|
||||||
"&isDebug=" + App.isDebug() |
|
||||||
} |
|
||||||
|
|
||||||
val DO_FILTER_KEY = "79qdunN8534y44T3".toByteArray() |
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,106 @@ |
|||||||
|
/* |
||||||
|
* 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.view.ViewGroup |
||||||
|
import android.widget.RelativeLayout |
||||||
|
import android.widget.ScrollView |
||||||
|
import android.widget.TextView |
||||||
|
import androidx.core.content.ContextCompat |
||||||
|
import androidx.core.view.get |
||||||
|
import androidx.viewbinding.ViewBinding |
||||||
|
import me.fycz.maple.MapleBridge |
||||||
|
import me.fycz.maple.MapleUtils |
||||||
|
import me.fycz.maple.MethodHook |
||||||
|
import xyz.fycz.myreader.R |
||||||
|
import xyz.fycz.myreader.base.adapter2.onClick |
||||||
|
import xyz.fycz.myreader.ui.activity.MoreSettingActivity |
||||||
|
import xyz.fycz.myreader.util.ToastUtils |
||||||
|
import xyz.fycz.myreader.util.utils.FileUtils |
||||||
|
import xyz.fycz.myreader.util.utils.ScreenUtils |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fengyue |
||||||
|
* @date 2022/6/3 15:34 |
||||||
|
*/ |
||||||
|
@AppFix([243, 244, 245, 246], ["[设置-缓存设置]新增清除广告文件"], "2022-06-03") |
||||||
|
class App246Fix : AppFixHandle { |
||||||
|
|
||||||
|
override fun onFix(key: String): BooleanArray { |
||||||
|
return handleFix( |
||||||
|
key, |
||||||
|
"adFile" to { fxAdFile() }, |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
fun fxAdFile() { |
||||||
|
MapleUtils.findAndHookMethod( |
||||||
|
MoreSettingActivity::class.java, |
||||||
|
"initWidget", |
||||||
|
object : MethodHook() { |
||||||
|
override fun afterHookedMethod(param: MapleBridge.MethodHookParam) { |
||||||
|
val binding = |
||||||
|
MapleUtils.getObjectField(param.thisObject, "binding") as ViewBinding |
||||||
|
val rootLayout = |
||||||
|
(MapleUtils.getObjectField( |
||||||
|
binding, |
||||||
|
"svContent" |
||||||
|
) as ScrollView)[0] as ViewGroup |
||||||
|
addDeleteAdFileView(rootLayout, rootLayout.childCount) |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
fun addDeleteAdFileView(rootLayout: ViewGroup, index: Int) { |
||||||
|
val context = rootLayout.context |
||||||
|
val resources = context.resources |
||||||
|
val rlDeleteAdFile = RelativeLayout(context) |
||||||
|
val layoutParams = RelativeLayout.LayoutParams( |
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT, |
||||||
|
ScreenUtils.dpToPx(50) |
||||||
|
) |
||||||
|
rlDeleteAdFile.setPadding( |
||||||
|
ScreenUtils.dpToPx(20), |
||||||
|
0, |
||||||
|
ScreenUtils.dpToPx(20), |
||||||
|
0 |
||||||
|
) |
||||||
|
rlDeleteAdFile.background = |
||||||
|
ContextCompat.getDrawable(context, R.drawable.selector_common_bg) |
||||||
|
rlDeleteAdFile.id = R.id.rl_delete_ad_file |
||||||
|
val textview = TextView(context) |
||||||
|
val textViewParams = RelativeLayout.LayoutParams( |
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT, |
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT |
||||||
|
).apply { |
||||||
|
addRule(RelativeLayout.CENTER_VERTICAL) |
||||||
|
} |
||||||
|
textview.setText(R.string.delete_ad_file) |
||||||
|
textview.setTextColor(resources.getColor(R.color.textSecondary)) |
||||||
|
textview.textSize = |
||||||
|
ScreenUtils.pxToSp(resources.getDimension(R.dimen.text_normal_size).toInt()).toFloat() |
||||||
|
rlDeleteAdFile.addView(textview, textViewParams) |
||||||
|
rlDeleteAdFile.onClick { |
||||||
|
FileUtils.deleteFile(FileUtils.getFilePath()) |
||||||
|
ToastUtils.showSuccess("广告文件删除成功") |
||||||
|
} |
||||||
|
rootLayout.addView(rlDeleteAdFile, index, layoutParams) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
/* |
||||||
|
* 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 me.fycz.maple.MapleBridge |
||||||
|
import me.fycz.maple.MapleUtils |
||||||
|
import me.fycz.maple.MethodHook |
||||||
|
import xyz.fycz.myreader.widget.page.PageView |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fengyue |
||||||
|
* @date 2022/6/23 20:51 |
||||||
|
*/ |
||||||
|
@AppFix([243, 244, 245, 246], ["修复阅读界面概率性闪退的问题"], "2022-06-23") |
||||||
|
class App246Fix2 : AppFixHandle { |
||||||
|
override fun onFix(key: String): BooleanArray { |
||||||
|
return handleFix( |
||||||
|
key, |
||||||
|
"pageView" to { fxPageView() }, |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
private fun fxPageView() { |
||||||
|
MapleUtils.findAndHookMethod( |
||||||
|
PageView::class.java, |
||||||
|
"onDetachedFromWindow", |
||||||
|
object : MethodHook(){ |
||||||
|
override fun beforeHookedMethod(param: MapleBridge.MethodHookParam) { |
||||||
|
val mPageAnim = MapleUtils.getObjectField(param.thisObject, "mPageAnim") |
||||||
|
if (mPageAnim == null){ |
||||||
|
MapleUtils.setObjectField(param.thisObject, "mPageLoader", null) |
||||||
|
param.result = null |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,139 @@ |
|||||||
|
/* |
||||||
|
* 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.annotation.SuppressLint |
||||||
|
import android.view.Gravity |
||||||
|
import android.view.View |
||||||
|
import android.view.ViewGroup |
||||||
|
import android.widget.RelativeLayout |
||||||
|
import android.widget.TextView |
||||||
|
import androidx.appcompat.widget.AppCompatImageView |
||||||
|
import androidx.core.content.ContextCompat |
||||||
|
import androidx.core.view.get |
||||||
|
import androidx.core.widget.NestedScrollView |
||||||
|
import androidx.viewbinding.ViewBinding |
||||||
|
import me.fycz.maple.MapleBridge |
||||||
|
import me.fycz.maple.MapleUtils |
||||||
|
import me.fycz.maple.MethodHook |
||||||
|
import xyz.fycz.dynamic.AppLoadImpl |
||||||
|
import xyz.fycz.myreader.R |
||||||
|
import xyz.fycz.myreader.base.adapter2.onClick |
||||||
|
import xyz.fycz.myreader.entity.PluginConfig |
||||||
|
import xyz.fycz.myreader.ui.activity.AboutActivity |
||||||
|
import xyz.fycz.myreader.ui.dialog.DialogCreator |
||||||
|
import xyz.fycz.myreader.util.SharedPreUtils |
||||||
|
import xyz.fycz.myreader.util.utils.GSON |
||||||
|
import xyz.fycz.myreader.util.utils.ScreenUtils |
||||||
|
import xyz.fycz.myreader.util.utils.fromJsonObject |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fengyue |
||||||
|
* @date 2022/6/28 19:22 |
||||||
|
*/ |
||||||
|
@AppFix([243, 244, 245, 246], ["关于界面新增插件加载结果"], "2022-06-28") |
||||||
|
class App246Fix3 : AppFixHandle { |
||||||
|
|
||||||
|
override fun onFix(key: String): BooleanArray { |
||||||
|
return handleFix( |
||||||
|
key, |
||||||
|
"pluginView" to { fxPluginView() }, |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
private fun fxPluginView() { |
||||||
|
MapleUtils.findAndHookMethod( |
||||||
|
AboutActivity::class.java, |
||||||
|
"initWidget", |
||||||
|
object : MethodHook() { |
||||||
|
override fun afterHookedMethod(param: MapleBridge.MethodHookParam) { |
||||||
|
val binding = |
||||||
|
MapleUtils.getObjectField(param.thisObject, "binding") as ViewBinding |
||||||
|
val ilBinding = MapleUtils.getObjectField(binding, "il") as ViewBinding |
||||||
|
val rootLayout = (ilBinding.root as NestedScrollView)[0] as ViewGroup |
||||||
|
addPluginView(rootLayout, 1) |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n") |
||||||
|
fun addPluginView(rootLayout: ViewGroup, index: Int) { |
||||||
|
val pluginConfig = GSON.fromJsonObject<PluginConfig>( |
||||||
|
SharedPreUtils.getInstance().getString("pluginConfig") |
||||||
|
) ?: PluginConfig("dynamic.dex", 100) |
||||||
|
|
||||||
|
val context = rootLayout.context |
||||||
|
val rlPlugin = RelativeLayout(context) |
||||||
|
val pluginLayoutParams = RelativeLayout.LayoutParams( |
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT, |
||||||
|
ScreenUtils.dpToPx(50) |
||||||
|
) |
||||||
|
rlPlugin.background = ContextCompat.getDrawable(context, R.drawable.selector_common_bg) |
||||||
|
rlPlugin.gravity = Gravity.CENTER |
||||||
|
rlPlugin.id = R.id.rl_update |
||||||
|
rlPlugin.setPadding( |
||||||
|
ScreenUtils.dpToPx(20), |
||||||
|
0, |
||||||
|
ScreenUtils.dpToPx(10), |
||||||
|
0 |
||||||
|
) |
||||||
|
val textview = TextView(context) |
||||||
|
val textviewLayoutParams = RelativeLayout.LayoutParams( |
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT, |
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT |
||||||
|
).apply { |
||||||
|
addRule(RelativeLayout.CENTER_VERTICAL) |
||||||
|
} |
||||||
|
textview.text = "插件版本:${pluginConfig.version}" |
||||||
|
textview.setTextColor(context.resources.getColor(R.color.textPrimary)) |
||||||
|
textview.textSize = |
||||||
|
ScreenUtils.pxToSp( |
||||||
|
context.resources.getDimension(R.dimen.text_normal_size).toInt() |
||||||
|
).toFloat() |
||||||
|
rlPlugin.addView(textview, textviewLayoutParams) |
||||||
|
val imageView = AppCompatImageView(context) |
||||||
|
val imageViewLayoutParams = RelativeLayout.LayoutParams( |
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT, |
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT |
||||||
|
).apply { |
||||||
|
addRule(RelativeLayout.ALIGN_PARENT_END) |
||||||
|
addRule(RelativeLayout.CENTER_VERTICAL) |
||||||
|
} |
||||||
|
imageView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_right_arrow)) |
||||||
|
imageView.drawable.setTint(context.resources.getColor(R.color.textPrimary)) |
||||||
|
rlPlugin.addView(imageView, imageViewLayoutParams) |
||||||
|
rlPlugin.onClick { |
||||||
|
DialogCreator.createTipDialog( |
||||||
|
context, |
||||||
|
"插件版本:${pluginConfig.version}", |
||||||
|
"当前版本更新日志:\n${pluginConfig.changelog}\n\n插件加载结果:\n" + |
||||||
|
AppLoadImpl.allFixInfoSb.toString() |
||||||
|
) |
||||||
|
} |
||||||
|
rootLayout.addView(rlPlugin, index, pluginLayoutParams) |
||||||
|
|
||||||
|
val view = View(context) |
||||||
|
val layoutParams = ViewGroup.MarginLayoutParams( |
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT, |
||||||
|
ScreenUtils.dpToPx(10) |
||||||
|
) |
||||||
|
rootLayout.addView(view, index + 1, layoutParams) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,84 @@ |
|||||||
|
/* |
||||||
|
* 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 me.fycz.maple.MapleBridge |
||||||
|
import me.fycz.maple.MapleUtils |
||||||
|
import me.fycz.maple.MethodReplacement |
||||||
|
import xyz.fycz.dynamic.utils.LanZouUtils |
||||||
|
import xyz.fycz.myreader.base.observer.MyObserver |
||||||
|
import xyz.fycz.myreader.util.utils.RxUtils |
||||||
|
import xyz.fycz.myreader.webapi.LanZouApi |
||||||
|
import xyz.fycz.myreader.webapi.LanZousApi |
||||||
|
import xyz.fycz.myreader.webapi.ResultCallback |
||||||
|
import java.lang.Exception |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fengyue |
||||||
|
* @date 2022/6/30 20:40 |
||||||
|
*/ |
||||||
|
@AppFix([243, 244, 245, 246], ["修复书源订阅失败的问题", "修复字体下载失败的问题"], "2022-06-30") |
||||||
|
class App246Fix4: AppFixHandle { |
||||||
|
override fun onFix(key: String): BooleanArray { |
||||||
|
return handleFix( |
||||||
|
key, |
||||||
|
"lanZouApi" to { fxLanZouApi() }, |
||||||
|
"fontLanZouApi" to { fxFontLanZouApi() }, |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
private fun fxLanZouApi() { |
||||||
|
MapleUtils.findAndHookMethod( |
||||||
|
LanZouApi::class.java, |
||||||
|
"getFileUrl", |
||||||
|
String::class.java, |
||||||
|
String::class.java, |
||||||
|
object : MethodReplacement(){ |
||||||
|
override fun replaceHookedMethod(param: MapleBridge.MethodHookParam): Any { |
||||||
|
return LanZouUtils.getFileUrl(param.args[0] as String, param.args[1] as String) |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
private fun fxFontLanZouApi(){ |
||||||
|
MapleUtils.findAndHookMethod( |
||||||
|
LanZousApi::class.java, |
||||||
|
"getUrl", |
||||||
|
String::class.java, |
||||||
|
ResultCallback::class.java, |
||||||
|
object : MethodReplacement(){ |
||||||
|
override fun replaceHookedMethod(param: MapleBridge.MethodHookParam) { |
||||||
|
val callback = param.args[1] as ResultCallback |
||||||
|
LanZouUtils.getFileUrl(param.args[0] as String) |
||||||
|
.compose { RxUtils.toSimpleSingle(it) } |
||||||
|
.subscribe(object : MyObserver<String>(){ |
||||||
|
override fun onNext(t: String) { |
||||||
|
callback.onFinish(t, 1) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onError(e: Throwable) { |
||||||
|
callback.onError(e as Exception) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,208 @@ |
|||||||
|
/* |
||||||
|
* 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 android.widget.TextView |
||||||
|
import androidx.appcompat.app.AppCompatActivity |
||||||
|
import androidx.viewbinding.ViewBinding |
||||||
|
import io.reactivex.Observable |
||||||
|
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.base.observer.MyObserver |
||||||
|
import xyz.fycz.myreader.common.URLCONST |
||||||
|
import xyz.fycz.myreader.ui.dialog.UpdateDialog |
||||||
|
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 xyz.fycz.myreader.util.utils.RxUtils |
||||||
|
import xyz.fycz.myreader.webapi.LanZouApi.getFileUrl |
||||||
|
import xyz.fycz.myreader.widget.BarPercentView |
||||||
|
import java.io.IOException |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fengyue |
||||||
|
* @date 2022/7/1 15:45 |
||||||
|
*/ |
||||||
|
@AppFix([243, 244, 245, 246], ["修复检查更新失败的问题", "修复获取更新链接失败的问题"], "2022-07-02") |
||||||
|
class App246Fix5 : AppFixHandle { |
||||||
|
override fun onFix(key: String): BooleanArray { |
||||||
|
return handleFix( |
||||||
|
key, |
||||||
|
"checkUpdateUrl" to { fxCheckUpdateUrl() }, |
||||||
|
"downloadLanzou" to { fxDownloadLanzou() }, |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
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("检查更新失败!") |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private fun fxDownloadLanzou() { |
||||||
|
MapleUtils.findAndHookMethod( |
||||||
|
UpdateDialog::class.java, |
||||||
|
"downloadWithLanzous", |
||||||
|
String::class.java, |
||||||
|
object : MethodReplacement() { |
||||||
|
override fun replaceHookedMethod(param: MapleBridge.MethodHookParam) { |
||||||
|
val updateDialog = param.thisObject as UpdateDialog |
||||||
|
val binding = MapleUtils.getObjectField(updateDialog, "binding") |
||||||
|
as ViewBinding |
||||||
|
val tvProgress = MapleUtils.getObjectField(binding, "tvProgress") |
||||||
|
as TextView |
||||||
|
val barPercentView = MapleUtils.getObjectField(binding, "barPercentView") |
||||||
|
as BarPercentView |
||||||
|
tvProgress.text = "正在获取下载链接..." |
||||||
|
barPercentView.setPercentage(0F) |
||||||
|
val apkUrl = param.args[0] as String |
||||||
|
getFileUrl(apkUrl) |
||||||
|
.compose { RxUtils.toSimpleSingle(it) } |
||||||
|
.subscribe(object : MyObserver<String>() { |
||||||
|
override fun onNext(directUrl: String) { |
||||||
|
MapleUtils.callMethod( |
||||||
|
updateDialog, |
||||||
|
"downloadApkNormal", |
||||||
|
arrayOf(String::class.java), |
||||||
|
directUrl |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onError(e: Throwable) { |
||||||
|
MapleUtils.callMethod( |
||||||
|
updateDialog, |
||||||
|
"error" |
||||||
|
) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
@Throws(IOException::class) |
||||||
|
fun getBakUpdateInfo(): String { |
||||||
|
return OkHttpUtils.getHtml( |
||||||
|
"https://gitlab.com/fengyuecanzhu/fyreader-resource/-/raw/main/FYReader-Update/" + |
||||||
|
(if (App.isDebug()) "debug" else "release") + |
||||||
|
"/content.txt" |
||||||
|
) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
/* |
||||||
|
* 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 me.fycz.maple.MapleBridge |
||||||
|
import me.fycz.maple.MapleUtils |
||||||
|
import me.fycz.maple.MethodHook |
||||||
|
import xyz.fycz.myreader.common.URLCONST |
||||||
|
import xyz.fycz.myreader.webapi.LanZouApi |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fengyue |
||||||
|
* @date 2022/6/21 18:30 |
||||||
|
*/ |
||||||
|
@AppFix([], ["更新订阅书源链接,仅支持v2.4.3版本及以上版本"], "2022-06-21") |
||||||
|
class AppSubSourceFix : AppFixHandle { |
||||||
|
override fun onFix(key: String): BooleanArray { |
||||||
|
return handleFix( |
||||||
|
key, |
||||||
|
"subSource" to { fxSubSource() }, |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
private fun fxSubSource() { |
||||||
|
MapleUtils.findAndHookMethod( |
||||||
|
LanZouApi::class.java, |
||||||
|
"getFoldFiles", |
||||||
|
String::class.java, |
||||||
|
Int::class.java, |
||||||
|
String::class.java, |
||||||
|
object : MethodHook() { |
||||||
|
override fun beforeHookedMethod(param: MapleBridge.MethodHookParam) { |
||||||
|
if (param.args[0] == URLCONST.SUB_SOURCE_URL) { |
||||||
|
param.args[0] = "https://fycz.lanzoum.com/b00pucrch" |
||||||
|
param.args[2] = "b0ox" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,149 @@ |
|||||||
|
/* |
||||||
|
* 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.utils |
||||||
|
|
||||||
|
import android.util.Log |
||||||
|
import io.reactivex.Observable |
||||||
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull |
||||||
|
import okhttp3.RequestBody.Companion.toRequestBody |
||||||
|
import org.jsoup.Jsoup |
||||||
|
import xyz.fycz.myreader.common.URLCONST |
||||||
|
import xyz.fycz.myreader.entity.lanzou.LanZouParseBean |
||||||
|
import xyz.fycz.myreader.util.help.StringHelper |
||||||
|
import xyz.fycz.myreader.util.utils.GSON |
||||||
|
import xyz.fycz.myreader.util.utils.OkHttpUtils |
||||||
|
import xyz.fycz.myreader.util.utils.StringUtils |
||||||
|
import xyz.fycz.myreader.util.utils.fromJsonObject |
||||||
|
import java.net.HttpURLConnection |
||||||
|
import java.net.URL |
||||||
|
|
||||||
|
/** |
||||||
|
* @author fengyue |
||||||
|
* @date 2022/1/22 18:50 |
||||||
|
*/ |
||||||
|
object LanZouUtils { |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过api获取蓝奏云可下载直链 |
||||||
|
* |
||||||
|
* @param url |
||||||
|
* @param password |
||||||
|
*/ |
||||||
|
fun getFileUrl(url: String, password: String = ""): Observable<String> { |
||||||
|
return Observable.create { |
||||||
|
var html = OkHttpUtils.getHtml(url) |
||||||
|
val url2 = if (password.isEmpty()) { |
||||||
|
val url1 = getUrl1(html) |
||||||
|
html = OkHttpUtils.getHtml(url1) |
||||||
|
val data = getDataString(html) |
||||||
|
Log.d("LanZouUtils", "data:$data") |
||||||
|
val key = getKeyValueByKey(html, data, "sign") + |
||||||
|
"&" + getKeyValueByKey(html, data, "websignkey") |
||||||
|
Log.d("LanZouUtils", "key:$key") |
||||||
|
getUrl2(key, url1) |
||||||
|
} else { |
||||||
|
getUrl2(StringHelper.getSubString(html, "sign=", "&"), url, password) |
||||||
|
} |
||||||
|
if (url2.contains("file")) { |
||||||
|
it.onNext(getRedirectUrl(url2)) |
||||||
|
} else { |
||||||
|
it.onError(Throwable(url2)) |
||||||
|
} |
||||||
|
it.onComplete() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fun getUrl1(html: String): String { |
||||||
|
val doc = Jsoup.parse(html) |
||||||
|
return URLCONST.LAN_ZOU_URL + doc.getElementsByTag("iframe").attr("src") |
||||||
|
} |
||||||
|
|
||||||
|
fun getKeyValueByKey(html: String, data: String, key: String): String { |
||||||
|
val keyName = StringHelper.getSubString(data, "'$key':", ",") |
||||||
|
return if (keyName.endsWith("'")) { |
||||||
|
key + "=" + keyName.replace("'", "") |
||||||
|
} else { |
||||||
|
val lanzousKeyStart = "var $keyName = '" |
||||||
|
key + "=" + StringHelper.getSubString(html, lanzousKeyStart, "'") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fun getUrl2(key: String, referer: String, password: String = ""): String { |
||||||
|
val mediaType = "application/x-www-form-urlencoded".toMediaTypeOrNull() |
||||||
|
val body = if (password.isEmpty()) { |
||||||
|
"action=downprocess&signs=?ctdf&websign=&ves=1&$key" |
||||||
|
} else { |
||||||
|
"action=downprocess&sign=$key&p=$password" |
||||||
|
} |
||||||
|
val requestBody = body.toRequestBody(mediaType) |
||||||
|
|
||||||
|
val headers = HashMap<String, String>() |
||||||
|
headers["Referer"] = referer |
||||||
|
|
||||||
|
val html = OkHttpUtils.getHtml( |
||||||
|
URLCONST.LAN_ZOU_URL + "/ajaxm.php", requestBody, |
||||||
|
"UTF-8", headers |
||||||
|
) |
||||||
|
return getUrl2(html) |
||||||
|
} |
||||||
|
|
||||||
|
private fun getUrl2(o: String): String { |
||||||
|
val lanZouBean = GSON.fromJsonObject<LanZouParseBean>(o) |
||||||
|
lanZouBean?.run { |
||||||
|
return if (zt == 1) { |
||||||
|
"$dom/file/$url" |
||||||
|
} else { |
||||||
|
"解析失败\n信息:$inf" |
||||||
|
} |
||||||
|
} |
||||||
|
return "" |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取重定向地址 |
||||||
|
* |
||||||
|
* @param path |
||||||
|
*/ |
||||||
|
fun getRedirectUrl(path: String): String { |
||||||
|
val conn = URL(path) |
||||||
|
.openConnection() as HttpURLConnection |
||||||
|
conn.instanceFollowRedirects = false |
||||||
|
conn.connectTimeout = 5000 |
||||||
|
conn.setRequestProperty( |
||||||
|
"User-Agent", |
||||||
|
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" |
||||||
|
) |
||||||
|
conn.setRequestProperty("Accept-Language", "zh-cn") |
||||||
|
conn.setRequestProperty("Connection", "Keep-Alive") |
||||||
|
conn.setRequestProperty( |
||||||
|
"Accept", |
||||||
|
"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, */*" |
||||||
|
) |
||||||
|
conn.connect() |
||||||
|
val redirectUrl = conn.getHeaderField("Location") |
||||||
|
conn.disconnect() |
||||||
|
return redirectUrl |
||||||
|
} |
||||||
|
|
||||||
|
fun getDataString(html: String): String { |
||||||
|
val start = html.lastIndexOf("data :") + "data :".length |
||||||
|
val end = html.indexOf("},", start) + 1 |
||||||
|
return html.substring(start, end) |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue