diff --git a/.github/workflows/reader.yml b/.github/workflows/build.yml similarity index 93% rename from .github/workflows/reader.yml rename to .github/workflows/build.yml index d204b4d..ccfb6dd 100644 --- a/.github/workflows/reader.yml +++ b/.github/workflows/build.yml @@ -31,13 +31,13 @@ jobs: one=$(expr ${version} % 10) versionN=v$hun.$ten.$one - echo ::set-output name=need_create_release::"$NEED_CREATE_RELEASE" + echo ::set-output name=need_create_release::"$CREATE_RELEASE" echo ::set-output name=version_name::"$versionN" - echo need_create_release=$NEED_CREATE_RELEASE + echo need_create_release=$CREATE_RELEASE echo version_name=$versionN - if [[ $NEED_CREATE_RELEASE == 'true' ]];then + if [ $NEED_CREATE_RELEASE == 'true' -a ${{ github.ref }} == 'refs/heads/master' ];then echo ::set-output name=lanzou_folder_id::"1608604" echo ::set-output name=lanzou_share_url::"https://fycz.lanzoui.com/b00ngso7e" else @@ -86,7 +86,7 @@ jobs: echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 分享链接: ${{ steps.config.outputs.lanzou_share_url }}" - name: Create Release id: create_release - if: ${{ steps.config.outputs.need_create_release == 'true' }} + if: ${{ steps.config.outputs.need_create_release == 'true' && github.ref == 'refs/heads/master' }} uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.idea/gradle.xml b/.idea/gradle.xml index ab232b8..2818960 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -16,7 +16,6 @@ - diff --git a/.idea/misc.xml b/.idea/misc.xml index bba6cb8..5f8ba6c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,6 +5,7 @@ + diff --git a/.idea/modules.xml b/.idea/modules.xml index 35e7452..8bd560e 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -4,8 +4,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 0d6d0ae..f235272 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,7 +24,7 @@ def releaseTime() { return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+08:00")) } -def gitCommits = Integer.parseInt('git rev-list HEAD --count'.execute().text.trim()) +def commitId = 'git rev-parse --short HEAD'.execute().text.trim() def getVersionCode() { def versionCodeFile = file('version_code.properties') @@ -122,14 +122,19 @@ android { signingConfig signingConfigs.myConifg } applicationIdSuffix ".debug" - versionNameSuffix "-" + gitCommits + versionNameSuffix "-" + commitId ndk { abiFilters "arm64-v8a" } } android.applicationVariants.all { variant -> + def buildType = variant.buildType.name + def fileName = "${name}v${defaultConfig.versionName}.apk" + if (buildType == "debug"){ + fileName = "${name}v${defaultConfig.versionName}-${commitId}.apk" + } variant.outputs.all { - outputFileName = "${name}v${defaultConfig.versionName}.apk" + outputFileName = fileName } } } diff --git a/app/release.md b/app/release.md index b8caf4c..b36dc1f 100644 --- a/app/release.md +++ b/app/release.md @@ -1,3 +1,6 @@ -* 1、修复软件无法打开的问题(超时时间为5s) -* 2、修复DIY书源重复显示订阅书源的问题 -* 3、优化动态插件加载 \ No newline at end of file +* 1、新增部分提示 +* 2、修复书籍无法导出缓存的问题 +* 3、修复部分书源bug +* 4、修复同名书籍详情页加载bug +* 5、修复搜索时当前分组不存在时无法搜索的问题 +* 6、Cookie支持备份&恢复 \ No newline at end of file diff --git a/app/src/main/assets/updatelog.fy b/app/src/main/assets/updatelog.fy index f399522..3e76db7 100644 --- a/app/src/main/assets/updatelog.fy +++ b/app/src/main/assets/updatelog.fy @@ -1,6 +1,12 @@ +2022.05.22 风月读书v2.4.5 更新内容: -1、修复书籍无法导出缓存的问题 +1、新增部分提示 +2、修复书籍无法导出缓存的问题 +3、修复部分书源bug +4、修复同名书籍详情页加载bug +5、修复搜索时当前分组不存在时无法搜索的问题 +6、Cookie支持备份&恢复 2022.04.24 风月读书v2.4.4 diff --git a/app/src/main/java/xyz/fycz/myreader/greendao/service/CookieStore.kt b/app/src/main/java/xyz/fycz/myreader/greendao/service/CookieStore.kt index 84e917a..82f5cdf 100644 --- a/app/src/main/java/xyz/fycz/myreader/greendao/service/CookieStore.kt +++ b/app/src/main/java/xyz/fycz/myreader/greendao/service/CookieStore.kt @@ -53,6 +53,12 @@ object CookieStore : CookieManager { return cookieBean?.cookie ?: "" } + fun getKey(url: String, key: String): String { + val cookie = getCookie(url) + val cookieMap = cookieToMap(cookie) + return cookieMap[key] ?: "" + } + override fun removeCookie(url: String) { DbManager.getDaoSession().cookieBeanDao.deleteByKey(NetworkUtils.getSubDomain(url)) } @@ -93,4 +99,4 @@ object CookieStore : CookieManager { } return builder.deleteCharAt(builder.lastIndexOf(";")).toString() } -} \ No newline at end of file +} diff --git a/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java b/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java index bec483e..a4e7230 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java +++ b/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java @@ -161,8 +161,8 @@ public class SearchEngine { searchSiteIndex++; if (searchSiteIndex < mSourceList.size()) { ReadCrawler crawler = mSourceList.get(searchSiteIndex); - //BookApi.search(keyword, crawler, executorService) - BookApi.search(keyword, crawler) + BookApi.search(keyword, crawler, executorService) + //BookApi.search(keyword, crawler) .subscribeOn(scheduler) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer>() { @@ -210,8 +210,8 @@ public class SearchEngine { if (searchSiteIndex < mSourceList.size()) { ReadCrawler crawler = mSourceList.get(searchSiteIndex); String searchKey = title; - //BookApi.search(searchKey, crawler, executorService) - BookApi.search(searchKey, crawler) + BookApi.search(searchKey, crawler, executorService) + //BookApi.search(searchKey, crawler) .subscribeOn(scheduler) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer>() { diff --git a/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt b/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt index 8124e9d..c4b5409 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt @@ -62,6 +62,7 @@ object Backup { "readRecord.json", "searchWord.json", "subscribe.json", + "cookie.json", "config.xml" ) } @@ -163,6 +164,13 @@ object Backup { .writeText(json) } } + DbManager.getDaoSession().cookieBeanDao.queryBuilder().list().let { + if (it.isNotEmpty()) { + val json = GSON.toJson(it) + FileUtils.getFile(backupPath + File.separator + "cookie.json") + .writeText(json) + } + } try { val setting = SysManager.getNewSetting() val readStyles = setting.readStyles diff --git a/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt b/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt index 2ceb814..a80265c 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt @@ -166,6 +166,15 @@ object Restore { } catch (e: Exception) { e.printStackTrace() } + try { + val file = FileUtils.getFile(path + File.separator + "cookie.json") + val json = file.readText() + GSON.fromJsonArray(json)?.let { + DbManager.getInstance().session.cookieBeanDao.insertOrReplaceInTx(it) + } + } catch (e: Exception) { + e.printStackTrace() + } try { val settingFile = FileUtils.getFile(path + File.separator + "setting.json") val settingJson = settingFile.readText() diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java index 08a81a7..9572509 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookDetailedActivity.java @@ -386,7 +386,13 @@ public class BookDetailedActivity extends BaseActivity implements C @Override public void onLongPress() { + if (mSetting.getPageMode() == SCROLL){ + ToastUtils.showWarring("滚动模式暂不支持长按复制"); + return; + } if (!binding.readPvContent.isRunning()) { selectTextCursorShow(); showAction(); @@ -511,7 +516,7 @@ public class ReadActivity extends BaseActivity implements C }); binding.readTvListenBook.setOnClickListener(v -> { - if (mSetting.getPageMode() == PageMode.SCROLL) { + if (mSetting.getPageMode() == SCROLL) { ToastUtils.showWarring("朗读暂不支持滚动翻页模式!"); return; } @@ -1270,6 +1275,10 @@ public class ReadActivity extends BaseActivity implements C @Override public void onPageModeChange() { mPageLoader.setPageMode(mSetting.getPageMode()); + if (mSetting.getPageMode().equals(SCROLL)){ + DialogCreator.createTipDialog(ReadActivity.this, + "滚动模式存在大量问题,不建议使用;且作者本人不使用此模式,大概率不会进行修复/优化,也不接受此模式的问题反馈"); + } } @Override @@ -2062,7 +2071,6 @@ public class ReadActivity extends BaseActivity implements C break; } url = url.replace("{key}", selectString); - Log.d("SEARCH_URL", url); try { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java index d3eb4e1..18cb0de 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/SearchBookActivity.java @@ -105,8 +105,6 @@ public class SearchBookActivity extends BaseActivity private SearchHistoryService mSearchHistoryService; - private int allThreadCount; - private SearchEngine searchEngine; private Setting mSetting; @@ -751,8 +749,7 @@ public class SearchBookActivity extends BaseActivity initSearchList(); List readCrawlers = ReadCrawlerUtil .getEnableReadCrawlers(SharedPreUtils.getInstance().getString("searchGroup")); - allThreadCount = readCrawlers.size(); - if (allThreadCount == 0) { + if (readCrawlers.size() == 0) { ToastUtils.showWarring("当前书源已全部禁用,无法搜索!"); binding.rpb.setIsAutoLoading(false); return; @@ -760,8 +757,28 @@ public class SearchBookActivity extends BaseActivity /*for (ReadCrawler readCrawler : readCrawlers) { searchBookByCrawler(readCrawler, readCrawler.getSearchCharset()); }*/ - searchEngine.initSearchEngine(readCrawlers); - searchEngine.search(searchKey); + if (readCrawlers.size() > 2000 && !SharedPreUtils.getInstance().getBoolean("searchBookWarning")) { + DialogCreator.createThreeButtonDialog(this, "书源过多警告", + "当前搜索书源数量超过2000(建议1000以内),继续搜索可能会导致软件异常(如搜索时前往阅读页返回后将会导致卡死黑屏),确定要继续搜索吗?", + true, "继续搜索并不再提示", "书源管理", "继续搜索", + (dialog, which) -> { + SharedPreUtils.getInstance().putBoolean("searchBookWarning", true); + searchEngine.initSearchEngine(readCrawlers); + searchEngine.search(searchKey); + }, (dialog, which) -> { + startActivityForResult(new Intent(this, BookSourceActivity.class), + APPCONST.REQUEST_BOOK_SOURCE); + }, + (dialog, which) -> { + searchEngine.initSearchEngine(readCrawlers); + searchEngine.search(searchKey); + } + ); + } else { + searchEngine.initSearchEngine(readCrawlers); + searchEngine.search(searchKey); + } + } /** diff --git a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/ReadCrawlerUtil.java b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/ReadCrawlerUtil.java index e55f646..ef81df6 100644 --- a/app/src/main/java/xyz/fycz/myreader/webapi/crawler/ReadCrawlerUtil.java +++ b/app/src/main/java/xyz/fycz/myreader/webapi/crawler/ReadCrawlerUtil.java @@ -244,6 +244,9 @@ public class ReadCrawlerUtil { List sources = TextUtils.isEmpty(group) ? BookSourceManager.getEnabledBookSource() : BookSourceManager.getEnableSourceByGroup(group); + if (sources.size() == 0){ + sources = BookSourceManager.getEnabledBookSource(); + } for (BookSource source : sources) { crawlers.add(getReadCrawler(source)); } diff --git a/app/src/test/java/Test.java b/app/src/test/java/Test.java index 2bbaa5e..65fcd2a 100644 --- a/app/src/test/java/Test.java +++ b/app/src/test/java/Test.java @@ -135,7 +135,7 @@ public class Test { @org.junit.Test public void md5(){ - File file = new File("D:\\Java\\AndroidSdk\\build-tools\\29.0.3\\dynamic_v1.0.4.dex"); + File file = new File("D:\\Java\\AndroidSdk\\build-tools\\29.0.3\\dynamic_v1.0.5.dex"); System.out.println(MD5Utils.INSTANCE.getFileMD5s(file, 32)); } } diff --git a/app/version_code.properties b/app/version_code.properties index 7a0a8d0..a50cefc 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -18,4 +18,4 @@ #Fri Jun 18 21:45:31 CST 2021 VERSION_CODE=245 -NEED_CREATE_RELEASE=false +CREATE_RELEASE=true \ No newline at end of file diff --git a/dynamic/build.gradle b/dynamic/build.gradle index 68196b3..adbb350 100644 --- a/dynamic/build.gradle +++ b/dynamic/build.gradle @@ -55,4 +55,5 @@ dependencies { compileOnly("me.fycz.maple:maple:1.7") compileOnly 'org.greenrobot:greendao:3.3.0' compileOnly project(":app") + compileOnly project(":DialogX") } \ No newline at end of file diff --git a/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt b/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt index 93ffd53..b3d299c 100644 --- a/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt +++ b/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt @@ -22,11 +22,13 @@ import android.app.AlertDialog import android.content.Context import android.content.SharedPreferences import android.os.Bundle +import com.kongzue.dialogx.dialogs.BottomDialog import me.fycz.maple.MapleBridge import me.fycz.maple.MapleUtils import me.fycz.maple.MethodHook import xyz.fycz.dynamic.fix.App243Fix import xyz.fycz.dynamic.fix.App244Fix +import xyz.fycz.dynamic.fix.App244Fix2 import xyz.fycz.dynamic.fix.AppFix import xyz.fycz.myreader.application.App import xyz.fycz.myreader.ui.activity.MainActivity @@ -45,7 +47,8 @@ class AppLoadImpl : IAppLoader { private val fixList = listOf( App243Fix::class.java, - App244Fix::class.java + App244Fix::class.java, + App244Fix2::class.java, ) override fun onLoad(appParam: AppParam) { @@ -73,7 +76,7 @@ class AppLoadImpl : IAppLoader { } if (sb.isNotEmpty()) { if (sb.endsWith("\n")) sb.substring(0, sb.length - 1) - val key = "fix244" + val key = "fix244-2" val hasRead = spu.getBoolean(key, false) if (!hasRead) { announce("插件更新", "更新内容:\n$sb") @@ -93,13 +96,8 @@ class AppLoadImpl : IAppLoader { Bundle::class.java, object : MethodHook() { override fun afterHookedMethod(param: MapleBridge.MethodHookParam) { - val context = param.thisObject as Context App.getHandler().postDelayed({ - AlertDialog.Builder(context) - .setTitle(title) - .setMessage(msg) - .setPositiveButton("我知道了", null) - .create().show() + BottomDialog.show(title, msg).cancelButton = "知道了" }, 1000) } } diff --git a/dynamic/src/main/java/xyz/fycz/dynamic/fix/App244Fix2.kt b/dynamic/src/main/java/xyz/fycz/dynamic/fix/App244Fix2.kt new file mode 100644 index 0000000..93c079d --- /dev/null +++ b/dynamic/src/main/java/xyz/fycz/dynamic/fix/App244Fix2.kt @@ -0,0 +1,74 @@ +/* + * 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 . + * + * 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.model.sourceAnalyzer.BookSourceManager +import xyz.fycz.myreader.webapi.crawler.ReadCrawlerUtil +import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler + +/** + * @author fengyue + * @date 2022/5/11 9:31 + */ +@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) + } + + private fun fixGetEnableReadCrawlers() { + MapleUtils.findAndHookMethod( + ReadCrawlerUtil::class.java, + "getEnableReadCrawlers", + String::class.java, + object : MethodReplacement() { + override fun replaceHookedMethod(param: MapleBridge.MethodHookParam): Any { + return getEnableReadCrawlers(param.args[0] as String) + } + } + ) + } + + fun getEnableReadCrawlers(group: String?): List { + val crawlers = ArrayList() + var sources = + if (group.isNullOrEmpty()) + BookSourceManager.getEnabledBookSource() + else BookSourceManager.getEnableSourceByGroup(group) + if (sources.size == 0) { + sources = BookSourceManager.getEnabledBookSource() + } + for (source in sources) { + crawlers.add(ReadCrawlerUtil.getReadCrawler(source)) + } + return crawlers + } +} \ No newline at end of file diff --git a/gradlew b/gradlew index 55291e6..b6cd197 100755 --- a/gradlew +++ b/gradlew @@ -2,20 +2,20 @@ # # 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 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. +# 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 . +# You should have received a copy of the GNU General Public License +# along with FYReader. If not, see . # -# Copyright (C) 2020 - 2022 fengyuecanzhu +# Copyright (C) 2020 - 2022 fengyuecanzhu # ##############################################################################