v2.1.7-debug

master
fengyuecanzhu 3 years ago
parent 638bfd4deb
commit 471a5c9cc2
  1. 32
      .idea/assetWizardSettings.xml
  2. 3
      .idea/misc.xml
  3. 2
      app/build.gradle
  4. 4
      app/release.md
  5. 6
      app/src/main/assets/updatelog.fy
  6. 25
      app/src/main/java/xyz/fycz/myreader/greendao/entity/Book.java
  7. 5
      app/src/main/java/xyz/fycz/myreader/model/storage/BackupRestoreUi.kt
  8. 10
      app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt
  9. 5
      app/src/main/java/xyz/fycz/myreader/model/storage/WebDavHelp.kt
  10. 11
      app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java
  11. 7
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java
  12. 8
      app/src/main/java/xyz/fycz/myreader/ui/adapter/SearchAdapter.kt
  13. 2
      app/src/main/java/xyz/fycz/myreader/ui/fragment/MineFragment.java
  14. 2
      app/src/main/java/xyz/fycz/myreader/ui/fragment/WebDavFragment.java
  15. 4
      app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java
  16. 134
      app/src/main/java/xyz/fycz/myreader/util/help/ChapterContentHelp.java
  17. 12
      app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java
  18. 12
      app/src/main/res/drawable/ic_re_seg.xml
  19. 27
      app/src/main/res/layout/activity_more_setting.xml
  20. 5
      app/src/main/res/menu/menu_book.xml
  21. 9
      app/src/main/res/menu/menu_read.xml
  22. 2
      app/src/main/res/values/strings.xml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="vectorWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="vectorAssetStep">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="assetSourceType" value="FILE" />
<entry key="outputName" value="ic_re_seg" />
<entry key="sourceFile" value="F:\SVG图标\段落说明.svg" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</component>
</project>

@ -3,12 +3,15 @@
<component name="DesignSurface"> <component name="DesignSurface">
<option name="filePathToZoomLevelMap"> <option name="filePathToZoomLevelMap">
<map> <map>
<entry key="..\:/android/FYReader/app/src/main/res/drawable/ic_re_seg.xml" value="0.1962962962962963" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_more_setting.xml" value="0.264" /> <entry key="..\:/android/FYReader/app/src/main/res/layout/activity_more_setting.xml" value="0.264" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fingerprint_dialog.xml" value="0.20425724637681159" /> <entry key="..\:/android/FYReader/app/src/main/res/layout/fingerprint_dialog.xml" value="0.20425724637681159" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_webdav_setting.xml" value="0.4" /> <entry key="..\:/android/FYReader/app/src/main/res/layout/fragment_webdav_setting.xml" value="0.4" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/listview_search_book_item.xml" value="0.22010869565217392" /> <entry key="..\:/android/FYReader/app/src/main/res/layout/listview_search_book_item.xml" value="0.22010869565217392" />
<entry key="..\:/android/FYReader/app/src/main/res/layout/view_file_picker.xml" value="0.12132725430597771" /> <entry key="..\:/android/FYReader/app/src/main/res/layout/view_file_picker.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book.xml" value="0.13703703703703704" /> <entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book.xml" value="0.13703703703703704" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book_detail.xml" value="0.24947916666666667" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_read.xml" value="0.24947916666666667" />
</map> </map>
</option> </option>
</component> </component>

@ -243,7 +243,7 @@ dependencies {
} }
greendao { greendao {
schemaVersion 29 schemaVersion 30
daoPackage 'xyz.fycz.myreader.greendao.gen' daoPackage 'xyz.fycz.myreader.greendao.gen'
// targetGenDir 'src/main/java' // targetGenDir 'src/main/java'
} }

@ -1,3 +1,5 @@
* 1、修复发现分类bug * 1、修复发现分类bug
* 2、新增章节内容智能分段 * 2、新增章节内容智能分段(阅读菜单-智能分段)
* 3、备份/恢复路径支持自定义 * 3、备份/恢复路径支持自定义
* 4、优化搜索
* 5、修复已知bug

@ -1,9 +1,11 @@
2021.08.25
风月读书v2.1.7 风月读书v2.1.7
更新内容: 更新内容:
1、修复发现分类bug 1、修复发现分类bug
2、新增章节内容智能分段 2、新增章节内容智能分段(阅读菜单-智能分段)
3、备份/恢复路径支持自定义 3、备份/恢复路径支持自定义
4、优化搜索
5、修复已知bug
2021.07.24 2021.07.24
风月读书v2.1.6 风月读书v2.1.6

@ -65,6 +65,8 @@ public class Book implements Serializable {
private int groupSort;//分组排序 private int groupSort;//分组排序
private boolean reSeg;//智能分段
private String tag; private String tag;
private Boolean replaceEnable = SharedPreUtils.getInstance().getBoolean("replaceEnableDefault", true); private Boolean replaceEnable = SharedPreUtils.getInstance().getBoolean("replaceEnableDefault", true);
@ -83,13 +85,13 @@ public class Book implements Serializable {
public Book() { public Book() {
} }
@Generated(hash = 1910282685) @Generated(hash = 1472063028)
public Book(String id, String name, String chapterUrl, String infoUrl, String imgUrl, String desc, public Book(String id, String name, String chapterUrl, String infoUrl, String imgUrl, String desc, String author,
String author, String type, String updateDate, String wordCount, String status, String type, String updateDate, String wordCount, String status, String newestChapterId,
String newestChapterId, String newestChapterTitle, String historyChapterId, int histtoryChapterNum, String newestChapterTitle, String historyChapterId, int histtoryChapterNum, int sortCode, int noReadNum,
int sortCode, int noReadNum, int chapterTotalNum, int lastReadPosition, String source, int chapterTotalNum, int lastReadPosition, String source, boolean isCloseUpdate, boolean isDownLoadAll,
boolean isCloseUpdate, boolean isDownLoadAll, String groupId, int groupSort, String tag, String groupId, int groupSort, boolean reSeg, String tag, Boolean replaceEnable, long lastReadTime,
Boolean replaceEnable, long lastReadTime, String variable) { String variable) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.chapterUrl = chapterUrl; this.chapterUrl = chapterUrl;
@ -114,6 +116,7 @@ public class Book implements Serializable {
this.isDownLoadAll = isDownLoadAll; this.isDownLoadAll = isDownLoadAll;
this.groupId = groupId; this.groupId = groupId;
this.groupSort = groupSort; this.groupSort = groupSort;
this.reSeg = reSeg;
this.tag = tag; this.tag = tag;
this.replaceEnable = replaceEnable; this.replaceEnable = replaceEnable;
this.lastReadTime = lastReadTime; this.lastReadTime = lastReadTime;
@ -419,4 +422,12 @@ public class Book implements Serializable {
catheMap.clear(); catheMap.clear();
} }
} }
public boolean getReSeg() {
return this.reSeg;
}
public void setReSeg(boolean reSeg) {
this.reSeg = reSeg;
}
} }

@ -5,10 +5,8 @@ import android.app.Activity.RESULT_OK
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.text.TextUtils import android.text.TextUtils
import androidx.core.content.ContextCompat
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import com.kongzue.dialogx.dialogs.BottomMenu import com.kongzue.dialogx.dialogs.BottomMenu
import com.kongzue.dialogx.interfaces.OnMenuItemClickListener
import io.reactivex.Single import io.reactivex.Single
import io.reactivex.SingleEmitter import io.reactivex.SingleEmitter
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
@ -17,7 +15,6 @@ import xyz.fycz.myreader.R
import xyz.fycz.myreader.application.App import xyz.fycz.myreader.application.App
import xyz.fycz.myreader.application.SysManager import xyz.fycz.myreader.application.SysManager
import xyz.fycz.myreader.base.observer.MySingleObserver import xyz.fycz.myreader.base.observer.MySingleObserver
import xyz.fycz.myreader.common.APPCONST
import xyz.fycz.myreader.model.storage.WebDavHelp.getWebDavFileNames import xyz.fycz.myreader.model.storage.WebDavHelp.getWebDavFileNames
import xyz.fycz.myreader.model.storage.WebDavHelp.showRestoreDialog import xyz.fycz.myreader.model.storage.WebDavHelp.showRestoreDialog
import xyz.fycz.myreader.util.SharedPreUtils import xyz.fycz.myreader.util.SharedPreUtils
@ -139,7 +136,7 @@ object BackupRestoreUi : Backup.CallBack, Restore.CallBack {
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(object : MySingleObserver<ArrayList<String>?>() { .subscribe(object : MySingleObserver<ArrayList<String>?>() {
override fun onSuccess(strings: ArrayList<String>) { override fun onSuccess(strings: ArrayList<String>) {
if (!showRestoreDialog(activity, strings, this@BackupRestoreUi)) { if (!showRestoreDialog(strings, this@BackupRestoreUi)) {
val path = getBackupPath() val path = getBackupPath()
if (TextUtils.isEmpty(path)) { if (TextUtils.isEmpty(path)) {
selectRestoreFolder(activity) selectRestoreFolder(activity)

@ -23,6 +23,7 @@ object Restore {
fun restore(context: Context, uri: Uri, callBack: CallBack?) { fun restore(context: Context, uri: Uri, callBack: CallBack?) {
Single.create(SingleOnSubscribe<Boolean> { e -> Single.create(SingleOnSubscribe<Boolean> { e ->
deleteOldFile()
DocumentFile.fromTreeUri(context, uri)?.listFiles()?.forEach { doc -> DocumentFile.fromTreeUri(context, uri)?.listFiles()?.forEach { doc ->
for (fileName in Backup.backupFileNames) { for (fileName in Backup.backupFileNames) {
if (doc.name == fileName) { if (doc.name == fileName) {
@ -48,6 +49,15 @@ object Restore {
}) })
} }
private fun deleteOldFile() {
val dir = FileUtils.getFile(Backup.backupPath)
dir.listFiles()?.forEach {
if (it.name in Backup.backupFileNames){
it?.delete()
}
}
}
fun restore(path: String, callBack: CallBack?) { fun restore(path: String, callBack: CallBack?) {
Single.create(SingleOnSubscribe<Boolean> { e -> Single.create(SingleOnSubscribe<Boolean> { e ->
try { try {

@ -1,15 +1,12 @@
package xyz.fycz.myreader.model.storage package xyz.fycz.myreader.model.storage
import android.content.Context
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import com.kongzue.dialogx.dialogs.BottomMenu import com.kongzue.dialogx.dialogs.BottomMenu
import com.kongzue.dialogx.interfaces.OnMenuItemClickListener
import io.reactivex.Single import io.reactivex.Single
import io.reactivex.SingleOnSubscribe import io.reactivex.SingleOnSubscribe
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import org.jetbrains.anko.selector
import xyz.fycz.myreader.R import xyz.fycz.myreader.R
import xyz.fycz.myreader.base.observer.MySingleObserver import xyz.fycz.myreader.base.observer.MySingleObserver
import xyz.fycz.myreader.common.APPCONST import xyz.fycz.myreader.common.APPCONST
@ -70,7 +67,7 @@ object WebDavHelp {
return names return names
} }
fun showRestoreDialog(context: Context, names: ArrayList<String>, callBack: Restore.CallBack?): Boolean { fun showRestoreDialog(names: ArrayList<String>, callBack: Restore.CallBack?): Boolean {
return if (names.isNotEmpty()) { return if (names.isNotEmpty()) {
/*context.selector(title = "选择恢复文件", items = names) { _, index -> /*context.selector(title = "选择恢复文件", items = names) { _, index ->
if (index in 0 until 30.coerceAtLeast(names.size)) { if (index in 0 until 30.coerceAtLeast(names.size)) {

@ -84,7 +84,6 @@ public class MoreSettingActivity extends BaseActivity implements SharedPreferenc
private boolean noMenuTitle; private boolean noMenuTitle;
private boolean readAloudVolumeTurnPage; private boolean readAloudVolumeTurnPage;
private boolean enType; private boolean enType;
private boolean reSeg;
private ArrayList<Book> mBooks; private ArrayList<Book> mBooks;
int booksCount; int booksCount;
@ -129,7 +128,6 @@ public class MoreSettingActivity extends BaseActivity implements SharedPreferenc
noMenuTitle = mSetting.isNoMenuChTitle(); noMenuTitle = mSetting.isNoMenuChTitle();
readAloudVolumeTurnPage = mSetting.isReadAloudVolumeTurnPage(); readAloudVolumeTurnPage = mSetting.isReadAloudVolumeTurnPage();
enType = mSetting.isEnType(); enType = mSetting.isEnType();
reSeg = mSetting.isLightNovelParagraph();
threadNum = SharedPreUtils.getInstance().getInt(getString(R.string.threadNum), 8); threadNum = SharedPreUtils.getInstance().getInt(getString(R.string.threadNum), 8);
isWebDav = getIntent().getBooleanExtra(APPCONST.WEB_DAV, false); isWebDav = getIntent().getBooleanExtra(APPCONST.WEB_DAV, false);
} }
@ -216,7 +214,6 @@ public class MoreSettingActivity extends BaseActivity implements SharedPreferenc
binding.scLongPress.setChecked(isLongPress); binding.scLongPress.setChecked(isLongPress);
binding.scNoMenuTitle.setChecked(noMenuTitle); binding.scNoMenuTitle.setChecked(noMenuTitle);
binding.scAdaptEnType.setChecked(enType); binding.scAdaptEnType.setChecked(enType);
binding.scReSeg.setChecked(reSeg);
binding.scReadAloudVolumeTurnPage.setChecked(readAloudVolumeTurnPage); binding.scReadAloudVolumeTurnPage.setChecked(readAloudVolumeTurnPage);
} }
@ -300,14 +297,6 @@ public class MoreSettingActivity extends BaseActivity implements SharedPreferenc
} }
); );
binding.rlReSeg.setOnClickListener(v -> {
needRefresh = true;
reSeg = !reSeg;
binding.scReSeg.setChecked(reSeg);
mSetting.setLightNovelParagraph(reSeg);
SysManager.saveSetting(mSetting);
});
binding.llBookSort.setOnClickListener(v -> { binding.llBookSort.setOnClickListener(v -> {
/*MyAlertDialog.build(this) /*MyAlertDialog.build(this)
.setTitle(getString(R.string.book_sort)) .setTitle(getString(R.string.book_sort))

@ -722,6 +722,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
menu.findItem(R.id.action_open_link).setVisible(false); menu.findItem(R.id.action_open_link).setVisible(false);
menu.findItem(R.id.action_download).setVisible(false); menu.findItem(R.id.action_download).setVisible(false);
} }
menu.findItem(R.id.action_re_seg).setChecked(mBook.getReSeg());
return super.onPrepareOptionsMenu(menu); return super.onPrepareOptionsMenu(menu);
} }
@ -760,6 +761,12 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
} else if (itemId == R.id.action_replace_content) { } else if (itemId == R.id.action_replace_content) {
Intent ruleIntent = new Intent(this, ReplaceRuleActivity.class); Intent ruleIntent = new Intent(this, ReplaceRuleActivity.class);
startActivityForResult(ruleIntent, APPCONST.REQUEST_REFRESH_READ_UI); startActivityForResult(ruleIntent, APPCONST.REQUEST_REFRESH_READ_UI);
}else if(itemId == R.id.action_re_seg){
mBook.setReSeg(!mBook.getReSeg());
mBookService.updateEntity(mBook);
if (mPageLoader != null) {
mPageLoader.refreshUi();
}
} else if (itemId == R.id.action_copy_content) { } else if (itemId == R.id.action_copy_content) {
String content = mPageLoader.getContentStartPage(0); String content = mPageLoader.getContentStartPage(0);
MyAlertDialog.showTipDialogWithLink(this, "拷贝内容", content == null ? "章节内容为空!" : content); MyAlertDialog.showTipDialogWithLink(this, "拷贝内容", content == null ? "章节内容为空!" : content);

@ -309,7 +309,7 @@ class SearchAdapter(
} }
} }
if (filterDataS.size > 0) { if (filterDataS.size > 0) {
val searchBookBeansAdd: MutableList<SearchBookBean> = java.util.ArrayList() val searchBookBeansAdd: MutableList<SearchBookBean> = ArrayList()
if (copyDataS.size == 0) { if (copyDataS.size == 0) {
copyDataS.addAll(filterDataS) copyDataS.addAll(filterDataS)
} else { } else {
@ -345,10 +345,8 @@ class SearchAdapter(
} else if (TextUtils.equals(keyWord, temp.author)) { } else if (TextUtils.equals(keyWord, temp.author)) {
for (i in copyDataS.indices) { for (i in copyDataS.indices) {
val searchBook = copyDataS[i] val searchBook = copyDataS[i]
if (!TextUtils.equals(keyWord, searchBook.name) && !TextUtils.equals( if (!TextUtils.equals(keyWord, searchBook.name) &&
keyWord, !TextUtils.equals(keyWord, searchBook.author)
searchBook.author
)
) { ) {
copyDataS.add(i, temp) copyDataS.add(i, temp)
break break

@ -184,7 +184,7 @@ public class MineFragment extends BaseFragment {
} }
@Override @Override
public void onSuccess(ArrayList<String> strings) { public void onSuccess(ArrayList<String> strings) {
if (!WebDavHelp.INSTANCE.showRestoreDialog(getContext(), strings, new Restore.CallBack() { if (!WebDavHelp.INSTANCE.showRestoreDialog(strings, new Restore.CallBack() {
@Override @Override
public void restoreSuccess() { public void restoreSuccess() {
SysManager.regetmSetting(); SysManager.regetmSetting();

@ -130,7 +130,7 @@ public class WebDavFragment extends BaseFragment {
} }
@Override @Override
public void onSuccess(ArrayList<String> strings) { public void onSuccess(ArrayList<String> strings) {
if (!WebDavHelp.INSTANCE.showRestoreDialog(getContext(), strings, new Restore.CallBack() { if (!WebDavHelp.INSTANCE.showRestoreDialog(strings, new Restore.CallBack() {
@Override @Override
public void restoreSuccess() { public void restoreSuccess() {
SysManager.regetmSetting(); SysManager.regetmSetting();

@ -504,10 +504,10 @@ public class BookcasePresenter implements BasePresenter {
} else if (itemId == R.id.action_addLocalBook) { } else if (itemId == R.id.action_addLocalBook) {
addLocalBook(); addLocalBook();
return true; return true;
} else if (itemId == R.id.action_add_url) { } /*else if (itemId == R.id.action_add_url) {
return true; return true;
} else if (itemId == R.id.action_download_all) { }*/ else if (itemId == R.id.action_download_all) {
if (!SharedPreUtils.getInstance().getBoolean(mMainActivity.getString(R.string.isReadDownloadAllTip), false)) { if (!SharedPreUtils.getInstance().getBoolean(mMainActivity.getString(R.string.isReadDownloadAllTip), false)) {
DialogCreator.createCommonDialog(mMainActivity, "一键缓存", DialogCreator.createCommonDialog(mMainActivity, "一键缓存",
mMainActivity.getString(R.string.all_cathe_tip), true, mMainActivity.getString(R.string.all_cathe_tip), true,

@ -493,90 +493,90 @@ public class ChapterContentHelp {
* @return * @return
*/ */
public static String LightNovelParagraph2(String content, String chapterName) { public static String LightNovelParagraph2(String content, String chapterName) {
if (SysManager.getSetting().isLightNovelParagraph()) { // if (SysManager.getSetting().isLightNovelParagraph()) {
String _content; String _content;
int chapterNameLength = chapterName.trim().length(); int chapterNameLength = chapterName.trim().length();
if (chapterNameLength > 1) { if (chapterNameLength > 1) {
String regexp = chapterName.trim().replaceAll("\\s+", "(\\\\s*)"); String regexp = chapterName.trim().replaceAll("\\s+", "(\\\\s*)");
// 质量较低的页面,章节内可能重复出现章节标题 // 质量较低的页面,章节内可能重复出现章节标题
if (chapterNameLength > 5) if (chapterNameLength > 5)
_content = content.replaceAll(regexp, "").trim(); _content = content.replaceAll(regexp, "").trim();
else else
_content = content.replaceFirst("^\\s*" + regexp, "").trim(); _content = content.replaceFirst("^\\s*" + regexp, "").trim();
} else { } else {
_content = content; _content = content;
} }
List<String> dict = makeDict(_content); List<String> dict = makeDict(_content);
String[] p = _content String[] p = _content
.replaceAll("&quot;", "“") .replaceAll("&quot;", "“")
.replaceAll("[::]['\"‘”“]+", ":“") .replaceAll("[::]['\"‘”“]+", ":“")
.replaceAll("[\"”“]+[\\s]*[\"”“][\\s\"”“]*", "”\n“") .replaceAll("[\"”“]+[\\s]*[\"”“][\\s\"”“]*", "”\n“")
.split("\n(\\s*)"); .split("\n(\\s*)");
// 初始化StringBuffer的长度,在原content的长度基础上做冗余 // 初始化StringBuffer的长度,在原content的长度基础上做冗余
StringBuffer buffer = new StringBuffer((int) (content.length() * 1.15)); StringBuffer buffer = new StringBuffer((int) (content.length() * 1.15));
// 章节的文本格式为章节标题-空行-首段,所以处理段落时需要略过第一行文本。 // 章节的文本格式为章节标题-空行-首段,所以处理段落时需要略过第一行文本。
buffer.append(" "); buffer.append(" ");
if (!chapterName.trim().equals(p[0].trim())) { if (!chapterName.trim().equals(p[0].trim())) {
// 去除段落内空格。unicode 3000 象形字间隔(中日韩符号和标点),不包含在\s内 // 去除段落内空格。unicode 3000 象形字间隔(中日韩符号和标点),不包含在\s内
buffer.append(p[0].replaceAll("[\u3000\\s]+", "")); buffer.append(p[0].replaceAll("[\u3000\\s]+", ""));
} }
// 如果原文存在分段错误,需要把段落重新黏合 // 如果原文存在分段错误,需要把段落重新黏合
for (int i = 1; i < p.length; i++) { for (int i = 1; i < p.length; i++) {
if (match(MARK_SENTENCES_END, buffer.charAt(buffer.length() - 1))) if (match(MARK_SENTENCES_END, buffer.charAt(buffer.length() - 1)))
buffer.append("\n"); buffer.append("\n");
// 段落开头以外的地方不应该有空格 // 段落开头以外的地方不应该有空格
// 去除段落内空格。unicode 3000 象形字间隔(中日韩符号和标点),不包含在\s内 // 去除段落内空格。unicode 3000 象形字间隔(中日韩符号和标点),不包含在\s内
buffer.append(p[i].replaceAll("[\u3000\\s]", "")); buffer.append(p[i].replaceAll("[\u3000\\s]", ""));
} }
// 预分段预处理 // 预分段预处理
// ”“处理为”\n“。 // ”“处理为”\n“。
// ”。“处理为”。\n“。不考虑“?” “!”的情况。 // ”。“处理为”。\n“。不考虑“?” “!”的情况。
// ”。xxx处理为 ”。\n xxx // ”。xxx处理为 ”。\n xxx
p = buffer.toString() p = buffer.toString()
.replaceAll("[\"”“]+[\\s]*[\"”“]+", "”\n“") .replaceAll("[\"”“]+[\\s]*[\"”“]+", "”\n“")
.replaceAll("[\"”“]+(?。!?!~)[\"”“]+", "”$1\n“") .replaceAll("[\"”“]+(?。!?!~)[\"”“]+", "”$1\n“")
.replaceAll("[\"”“]+(?。!?!~)([^\"”“])", "”$1\n$2") .replaceAll("[\"”“]+(?。!?!~)([^\"”“])", "”$1\n$2")
.replaceAll("([问说喊唱叫骂道着答])[\\.。]", "$1。\n") .replaceAll("([问说喊唱叫骂道着答])[\\.。]", "$1。\n")
// .replaceAll("([\\.。\\!!??])([^\"”“]+)[::][\"”“]", "$1\n$2:“") // .replaceAll("([\\.。\\!!??])([^\"”“]+)[::][\"”“]", "$1\n$2:“")
.split("\n"); .split("\n");
buffer = new StringBuffer((int) (content.length() * 1.15)); buffer = new StringBuffer((int) (content.length() * 1.15));
for (String s : p) { for (String s : p) {
buffer.append("\n"); buffer.append("\n");
buffer.append(FindNewLines(s, dict) buffer.append(FindNewLines(s, dict)
); );
} }
buffer = reduceLength(buffer); buffer = reduceLength(buffer);
content = chapterName + "\n\n" content = chapterName + "\n\n"
+ buffer.toString() + buffer.toString()
//处理章节头部空格和换行 //处理章节头部空格和换行
.replaceFirst("^\\s+", "") .replaceFirst("^\\s+", "")
// 此规则会造成不规范引号被误换行,暂时无法解决,我认为利大于弊 // 此规则会造成不规范引号被误换行,暂时无法解决,我认为利大于弊
// 例句:“你”“我”“他”都是一样的 // 例句:“你”“我”“他”都是一样的
// 误处理为 “你”\n“我”\n“他”都是一样的 // 误处理为 “你”\n“我”\n“他”都是一样的
// 而规范使用的标点不会被误处理: “你”、“我”、“他”,都是一样的。 // 而规范使用的标点不会被误处理: “你”、“我”、“他”,都是一样的。
.replaceAll("\\s*[\"”“]+[\\s]*[\"”“][\\s\"”“]*", "”\n“") .replaceAll("\\s*[\"”“]+[\\s]*[\"”“][\\s\"”“]*", "”\n“")
// 规范 A:“B... // 规范 A:“B...
.replaceAll("[::][”“\"\\s]+", ":“") .replaceAll("[::][”“\"\\s]+", ":“")
// 处理奇怪的多余引号 \n”A:“B... 为 \nA:“B... // 处理奇怪的多余引号 \n”A:“B... 为 \nA:“B...
.replaceAll("\n[\"“”]([^\n\"“”]+)([,:,:][\"”“])([^\n\"“”]+)", "\n$1:“$3") .replaceAll("\n[\"“”]([^\n\"“”]+)([,:,:][\"”“])([^\n\"“”]+)", "\n$1:“$3")
.replaceAll("\n(\\s*)", "\n") .replaceAll("\n(\\s*)", "\n")
// 处理“……” // 处理“……”
// .replaceAll("\n[\"”“][.,。,…]+\\s*[.,。,…]+[\"”“]","\n“……”") // .replaceAll("\n[\"”“][.,。,…]+\\s*[.,。,…]+[\"”“]","\n“……”")
// 处理被错误断行的省略号。存在较高的误判,但是我认为利大于弊 // 处理被错误断行的省略号。存在较高的误判,但是我认为利大于弊
.replaceAll("[.,。,…]+\\s*[.,。,…]+", "……") .replaceAll("[.,。,…]+\\s*[.,。,…]+", "……")
.replaceAll("\n([\\s::,,]+)", "\n") .replaceAll("\n([\\s::,,]+)", "\n")
; ;
} // }
return content; return content;
} }

@ -285,9 +285,7 @@ public abstract class PageLoader {
mTextPaint = new TextPaint(); mTextPaint = new TextPaint();
mTextPaint.setColor(mTextColor); mTextPaint.setColor(mTextColor);
mTextPaint.setTextSize(mTextSize); mTextPaint.setTextSize(mTextSize);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mTextPaint.setLetterSpacing(mSettingManager.getTextLetterSpacing());
mTextPaint.setLetterSpacing(mSettingManager.getTextLetterSpacing());
}
mTextPaint.setTypeface(mTypeFace); mTextPaint.setTypeface(mTypeFace);
mTextPaint.setAntiAlias(true); mTextPaint.setAntiAlias(true);
@ -295,9 +293,7 @@ public abstract class PageLoader {
mTitlePaint = new TextPaint(); mTitlePaint = new TextPaint();
mTitlePaint.setColor(mTextColor); mTitlePaint.setColor(mTextColor);
mTitlePaint.setTextSize(mTitleSize); mTitlePaint.setTextSize(mTitleSize);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mTitlePaint.setLetterSpacing(mSettingManager.getTextLetterSpacing());
mTitlePaint.setLetterSpacing(mSettingManager.getTextLetterSpacing());
}
mTitlePaint.setStyle(Paint.Style.FILL_AND_STROKE); mTitlePaint.setStyle(Paint.Style.FILL_AND_STROKE);
mTitlePaint.setTypeface(Typeface.create(mTypeFace, Typeface.BOLD)); mTitlePaint.setTypeface(Typeface.create(mTypeFace, Typeface.BOLD));
mTitlePaint.setAntiAlias(true); mTitlePaint.setAntiAlias(true);
@ -1672,7 +1668,9 @@ public abstract class PageLoader {
TxtChapter txtChapter = new TxtChapter(chapter.getNumber()); TxtChapter txtChapter = new TxtChapter(chapter.getNumber());
content = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), content, true); content = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), content, true);
content = contentHelper.LightNovelParagraph2(content, chapter.getTitle()); if (mCollBook.getReSeg()) {
content = contentHelper.LightNovelParagraph2(content, chapter.getTitle());
}
String[] allLine = content.split("\n"); String[] allLine = content.split("\n");
//使用流的方式加载 //使用流的方式加载

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M768,128H256A128,128 0,0 0,128 256v512A128,128 0,0 0,256 896h512a128,128 0,0 0,128 -128V256A128,128 0,0 0,768 128zM844.8,768a76.8,76.8 0,0 1,-76.8 76.8H256A76.8,76.8 0,0 1,179.2 768V256A76.8,76.8 0,0 1,256 179.2h512A76.8,76.8 0,0 1,844.8 256z"
android:fillColor="#FFFFFF"/>
<path
android:pathData="M716.8,321.54H307.2a25.6,25.6 0,0 0,0 51.2h409.6a25.6,25.6 0,0 0,0 -51.2zM307.2,541.18h204.8a25.6,25.6 0,0 0,0 -51.2H307.2a25.6,25.6 0,0 0,0 51.2zM716.8,658.43H307.2a25.6,25.6 0,1 0,0 51.2h409.6a25.6,25.6 0,0 0,0 -51.2z"
android:fillColor="#FFFFFF"/>
</vector>

@ -297,33 +297,6 @@
android:longClickable="false" /> android:longClickable="false" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:id="@+id/rl_re_seg"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/selector_common_bg"
android:gravity="center"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/re_seg"
android:textColor="@color/textSecondary"
android:textSize="@dimen/text_normal_size" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/sc_re_seg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:clickable="false"
android:longClickable="false" />
</RelativeLayout>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="25dp" android:layout_height="25dp"

@ -42,12 +42,11 @@
android:title="@string/menu_bookcase_add" android:title="@string/menu_bookcase_add"
app:showAsAction="never" /> app:showAsAction="never" />
<item <!--<item
android:id="@+id/action_add_url" android:id="@+id/action_add_url"
android:icon="@drawable/ic_online_syn" android:icon="@drawable/ic_online_syn"
android:visible="false"
android:title="@string/add_url" android:title="@string/add_url"
app:showAsAction="never" /> app:showAsAction="never" />-->
<item <item
android:id="@+id/action_download_all" android:id="@+id/action_download_all"

@ -30,6 +30,15 @@
android:icon="@drawable/ic_replace" android:icon="@drawable/ic_replace"
android:title="@string/content_replace" android:title="@string/content_replace"
app:showAsAction="never"/> app:showAsAction="never"/>
<item
android:id="@+id/action_re_seg"
android:checkable="true"
android:checked="false"
android:icon="@drawable/ic_re_seg"
android:title="@string/re_seg"
app:showAsAction="never" />
<item <item
android:id="@+id/action_copy_content" android:id="@+id/action_copy_content"
android:icon="@drawable/ic_copy" android:icon="@drawable/ic_copy"

@ -502,7 +502,7 @@
<string name="contact_author">联系作者</string> <string name="contact_author">联系作者</string>
<string name="browser">浏览器</string> <string name="browser">浏览器</string>
<string name="add_url">添加网址</string> <string name="add_url">添加网址</string>
<string name="re_seg">章节内容智能分段</string> <string name="re_seg">智能分段</string>
<string name="backup_path">备份路径</string> <string name="backup_path">备份路径</string>
<string name="cathe_path">缓存路径</string> <string name="cathe_path">缓存路径</string>
<string name="sort_type">排序方式</string> <string name="sort_type">排序方式</string>

Loading…
Cancel
Save