From c5e78ed129bd945c18a835b921b0c44f768a1de4 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Sat, 29 May 2021 12:41:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- app/src/main/assets/updatelog.fy | 9 ++- .../xyz/fycz/myreader/entity/ReadStyle.java | 10 ++++ .../xyz/fycz/myreader/entity/Setting.java | 8 +++ .../xyz/fycz/myreader/model/SearchEngine.java | 3 +- .../myreader/ui/activity/MainActivity.java | 2 + .../ui/activity/MoreSettingActivity.java | 55 +++++++------------ .../myreader/ui/activity/ReadActivity.java | 3 +- .../myreader/ui/fragment/MineFragment.java | 28 +++++++++- .../myreader/ui/fragment/WebDavFragment.java | 23 +++++++- .../fycz/myreader/widget/page/PageLoader.java | 6 +- .../main/res/layout/activity_more_setting.xml | 25 +++++++++ app/src/main/res/values/strings.xml | 1 + app/version_code.properties | 4 +- 14 files changed, 135 insertions(+), 44 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 794aa67..58918f5 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/app/src/main/assets/updatelog.fy b/app/src/main/assets/updatelog.fy index 7a2ef9a..b99186b 100644 --- a/app/src/main/assets/updatelog.fy +++ b/app/src/main/assets/updatelog.fy @@ -1,7 +1,14 @@ +2021.05.29 +风月读书v2.0.2 +更新内容: +1、阅读设置新增适配英文排版开关(默认关闭) +2、修复书籍未加入书架时阅读界面无法换源的bug +3、优化恢复 + 2021.05.17 风月读书v2.0.1 更新内容: -1、修复第三方书源阅读界面换源后无法加载目录的bug +1、修复第三方书源阅读界面换源后无法加载目录的bug(如果还是无法加载建议到书籍详情页或直接搜索后换源) 2、优化阅读界面换源 2021.05.16 diff --git a/app/src/main/java/xyz/fycz/myreader/entity/ReadStyle.java b/app/src/main/java/xyz/fycz/myreader/entity/ReadStyle.java index 4e496ac..b0b19c5 100644 --- a/app/src/main/java/xyz/fycz/myreader/entity/ReadStyle.java +++ b/app/src/main/java/xyz/fycz/myreader/entity/ReadStyle.java @@ -72,6 +72,8 @@ public class ReadStyle implements Serializable { private int blueFilterPercent;//蓝光过滤比率 + private boolean enType;//英文排版 + @Override public Object clone() { try { @@ -315,4 +317,12 @@ public class ReadStyle implements Serializable { public void setBlueFilterPercent(int blueFilterPercent) { this.blueFilterPercent = blueFilterPercent; } + + public boolean isEnType() { + return enType; + } + + public void setEnType(boolean enType) { + this.enType = enType; + } } diff --git a/app/src/main/java/xyz/fycz/myreader/entity/Setting.java b/app/src/main/java/xyz/fycz/myreader/entity/Setting.java index 5234728..c12a76c 100644 --- a/app/src/main/java/xyz/fycz/myreader/entity/Setting.java +++ b/app/src/main/java/xyz/fycz/myreader/entity/Setting.java @@ -180,6 +180,7 @@ public class Setting implements Serializable { readStyle.setBgPath(""); readStyle.setBlueFilterPercent(30); readStyle.setProtectEye(false); + readStyle.setEnType(false); readStyle.setComposition(1); readStyles.add(readStyle); @@ -708,4 +709,11 @@ public class Setting implements Serializable { public void setLightNovelParagraph(boolean lightNovelParagraph) { this.lightNovelParagraph = lightNovelParagraph; } + public boolean isEnType() { + return getCurReadStyle().isEnType(); + } + + public void setEnType(boolean enType) { + getCurReadStyle().setEnType(enType); + } } 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 0845f4e..7de5a10 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java +++ b/app/src/main/java/xyz/fycz/myreader/model/SearchEngine.java @@ -21,6 +21,7 @@ import xyz.fycz.myreader.util.ToastUtils; import xyz.fycz.myreader.webapi.BookApi; import xyz.fycz.myreader.webapi.crawler.base.BookInfoCrawler; import xyz.fycz.myreader.webapi.crawler.base.ReadCrawler; +import xyz.fycz.myreader.webapi.crawler.source.ThirdCrawler; import java.util.ArrayList; import java.util.List; @@ -267,7 +268,7 @@ public class SearchEngine { public Observable> getBookInfo(ConMVMap bookMap, ReadCrawler rc) { return Observable.create(emitter -> { - if (isRead && rc instanceof BookInfoCrawler) { + if (isRead && rc instanceof ThirdCrawler) { List books = bookMap.values(); for (Book book : books) { BookApi.getBookInfo(book, (BookInfoCrawler) rc).subscribe(); diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java index e93ea31..c2fb10e 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java @@ -46,6 +46,7 @@ import xyz.fycz.myreader.ui.fragment.MineFragment; import xyz.fycz.myreader.util.SharedPreUtils; import xyz.fycz.myreader.util.StringHelper; import xyz.fycz.myreader.util.ToastUtils; +import xyz.fycz.myreader.util.utils.AdUtils; import xyz.fycz.myreader.util.utils.GsonExtensionsKt; import static androidx.fragment.app.FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT; @@ -220,6 +221,7 @@ public class MainActivity extends BaseActivity { ToastUtils.showError(e.getLocalizedMessage()); e.printStackTrace(); } + AdUtils.adRecord("Usage", "usTimes"); } private void reLoadFragment() { diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java index 8d34454..dcec558 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java @@ -67,6 +67,7 @@ public class MoreSettingActivity extends BaseActivity { private boolean alwaysNext; private boolean noMenuTitle; private boolean readAloudVolumeTurnPage; + private boolean enType; private ArrayList mBooks; int booksCount; @@ -110,6 +111,7 @@ public class MoreSettingActivity extends BaseActivity { isLongPress = mSetting.isCanSelectText(); noMenuTitle = mSetting.isNoMenuChTitle(); readAloudVolumeTurnPage = mSetting.isReadAloudVolumeTurnPage(); + enType = mSetting.isEnType(); threadNum = SharedPreUtils.getInstance().getInt(getString(R.string.threadNum), 8); isWebDav = getIntent().getBooleanExtra(APPCONST.WEB_DAV, false); } @@ -193,6 +195,7 @@ public class MoreSettingActivity extends BaseActivity { binding.scShowStatus.setChecked(isShowStatusBar); binding.scLongPress.setChecked(isLongPress); binding.scNoMenuTitle.setChecked(noMenuTitle); + binding.scAdaptEnType.setChecked(enType); binding.scReadAloudVolumeTurnPage.setChecked(readAloudVolumeTurnPage); } @@ -215,11 +218,7 @@ public class MoreSettingActivity extends BaseActivity { binding.rlVolume.setOnClickListener( (v) -> { - if (isVolumeTurnPage) { - isVolumeTurnPage = false; - } else { - isVolumeTurnPage = true; - } + isVolumeTurnPage = !isVolumeTurnPage; binding.scVolume.setChecked(isVolumeTurnPage); mSetting.setVolumeTurnPage(isVolumeTurnPage); SysManager.saveSetting(mSetting); @@ -227,11 +226,7 @@ public class MoreSettingActivity extends BaseActivity { ); binding.rlAlwaysNext.setOnClickListener( (v) -> { - if (alwaysNext) { - alwaysNext = false; - } else { - alwaysNext = true; - } + alwaysNext = !alwaysNext; binding.scAlwaysNext.setChecked(alwaysNext); mSetting.setAlwaysNext(alwaysNext); SysManager.saveSetting(mSetting); @@ -240,11 +235,7 @@ public class MoreSettingActivity extends BaseActivity { binding.rlShowStatus.setOnClickListener( (v) -> { needRefresh = true; - if (isShowStatusBar) { - isShowStatusBar = false; - } else { - isShowStatusBar = true; - } + isShowStatusBar = !isShowStatusBar; binding.scShowStatus.setChecked(isShowStatusBar); mSetting.setShowStatusBar(isShowStatusBar); SysManager.saveSetting(mSetting); @@ -253,11 +244,7 @@ public class MoreSettingActivity extends BaseActivity { binding.rlLongPress.setOnClickListener( (v) -> { needRefresh = false; - if (isLongPress) { - isLongPress = false; - } else { - isLongPress = true; - } + isLongPress = !isLongPress; binding.scLongPress.setChecked(isLongPress); mSetting.setCanSelectText(isLongPress); SysManager.saveSetting(mSetting); @@ -266,11 +253,7 @@ public class MoreSettingActivity extends BaseActivity { binding.rlContentReplace.setOnClickListener(v -> startActivity(new Intent(this, ReplaceRuleActivity.class))); binding.rlReadAloudVolumeTurnPage.setOnClickListener( (v) -> { - if (readAloudVolumeTurnPage) { - readAloudVolumeTurnPage = false; - } else { - readAloudVolumeTurnPage = true; - } + readAloudVolumeTurnPage = !readAloudVolumeTurnPage; binding.scReadAloudVolumeTurnPage.setChecked(readAloudVolumeTurnPage); mSetting.setReadAloudVolumeTurnPage(readAloudVolumeTurnPage); SysManager.saveSetting(mSetting); @@ -279,17 +262,23 @@ public class MoreSettingActivity extends BaseActivity { binding.rlNoMenuTitle.setOnClickListener( (v) -> { upMenu = true; - if (noMenuTitle) { - noMenuTitle = false; - } else { - noMenuTitle = true; - } + noMenuTitle = !noMenuTitle; binding.scNoMenuTitle.setChecked(noMenuTitle); mSetting.setNoMenuChTitle(noMenuTitle); SysManager.saveSetting(mSetting); } ); + binding.rlAdaptEnType.setOnClickListener( + (v) -> { + needRefresh = true; + enType = !enType; + binding.scAdaptEnType.setChecked(enType); + mSetting.setEnType(enType); + SysManager.saveSetting(mSetting); + } + ); + binding.llBookSort.setOnClickListener(v -> { MyAlertDialog.build(this) .setTitle(getString(R.string.book_sort)) @@ -320,11 +309,7 @@ public class MoreSettingActivity extends BaseActivity { binding.rlAutoRefresh.setOnClickListener( (v) -> { - if (autoRefresh) { - autoRefresh = false; - } else { - autoRefresh = true; - } + autoRefresh = !autoRefresh; binding.scAutoRefresh.setChecked(autoRefresh); mSetting.setRefreshWhenStart(autoRefresh); SysManager.saveSetting(mSetting); diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java index 699c18b..36d7731 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java @@ -493,7 +493,8 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe if (!isCollected) { intent.putExtra("isCollected", false); } - finish(); + //finish(); + exit(); startActivity(intent); }); diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java b/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java index 16f14fe..8521fe8 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java @@ -14,6 +14,8 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; +import org.jetbrains.annotations.NotNull; + import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -42,6 +44,7 @@ import xyz.fycz.myreader.ui.activity.AdSettingActivity; import xyz.fycz.myreader.ui.activity.BookSourceActivity; import xyz.fycz.myreader.ui.activity.DonateActivity; import xyz.fycz.myreader.ui.activity.FeedbackActivity; +import xyz.fycz.myreader.ui.activity.MainActivity; import xyz.fycz.myreader.ui.activity.MoreSettingActivity; import xyz.fycz.myreader.ui.dialog.DialogCreator; import xyz.fycz.myreader.ui.dialog.MyAlertDialog; @@ -167,7 +170,22 @@ public class MineFragment extends BaseFragment { .subscribe(new MySingleObserver>() { @Override public void onSuccess(ArrayList strings) { - if (!WebDavHelp.INSTANCE.showRestoreDialog(getContext(), strings, BackupRestoreUi.INSTANCE)) { + if (!WebDavHelp.INSTANCE.showRestoreDialog(getContext(), strings, new Restore.CallBack() { + @Override + public void restoreSuccess() { + SysManager.regetmSetting(); + ToastUtils.showSuccess("成功将书架从网络同步至本地!"); + if (getActivity() != null) { + getActivity().finish(); + } + startActivity(new Intent(getContext(), MainActivity.class)); + } + + @Override + public void restoreError(@NotNull String msg) { + ToastUtils.showError(msg); + } + })) { ToastUtils.showWarring("WebDav服务端没有备份或WebDav配置错误"); } } @@ -353,6 +371,10 @@ public class MineFragment extends BaseFragment { // "恢复成功!\n注意:本功能属于实验功能,书架恢复后,书籍初次加载时可能加载失败,返回重新加载即可!"); SysManager.regetmSetting(); ToastUtils.showSuccess("书架恢复成功!"); + if (getActivity() != null) { + getActivity().finish(); + } + startActivity(new Intent(getContext(), MainActivity.class)); } @Override @@ -441,6 +463,10 @@ public class MineFragment extends BaseFragment { // "恢复成功!\n注意:本功能属于实验功能,书架恢复后,书籍初次加载时可能加载失败,返回重新加载即可!");、 SysManager.regetmSetting(); ToastUtils.showSuccess("成功将书架从网络同步至本地!"); + if (getActivity() != null) { + getActivity().finish(); + } + startActivity(new Intent(getContext(), MainActivity.class)); } else { DialogCreator.createTipDialog(getContext(), "未找到同步文件,同步失败!"); } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/fragment/WebDavFragment.java b/app/src/main/java/xyz/fycz/myreader/ui/fragment/WebDavFragment.java index 917d7c3..0c9ed89 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/fragment/WebDavFragment.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/fragment/WebDavFragment.java @@ -1,5 +1,6 @@ package xyz.fycz.myreader.ui.fragment; +import android.content.Intent; import android.os.Bundle; import android.text.InputType; import android.view.LayoutInflater; @@ -7,6 +8,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.NumberPicker; +import org.jetbrains.annotations.NotNull; + import java.util.ArrayList; import io.reactivex.Single; @@ -14,12 +17,15 @@ import io.reactivex.SingleOnSubscribe; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; import xyz.fycz.myreader.R; +import xyz.fycz.myreader.application.SysManager; import xyz.fycz.myreader.base.BaseFragment; import xyz.fycz.myreader.base.observer.MySingleObserver; import xyz.fycz.myreader.common.APPCONST; import xyz.fycz.myreader.databinding.FragmentWebdavSettingBinding; import xyz.fycz.myreader.model.storage.BackupRestoreUi; +import xyz.fycz.myreader.model.storage.Restore; import xyz.fycz.myreader.model.storage.WebDavHelp; +import xyz.fycz.myreader.ui.activity.MainActivity; import xyz.fycz.myreader.ui.dialog.MyAlertDialog; import xyz.fycz.myreader.util.SharedPreUtils; import xyz.fycz.myreader.util.StringHelper; @@ -113,7 +119,22 @@ public class WebDavFragment extends BaseFragment { .subscribe(new MySingleObserver>() { @Override public void onSuccess(ArrayList strings) { - if (!WebDavHelp.INSTANCE.showRestoreDialog(getContext(), strings, BackupRestoreUi.INSTANCE)) { + if (!WebDavHelp.INSTANCE.showRestoreDialog(getContext(), strings, new Restore.CallBack() { + @Override + public void restoreSuccess() { + SysManager.regetmSetting(); + ToastUtils.showSuccess("成功将书架从网络同步至本地!"); + if (getActivity() != null) { + getActivity().finish(); + } + startActivity(new Intent(getContext(), MainActivity.class)); + } + + @Override + public void restoreError(@NotNull String msg) { + ToastUtils.showError(msg); + } + })) { ToastUtils.showWarring("WebDav服务端没有备份或WebDav配置错误"); } } diff --git a/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java b/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java index 9efa66e..1195aa3 100644 --- a/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java +++ b/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java @@ -1673,7 +1673,11 @@ public abstract class PageLoader { } // 重置段落 if (!showTitle) { - paragraph = StringUtils.trim(paragraph.replace("\t", "")); + if (mSettingManager.isEnType()) { + paragraph = StringUtils.trim(paragraph.replace("\t", "")); + } else { + paragraph = paragraph.replaceAll("\\s", ""); + } // 如果只有换行符,那么就不执行 if (paragraph.equals("")) continue; paragraph = indent + paragraph + "\n"; diff --git a/app/src/main/res/layout/activity_more_setting.xml b/app/src/main/res/layout/activity_more_setting.xml index 992dc7b..8eb99ca 100644 --- a/app/src/main/res/layout/activity_more_setting.xml +++ b/app/src/main/res/layout/activity_more_setting.xml @@ -270,7 +270,32 @@ android:clickable="false" android:longClickable="false" /> + + + + + 正在打开首页,成功自动返回主界面 清除Cookie 编辑书源 + 适配英文排版 diff --git a/app/version_code.properties b/app/version_code.properties index 8dd717e..4e383d4 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Mon May 17 11:39:21 CST 2021 -VERSION_CODE=200 +#Sat May 29 12:39:33 CST 2021 +VERSION_CODE=202