Merge pull request #3 from gedoor/master

update
pull/321/head
Gladtbam 4 years ago committed by GitHub
commit 9bab8bc419
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/src/main/assets/updateLog.md
  2. 18
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  3. 13
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  5. 6
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt
  6. 6
      app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt
  7. 16
      app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditViewModel.kt
  8. 2
      app/src/main/java/io/legado/app/ui/widget/dialog/PhotoDialog.kt
  9. 2
      app/src/main/res/values-zh-rHK/strings.xml
  10. 2
      app/src/main/res/values-zh-rTW/strings.xml
  11. 2
      app/src/main/res/values-zh/strings.xml
  12. 2
      app/src/main/res/values/strings.xml
  13. 2
      build.gradle

@ -3,6 +3,9 @@
* 关注合作公众号 **[小说拾遗]()** 获取好看的小说。 * 关注合作公众号 **[小说拾遗]()** 获取好看的小说。
- 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 - 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。
**2020/08/19**
* 选择文本替换时带入书名和书源
**2020/08/16** **2020/08/16**
* 添加亮度调节控件显示开关 * 添加亮度调节控件显示开关
* 添加应用内语言切换 * 添加应用内语言切换

@ -7,6 +7,7 @@ import io.legado.app.R
import io.legado.app.constant.BookType import io.legado.app.constant.BookType
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.data.entities.BookSource
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.help.BookHelp import io.legado.app.help.BookHelp
import io.legado.app.help.IntentDataHelp import io.legado.app.help.IntentDataHelp
@ -35,6 +36,7 @@ object ReadBook {
var prevTextChapter: TextChapter? = null var prevTextChapter: TextChapter? = null
var curTextChapter: TextChapter? = null var curTextChapter: TextChapter? = null
var nextTextChapter: TextChapter? = null var nextTextChapter: TextChapter? = null
var bookSource: BookSource? = null
var webBook: WebBook? = null var webBook: WebBook? = null
var msg: String? = null var msg: String? = null
private val loadingChapters = arrayListOf<Int>() private val loadingChapters = arrayListOf<Int>()
@ -54,14 +56,16 @@ object ReadBook {
} }
fun upWebBook(book: Book) { fun upWebBook(book: Book) {
webBook = if (book.origin == BookType.local) { if (book.origin == BookType.local) {
null bookSource = null
webBook = null
} else { } else {
val bookSource = App.db.bookSourceDao().getBookSource(book.origin) App.db.bookSourceDao().getBookSource(book.origin)?.let {
if (bookSource != null) { bookSource = it
WebBook(bookSource) webBook = WebBook(it)
} else { } ?: let {
null bookSource = null
webBook = null
} }
} }
} }

@ -470,7 +470,18 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
override fun onMenuItemSelected(itemId: Int): Boolean { override fun onMenuItemSelected(itemId: Int): Boolean {
when (itemId) { when (itemId) {
R.id.menu_replace -> { R.id.menu_replace -> {
ReplaceEditDialog.show(supportFragmentManager, pattern = selectedText) val scopes = arrayListOf<String>()
ReadBook.book?.name?.let {
scopes.add(it)
}
ReadBook.bookSource?.bookSourceUrl?.let {
scopes.add(it)
}
ReplaceEditDialog.show(
supportFragmentManager,
pattern = selectedText,
scope = scopes.joinToString(";")
)
return true return true
} }
} }

@ -163,7 +163,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
ReadBook.book!!, ReadBook.book!!,
textPage.chapterIndex, textPage.chapterIndex,
textChar.charData, textChar.charData,
textChar.charData, null,
true true
)?.let { )?.let {
canvas.drawBitmap(it, null, rectF, null) canvas.drawBitmap(it, null, rectF, null)

@ -31,7 +31,7 @@ object ImageProvider {
indexCache[src] = bitmap indexCache[src] = bitmap
} }
fun getImage(book: Book, chapterIndex: Int, src: String, baseUrl: String, onUi: Boolean = false): Bitmap? { fun getImage(book: Book, chapterIndex: Int, src: String, referrer: String?, onUi: Boolean = false): Bitmap? {
getCache(chapterIndex, src)?.let { getCache(chapterIndex, src)?.let {
return it return it
} }
@ -48,8 +48,8 @@ object ImageProvider {
out.flush() out.flush()
out.close() out.close()
} }
} else if (!onUi) { } else if (!onUi && referrer != null) {
HttpHelper.getBytes(src, baseUrl)?.let { HttpHelper.getBytes(src, referrer)?.let {
FileUtils.createFileIfNotExist(vFile.absolutePath).writeBytes(it) FileUtils.createFileIfNotExist(vFile.absolutePath).writeBytes(it)
} }
} }

@ -35,15 +35,17 @@ class ReplaceEditDialog : BaseDialogFragment(),
fragmentManager: FragmentManager, fragmentManager: FragmentManager,
id: Long = -1, id: Long = -1,
pattern: String? = null, pattern: String? = null,
isRegex: Boolean = false isRegex: Boolean = false,
scope: String? = null
) { ) {
val dialog = ReplaceEditDialog() val dialog = ReplaceEditDialog()
val bundle = Bundle() val bundle = Bundle()
bundle.putLong("id", id) bundle.putLong("id", id)
bundle.putString("pattern", pattern) bundle.putString("pattern", pattern)
bundle.putBoolean("isRegex", isRegex) bundle.putBoolean("isRegex", isRegex)
bundle.putString("scope", scope)
dialog.arguments = bundle dialog.arguments = bundle
dialog.show(fragmentManager, "editReplace") dialog.show(fragmentManager, this::class.simpleName)
} }
} }

@ -20,12 +20,16 @@ class ReplaceEditViewModel(application: Application) : BaseViewModel(application
replaceRuleData.postValue(it) replaceRuleData.postValue(it)
} }
} else { } else {
bundle.getString("pattern")?.let { pattern -> val pattern = bundle.getString("pattern") ?: ""
val isRegex = bundle.getBoolean("isRegex") val isRegex = bundle.getBoolean("isRegex")
replaceRuleData.postValue( val scope = bundle.getString("scope")
ReplaceRule(name = pattern, pattern = pattern, isRegex = isRegex) val rule = ReplaceRule(
) name = pattern,
} pattern = pattern,
isRegex = isRegex,
scope = scope
)
replaceRuleData.postValue(rule)
} }
} }
} }

@ -56,7 +56,7 @@ class PhotoDialog : BaseDialogFragment() {
val src = it.getString("src") val src = it.getString("src")
ReadBook.book?.let { book -> ReadBook.book?.let { book ->
src?.let { src?.let {
ImageProvider.getImage(book, chapterIndex, src, src)?.let { bitmap -> ImageProvider.getImage(book, chapterIndex, src, null)?.let { bitmap ->
photo_view.setImageBitmap(bitmap) photo_view.setImageBitmap(bitmap)
} }
} }

@ -319,7 +319,7 @@
<string name="book_info_edit">書籍信息編輯</string> <string name="book_info_edit">書籍信息編輯</string>
<string name="ps_default_read">默認打開書架</string> <string name="ps_default_read">默認打開書架</string>
<string name="pt_default_read">自動跳轉最近閲讀</string> <string name="pt_default_read">自動跳轉最近閲讀</string>
<string name="use_to">替換範圍,選填書名或者源名</string> <string name="use_to">替換範圍,選填書名或者書源url</string>
<string name="menu_action_group">分組</string> <string name="menu_action_group">分組</string>
<string name="download_path">內容緩存路徑</string> <string name="download_path">內容緩存路徑</string>
<string name="cleanCache">清理緩存</string> <string name="cleanCache">清理緩存</string>

@ -320,7 +320,7 @@
<string name="book_info_edit">書籍訊息編輯</string> <string name="book_info_edit">書籍訊息編輯</string>
<string name="ps_default_read">預設打開書架</string> <string name="ps_default_read">預設打開書架</string>
<string name="pt_default_read">自動跳轉最近閱讀</string> <string name="pt_default_read">自動跳轉最近閱讀</string>
<string name="use_to">取代範圍,選填書名或者源名</string> <string name="use_to">取代範圍,選填書名或者書源url</string>
<string name="menu_action_group">分組</string> <string name="menu_action_group">分組</string>
<string name="download_path">內容快取路徑</string> <string name="download_path">內容快取路徑</string>
<string name="cleanCache">清理快取</string> <string name="cleanCache">清理快取</string>

@ -321,7 +321,7 @@
<string name="book_info_edit">书籍信息编辑</string> <string name="book_info_edit">书籍信息编辑</string>
<string name="ps_default_read">默认打开书架</string> <string name="ps_default_read">默认打开书架</string>
<string name="pt_default_read">自动跳转最近阅读</string> <string name="pt_default_read">自动跳转最近阅读</string>
<string name="use_to">替换范围,选填书名或者源名</string> <string name="use_to">替换范围,选填书名或者书源url</string>
<string name="menu_action_group">分组</string> <string name="menu_action_group">分组</string>
<string name="download_path">内容缓存路径</string> <string name="download_path">内容缓存路径</string>
<string name="cleanCache">清理缓存</string> <string name="cleanCache">清理缓存</string>

@ -321,7 +321,7 @@
<string name="book_info_edit">Edit book infomation</string> <string name="book_info_edit">Edit book infomation</string>
<string name="ps_default_read">Use Bookshelf as start page</string> <string name="ps_default_read">Use Bookshelf as start page</string>
<string name="pt_default_read">Auto jump to Recent list</string> <string name="pt_default_read">Auto jump to Recent list</string>
<string name="use_to">Replacement object. Book name or source name is available</string> <string name="use_to">Replacement object. Book name or source url is available</string>
<string name="menu_action_group">Groups</string> <string name="menu_action_group">Groups</string>
<string name="download_path">Cache path</string> <string name="download_path">Cache path</string>
<string name="cleanCache">Clear cache</string> <string name="cleanCache">Clear cache</string>

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.3.72' ext.kotlin_version = '1.4.0'
repositories { repositories {
google() google()
jcenter() jcenter()

Loading…
Cancel
Save