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)【我的】->【备份与恢复】,选择【导入旧版本数据】。
**2020/08/19**
* 选择文本替换时带入书名和书源
**2020/08/16**
* 添加亮度调节控件显示开关
* 添加应用内语言切换

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

@ -470,7 +470,18 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
override fun onMenuItemSelected(itemId: Int): Boolean {
when (itemId) {
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
}
}

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

@ -31,7 +31,7 @@ object ImageProvider {
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 {
return it
}
@ -48,8 +48,8 @@ object ImageProvider {
out.flush()
out.close()
}
} else if (!onUi) {
HttpHelper.getBytes(src, baseUrl)?.let {
} else if (!onUi && referrer != null) {
HttpHelper.getBytes(src, referrer)?.let {
FileUtils.createFileIfNotExist(vFile.absolutePath).writeBytes(it)
}
}

@ -35,15 +35,17 @@ class ReplaceEditDialog : BaseDialogFragment(),
fragmentManager: FragmentManager,
id: Long = -1,
pattern: String? = null,
isRegex: Boolean = false
isRegex: Boolean = false,
scope: String? = null
) {
val dialog = ReplaceEditDialog()
val bundle = Bundle()
bundle.putLong("id", id)
bundle.putString("pattern", pattern)
bundle.putBoolean("isRegex", isRegex)
bundle.putString("scope", scope)
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)
}
} else {
bundle.getString("pattern")?.let { pattern ->
val isRegex = bundle.getBoolean("isRegex")
replaceRuleData.postValue(
ReplaceRule(name = pattern, pattern = pattern, isRegex = isRegex)
)
}
val pattern = bundle.getString("pattern") ?: ""
val isRegex = bundle.getBoolean("isRegex")
val scope = bundle.getString("scope")
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")
ReadBook.book?.let { book ->
src?.let {
ImageProvider.getImage(book, chapterIndex, src, src)?.let { bitmap ->
ImageProvider.getImage(book, chapterIndex, src, null)?.let { bitmap ->
photo_view.setImageBitmap(bitmap)
}
}

@ -319,7 +319,7 @@
<string name="book_info_edit">書籍信息編輯</string>
<string name="ps_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="download_path">內容緩存路徑</string>
<string name="cleanCache">清理緩存</string>

@ -320,7 +320,7 @@
<string name="book_info_edit">書籍訊息編輯</string>
<string name="ps_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="download_path">內容快取路徑</string>
<string name="cleanCache">清理快取</string>

@ -321,7 +321,7 @@
<string name="book_info_edit">书籍信息编辑</string>
<string name="ps_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="download_path">内容缓存路径</string>
<string name="cleanCache">清理缓存</string>

@ -321,7 +321,7 @@
<string name="book_info_edit">Edit book infomation</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="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="download_path">Cache path</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.
buildscript {
ext.kotlin_version = '1.3.72'
ext.kotlin_version = '1.4.0'
repositories {
google()
jcenter()

Loading…
Cancel
Save