pull/754/head
Robot 4 years ago
commit a5f737e68d
  1. 8
      app/src/main/assets/help/httpTTSHelp.md
  2. 15
      app/src/main/assets/updateLog.md
  3. 5
      app/src/main/java/io/legado/app/constant/AppConst.kt
  4. 6
      app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt
  5. 16
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  6. 68
      app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt
  7. 1
      app/src/main/res/layout/fragment_rss.xml
  8. 10
      app/src/main/res/menu/main_rss.xml

@ -2,14 +2,14 @@
* 在线朗读规则为url规则,同书源url
* js参数
~~~
```
speakText //朗读文本
speakSpeed //朗读速度,0-45
~~~
```
* 例:
~~~
```
http://tts.baidu.com/text2audio,{
"method": "POST",
"body": "tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{String((speakSpeed + 5) / 10 + 4)}}&per=5003&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=1&vol=5&pit=5&_res_tag_=audio"
}
~~~
```

@ -243,34 +243,21 @@ getTxtInFolder(unzipPath: String): String
* 修复主题导入导出bug
* 优化分屏模式状态栏
* 书源基本属性增加“书源注释”
**2020/09/08**
* 页眉页脚跟随背景
* 主题导入导出
**2020/09/07**
* 订阅源和替换规则添加滑动选择
* 修复排版配置导入导出
* 订阅界面添加下载文件功能
**2020/09/06**
* 优化翻页
* EInk模式独立背景
* 阅读排版配置导入导出,包括背景和字体,支持网络导入
**2020/09/03**
* 修复替换中的回车消失的bug
* 所有内容恢复htmlFormat, 在想其它办法解决丢失一些内容的问题
* 图片(漫画)支持导出
**2020/09/02**
* 搜索url支持put,get,js里使用java.put,java.get
* 正文合并后替换规则支持所有规则写法,包括js
**2020/09/01**
* 导入书源列表添加全不选
* 详情页菜单添加清理缓存,清理当前书籍缓存
* 修复滑动选择,选择数量不更新的bug
* 字体跟随背景,每个背景对应一个字体
* 优化图片下载
* 优化图片下载

@ -36,8 +36,9 @@ object AppConst {
val keyboardToolChars: List<String> by lazy {
arrayListOf(
"", "@css:", "<js></js>", "{{}}", "&&", "%%", "||", "//", "$.", "@", "class", "id", "href",
"textNodes", "ownText", "all", "html", "[", "]", "<", ">","#", "!", ".", "+", "-", "*", "="
"", "@css:", "<js></js>", "{{}}", "&&", "%%", "||", "//", "$.", "@",
"\\", ":", "class", "id", "href", "textNodes", "ownText", "all", "html",
"[", "]", "<", ">", "#", "!", ".", "+", "-", "*", "="
)
}

@ -11,7 +11,7 @@ interface RssSourceDao {
fun getByKey(key: String): RssSource?
@Query("select * from rssSources where sourceUrl in (:sourceUrls)")
fun getRssSources(vararg sourceUrls: String):List<RssSource>
fun getRssSources(vararg sourceUrls: String): List<RssSource>
@get:Query("SELECT * FROM rssSources")
val all: List<RssSource>
@ -25,8 +25,8 @@ interface RssSourceDao {
@Query("SELECT * FROM rssSources where sourceName like :key or sourceUrl like :key or sourceGroup like :key order by customOrder")
fun liveSearch(key: String): LiveData<List<RssSource>>
@Query("SELECT * FROM rssSources where enabled = 1 order by customOrder")
fun liveEnabled(): LiveData<List<RssSource>>
@Query("SELECT * FROM rssSources where enabled = 1 and (sourceName like '%'||:searchKey||'%' or sourceGroup like '%'||:searchKey||'%' or sourceUrl like '%'||:searchKey||'%') order by customOrder")
fun liveEnabled(searchKey: String): LiveData<List<RssSource>>
@Query("select sourceGroup from rssSources where trim(sourceGroup) <> ''")
fun liveGroup(): LiveData<List<String>>

@ -70,6 +70,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
AutoReadDialog.CallBack,
TocRegexDialog.CallBack,
ColorPickerDialogListener {
private val requestCodeChapterList = 568
private val requestCodeReplace = 312
private val requestCodeSearchResult = 123
@ -154,6 +155,9 @@ class ReadBookActivity : ReadBookBaseActivity(),
return super.onPrepareOptionsMenu(menu)
}
/**
* 更新菜单
*/
private fun upMenu() {
val menu = menu
val book = ReadBook.book
@ -189,10 +193,14 @@ class ReadBookActivity : ReadBookBaseActivity(),
}
}
R.id.menu_refresh -> {
ReadBook.book?.let {
ReadBook.curTextChapter = null
binding.readView.upContent()
viewModel.refreshContent(it)
if (ReadBook.bookSource == null) {
upContent()
} else {
ReadBook.book?.let {
ReadBook.curTextChapter = null
binding.readView.upContent()
viewModel.refreshContent(it)
}
}
}
R.id.menu_download -> showDownloadDialog()

@ -3,14 +3,19 @@ package io.legado.app.ui.main.rss
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.SubMenu
import android.view.View
import androidx.appcompat.widget.SearchView
import androidx.lifecycle.LiveData
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.VMBaseFragment
import io.legado.app.constant.AppPattern
import io.legado.app.data.entities.RssSource
import io.legado.app.databinding.FragmentRssBinding
import io.legado.app.databinding.ItemRssBinding
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.ui.rss.article.RssSortActivity
import io.legado.app.ui.rss.favorites.RssFavoritesActivity
import io.legado.app.ui.rss.read.ReadRssActivity
@ -18,7 +23,9 @@ import io.legado.app.ui.rss.source.edit.RssSourceEditActivity
import io.legado.app.ui.rss.source.manage.RssSourceActivity
import io.legado.app.ui.rss.source.manage.RssSourceViewModel
import io.legado.app.ui.rss.subscription.RuleSubActivity
import io.legado.app.utils.cnCompare
import io.legado.app.utils.getViewModel
import io.legado.app.utils.splitNotBlank
import io.legado.app.utils.startActivity
import io.legado.app.utils.viewbindingdelegate.viewBinding
import org.jetbrains.anko.sdk27.listeners.onClick
@ -30,17 +37,27 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
RssAdapter.CallBack {
private val binding by viewBinding(FragmentRssBinding::bind)
private lateinit var adapter: RssAdapter
private lateinit var searchView: SearchView
override val viewModel: RssSourceViewModel
get() = getViewModel(RssSourceViewModel::class.java)
private var liveRssData: LiveData<List<RssSource>>? = null
private val groups = linkedSetOf<String>()
private var liveGroup: LiveData<List<String>>? = null
private var groupsMenu: SubMenu? = null
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
searchView = binding.titleBar.findViewById(R.id.search_view)
setSupportToolbar(binding.titleBar.toolbar)
initSearchView()
initRecyclerView()
initGroupData()
initData()
}
override fun onCompatCreateOptionsMenu(menu: Menu) {
menuInflater.inflate(R.menu.main_rss, menu)
groupsMenu = menu.findItem(R.id.menu_group)?.subMenu
upGroupsMenu()
}
override fun onCompatOptionsItemSelected(item: MenuItem) {
@ -48,9 +65,39 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
when (item.itemId) {
R.id.menu_rss_config -> startActivity<RssSourceActivity>()
R.id.menu_rss_star -> startActivity<RssFavoritesActivity>()
else -> if (item.groupId == R.id.menu_group_text) {
searchView.setQuery(item.title, true)
}
}
}
private fun upGroupsMenu() = groupsMenu?.let { subMenu ->
subMenu.removeGroup(R.id.menu_group_text)
groups.sortedWith { o1, o2 ->
o1.cnCompare(o2)
}.forEach {
subMenu.add(R.id.menu_group_text, Menu.NONE, Menu.NONE, it)
}
}
private fun initSearchView() {
ATH.setTint(searchView, primaryTextColor)
searchView.onActionViewExpanded()
searchView.isSubmitButtonEnabled = true
searchView.queryHint = getString(R.string.rss)
searchView.clearFocus()
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
return false
}
override fun onQueryTextChange(newText: String?): Boolean {
initData(newText ?: "")
return false
}
})
}
private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.recyclerView)
adapter = RssAdapter(requireContext(), this)
@ -66,9 +113,24 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
}
}
private fun initData() {
App.db.rssSourceDao.liveEnabled().observe(viewLifecycleOwner, {
adapter.setItems(it)
private fun initData(searchKey: String = "") {
liveRssData?.removeObservers(this)
liveRssData = App.db.rssSourceDao.liveEnabled(searchKey).apply {
observe(viewLifecycleOwner, {
adapter.setItems(it)
})
}
}
private fun initGroupData() {
liveGroup?.removeObservers(viewLifecycleOwner)
liveGroup = App.db.rssSourceDao.liveGroup()
liveGroup?.observe(viewLifecycleOwner, {
groups.clear()
it.map { group ->
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
}
upGroupsMenu()
})
}

@ -11,6 +11,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:attachToActivity="false"
app:contentLayout="@layout/view_search"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/rss" />

@ -9,6 +9,16 @@
android:icon="@drawable/ic_star"
app:showAsAction="always" />
<item
android:id="@+id/menu_group"
android:title="@string/group"
android:icon="@drawable/ic_groups"
app:showAsAction="always">
<menu />
</item>
<item
android:id="@+id/menu_rss_config"
android:title="@string/setting"

Loading…
Cancel
Save