mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
Merge branch 'gedoor:master' into master
This commit is contained in:
commit
86e83a23a1
@ -11,14 +11,15 @@
|
||||
* 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。
|
||||
* 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源!
|
||||
|
||||
**2022/10/08**
|
||||
**2022/10/09**
|
||||
|
||||
* 添加正文阅读界面进度条(本章/整本)设置
|
||||
* 添加源编辑输入框最大行数设置
|
||||
* 添加正文阅读界面进度条(本章/整本)设置 by 821938089
|
||||
* 优化下拉加载更多相关界面
|
||||
* 修复横屏竖屏切换后主题改变的bug
|
||||
* 优化章节替换净化
|
||||
* 封面支持svg 正文img标签支持svg图片链接
|
||||
* 调整申请设置书籍保存位置的时机
|
||||
* 修复横屏竖屏切换后主题改变的bug by 821938089
|
||||
* 优化章节替换净化 by Xwite
|
||||
* 封面支持svg 正文img标签支持svg图片链接 by Xwite
|
||||
* 调整申请设置书籍保存位置的时机 by Xwite
|
||||
|
||||
**2022/10/05**
|
||||
|
||||
|
@ -115,6 +115,7 @@ object PreferKey {
|
||||
const val ignoreAudioFocus = "ignoreAudioFocus"
|
||||
const val parallelExportBook = "parallelExportBook"
|
||||
const val progressBarBehavior = "progressBarBehavior"
|
||||
const val sourceEditMaxLine = "sourceEditMaxLine"
|
||||
|
||||
const val cPrimary = "colorPrimary"
|
||||
const val cAccent = "colorAccent"
|
||||
|
@ -368,15 +368,27 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
appCtx.putPrefInt(PreferKey.bitmapCacheSize, value)
|
||||
}
|
||||
|
||||
var showReadTitleBarAddition : Boolean
|
||||
var showReadTitleBarAddition: Boolean
|
||||
get() = appCtx.getPrefBoolean(PreferKey.showReadTitleAddition, true)
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.showReadTitleAddition, value)
|
||||
}
|
||||
var readBarStyleFollowPage : Boolean
|
||||
var readBarStyleFollowPage: Boolean
|
||||
get() = appCtx.getPrefBoolean(PreferKey.readBarStyleFollowPage, false)
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.readBarStyleFollowPage, value)
|
||||
}
|
||||
|
||||
var sourceEditMaxLine: Int
|
||||
get() {
|
||||
val maxLine = appCtx.getPrefInt(PreferKey.sourceEditMaxLine, 99)
|
||||
if (maxLine < 10) {
|
||||
return 99
|
||||
}
|
||||
return maxLine
|
||||
}
|
||||
set(value) {
|
||||
appCtx.putPrefInt(PreferKey.sourceEditMaxLine, value)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ class EpubFile(var book: Book) {
|
||||
cover.compress(Bitmap.CompressFormat.JPEG, 90, out)
|
||||
out.flush()
|
||||
out.close()
|
||||
}
|
||||
} ?: AppLog.putDebug("Epub: 封面获取为空. path: ${book.bookUrl}")
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@ -131,25 +131,34 @@ class EpubFile(var book: Book) {
|
||||
val startFragmentId = chapter.startFragmentId
|
||||
val endFragmentId = chapter.endFragmentId
|
||||
val elements = Elements()
|
||||
var isChapter = false
|
||||
var hasMoreResources = false
|
||||
val includeNextChapterResource = !endFragmentId.isNullOrBlank()
|
||||
/*一些书籍依靠href索引的resource会包含多个章节,需要依靠fragmentId来截取到当前章节的内容*/
|
||||
/*注:这里较大增加了内容加载的时间,所以首次获取内容后可存储到本地cache,减少重复加载*/
|
||||
for (res in epubBook.contents) {
|
||||
if (chapter.url.substringBeforeLast("#") == res.href) {
|
||||
elements.add(getBody(res, startFragmentId, endFragmentId))
|
||||
isChapter = true
|
||||
/**
|
||||
* fix https://github.com/gedoor/legado/issues/1927 加载全部内容的bug
|
||||
* content src text/000001.html(当前章节)
|
||||
- * content src text/000001.html#toc_id_x (下一章节)
|
||||
*/
|
||||
if (res.href == nextUrl?.substringBeforeLast("#")) break
|
||||
} else if (isChapter) {
|
||||
// fix 最后一章存在多个html时 内容缺失
|
||||
if (res.href == nextUrl?.substringBeforeLast("#")) {
|
||||
val isFirstResource = chapter.url.substringBeforeLast("#") == res.href
|
||||
val isNextChapterResource = res.href == nextUrl?.substringBeforeLast("#")
|
||||
if (isFirstResource) {
|
||||
// add first resource to elements
|
||||
elements.add(
|
||||
/* pass endFragmentId if only has one resource */
|
||||
getBody(res, startFragmentId, endFragmentId)
|
||||
)
|
||||
// check current resource
|
||||
if (isNextChapterResource) {
|
||||
/* FragmentId should not be same in same resource */
|
||||
if (!endFragmentId.isNullOrBlank() && endFragmentId == startFragmentId)
|
||||
AppLog.putDebug("Epub: Resource (${res.href}) has same FragmentId, check the file: ${book.bookUrl}")
|
||||
break
|
||||
}
|
||||
elements.add(getBody(res, startFragmentId, endFragmentId))
|
||||
hasMoreResources = true
|
||||
} else if (hasMoreResources) {
|
||||
if (isNextChapterResource) {
|
||||
if (includeNextChapterResource) elements.add(getBody(res, null/* FragmentId may be same in different resources, pass null */, endFragmentId))
|
||||
break
|
||||
}
|
||||
// rest resource should not have fragmentId, pass null
|
||||
elements.add(getBody(res, null, null))
|
||||
}
|
||||
}
|
||||
//title标签中的内容不需要显示在正文中,去除
|
||||
@ -226,7 +235,7 @@ class EpubFile(var book: Book) {
|
||||
epubBook?.let { eBook ->
|
||||
val refs = eBook.tableOfContents.tocReferences
|
||||
if (refs == null || refs.isEmpty()) {
|
||||
AppLog.put("NCX file parse error, check the epub file")
|
||||
AppLog.putDebug("Epub: NCX file parse error, check the file: ${book.bookUrl}")
|
||||
val spineReferences = eBook.spine.spineReferences
|
||||
var i = 0
|
||||
val size = spineReferences.size
|
||||
@ -340,4 +349,4 @@ class EpubFile(var book: Book) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,15 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.legado.app.R
|
||||
import io.legado.app.databinding.ItemSourceEditBinding
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.ui.widget.code.addJsPattern
|
||||
import io.legado.app.ui.widget.code.addJsonPattern
|
||||
import io.legado.app.ui.widget.code.addLegadoPattern
|
||||
|
||||
class BookSourceEditAdapter : RecyclerView.Adapter<BookSourceEditAdapter.MyViewHolder>() {
|
||||
|
||||
val editEntityMaxLine = AppConfig.sourceEditMaxLine
|
||||
|
||||
var editEntities: ArrayList<EditEntity> = ArrayList()
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
set(value) {
|
||||
@ -39,10 +42,12 @@ class BookSourceEditAdapter : RecyclerView.Adapter<BookSourceEditAdapter.MyViewH
|
||||
return editEntities.size
|
||||
}
|
||||
|
||||
class MyViewHolder(val binding: ItemSourceEditBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
inner class MyViewHolder(val binding: ItemSourceEditBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(editEntity: EditEntity) = binding.run {
|
||||
editText.setTag(R.id.tag, editEntity.key)
|
||||
editText.maxLines = editEntityMaxLine
|
||||
if (editText.getTag(R.id.tag1) == null) {
|
||||
val listener = object : View.OnAttachStateChangeListener {
|
||||
override fun onViewAttachedToWindow(v: View) {
|
||||
|
@ -60,6 +60,7 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
}
|
||||
upPreferenceSummary(PreferKey.checkSource, CheckSource.summary)
|
||||
upPreferenceSummary(PreferKey.bitmapCacheSize, AppConfig.bitmapCacheSize.toString())
|
||||
upPreferenceSummary(PreferKey.sourceEditMaxLine, AppConfig.sourceEditMaxLine.toString())
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@ -119,7 +120,16 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
ImageProvider.bitmapLruCache.resize(ImageProvider.cacheSize)
|
||||
}
|
||||
}
|
||||
|
||||
PreferKey.sourceEditMaxLine -> {
|
||||
NumberPickerDialog(requireContext())
|
||||
.setTitle(getString(R.string.source_edit_text_max_line))
|
||||
.setMaxValue(99)
|
||||
.setMinValue(10)
|
||||
.setValue(AppConfig.sourceEditMaxLine)
|
||||
.show {
|
||||
AppConfig.sourceEditMaxLine = it
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onPreferenceTreeClick(preference)
|
||||
}
|
||||
@ -160,6 +170,9 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
PreferKey.bitmapCacheSize -> {
|
||||
upPreferenceSummary(key, AppConfig.bitmapCacheSize.toString())
|
||||
}
|
||||
PreferKey.sourceEditMaxLine -> {
|
||||
upPreferenceSummary(key, AppConfig.sourceEditMaxLine.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,7 +183,10 @@ class OtherConfigFragment : PreferenceFragment(),
|
||||
getString(R.string.pre_download_s, value)
|
||||
PreferKey.threadCount -> preference.summary = getString(R.string.threads_num, value)
|
||||
PreferKey.webPort -> preference.summary = getString(R.string.web_port_summary, value)
|
||||
PreferKey.bitmapCacheSize -> preference.summary = getString(R.string.bitmap_cache_size_summary, value)
|
||||
PreferKey.bitmapCacheSize -> preference.summary =
|
||||
getString(R.string.bitmap_cache_size_summary, value)
|
||||
PreferKey.sourceEditMaxLine -> preference.summary =
|
||||
getString(R.string.source_edit_max_line_summary, value)
|
||||
else -> if (preference is ListPreference) {
|
||||
val index = preference.findIndexOfValue(value)
|
||||
// Set the summary to reflect the new value.
|
||||
|
@ -9,12 +9,15 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.legado.app.R
|
||||
import io.legado.app.databinding.ItemSourceEditBinding
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.ui.widget.code.addJsPattern
|
||||
import io.legado.app.ui.widget.code.addJsonPattern
|
||||
import io.legado.app.ui.widget.code.addLegadoPattern
|
||||
|
||||
class RssSourceEditAdapter : RecyclerView.Adapter<RssSourceEditAdapter.MyViewHolder>() {
|
||||
|
||||
val editEntityMaxLine = AppConfig.sourceEditMaxLine
|
||||
|
||||
var editEntities: ArrayList<EditEntity> = ArrayList()
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
set(value) {
|
||||
@ -39,9 +42,11 @@ class RssSourceEditAdapter : RecyclerView.Adapter<RssSourceEditAdapter.MyViewHol
|
||||
return editEntities.size
|
||||
}
|
||||
|
||||
class MyViewHolder(val binding: ItemSourceEditBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
inner class MyViewHolder(val binding: ItemSourceEditBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(editEntity: EditEntity) = binding.run {
|
||||
editText.maxLines = editEntityMaxLine
|
||||
if (editText.getTag(R.id.tag1) == null) {
|
||||
val listener = object : View.OnAttachStateChangeListener {
|
||||
override fun onViewAttachedToWindow(v: View) {
|
||||
|
@ -86,7 +86,7 @@
|
||||
android:visibility="invisible"
|
||||
android:contentDescription="@string/stop"
|
||||
app:fabSize="mini"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/ll_search_base_info"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -9,7 +9,6 @@
|
||||
android:id="@+id/editText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLines="12" />
|
||||
android:inputType="textMultiLine" />
|
||||
|
||||
</io.legado.app.ui.widget.text.TextInputLayout>
|
@ -1023,7 +1023,7 @@
|
||||
<string name="delete_review_url">删除段评URL(deleteUrl)</string>
|
||||
<string name="tag_explore_enabled">标志:发现已启用</string>
|
||||
<string name="tag_explore_disabled">标志:发现已禁用</string>
|
||||
<string name="show_read_title_addition">show read title addition area</string>
|
||||
<string name="show_read_title_addition">show read title addition área</string>
|
||||
<string name="read_bar_style_follow_page">read bar style follow page</string>
|
||||
<string name="rule_image_decode">Decode Image(imageDecode)</string>
|
||||
<string name="like_source">赞</string>
|
||||
@ -1037,4 +1037,6 @@
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||
</resources>
|
||||
|
@ -1040,4 +1040,6 @@
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||
</resources>
|
||||
|
@ -1040,4 +1040,6 @@
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||
</resources>
|
||||
|
@ -1037,4 +1037,6 @@
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||
</resources>
|
||||
|
@ -1039,4 +1039,6 @@
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||
</resources>
|
||||
|
@ -1039,4 +1039,6 @@
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||
</resources>
|
||||
|
@ -1040,4 +1040,6 @@
|
||||
<string name="local_no_group">本地未分组</string>
|
||||
<string name="parallel_export_book">多线程导出TXT</string>
|
||||
<string name="progress_bar_behavior">进度条行为</string>
|
||||
<string name="source_edit_text_max_line">源编辑框最大行数</string>
|
||||
<string name="source_edit_max_line_summary">%s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑</string>
|
||||
</resources>
|
||||
|
@ -61,6 +61,10 @@
|
||||
android:summary="@string/book_tree_uri_s"
|
||||
android:title="@string/book_tree_uri_t" />
|
||||
|
||||
<io.legado.app.lib.prefs.Preference
|
||||
android:key="sourceEditMaxLine"
|
||||
android:title="@string/source_edit_text_max_line" />
|
||||
|
||||
<io.legado.app.lib.prefs.Preference
|
||||
android:key="checkSource"
|
||||
android:title="@string/check_source_config" />
|
||||
|
Loading…
Reference in New Issue
Block a user