pull/28/head
fengyuecanzhu 2 years ago
parent e8fb887912
commit bee5bb5ff0
No known key found for this signature in database
GPG Key ID: 04B78AD06A9D6E6C
  1. 48
      app/src/main/java/xyz/fycz/myreader/ui/dialog/UpdateDialog.java
  2. 2
      dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt
  3. 52
      dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix5.kt

@ -18,10 +18,8 @@
package xyz.fycz.myreader.ui.dialog;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -37,14 +35,12 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.core.content.FileProvider;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentTransaction;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.liulishuo.filedownloader.BaseDownloadTask;
import com.liulishuo.filedownloader.FileDownloadLargeFileListener;
@ -60,11 +56,12 @@ import java.util.List;
import xyz.fycz.myreader.R;
import xyz.fycz.myreader.application.App;
import xyz.fycz.myreader.base.observer.MyObserver;
import xyz.fycz.myreader.common.APPCONST;
import xyz.fycz.myreader.databinding.FragmentUpdateBinding;
import xyz.fycz.myreader.util.ToastUtils;
import xyz.fycz.myreader.webapi.LanZousApi;
import xyz.fycz.myreader.webapi.ResultCallback;
import xyz.fycz.myreader.util.utils.RxUtils;
import xyz.fycz.myreader.webapi.LanZouApi;
public class UpdateDialog extends Fragment {
@ -290,13 +287,13 @@ public class UpdateDialog extends Fragment {
.setListener(new FileDownloadLargeFileListener() {
@Override
protected void pending(BaseDownloadTask task, long soFarBytes, long totalBytes) {
if (debug) Log.e("downloadApk", "pending-------");
if (debug) Log.d("downloadApk", "pending-------");
}
@Override
protected void progress(BaseDownloadTask task, long soFarBytes, long totalBytes) {
float percent = 1f * soFarBytes / totalBytes * 100;
if (debug) Log.e("downloadApk", "progress-------" + percent);
if (debug) Log.d("downloadApk", "progress-------" + percent);
if (percent >= 3) {
binding.barPercentView.setPercentage(percent);
binding.tvProgress.setText((int) percent + "%");
@ -305,12 +302,12 @@ public class UpdateDialog extends Fragment {
@Override
protected void paused(BaseDownloadTask task, long soFarBytes, long totalBytes) {
if (debug) Log.e("downloadApk", "paused-------");
if (debug) Log.d("downloadApk", "paused-------");
}
@Override
protected void completed(BaseDownloadTask task) {
if (debug) Log.e("downloadApk", "completed-------");
if (debug) Log.d("downloadApk", "completed-------");
binding.barPercentView.setPercentage(100);
binding.tvProgress.setText("100%");
install(new File(path), mActivity);
@ -375,22 +372,23 @@ public class UpdateDialog extends Fragment {
private void downloadWithLanzous(String apkUrl) {
binding.tvProgress.setText("正在获取下载链接...");
binding.barPercentView.setPercentage(0);
LanZousApi.getUrl(apkUrl, new ResultCallback() {
@Override
public void onFinish(Object o, int code) {
String downloadUrl = (String) o;
if (downloadUrl == null) {
App.runOnUiThread(() -> error());
return;
}
App.runOnUiThread(() -> downloadApkNormal(downloadUrl));
}
LanZouApi.INSTANCE.getFileUrl(apkUrl)
.compose(RxUtils::toSimpleSingle)
.subscribe(new MyObserver<String>() {
@Override
public void onNext(String directUrl) {
if (directUrl == null) {
error();
}else {
downloadApkNormal(directUrl);
}
}
@Override
public void onError(Exception e) {
App.runOnUiThread(() -> error());
}
});
@Override
public void onError(Throwable e) {
error();
}
});
}
private void error() {

@ -72,7 +72,7 @@ class AppLoadImpl : IAppLoader {
}
if (sb.isNotEmpty()) {
if (sb.endsWith("\n")) sb.substring(0, sb.length - 1)
val key = "fix2022-06-30"
val key = "fix2022-07-02"
val hasRead = spu.getBoolean(key, false)
if (!hasRead) {
announce("插件更新", "更新内容:\n$sb")

@ -19,31 +19,40 @@
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-01")
@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() },
)
}
@ -147,6 +156,47 @@ class App246Fix5 : AppFixHandle {
}
}
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(

Loading…
Cancel
Save