Merge remote-tracking branch 'origin/master' into master

pull/408/head
口口吕 6 years ago
commit dc96606ec6
  1. 2
      app/src/debug/res/values-zh-rTW/strings.xml
  2. 6
      app/src/google/res/values-zh-rTW/strings.xml
  3. 2
      app/src/main/AndroidManifest.xml
  4. 7
      app/src/main/assets/updateLog.md
  5. 29
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  6. 2
      app/src/main/java/io/legado/app/help/storage/Restore.kt
  7. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  8. 1
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  9. 57
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  10. 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  11. 16
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  12. 24
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt
  13. 2
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentAdapter.kt
  14. 2
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentViewModel.kt
  15. 10
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  16. 16
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  17. 11
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  18. 41
      app/src/main/res/layout/activity_book_search.xml
  19. 8
      app/src/main/res/layout/activity_search_content.xml
  20. 2
      app/src/main/res/menu/main_bnv.xml
  21. 1
      app/src/main/res/values-zh-rHK/strings.xml
  22. 41
      app/src/main/res/values-zh-rTW/strings.xml
  23. 1
      app/src/main/res/values-zh/strings.xml
  24. 5
      app/src/main/res/values/strings.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">閲讀.D</string> <string name="app_name">閲讀.D</string>
<string name="receiving_shared_label">閲讀·D·搜</string> <string name="receiving_shared_label">閲讀·D·搜</string>
</resources> </resources>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">閱讀Pro</string>
</resources>

@ -224,7 +224,7 @@
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="behind" /> android:screenOrientation="behind" />
<activity <activity
android:name=".ui.book.searchContent.SearchListActivity" android:name=".ui.book.searchContent.SearchContentActivity"
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="behind" /> android:screenOrientation="behind" />
<!-- RSS条目 --> <!-- RSS条目 -->

@ -3,6 +3,13 @@
* 关注合作公众号 **[小说拾遗]()** 获取好看的小说。 * 关注合作公众号 **[小说拾遗]()** 获取好看的小说。
- 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 - 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。
**2020/10/02**
* 优化规则解析
* 优化正文搜索
* 翻页动画跟随背景
* 双击发现折叠发现,再次双击滚动至顶端
* 修复bug
**2020/09/29** **2020/09/29**
* 增加了几个方法用于处理文件 by [Celeter](https://github.com/Celeter) * 增加了几个方法用于处理文件 by [Celeter](https://github.com/Celeter)
``` ```

@ -158,12 +158,6 @@ object ReadBookConfig {
App.INSTANCE.putPrefBoolean(PreferKey.shareLayout, value) App.INSTANCE.putPrefBoolean(PreferKey.shareLayout, value)
} }
} }
var pageAnim: Int
get() = if (AppConfig.isEInkMode) -1 else App.INSTANCE.getPrefInt(PreferKey.pageAnim)
set(value) {
App.INSTANCE.putPrefInt(PreferKey.pageAnim, value)
isScroll = pageAnim == 3
}
var isScroll = pageAnim == 3 var isScroll = pageAnim == 3
val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true) val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true)
val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true) val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true)
@ -182,6 +176,13 @@ object ReadBookConfig {
val config get() = if (shareLayout) shareConfig else durConfig val config get() = if (shareLayout) shareConfig else durConfig
var pageAnim: Int
get() = config.pageAnim()
set(value) {
config.setPageAnim(value)
isScroll = pageAnim == 3
}
var textFont: String var textFont: String
get() = config.textFont get() = config.textFont
set(value) { set(value) {
@ -379,6 +380,8 @@ object ReadBookConfig {
private var textColor: String = "#3E3D3B",//白天文字颜色 private var textColor: String = "#3E3D3B",//白天文字颜色
private var textColorNight: String = "#ADADAD",//夜间文字颜色 private var textColorNight: String = "#ADADAD",//夜间文字颜色
private var textColorEInk: String = "#000000", private var textColorEInk: String = "#000000",
private var pageAnim: Int = 0,
private var pageAnimEInk: Int = 3,
var textFont: String = "",//字体 var textFont: String = "",//字体
var textBold: Int = 0,//是否粗体字 0:正常, 1:粗体, 2:细体 var textBold: Int = 0,//是否粗体字 0:正常, 1:粗体, 2:细体
var textSize: Int = 20,//文字大小 var textSize: Int = 20,//文字大小
@ -454,6 +457,20 @@ object ReadBookConfig {
} }
} }
fun setPageAnim(anim: Int) {
when {
AppConfig.isEInkMode -> pageAnimEInk = anim
else -> pageAnim = anim
}
}
fun pageAnim(): Int {
return when {
AppConfig.isEInkMode -> pageAnimEInk
else -> pageAnim
}
}
fun textColor(): Int { fun textColor(): Int {
return when { return when {
AppConfig.isEInkMode -> Color.parseColor(textColorEInk) AppConfig.isEInkMode -> Color.parseColor(textColorEInk)

@ -61,7 +61,6 @@ object Restore {
private val readPrefKeys = arrayOf( private val readPrefKeys = arrayOf(
PreferKey.readStyleSelect, PreferKey.readStyleSelect,
PreferKey.shareLayout, PreferKey.shareLayout,
PreferKey.pageAnim,
PreferKey.hideStatusBar, PreferKey.hideStatusBar,
PreferKey.hideNavigationBar, PreferKey.hideNavigationBar,
PreferKey.bodyIndent, PreferKey.bodyIndent,
@ -215,7 +214,6 @@ object Restore {
ReadBookConfig.apply { ReadBookConfig.apply {
styleSelect = App.INSTANCE.getPrefInt(PreferKey.readStyleSelect) styleSelect = App.INSTANCE.getPrefInt(PreferKey.readStyleSelect)
shareLayout = App.INSTANCE.getPrefBoolean(PreferKey.shareLayout) shareLayout = App.INSTANCE.getPrefBoolean(PreferKey.shareLayout)
pageAnim = App.INSTANCE.getPrefInt(PreferKey.pageAnim)
hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar) hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar)
hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar) hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar)
bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2) bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2)

@ -456,7 +456,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
while (evalMatcher.find()) { while (evalMatcher.find()) {
if (evalMatcher.start() > start) { if (evalMatcher.start() > start) {
tmp = rule.substring(start, evalMatcher.start()) tmp = rule.substring(start, evalMatcher.start())
if (mode != Mode.Js && mode != Mode.Json && mode != Mode.Regex if (mode != Mode.Js && mode != Mode.Regex
&& start == 0 && !tmp.contains("##") && start == 0 && !tmp.contains("##")
) { ) {
mode = Mode.Regex mode = Mode.Regex

@ -34,7 +34,6 @@ import io.legado.app.utils.getViewModel
import io.legado.app.utils.requestInputMethod import io.legado.app.utils.requestInputMethod
import kotlinx.android.synthetic.main.dialog_book_group_picker.* import kotlinx.android.synthetic.main.dialog_book_group_picker.*
import kotlinx.android.synthetic.main.dialog_edit_text.view.* import kotlinx.android.synthetic.main.dialog_edit_text.view.*
import kotlinx.android.synthetic.main.dialog_recycler_view.recycler_view
import kotlinx.android.synthetic.main.dialog_recycler_view.tool_bar import kotlinx.android.synthetic.main.dialog_recycler_view.tool_bar
import kotlinx.android.synthetic.main.item_group_select.view.* import kotlinx.android.synthetic.main.item_group_select.view.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick

@ -9,7 +9,6 @@ import android.graphics.drawable.ColorDrawable
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.util.Log
import android.view.* import android.view.*
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import androidx.core.view.get import androidx.core.view.get
@ -48,7 +47,7 @@ import io.legado.app.ui.book.read.page.ContentTextView
import io.legado.app.ui.book.read.page.PageView 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.TextPageFactory
import io.legado.app.ui.book.read.page.delegate.PageDelegate 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.SearchContentActivity
import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.login.SourceLogin import io.legado.app.ui.login.SourceLogin
import io.legado.app.ui.replacerule.ReplaceRuleActivity import io.legado.app.ui.replacerule.ReplaceRuleActivity
@ -57,14 +56,16 @@ import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_book_read.* import kotlinx.android.synthetic.main.activity_book_read.*
import kotlinx.android.synthetic.main.view_read_menu.* import kotlinx.android.synthetic.main.view_read_menu.*
import kotlinx.coroutines.* import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast import org.jetbrains.anko.toast
import java.lang.Runnable
class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_book_read), class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_book_read),
View.OnTouchListener, View.OnTouchListener,
@ -494,6 +495,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
return true return true
} }
R.id.menu_search_content -> { R.id.menu_search_content -> {
viewModel.searchContentQuery = selectedText
openSearchActivity(selectedText) openSearchActivity(selectedText)
return true return true
} }
@ -683,10 +685,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
*/ */
override fun openSearchActivity(searchWord: String?) { override fun openSearchActivity(searchWord: String?) {
ReadBook.book?.let { ReadBook.book?.let {
startActivityForResult<SearchListActivity>( startActivityForResult<SearchContentActivity>(
requestCodeSearchResult, requestCodeSearchResult,
Pair("bookUrl", it.bookUrl), Pair("bookUrl", it.bookUrl),
Pair("searchWord", searchWord) Pair("searchWord", searchWord ?: viewModel.searchContentQuery)
) )
} }
} }
@ -771,33 +773,50 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
requestCodeChapterList -> requestCodeChapterList ->
data?.getIntExtra("index", ReadBook.durChapterIndex)?.let { index -> data?.getIntExtra("index", ReadBook.durChapterIndex)?.let { index ->
if (index != ReadBook.durChapterIndex) { if (index != ReadBook.durChapterIndex) {
val pageIndex = data.getIntExtra("pageIndex", 0) val pageIndex = data.getIntExtra("pageIndex", 0)
viewModel.openChapter(index, pageIndex) viewModel.openChapter(index, pageIndex)
}
} }
}
requestCodeSearchResult -> requestCodeSearchResult ->
data?.getIntExtra("index", ReadBook.durChapterIndex)?.let { index -> data?.getIntExtra("index", ReadBook.durChapterIndex)?.let { index ->
launch(IO){ launch(IO) {
val indexWithinChapter = data.getIntExtra("indexWithinChapter", 0) val indexWithinChapter = data.getIntExtra("indexWithinChapter", 0)
val query = data.getStringExtra("query") viewModel.searchContentQuery = data.getStringExtra("query") ?: ""
viewModel.openChapter(index) viewModel.openChapter(index)
// block until load correct chapter and pages // block until load correct chapter and pages
var pages = ReadBook.curTextChapter?.pages var pages = ReadBook.curTextChapter?.pages
while (ReadBook.durChapterIndex != index || pages == null ){ while (ReadBook.durChapterIndex != index || pages == null) {
delay(100L) delay(100L)
pages = ReadBook.curTextChapter?.pages pages = ReadBook.curTextChapter?.pages
} }
val positions = ReadBook.searchResultPositions(pages, indexWithinChapter, query!!) val positions =
while (ReadBook.durPageIndex != positions[0]){ ReadBook.searchResultPositions(
pages,
indexWithinChapter,
viewModel.searchContentQuery
)
while (ReadBook.durPageIndex != positions[0]) {
delay(100L) delay(100L)
ReadBook.skipToPage(positions[0]) ReadBook.skipToPage(positions[0])
} }
withContext(Main){ withContext(Main) {
page_view.curPage.selectStartMoveIndex(0, positions[1], positions[2]) page_view.curPage.selectStartMoveIndex(
0,
positions[1],
positions[2]
)
delay(20L) delay(20L)
when (positions[3]){ when (positions[3]) {
0 -> page_view.curPage.selectEndMoveIndex(0, positions[1], positions[2] + query.length - 1) 0 -> page_view.curPage.selectEndMoveIndex(
1 -> page_view.curPage.selectEndMoveIndex(0, positions[1] + 1, positions[4]) 0,
positions[1],
positions[2] + viewModel.searchContentQuery.length - 1
)
1 -> page_view.curPage.selectEndMoveIndex(
0,
positions[1] + 1,
positions[4]
)
//todo: consider change page, jump to scroll position //todo: consider change page, jump to scroll position
-1 -> page_view.curPage.selectEndMoveIndex(1, 0, positions[4]) -1 -> page_view.curPage.selectEndMoveIndex(1, 0, positions[4])
} }

@ -23,6 +23,7 @@ import kotlinx.coroutines.withContext
class ReadBookViewModel(application: Application) : BaseViewModel(application) { class ReadBookViewModel(application: Application) : BaseViewModel(application) {
var isInitFinish = false var isInitFinish = false
var searchContentQuery = ""
fun initData(intent: Intent) { fun initData(intent: Intent) {
execute { execute {

@ -104,12 +104,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
private fun initData() { private fun initData() {
cb_share_layout.isChecked = ReadBookConfig.shareLayout cb_share_layout.isChecked = ReadBookConfig.shareLayout
ReadBookConfig.pageAnim.let { upView()
if (it >= 0 && it < rg_page_anim.childCount) {
rg_page_anim.check(rg_page_anim[it].id)
}
}
upStyle()
styleAdapter.setItems(ReadBookConfig.configList) styleAdapter.setItems(ReadBookConfig.configList)
} }
@ -149,7 +144,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
cb_share_layout.onCheckedChangeListener = { checkBox, isChecked -> cb_share_layout.onCheckedChangeListener = { checkBox, isChecked ->
if (checkBox.isPressed) { if (checkBox.isPressed) {
ReadBookConfig.shareLayout = isChecked ReadBookConfig.shareLayout = isChecked
upStyle() upView()
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }
@ -206,7 +201,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
if (index != oldIndex) { if (index != oldIndex) {
ReadBookConfig.styleSelect = index ReadBookConfig.styleSelect = index
ReadBookConfig.upBg() ReadBookConfig.upBg()
upStyle() upView()
styleAdapter.notifyItemChanged(oldIndex) styleAdapter.notifyItemChanged(oldIndex)
styleAdapter.notifyItemChanged(index) styleAdapter.notifyItemChanged(index)
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
@ -220,8 +215,11 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
return true return true
} }
private fun upStyle() { private fun upView() {
ReadBookConfig.let { ReadBookConfig.let {
if (it.pageAnim >= 0 && it.pageAnim < rg_page_anim.childCount) {
rg_page_anim.check(rg_page_anim[it.pageAnim].id)
}
dsb_text_size.progress = it.textSize - 5 dsb_text_size.progress = it.textSize - 5
dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50
dsb_line_size.progress = it.lineSpacingExtra dsb_line_size.progress = it.lineSpacingExtra

@ -22,19 +22,20 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.ColorUtils import io.legado.app.utils.ColorUtils
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import io.legado.app.utils.observeEvent import io.legado.app.utils.observeEvent
import kotlinx.android.synthetic.main.activity_search_list.* import kotlinx.android.synthetic.main.activity_search_content.*
import kotlinx.android.synthetic.main.view_search.* import kotlinx.android.synthetic.main.view_search.*
import kotlinx.coroutines.* import kotlinx.coroutines.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity_search_list), class SearchContentActivity :
SearchListAdapter.Callback { VMBaseActivity<SearchContentViewModel>(R.layout.activity_search_content),
SearchContentAdapter.Callback {
override val viewModel: SearchListViewModel override val viewModel: SearchContentViewModel
get() = getViewModel(SearchListViewModel::class.java) get() = getViewModel(SearchContentViewModel::class.java)
lateinit var adapter: SearchListAdapter lateinit var adapter: SearchContentAdapter
private lateinit var mLayoutManager: UpLinearLayoutManager private lateinit var mLayoutManager: UpLinearLayoutManager
private var searchResultCounts = 0 private var searchResultCounts = 0
private var durChapterIndex = 0 private var durChapterIndex = 0
@ -78,7 +79,7 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity
} }
private fun initRecyclerView() { private fun initRecyclerView() {
adapter = SearchListAdapter(this, this) adapter = SearchContentAdapter(this, this)
mLayoutManager = UpLinearLayoutManager(this) mLayoutManager = UpLinearLayoutManager(this)
recycler_view.layoutManager = mLayoutManager recycler_view.layoutManager = mLayoutManager
recycler_view.addItemDecoration(VerticalDivider(this)) recycler_view.addItemDecoration(VerticalDivider(this))
@ -134,17 +135,15 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity
if (!newText.isBlank()) { if (!newText.isBlank()) {
adapter.clearItems() adapter.clearItems()
searchResultList.clear() searchResultList.clear()
refresh_progress_bar.isAutoLoading = true
searchResultCounts = 0 searchResultCounts = 0
viewModel.lastQuery = newText viewModel.lastQuery = newText
var searchResults = listOf<SearchResult>() var searchResults = listOf<SearchResult>()
launch(Dispatchers.Main) { launch(Dispatchers.Main) {
App.db.bookChapterDao().getChapterList(viewModel.bookUrl).map { chapter -> App.db.bookChapterDao().getChapterList(viewModel.bookUrl).map { chapter ->
val job = async(Dispatchers.IO) { val job = async(Dispatchers.IO) {
if (isLocalBook || adapter.cacheFileNames.contains( if (isLocalBook
BookHelp.formatChapterName( || adapter.cacheFileNames.contains(BookHelp.formatChapterName(chapter))
chapter
)
)
) { ) {
searchResults = searchChapter(newText, chapter) searchResults = searchChapter(newText, chapter)
} }
@ -152,6 +151,7 @@ class SearchListActivity : VMBaseActivity<SearchListViewModel>(R.layout.activity
job.await() job.await()
if (searchResults.isNotEmpty()) { if (searchResults.isNotEmpty()) {
searchResultList.addAll(searchResults) searchResultList.addAll(searchResults)
refresh_progress_bar.isAutoLoading = false
tv_current_search_info.text = "搜索结果:$searchResultCounts" tv_current_search_info.text = "搜索结果:$searchResultCounts"
adapter.addItems(searchResults) adapter.addItems(searchResults)
searchResults = listOf() searchResults = listOf()

@ -10,7 +10,7 @@ import io.legado.app.utils.hexString
import kotlinx.android.synthetic.main.item_search_list.view.* import kotlinx.android.synthetic.main.item_search_list.view.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
class SearchListAdapter(context: Context, val callback: Callback) : class SearchContentAdapter(context: Context, val callback: Callback) :
SimpleRecyclerAdapter<SearchResult>(context, R.layout.item_search_list) { SimpleRecyclerAdapter<SearchResult>(context, R.layout.item_search_list) {
val cacheFileNames = hashSetOf<String>() val cacheFileNames = hashSetOf<String>()

@ -6,7 +6,7 @@ import io.legado.app.App
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
class SearchListViewModel(application: Application) : BaseViewModel(application) { class SearchContentViewModel(application: Application) : BaseViewModel(application) {
var bookUrl: String = "" var bookUrl: String = ""
var book: Book? = null var book: Book? = null
var lastQuery: String = "" var lastQuery: String = ""

@ -39,6 +39,7 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
get() = getViewModel(MainViewModel::class.java) get() = getViewModel(MainViewModel::class.java)
private var exitTime: Long = 0 private var exitTime: Long = 0
private var bookshelfReselected: Long = 0 private var bookshelfReselected: Long = 0
private var exploreReselected: Long = 0
private var pagePosition = 0 private var pagePosition = 0
private val fragmentMap = hashMapOf<Int, Fragment>() private val fragmentMap = hashMapOf<Int, Fragment>()
@ -72,7 +73,7 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
override fun onNavigationItemSelected(item: MenuItem): Boolean { override fun onNavigationItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_bookshelf -> view_pager_main.setCurrentItem(0, false) R.id.menu_bookshelf -> view_pager_main.setCurrentItem(0, false)
R.id.menu_find_book -> view_pager_main.setCurrentItem(1, false) R.id.menu_explore -> view_pager_main.setCurrentItem(1, false)
R.id.menu_rss -> view_pager_main.setCurrentItem(2, false) R.id.menu_rss -> view_pager_main.setCurrentItem(2, false)
R.id.menu_my_config -> view_pager_main.setCurrentItem(3, false) R.id.menu_my_config -> view_pager_main.setCurrentItem(3, false)
} }
@ -88,6 +89,13 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
(fragmentMap[0] as? BookshelfFragment)?.gotoTop() (fragmentMap[0] as? BookshelfFragment)?.gotoTop()
} }
} }
R.id.menu_explore -> {
if (System.currentTimeMillis() - exploreReselected > 300) {
exploreReselected = System.currentTimeMillis()
} else {
(fragmentMap[1] as? ExploreFragment)?.compressExplore()
}
}
} }
} }

@ -11,7 +11,10 @@ import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.* import io.legado.app.utils.ACache
import io.legado.app.utils.dp
import io.legado.app.utils.gone
import io.legado.app.utils.visible
import kotlinx.android.synthetic.main.item_fillet_text.view.* import kotlinx.android.synthetic.main.item_fillet_text.view.*
import kotlinx.android.synthetic.main.item_find_book.view.* import kotlinx.android.synthetic.main.item_find_book.view.*
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -97,6 +100,17 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
} }
} }
fun compressExplore(): Boolean {
return if (exIndex < 0) {
false
} else {
val oldExIndex = exIndex
exIndex = -1
notifyItemChanged(oldExIndex)
true
}
}
private fun showMenu(view: View, position: Int): Boolean { private fun showMenu(view: View, position: Int): Boolean {
val source = getItem(position) ?: return true val source = getItem(position) ?: return true
val popupMenu = PopupMenu(context, view) val popupMenu = PopupMenu(context, view)

@ -15,6 +15,7 @@ import io.legado.app.R
import io.legado.app.base.VMBaseFragment import io.legado.app.base.VMBaseFragment
import io.legado.app.constant.AppPattern import io.legado.app.constant.AppPattern
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.AppConfig
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryTextColor import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.ui.book.explore.ExploreShowActivity import io.legado.app.ui.book.explore.ExploreShowActivity
@ -154,4 +155,14 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_find_
viewModel.topSource(source) viewModel.topSource(source)
} }
fun compressExplore() {
if (!adapter.compressExplore()) {
if (AppConfig.isEInkMode) {
rv_find.scrollToPosition(0)
} else {
rv_find.smoothScrollToPosition(0)
}
}
}
} }

@ -1,20 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_height="match_parent"
tools:context=".ui.book.search.SearchActivity"> tools:context=".ui.book.search.SearchActivity">
<io.legado.app.ui.widget.TitleBar <io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar" android:id="@+id/title_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:contentLayout="@layout/view_search" app:contentInsetStartWithNavigation="0dp"
app:contentInsetStartWithNavigation="0dp" app:contentLayout="@layout/view_search"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:title="搜索"/> app:title="搜索" />
<io.legado.app.ui.widget.anima.RefreshProgressBar <io.legado.app.ui.widget.anima.RefreshProgressBar
android:id="@+id/refresh_progress_bar" android:id="@+id/refresh_progress_bar"
@ -23,10 +22,10 @@
app:layout_constraintTop_toBottomOf="@id/title_bar" /> app:layout_constraintTop_toBottomOf="@id/title_bar" />
<io.legado.app.ui.widget.dynamiclayout.DynamicFrameLayout <io.legado.app.ui.widget.dynamiclayout.DynamicFrameLayout
android:id="@+id/content_view" android:id="@+id/content_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/refresh_progress_bar"> app:layout_constraintTop_toBottomOf="@id/refresh_progress_bar">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
@ -41,12 +40,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:background="@color/background" android:background="@color/background"
android:orientation="vertical"
android:visibility="gone"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
app:layout_constraintTop_toBottomOf="@id/title_bar" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"> android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/title_bar">
<TextView <TextView
android:id="@+id/tv_book_show" android:id="@+id/tv_book_show"

@ -13,13 +13,19 @@
app:contentInsetRight="24dp" app:contentInsetRight="24dp"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<io.legado.app.ui.widget.anima.RefreshProgressBar
android:id="@+id/refresh_progress_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
app:layout_constraintTop_toBottomOf="@id/title_bar" />
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView <io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:overScrollMode="never" android:overScrollMode="never"
app:layout_constraintBottom_toTopOf="@+id/ll_search_base_info" app:layout_constraintBottom_toTopOf="@+id/ll_search_base_info"
app:layout_constraintTop_toBottomOf="@id/title_bar" /> app:layout_constraintTop_toBottomOf="@id/refresh_progress_bar" />
<LinearLayout <LinearLayout
android:id="@+id/ll_search_base_info" android:id="@+id/ll_search_base_info"

@ -8,7 +8,7 @@
android:icon="@drawable/ic_bottom_books" android:icon="@drawable/ic_bottom_books"
android:title="@string/bookshelf" /> android:title="@string/bookshelf" />
<item <item
android:id="@+id/menu_find_book" android:id="@+id/menu_explore"
android:icon="@drawable/ic_bottom_explore" android:icon="@drawable/ic_bottom_explore"
android:title="@string/find" /> android:title="@string/find" />
<item <item

@ -733,7 +733,6 @@
<string name="rule_replace_regex">替换规则(replaceRegex)</string> <string name="rule_replace_regex">替换规则(replaceRegex)</string>
<string name="group_name">分組名稱</string> <string name="group_name">分組名稱</string>
<string name="note_content">備註內容</string> <string name="note_content">備註內容</string>
<string name="e_ink_change_bg">E-Ink模式下只有白纸黑字,不显示其它背景</string>
<string name="replace_enable_default_t">默认启用替换净化</string> <string name="replace_enable_default_t">默认启用替换净化</string>
<string name="replace_enable_default_s">新加入书架的书是否启用替换净化</string> <string name="replace_enable_default_s">新加入书架的书是否启用替换净化</string>
<string name="select_restore_file">选择恢复文件</string> <string name="select_restore_file">选择恢复文件</string>

@ -10,8 +10,8 @@
<string name="menu_import_old">匯入閱讀資料</string> <string name="menu_import_old">匯入閱讀資料</string>
<string name="mkdirs">建立子資料夾</string> <string name="mkdirs">建立子資料夾</string>
<string name="mkdirs_description">建立legado資料夾作為備份資料夾</string> <string name="mkdirs_description">建立legado資料夾作為備份資料夾</string>
<string name="webdav_cache_backup">離線緩存書籍備份</string> <string name="webdav_cache_backup">離線快取書籍備份</string>
<string name="webdav_cache_backup_s">導出本地同時備份到legado文件夾下exports目錄</string> <string name="webdav_cache_backup_s">匯出本機同時備份到legado資料夾下exports目錄</string>
<string name="backup_path">備份路徑</string> <string name="backup_path">備份路徑</string>
<string name="menu_import_old_version">匯入舊版資料</string> <string name="menu_import_old_version">匯入舊版資料</string>
<string name="menu_import_github">匯入Github資料</string> <string name="menu_import_github">匯入Github資料</string>
@ -56,7 +56,7 @@
<string name="bookshelf_layout">書架布局</string> <string name="bookshelf_layout">書架布局</string>
<string name="view">檢視</string> <string name="view">檢視</string>
<string name="book_library">書城</string> <string name="book_library">書城</string>
<string name="book_local">添加本機</string> <string name="book_local">新增本機</string>
<string name="book_source">書源</string> <string name="book_source">書源</string>
<string name="book_source_manage">書源管理</string> <string name="book_source_manage">書源管理</string>
<string name="book_source_manage_desc">建立/匯入/編輯/管理書源</string> <string name="book_source_manage_desc">建立/匯入/編輯/管理書源</string>
@ -85,9 +85,9 @@
<string name="web_service_desc">瀏覽器寫源,看書</string> <string name="web_service_desc">瀏覽器寫源,看書</string>
<string name="web_edit_source">web編輯書源</string> <string name="web_edit_source">web編輯書源</string>
<string name="http_ip">http://%1$s:%2$d</string> <string name="http_ip">http://%1$s:%2$d</string>
<string name="offline_cache">離線緩存</string> <string name="offline_cache">離線快取</string>
<string name="offline_cache_t">離線緩存</string> <string name="offline_cache_t">離線快取</string>
<string name="offline_cache_s">緩存選擇的章節到本機</string> <string name="offline_cache_s">快取選擇的章節到本機</string>
<string name="change_origin">換源</string> <string name="change_origin">換源</string>
<string name="about_description"> <string name="about_description">
\u3000\u3000這是一款使用Kotlin全新開發的開源的閱讀軟體,歡迎您的加入。關注公眾號[legado-top]! \u3000\u3000這是一款使用Kotlin全新開發的開源的閱讀軟體,歡迎您的加入。關注公眾號[legado-top]!
@ -97,7 +97,7 @@
</string> </string>
<string name="version_name">Version %s</string> <string name="version_name">Version %s</string>
<string name="pt_background_verification">後臺校驗書源</string> <string name="pt_background_verification">後臺校驗書源</string>
<string name="ps_background_verification">打開可以在校驗書源時自由操作</string> <string name="ps_background_verification">打開可以在校驗書源時自由操作</string>
<string name="pt_auto_refresh">自動重新整理</string> <string name="pt_auto_refresh">自動重新整理</string>
<string name="ps_auto_refresh">打開軟體時自動更新書籍</string> <string name="ps_auto_refresh">打開軟體時自動更新書籍</string>
<string name="pt_auto_download">自動下載最新章節</string> <string name="pt_auto_download">自動下載最新章節</string>
@ -159,8 +159,8 @@
<string name="can_not_open">無法打開</string> <string name="can_not_open">無法打開</string>
<string name="can_not_share">分享失敗</string> <string name="can_not_share">分享失敗</string>
<string name="no_chapter">無章節</string> <string name="no_chapter">無章節</string>
<string name="add_url">添加網址</string> <string name="add_url">新增網址</string>
<string name="add_book_url">添加書籍網址</string> <string name="add_book_url">新增書籍網址</string>
<string name="background">背景</string> <string name="background">背景</string>
<string name="author">作者</string> <string name="author">作者</string>
<string name="author_show">作者: %s</string> <string name="author_show">作者: %s</string>
@ -173,7 +173,7 @@
<string name="disable_book_source">禁用書源</string> <string name="disable_book_source">禁用書源</string>
<string name="add_book_source">建立書源</string> <string name="add_book_source">建立書源</string>
<string name="add_rss_source">建立訂閱源</string> <string name="add_rss_source">建立訂閱源</string>
<string name="book_file_selector">添加書籍</string> <string name="book_file_selector">新增書籍</string>
<string name="scan_book_source">掃描</string> <string name="scan_book_source">掃描</string>
<string name="copy_source">複製源</string> <string name="copy_source">複製源</string>
<string name="paste_source">貼上源</string> <string name="paste_source">貼上源</string>
@ -185,7 +185,7 @@
<string name="share">分享</string> <string name="share">分享</string>
<string name="share_app">軟體分享</string> <string name="share_app">軟體分享</string>
<string name="flow_sys">跟隨系統</string> <string name="flow_sys">跟隨系統</string>
<string name="add">添加</string> <string name="add">新增</string>
<string name="import_book_source">匯入書源</string> <string name="import_book_source">匯入書源</string>
<string name="import_book_source_local">本機匯入</string> <string name="import_book_source_local">本機匯入</string>
<string name="import_book_source_on_line">網路匯入</string> <string name="import_book_source_on_line">網路匯入</string>
@ -733,7 +733,6 @@
<string name="rule_replace_regex">取代規則(replaceRegex)</string> <string name="rule_replace_regex">取代規則(replaceRegex)</string>
<string name="group_name">分組名稱</string> <string name="group_name">分組名稱</string>
<string name="note_content">備註內容</string> <string name="note_content">備註內容</string>
<string name="e_ink_change_bg">E-Ink模式下只有白紙黑字,不顯示其它背景</string>
<string name="replace_enable_default_t">預設啟用取代淨化</string> <string name="replace_enable_default_t">預設啟用取代淨化</string>
<string name="replace_enable_default_s">新加入書架的書是否啟用取代淨化</string> <string name="replace_enable_default_s">新加入書架的書是否啟用取代淨化</string>
<string name="select_restore_file">選擇復原文件</string> <string name="select_restore_file">選擇復原文件</string>
@ -757,16 +756,16 @@
<string name="all_read_time">總閱讀時間</string> <string name="all_read_time">總閱讀時間</string>
<string name="un_select_all">全不選</string> <string name="un_select_all">全不選</string>
<string name="delete_all">刪除所有</string> <string name="delete_all">刪除所有</string>
<string name="import_str"></string> <string name="import_str"></string>
<string name="export_str"></string> <string name="export_str"></string>
<string name="save_theme_config">保存主题配置</string> <string name="save_theme_config">儲存主題配置</string>
<string name="save_day_theme_summary">保存白天主题配置以共调用和分享</string> <string name="save_day_theme_summary">儲存白天主題配置以供調用和分享</string>
<string name="save_night_theme_summary">保存夜间主题配置以共调用和分享</string> <string name="save_night_theme_summary">儲存夜間主題配置以供調用和分享</string>
<string name="theme_list">列表</string> <string name="theme_list">列表</string>
<string name="theme_list_summary">使用保存主题,导入,分享主题</string> <string name="theme_list_summary">使用儲存主題,匯入,分享主題</string>
<string name="select_theme">切換默認主題</string> <string name="select_theme">切換預設主題</string>
<string name="share_selected_source">分享選中書源</string> <string name="share_selected_source">分享選中書源</string>
<string name="sort_by_lastUppdateTime">時間排序</string> <string name="sort_by_lastUppdateTime">時間排序</string>
<string name="search_content">全文搜</string> <string name="search_content">全文搜</string>
</resources> </resources>

@ -738,7 +738,6 @@
<string name="rule_replace_regex">替换规则(replaceRegex)</string> <string name="rule_replace_regex">替换规则(replaceRegex)</string>
<string name="group_name">分组名称</string> <string name="group_name">分组名称</string>
<string name="note_content">备注内容</string> <string name="note_content">备注内容</string>
<string name="e_ink_change_bg">E-Ink模式下只有白纸黑字,不显示其它背景</string>
<string name="replace_enable_default_t">默认启用替换净化</string> <string name="replace_enable_default_t">默认启用替换净化</string>
<string name="replace_enable_default_s">新加入书架的书是否启用替换净化</string> <string name="replace_enable_default_s">新加入书架的书是否启用替换净化</string>
<string name="select_restore_file">选择恢复文件</string> <string name="select_restore_file">选择恢复文件</string>

@ -323,8 +323,8 @@
<string name="auto_next_page">Auto scroll</string> <string name="auto_next_page">Auto scroll</string>
<string name="auto_next_page_stop">Stop Auto scroll</string> <string name="auto_next_page_stop">Stop Auto scroll</string>
<string name="auto_next_page_speed">Auto scroll speed</string> <string name="auto_next_page_speed">Auto scroll speed</string>
<string name="book_info">Book infomation</string> <string name="book_info">Book information</string>
<string name="book_info_edit">Edit book infomation</string> <string name="book_info_edit">Edit book information</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 url is available</string> <string name="use_to">Replacement object. Book name or source url is available</string>
@ -739,7 +739,6 @@
<string name="read_config">Reading interface settings</string> <string name="read_config">Reading interface settings</string>
<string name="group_name">Group name</string> <string name="group_name">Group name</string>
<string name="note_content">Remarks section</string> <string name="note_content">Remarks section</string>
<string name="e_ink_change_bg">Only white page black text in E-Ink mode</string>
<string name="replace_enable_default_t">Enable replace rule by default</string> <string name="replace_enable_default_t">Enable replace rule by default</string>
<string name="replace_enable_default_s">For new added books</string> <string name="replace_enable_default_s">For new added books</string>
<string name="select_restore_file">Select restore file</string> <string name="select_restore_file">Select restore file</string>

Loading…
Cancel
Save