Merge pull request #40 from gedoor/master

merge
pull/392/head
口口吕 4 years ago committed by GitHub
commit e06867efda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/src/main/assets/updateLog.md
  2. 12
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
  4. 19
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  5. 11
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchListActivity.kt
  6. 10
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchListViewModel.kt
  7. 4
      app/src/main/res/menu/content_select_action.xml
  8. 2
      app/src/main/res/values-zh-rHK/strings.xml
  9. 3
      app/src/main/res/values-zh-rTW/strings.xml
  10. 2
      app/src/main/res/values-zh/strings.xml
  11. 2
      app/src/main/res/values/strings.xml

@ -3,6 +3,10 @@
* 关注合作公众号 **[小说拾遗]()** 获取好看的小说。
- 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。
**2020/09/20**
* 优化正文搜索
* 阅读界面信息添加书名
**2020/09/18**
* 解决正文替换{{title}}问题
* 修复共用布局配置不能读取的问题

@ -9,7 +9,6 @@ import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.util.Log
import android.view.*
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import androidx.core.view.get
@ -49,7 +48,6 @@ import io.legado.app.ui.book.read.page.PageView
import io.legado.app.ui.book.read.page.TextPageFactory
import io.legado.app.ui.book.read.page.delegate.PageDelegate
import io.legado.app.ui.book.searchContent.SearchListActivity
import io.legado.app.ui.book.searchContent.SearchResult
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.login.SourceLogin
import io.legado.app.ui.replacerule.ReplaceRuleActivity
@ -496,6 +494,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
)
return true
}
R.id.menu_search_content -> {
openSearchActivity(selectedText)
return true
}
}
return false
}
@ -680,12 +682,12 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
/**
* 打开搜索界面
*/
//todo: change request code
override fun openSearchList() {
override fun openSearchActivity(searchWord: String?) {
ReadBook.book?.let {
startActivityForResult<SearchListActivity>(
requestCodeSearchResult,
Pair("bookUrl", it.bookUrl)
Pair("bookUrl", it.bookUrl),
Pair("searchWord", searchWord)
)
}
}

@ -175,7 +175,7 @@ class ReadMenu : FrameLayout {
//搜索
fabSearch.onClick {
runMenuOut {
callBack?.openSearchList()
callBack?.openSearchActivity(null)
}
}
@ -300,7 +300,7 @@ class ReadMenu : FrameLayout {
fun autoPage()
fun openReplaceRule()
fun openChapterList()
fun openSearchList()
fun openSearchActivity(searchWord: String?)
fun showReadStyle()
fun showMoreSetting()
fun showReadAloudDialog()

@ -11,6 +11,7 @@ import io.legado.app.base.BaseActivity
import io.legado.app.constant.AppConst.timeFormat
import io.legado.app.help.ReadBookConfig
import io.legado.app.help.ReadTipConfig
import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.read.page.entities.TextPage
import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.ui.widget.BatteryView
@ -29,6 +30,7 @@ class ContentView(context: Context) : FrameLayout(context) {
private var tvPage: BatteryView? = null
private var tvTotalProgress: BatteryView? = null
private var tvPageAndTotal: BatteryView? = null
private var tvBookName: BatteryView? = null
val headerHeight: Int
get() = if (ReadBookConfig.hideStatusBar) {
@ -185,6 +187,19 @@ class ContentView(context: Context) : FrameLayout(context) {
isBattery = false
textSize = 12f
}
tvBookName = when (ReadTipConfig.bookName) {
ReadTipConfig.tipHeaderLeft -> bv_header_left
ReadTipConfig.tipHeaderMiddle -> tv_header_middle
ReadTipConfig.tipHeaderRight -> tv_header_right
ReadTipConfig.tipFooterLeft -> bv_footer_left
ReadTipConfig.tipFooterMiddle -> tv_footer_middle
ReadTipConfig.tipFooterRight -> tv_footer_right
else -> null
}
tvBookName?.apply {
isBattery = false
textSize = 12f
}
}
fun setBg(bg: Drawable?) {
@ -213,8 +228,8 @@ class ContentView(context: Context) : FrameLayout(context) {
@SuppressLint("SetTextI18n")
fun setProgress(textPage: TextPage) = textPage.apply {
val title = textPage.title
tvTitle?.text = title
tvBookName?.text = ReadBook.book?.name
tvTitle?.text = textPage.title
tvPage?.text = "${index.plus(1)}/$pageSize"
tvTotalProgress?.text = readProgress
tvPageAndTotal?.text = "${index.plus(1)}/$pageSize $readProgress"

@ -29,8 +29,7 @@ import org.jetbrains.anko.sdk27.listeners.onClick
class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity_search_list),
SearchListAdapter.Callback,
SearchListViewModel.SearchListCallBack {
SearchListAdapter.Callback {
override val viewModel: SearchListViewModel
get() = getViewModel(SearchListViewModel::class.java)
@ -42,7 +41,6 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity
private var searchResultList: MutableList<SearchResult> = mutableListOf()
override fun onActivityCreated(savedInstanceState: Bundle?) {
viewModel.searchCallBack = this
val bbg = bottomBackground
val btc = getPrimaryTextColor(ColorUtils.isColorLight(bbg))
ll_search_base_info.setBackgroundColor(bbg)
@ -68,7 +66,7 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity
search_view.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
if (viewModel.lastQuery != query) {
viewModel.startContentSearch(query)
startContentSearch(query)
}
return false
}
@ -103,6 +101,9 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity
viewModel.book?.let {
initCacheFileNames(it)
durChapterIndex = it.durChapterIndex
intent.getStringExtra("searchWord")?.let { searchWord ->
search_view.setQuery(searchWord, true)
}
}
}
}
@ -128,7 +129,7 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity
}
@SuppressLint("SetTextI18n")
override fun startContentSearch(newText: String) {
fun startContentSearch(newText: String) {
// 按章节搜索内容
if (!newText.isBlank()) {
adapter.clearItems()

@ -9,7 +9,6 @@ import io.legado.app.data.entities.Book
class SearchListViewModel(application: Application) : BaseViewModel(application) {
var bookUrl: String = ""
var book: Book? = null
var searchCallBack: SearchListCallBack? = null
var lastQuery: String = ""
fun initBook(bookUrl: String, success: () -> Unit) {
@ -21,13 +20,4 @@ class SearchListViewModel(application: Application) : BaseViewModel(application)
}
}
fun startContentSearch(newText: String) {
searchCallBack?.startContentSearch(newText)
}
interface SearchListCallBack {
fun startContentSearch(newText: String)
}
}

@ -13,6 +13,10 @@
android:id="@+id/menu_aloud"
android:title="@string/read_aloud" />
<item
android:id="@+id/menu_search_content"
android:title="@string/search_content" />
<item
android:id="@+id/menu_browser"
android:title="@string/browser" />

@ -766,6 +766,6 @@
<string name="select_theme">切換默認主題</string>
<string name="share_selected_source">分享選中書源</string>
<string name="sort_by_lastUppdateTime">時間排序</string>
<string name="search_content">搜索</string>
<string name="search_content">全文搜索</string>
</resources>

@ -766,7 +766,6 @@
<string name="select_theme">切換默認主題</string>
<string name="share_selected_source">分享選中書源</string>
<string name="sort_by_lastUppdateTime">時間排序</string>
<string name="search_content">搜索</string>
<string name="search_content">全文搜索</string>
</resources>

@ -769,6 +769,6 @@
<string name="theme_list_summary">使用保存主题,导入,分享主题</string>
<string name="select_theme">切换默认主题</string>
<string name="sort_by_lastUppdateTime">时间排序</string>
<string name="search_content">搜索</string>
<string name="search_content">全文搜索</string>
</resources>

@ -771,6 +771,6 @@
<string name="theme_list_summary">Save, Import, Share theme</string>
<string name="share_selected_source">Share selected sources</string>
<string name="sort_by_lastUppdateTime">Sort by update time</string>
<string name="search_content">Search</string>
<string name="search_content">Search content</string>
</resources>
Loading…
Cancel
Save