新增章节内容智能分段

master
fengyuecanzhu 3 years ago
parent bb2c74930f
commit 86385aaf90
  1. 32
      .idea/assetWizardSettings.xml
  2. 4
      .idea/compiler.xml
  3. 3
      .idea/gradle.xml
  4. 36
      .idea/inspectionProfiles/Project_Default.xml
  5. 10
      .idea/markdown-navigator-enh.xml
  6. 62
      .idea/markdown-navigator.xml
  7. 15
      .idea/misc.xml
  8. 10
      .idea/runConfigurations.xml
  9. 2
      .idea/vcs.xml
  10. 6
      app/src/main/assets/updatelog.fy
  11. 11
      app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java
  12. 2
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java
  13. 7
      app/src/main/java/xyz/fycz/myreader/widget/page/EpubPageLoader.java
  14. 15
      app/src/main/java/xyz/fycz/myreader/widget/page/LocalPageLoader.java
  15. 7
      app/src/main/java/xyz/fycz/myreader/widget/page/NetPageLoader.java
  16. 254
      app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java
  17. 28
      app/src/main/res/layout/activity_more_setting.xml
  18. 1
      app/src/main/res/values/strings.xml

@ -1,32 +0,0 @@
<?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_yulu" />
<entry key="sourceFile" value="F:\SVG图标\留言板.svg" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</component>
</project>

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8">
<module name="FYReader.DialogXIOSStyle" target="1.8" />
</bytecodeTargetLevel>
<bytecodeTargetLevel target="1.8" />
</component>
</project>

@ -4,7 +4,7 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="PLATFORM" />
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
@ -15,7 +15,6 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

@ -1,36 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="date" />
</inspection_tool>
</profile>
</component>

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownEnhProjectSettings">
<AnnotatorSettings targetHasSpaces="true" linkCaseMismatch="true" wikiCaseMismatch="true" wikiLinkHasDashes="true" notUnderWikiHome="true" targetNotWikiPageExt="true" notUnderSourceWikiHome="true" targetNameHasAnchor="true" targetPathHasAnchor="true" wikiLinkHasSlash="true" wikiLinkHasSubdir="true" wikiLinkHasOnlyAnchor="true" linkTargetsWikiHasExt="true" linkTargetsWikiHasBadExt="true" notUnderSameRepo="true" targetNotUnderVcs="false" linkNeedsExt="true" linkHasBadExt="true" linkTargetNeedsExt="true" linkTargetHasBadExt="true" wikiLinkNotInWiki="true" imageTargetNotInRaw="true" repoRelativeAcrossVcsRoots="true" multipleWikiTargetsMatch="true" unresolvedLinkReference="true" linkIsIgnored="true" anchorIsIgnored="true" anchorIsUnresolved="true" anchorLineReferenceIsUnresolved="true" anchorLineReferenceFormat="true" anchorHasDuplicates="true" abbreviationDuplicates="true" abbreviationNotUsed="true" attributeIdDuplicateDefinition="true" attributeIdNotUsed="true" footnoteDuplicateDefinition="true" footnoteUnresolved="true" footnoteDuplicates="true" footnoteNotUsed="true" macroDuplicateDefinition="true" macroUnresolved="true" macroDuplicates="true" macroNotUsed="true" referenceDuplicateDefinition="true" referenceUnresolved="true" referenceDuplicates="true" referenceNotUsed="true" referenceUnresolvedNumericId="true" enumRefDuplicateDefinition="true" enumRefUnresolved="true" enumRefDuplicates="true" enumRefNotUsed="true" enumRefLinkUnresolved="true" enumRefLinkDuplicates="true" simTocUpdateNeeded="true" simTocTitleSpaceNeeded="true" />
<HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="css" scriptDir="js" plainHtml="false" imageDir="" copyLinkedImages="false" imagePathType="0" targetPathType="2" targetExt="" useTargetExt="false" noCssNoScripts="false" useElementStyleAttribute="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
<LinkMapSettings>
<textMaps />
</LinkMapSettings>
</component>
</project>

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownProjectSettings">
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" synchronizePreviewPosition="true" highlightPreviewType="LINE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="true" showSelectionInPreview="true" lastLayoutSetsDefault="false">
<PanelProvider>
<provider providerId="com.vladsch.md.nav.editor.swing.html.panel" providerName="Default - Swing" />
</PanelProvider>
</PreviewSettings>
<ParserSettings gitHubSyntaxChange="false" correctedInvalidSettings="false" emojiShortcuts="1" emojiImages="0">
<PegdownExtensions>
<option name="ATXHEADERSPACE" value="true" />
<option name="FENCED_CODE_BLOCKS" value="true" />
<option name="INTELLIJ_DUMMY_IDENTIFIER" value="true" />
<option name="RELAXEDHRULES" value="true" />
<option name="STRIKETHROUGH" value="true" />
<option name="TABLES" value="true" />
<option name="TASKLISTITEMS" value="true" />
</PegdownExtensions>
<ParserOptions>
<option name="COMMONMARK_LISTS" value="true" />
<option name="EMOJI_SHORTCUTS" value="true" />
<option name="GFM_TABLE_RENDERING" value="true" />
<option name="PRODUCTION_SPEC_PARSER" value="true" />
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
</ParserOptions>
</ParserSettings>
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" addPageHeader="false" addAnchorLinks="false" anchorLinksWrapText="false" imageUriSerials="false" addDocTypeHtml="true" noParaTags="false" defaultUrlTitle="false" migratedPlantUml="true" migratedAnchorLinks="true" plantUmlConversion="0">
<GeneratorProvider>
<provider providerId="com.vladsch.md.nav.editor.text.html.generator" providerName="Unmodified HTML Generator" />
</GeneratorProvider>
<headerTop />
<headerBottom />
<bodyTop />
<bodyBottom />
<fencedCodeConversions>
<option name="c4plantuml" value="NONE" />
<option name="ditaa" value="NONE" />
<option name="erd" value="NONE" />
<option name="graphviz" value="NONE" />
<option name="latex" value="KATEX" />
<option name="math" value="KATEX" />
<option name="mermaid" value="NONE" />
<option name="nomnoml" value="NONE" />
<option name="plantuml" value="NONE" />
<option name="puml" value="NONE" />
<option name="svgbob" value="NONE" />
<option name="umlet" value="NONE" />
<option name="vega" value="NONE" />
<option name="vegalite" value="NONE" />
<option name="wavedrom" value="NONE" />
</fencedCodeConversions>
</HtmlSettings>
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="true" isCssTextEnabled="false" isDynamicPageWidth="true">
<StylesheetProvider>
<provider providerId="com.vladsch.md.nav.editor.text.html.css" providerName="No Stylesheet" />
</StylesheetProvider>
<ScriptProviders />
<cssText />
<cssUriHistory />
</CssSettings>
</component>
</project>

@ -1,4 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/android/FYReader/app/src/main/res/layout/activity_more_setting.xml" value="0.12132725430597771" />
<entry key="..\:/android/FYReader/app/src/main/res/menu/menu_book.xml" value="0.13703703703703704" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>

@ -1,3 +1,9 @@
2021.08.10
风月读书v2.1.7
更新内容:
1、修复发现分类bug
2、新增章节内容智能分段
2021.07.24
风月读书v2.1.6
更新内容:

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

@ -1937,7 +1937,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
ReplaceRuleBean oldRuleBean = new ReplaceRuleBean();
oldRuleBean.setReplaceSummary("");
oldRuleBean.setEnable(true);
oldRuleBean.setRegex(binding.readPvContent.getSelectStr().trim());
oldRuleBean.setRegex(binding.readPvContent.getSelectStr());
oldRuleBean.setIsRegex(false);
oldRuleBean.setReplacement("");
oldRuleBean.setSerialNumber(0);

@ -279,12 +279,13 @@ public class EpubPageLoader extends PageLoader {
}
@Override
protected BufferedReader getChapterReader(Chapter chapter) throws Exception {
protected String getChapterReader(Chapter chapter) throws Exception {
Log.d("getChapterReader", chapter.getTitle());
byte[] content = getChapterContent(chapter).getBytes();
/*byte[] content = getChapterContent(chapter).getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(content);
BufferedReader br = new BufferedReader(new InputStreamReader(bais));
return br;
return br;*/
return getChapterContent(chapter);
}
@Override

@ -370,20 +370,23 @@ public class LocalPageLoader extends PageLoader {
@Override
protected BufferedReader getChapterReader(Chapter chapter) throws Exception {
protected String getChapterReader(Chapter chapter) throws Exception {
if (chapter.getEnd() > 0) {
Log.d("getChapterReader", chapter.getTitle());
//从文件中获取数据
byte[] content = getContent(chapter);
/*byte[] content = getContent(chapter);
ByteArrayInputStream bais = new ByteArrayInputStream(content);
BufferedReader br = new BufferedReader(new InputStreamReader(bais, mCharset));
return br;
return br;*/
byte[] content = getContent(chapter);
return new String(content, mCharset);
}
File file = new File(APPCONST.BOOK_CACHE_PATH + mCollBook.getId()
/*File file = new File(APPCONST.BOOK_CACHE_PATH + mCollBook.getId()
+ File.separator + chapter.getTitle() + FileUtils.SUFFIX_FY);
if (!file.exists()) return null;
Log.d("getChapterReader", file.getPath());
return new BufferedReader(new FileReader(file));
if (!file.exists()) return null;
return new BufferedReader(new FileReader(file));*/
return mChapterService.getChapterCatheContent(chapter);
}

@ -102,12 +102,13 @@ public class NetPageLoader extends PageLoader {
}
@Override
protected BufferedReader getChapterReader(Chapter chapter) throws FileNotFoundException {
File file = new File(APPCONST.BOOK_CACHE_PATH + mCollBook.getId()
protected String getChapterReader(Chapter chapter) throws FileNotFoundException {
/*File file = new File(APPCONST.BOOK_CACHE_PATH + mCollBook.getId()
+ File.separator + chapter.getTitle() + FileUtils.SUFFIX_FY);
if (!file.exists()) return null;
BufferedReader br = new BufferedReader(new FileReader(file));
return br;
return br;*/
return mChapterService.getChapterCatheContent(chapter);
}
@Override

@ -847,7 +847,7 @@ public abstract class PageLoader {
return null;
}
// 获取章节的文本流
BufferedReader reader = getChapterReader(chapter);
String reader = getChapterReader(chapter);
TxtChapter txtChapter = loadPages(chapter, reader);
return txtChapter;
@ -862,12 +862,12 @@ public abstract class PageLoader {
public abstract void refreshChapterList();
/**
* 获取章节的文本
* 获取章节的文本
*
* @param chapter
* @return
*/
protected abstract BufferedReader getChapterReader(Chapter chapter) throws Exception;
protected abstract String getChapterReader(Chapter chapter) throws Exception;
/**
* 章节数据是否存在
@ -1665,11 +1665,16 @@ public abstract class PageLoader {
* 将章节数据解析成页面列表
*
* @param chapter章节信息
* @param br章节的文本流
* @param content章节的文本流
* @return
*/
private TxtChapter loadPages(Chapter chapter, BufferedReader br) {
private TxtChapter loadPages(Chapter chapter, String content) {
TxtChapter txtChapter = new TxtChapter(chapter.getNumber());
content = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), content, true);
content = contentHelper.LightNovelParagraph2(content, chapter.getTitle());
String[] allLine = content.split("\n");
//使用流的方式加载
List<String> lines = new ArrayList<>();
List<TxtLine> txtLists = new ArrayList<>();//记录每个字的位置 //pzl
@ -1677,147 +1682,144 @@ public abstract class PageLoader {
int titleLinesCount = 0;
boolean showTitle = true; // 是否展示标题
boolean firstLine = true;
String paragraph = chapter.getTitle();//默认展示标题
String paragraph = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), chapter.getTitle(), true);//默认展示标题
paragraph = paragraph.trim() + "\n";
try {
while (showTitle || (paragraph = br.readLine()) != null) {
paragraph = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), paragraph, true);
if (firstLine && !showTitle) {
paragraph = paragraph.replace(chapter.getTitle(), "");
firstLine = false;
int i = 1;
while (showTitle || i < allLine.length) {
if (firstLine && !showTitle) {
paragraph = paragraph.replace(chapter.getTitle(), "");
firstLine = false;
}
// 重置段落
if (!showTitle) {
paragraph = allLine[i];
if (mSettingManager.isEnType()) {
paragraph = StringUtils.trim(paragraph.replace("\t", ""));
} else {
paragraph = paragraph.replaceAll("\\s", "");
}
// 重置段落
if (!showTitle) {
if (mSettingManager.isEnType()) {
paragraph = StringUtils.trim(paragraph.replace("\t", ""));
} else {
paragraph = paragraph.replaceAll("\\s", "");
}
// 如果只有换行符,那么就不执行
if (paragraph.equals("")) continue;
paragraph = indent + paragraph + "\n";
i++;
// 如果只有换行符,那么就不执行
if (paragraph.equals("")) continue;
paragraph = indent + paragraph + "\n";
} else {
//设置 title 的顶部间距
rHeight -= mTitlePara;
}
addParagraphLength(txtChapter, paragraph.length());
int wordCount = 0;
String subStr = null;
while (paragraph.length() > 0) {
//当前空间,是否容得下一行文字
if (showTitle) {
rHeight -= mTitlePaint.getTextSize();
} else {
//设置 title 的顶部间距
rHeight -= mTitlePara;
rHeight -= mTextPaint.getTextSize();
}
addParagraphLength(txtChapter, paragraph.length());
int wordCount = 0;
String subStr = null;
while (paragraph.length() > 0) {
//当前空间,是否容得下一行文字
// 一页已经填充满了,创建 TextPage
if (rHeight <= 0) {
// 创建Page
TxtPage page = new TxtPage();
page.position = txtChapter.getTxtPageList().size();
page.title = chapter.getTitle();
page.lines = new ArrayList<>(lines);
page.txtLists = new ArrayList<>(txtLists);
page.titleLines = titleLinesCount;
txtChapter.addPage(page);
addTxtPageLength(txtChapter, page.getContent().length());
// 重置Lines
lines.clear();
txtLists.clear();//pzl
rHeight = mVisibleHeight;
titleLinesCount = 0;
continue;
}
//测量一行占用的字节数
if (mSettingManager.isTightCom()) {
if (showTitle) {
rHeight -= mTitlePaint.getTextSize();
wordCount = mTitlePaint.breakText(paragraph,
true, mVisibleWidth, null);
} else {
rHeight -= mTextPaint.getTextSize();
}
// 一页已经填充满了,创建 TextPage
if (rHeight <= 0) {
// 创建Page
TxtPage page = new TxtPage();
page.position = txtChapter.getTxtPageList().size();
page.title = chapter.getTitle();
page.lines = new ArrayList<>(lines);
page.txtLists = new ArrayList<>(txtLists);
page.titleLines = titleLinesCount;
txtChapter.addPage(page);
addTxtPageLength(txtChapter, page.getContent().length());
// 重置Lines
lines.clear();
txtLists.clear();//pzl
rHeight = mVisibleHeight;
titleLinesCount = 0;
continue;
wordCount = mTextPaint.breakText(paragraph,
true, mVisibleWidth, null);
}
//测量一行占用的字节数
if (mSettingManager.isTightCom()) {
if (showTitle) {
wordCount = mTitlePaint.breakText(paragraph,
true, mVisibleWidth, null);
} else {
wordCount = mTextPaint.breakText(paragraph,
true, mVisibleWidth, null);
}
subStr = paragraph.substring(0, wordCount);
if (paragraph.substring(wordCount).equals("\n")) {
subStr += "\n";
}
subStr = paragraph.substring(0, wordCount);
if (paragraph.substring(wordCount).equals("\n")) {
subStr += "\n";
}
} else {
Layout tempLayout;
if (showTitle) {
tempLayout = new StaticLayout(paragraph, mTitlePaint, mVisibleWidth, Layout.Alignment.ALIGN_NORMAL, 0, 0, false);
} else {
Layout tempLayout;
if (showTitle) {
tempLayout = new StaticLayout(paragraph, mTitlePaint, mVisibleWidth, Layout.Alignment.ALIGN_NORMAL, 0, 0, false);
} else {
tempLayout = new StaticLayout(paragraph, mTextPaint, mVisibleWidth, Layout.Alignment.ALIGN_NORMAL, 0, 0, false);
}
wordCount = tempLayout.getLineEnd(0);
subStr = paragraph.substring(0, wordCount);
tempLayout = new StaticLayout(paragraph, mTextPaint, mVisibleWidth, Layout.Alignment.ALIGN_NORMAL, 0, 0, false);
}
wordCount = tempLayout.getLineEnd(0);
subStr = paragraph.substring(0, wordCount);
}
if (!subStr.equals("\n")) {
//将一行字节,存储到lines中
lines.add(subStr);
//begin pzl
//记录每个字的位置
char[] cs = subStr.replace((char) 12288, ' ').trim().toCharArray();
TxtLine txtList = new TxtLine();//每一行
txtList.setCharsData(new ArrayList<>());
for (char c : cs) {
String mesasrustr = String.valueOf(c);
float charwidth = mTextPaint.measureText(mesasrustr);
if (showTitle) {
charwidth = mTitlePaint.measureText(mesasrustr);
}
TxtChar txtChar = new TxtChar();
txtChar.setChardata(c);
txtChar.setCharWidth(charwidth);//字宽
txtChar.setIndex(66);//每页每个字的位置
txtList.getCharsData().add(txtChar);
}
txtLists.add(txtList);
//end pzl
//设置段落间距
if (!subStr.equals("\n")) {
//将一行字节,存储到lines中
lines.add(subStr);
//begin pzl
//记录每个字的位置
char[] cs = subStr.replace((char) 12288, ' ').trim().toCharArray();
TxtLine txtList = new TxtLine();//每一行
txtList.setCharsData(new ArrayList<>());
for (char c : cs) {
String mesasrustr = String.valueOf(c);
float charwidth = mTextPaint.measureText(mesasrustr);
if (showTitle) {
titleLinesCount += 1;
rHeight -= mTitleInterval;
} else {
rHeight -= mTextInterval;
charwidth = mTitlePaint.measureText(mesasrustr);
}
TxtChar txtChar = new TxtChar();
txtChar.setChardata(c);
txtChar.setCharWidth(charwidth);//字宽
txtChar.setIndex(66);//每页每个字的位置
txtList.getCharsData().add(txtChar);
}
txtLists.add(txtList);
//end pzl
//设置段落间距
if (showTitle) {
titleLinesCount += 1;
rHeight -= mTitleInterval;
} else {
rHeight -= mTextInterval;
}
//裁剪
paragraph = paragraph.substring(wordCount);
}
//增加段落的间距
if (!showTitle && lines.size() != 0) {
rHeight = rHeight - mTextPara + mTextInterval;
}
//裁剪
paragraph = paragraph.substring(wordCount);
}
if (showTitle) {
rHeight = rHeight - mTitlePara + mTitleInterval;
showTitle = false;
}
//增加段落的间距
if (!showTitle && lines.size() != 0) {
rHeight = rHeight - mTextPara + mTextInterval;
}
if (lines.size() != 0) {
//创建Page
TxtPage page = new TxtPage();
page.position = txtChapter.getTxtPageList().size();
page.title = chapter.getTitle();
page.lines = new ArrayList<>(lines);
page.txtLists = new ArrayList<>(txtLists);
page.titleLines = titleLinesCount;
txtChapter.addPage(page);
addTxtPageLength(txtChapter, page.getContent().length());
//重置Lines
lines.clear();
txtLists.clear();
if (showTitle) {
rHeight = rHeight - mTitlePara + mTitleInterval;
showTitle = false;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.close(br);
}
if (lines.size() != 0) {
//创建Page
TxtPage page = new TxtPage();
page.position = txtChapter.getTxtPageList().size();
page.title = chapter.getTitle();
page.lines = new ArrayList<>(lines);
page.txtLists = new ArrayList<>(txtLists);
page.titleLines = titleLinesCount;
txtChapter.addPage(page);
addTxtPageLength(txtChapter, page.getContent().length());
//重置Lines
lines.clear();
txtLists.clear();
}
return txtChapter;
}

@ -296,6 +296,34 @@
android:clickable="false"
android:longClickable="false" />
</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
android:layout_width="match_parent"
android:layout_height="25dp"

@ -502,6 +502,7 @@
<string name="contact_author">联系作者</string>
<string name="browser">浏览器</string>
<string name="add_url">添加网址</string>
<string name="re_seg">章节内容智能分段</string>
<string-array name="reset_screen_time">

Loading…
Cancel
Save