pull/32/head
yangyxd 5 years ago
commit 6870876388
  1. 19
      app/src/main/java/io/legado/app/constant/RSSKeywords.kt
  2. 20
      app/src/main/java/io/legado/app/data/entities/RssArticle.kt
  3. 33
      app/src/main/java/io/legado/app/service/ReadAloudService.kt
  4. 8
      app/src/main/java/io/legado/app/ui/booksource/GroupManageDialog.kt
  5. 8
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt
  6. 7
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt
  7. 32
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfAdapter.kt
  8. 3
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  9. 23
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt
  10. 7
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  11. 16
      app/src/main/java/io/legado/app/ui/readbook/config/PaddingConfigDialog.kt
  12. 6
      app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt
  13. 101
      app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt
  14. 8
      app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt
  15. 13
      app/src/main/res/layout/activity_search.xml

@ -0,0 +1,19 @@
package io.legado.app.constant
object RSSKeywords {
const val RSS_ITEM = "item"
const val RSS_ITEM_TITLE = "title"
const val RSS_ITEM_LINK = "link"
const val RSS_ITEM_AUTHOR = "dc:creator"
const val RSS_ITEM_CATEGORY = "category"
const val RSS_ITEM_THUMBNAIL = "media:thumbnail"
const val RSS_ITEM_ENCLOSURE = "enclosure"
const val RSS_ITEM_DESCRIPTION = "description"
const val RSS_ITEM_CONTENT = "content:encoded"
const val RSS_ITEM_PUB_DATE = "pubDate"
const val RSS_ITEM_TIME = "time"
const val RSS_ITEM_URL = "url"
const val RSS_ITEM_TYPE = "type"
const val RSS_ITEM_GUID = "guid"
}

@ -0,0 +1,20 @@
package io.legado.app.data.entities
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "rssArticles")
data class RssArticle(
var origin: String = "",
@PrimaryKey
var guid: String? = null,
var title: String? = null,
var author: String? = null,
var link: String? = null,
var pubDate: String? = null,
var description: String? = null,
var content: String? = null,
var image: String? = null,
var categories: MutableList<String> = mutableListOf()
)

@ -125,7 +125,6 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener,
private lateinit var audioManager: AudioManager
private lateinit var mFocusRequest: AudioFocusRequest
private var broadcastReceiver: BroadcastReceiver? = null
private var speak: Boolean = true
private var nowSpeak: Int = 0
private val contentList = arrayListOf<String>()
private var readAloudNumber: Int = 0
@ -147,13 +146,13 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener,
}
initMediaSession()
initBroadcastReceiver()
upMediaSessionPlaybackState()
upSpeechRate()
ReadAloudNotification.upNotification(this)
}
override fun onDestroy() {
super.onDestroy()
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_STOPPED)
clearTTS()
unregisterReceiver(broadcastReceiver)
postEvent(Bus.ALOUD_STATE, Status.STOP)
@ -231,6 +230,7 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener,
return
}
if (requestFocus()) {
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING)
postEvent(Bus.ALOUD_STATE, Status.PLAY)
ReadAloudNotification.upNotification(this)
for (i in nowSpeak until contentList.size) {
@ -322,28 +322,31 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener,
}
/**
* 初始化MediaSession
* 初始化MediaSession, 注册多媒体按钮
*/
private fun initMediaSession() {
val mComponent = ComponentName(packageName, MediaButtonReceiver::class.java.name)
val mediaButtonIntent = Intent(Intent.ACTION_MEDIA_BUTTON)
mediaButtonIntent.component = mComponent
val mediaButtonIntent = Intent(Intent.ACTION_MEDIA_BUTTON).apply {
component = ComponentName(packageName, MediaButtonReceiver::class.java.name)
}
val mediaButtonReceiverPendingIntent = PendingIntent.getBroadcast(
this, 0,
mediaButtonIntent, PendingIntent.FLAG_CANCEL_CURRENT
this,
0,
mediaButtonIntent,
PendingIntent.FLAG_CANCEL_CURRENT
)
mediaSessionCompat =
MediaSessionCompat(this, tag, mComponent, mediaButtonReceiverPendingIntent)
mediaSessionCompat = MediaSessionCompat(this, tag)
mediaSessionCompat?.setCallback(object : MediaSessionCompat.Callback() {
override fun onMediaButtonEvent(mediaButtonEvent: Intent): Boolean {
return MediaButtonReceiver.handleIntent(this@ReadAloudService, mediaButtonEvent)
}
})
mediaSessionCompat?.setMediaButtonReceiver(mediaButtonReceiverPendingIntent)
mediaSessionCompat?.isActive = true
}
private fun initBroadcastReceiver() {
//断开耳机监听
broadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val action = intent.action
@ -357,9 +360,10 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener,
}
private fun pauseReadAloud(pause: Boolean) {
if (pause) postEvent(Bus.ALOUD_STATE, Status.PAUSE)
postEvent(Bus.ALOUD_STATE, Status.PAUSE)
this.pause = pause
textToSpeech?.stop()
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED)
ReadAloudNotification.upNotification(this)
}
@ -386,14 +390,11 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener,
return request == AudioManager.AUDIOFOCUS_REQUEST_GRANTED
}
private fun upMediaSessionPlaybackState() {
private fun upMediaSessionPlaybackState(state: Int) {
mediaSessionCompat?.setPlaybackState(
PlaybackStateCompat.Builder()
.setActions(MediaHelp.MEDIA_SESSION_ACTIONS)
.setState(
if (speak) PlaybackStateCompat.STATE_PLAYING else PlaybackStateCompat.STATE_PAUSED,
nowSpeak.toLong(), 1f
)
.setState(state, nowSpeak.toLong(), 1f)
.build()
)
}

@ -64,7 +64,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
tool_bar.inflateMenu(R.menu.group_manage)
tool_bar.menu.applyTint(requireContext(), false)
tool_bar.setOnMenuItemClickListener(this)
adapter = GroupAdapter(requireContext(), this)
adapter = GroupAdapter(requireContext())
recycler_view.layoutManager = LinearLayoutManager(requireContext())
recycler_view.addItemDecoration(
DividerItemDecoration(requireContext(), RecyclerView.VERTICAL)
@ -129,14 +129,14 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
}.show().applyTint().requestInputMethod()
}
class GroupAdapter(context: Context, val dialog: GroupManageDialog) :
private inner class GroupAdapter(context: Context) :
SimpleRecyclerAdapter<String>(context, R.layout.item_group_manage) {
override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList<Any>) {
with(holder.itemView) {
tv_group.text = item
tv_edit.onClick { dialog.editGroup(item) }
tv_del.onClick { dialog.viewModel.delGroup(item) }
tv_edit.onClick { editGroup(item) }
tv_del.onClick { viewModel.delGroup(item) }
}
}
}

@ -8,6 +8,7 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.appcompat.widget.SearchView
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
@ -48,6 +49,9 @@ class ChangeSourceDialog : DialogFragment(),
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel.searchStateData.observe(viewLifecycleOwner, Observer {
refresh_progress_bar.isAutoLoading = it
})
arguments?.let { bundle ->
bundle.getString("name")?.let {
viewModel.name = it
@ -141,10 +145,6 @@ class ChangeSourceDialog : DialogFragment(),
return changeSourceAdapter
}
override fun upSearchState(isSearch: Boolean) {
refresh_progress_bar.isAutoLoading = isSearch
}
interface CallBack {
fun curOrigin(): String?
fun oldBook(): Book?

@ -1,6 +1,7 @@
package io.legado.app.ui.changesource
import android.app.Application
import androidx.lifecycle.MutableLiveData
import androidx.recyclerview.widget.DiffUtil
import io.legado.app.App
import io.legado.app.R
@ -17,6 +18,7 @@ import org.jetbrains.anko.debug
class ChangeSourceViewModel(application: Application) : BaseViewModel(application) {
var callBack: CallBack? = null
val searchStateData = MutableLiveData<Boolean>()
var name: String = ""
var author: String = ""
private var task: Coroutine<*>? = null
@ -50,7 +52,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
fun search() {
task = execute {
callBack?.upSearchState(true)
searchStateData.postValue(true)
val bookSourceList = App.db.bookSourceDao().allEnabled
for (item in bookSourceList) {
//task取消时自动取消 by (scope = this@execute)
@ -73,7 +75,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
}
task?.invokeOnCompletion {
callBack?.upSearchState(false)
searchStateData.postValue(false)
}
}
@ -125,6 +127,5 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
interface CallBack {
fun adapter(): ChangeSourceAdapter
fun upSearchState(isSearch: Boolean)
}
}

@ -17,7 +17,8 @@ import kotlinx.android.synthetic.main.item_bookshelf_list.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.sdk27.listeners.onLongClick
class BookshelfAdapter : PagedListAdapter<Book, BookshelfAdapter.MyViewHolder>(DIFF_CALLBACK) {
class BookshelfAdapter(private val callBack: CallBack) :
PagedListAdapter<Book, BookshelfAdapter.MyViewHolder>(DIFF_CALLBACK) {
companion object {
@JvmField
@ -26,16 +27,13 @@ class BookshelfAdapter : PagedListAdapter<Book, BookshelfAdapter.MyViewHolder>(D
oldItem.bookUrl == newItem.bookUrl
override fun areContentsTheSame(oldItem: Book, newItem: Book): Boolean =
oldItem.bookUrl == newItem.bookUrl
&& oldItem.durChapterTitle == newItem.durChapterTitle
oldItem.durChapterTitle == newItem.durChapterTitle
&& oldItem.latestChapterTitle == newItem.latestChapterTitle
&& oldItem.durChapterTime == newItem.durChapterTime
&& oldItem.lastCheckTime == newItem.lastCheckTime
}
}
var callBack: CallBack? = null
fun notification(bookUrl: String) {
for (i in 0..itemCount) {
getItem(i)?.let {
@ -66,7 +64,7 @@ class BookshelfAdapter : PagedListAdapter<Book, BookshelfAdapter.MyViewHolder>(D
itemView.setBackgroundColor(ThemeStore.backgroundColor(itemView.context))
}
fun bind(book: Book, callBack: CallBack?) = with(itemView) {
fun bind(book: Book, callBack: CallBack) = with(itemView) {
this.setBackgroundColor(context.getCompatColor(R.color.background))
tv_name.text = book.name
tv_author.text = book.author
@ -79,21 +77,19 @@ class BookshelfAdapter : PagedListAdapter<Book, BookshelfAdapter.MyViewHolder>(D
.centerCrop()
.setAsDrawable(iv_cover)
}
itemView.onClick { callBack?.open(book) }
itemView.onClick { callBack.open(book) }
itemView.onLongClick {
callBack?.openBookInfo(book)
callBack.openBookInfo(book)
true
}
callBack?.let {
if (book.origin != BookType.local && it.isUpdate(book.bookUrl)) {
bv_unread.invisible()
rl_loading.show()
} else {
rl_loading.hide()
bv_unread.setBadgeCount(book.getUnreadChapterNum())
bv_unread.setHighlight(book.lastCheckCount > 0)
}
} ?: rl_loading.hide()
if (book.origin != BookType.local && callBack.isUpdate(book.bookUrl)) {
bv_unread.invisible()
rl_loading.show()
} else {
rl_loading.hide()
bv_unread.setBadgeCount(book.getUnreadChapterNum())
bv_unread.setHighlight(book.lastCheckCount > 0)
}
}
}

@ -85,9 +85,8 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
LinearLayoutManager.VERTICAL
)
)
bookshelfAdapter = BookshelfAdapter()
bookshelfAdapter = BookshelfAdapter(this)
rv_bookshelf.adapter = bookshelfAdapter
bookshelfAdapter.callBack = this
observeEvent<String>(Bus.UP_BOOK) { bookshelfAdapter.notification(it) }
}

@ -31,31 +31,30 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
fun upChapterList() {
execute {
App.db.bookDao().getRecentRead().map { book ->
App.db.bookDao().getRecentRead().forEach { book ->
if (book.origin != BookType.local) {
val bookSource = App.db.bookSourceDao().getBookSource(book.origin)
bookSource?.let {
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource ->
synchronized(this) {
updateList.add(book.bookUrl)
postEvent(Bus.UP_BOOK, book.bookUrl)
}
WebBook(bookSource).getChapterList(book)
.onSuccess(IO) {
it?.let {
App.db.bookDao().update(book)
App.db.bookChapterDao().delByBook(book.bookUrl)
App.db.bookChapterDao().insert(*it.toTypedArray())
}
it?.let {
App.db.bookDao().update(book)
App.db.bookChapterDao().delByBook(book.bookUrl)
App.db.bookChapterDao().insert(*it.toTypedArray())
}
}
.onError {
it.printStackTrace()
}
.onFinally {
synchronized(this) {
updateList.remove(book.bookUrl)
postEvent(Bus.UP_BOOK, book.bookUrl)
synchronized(this) {
updateList.remove(book.bookUrl)
postEvent(Bus.UP_BOOK, book.bookUrl)
}
}
}
}
}
delay(50)

@ -485,9 +485,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
}
}
override fun onDialogDismissed(dialogId: Int) {
}
/**
* colorSelectDialog
*/
override fun onDialogDismissed(dialogId: Int) = Unit
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)

@ -116,9 +116,7 @@ class PaddingConfigDialog : DialogFragment() {
tv_padding_top.text = paddingTop.toString()
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)
@ -130,9 +128,7 @@ class PaddingConfigDialog : DialogFragment() {
tv_padding_bottom.text = paddingBottom.toString()
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)
@ -144,9 +140,7 @@ class PaddingConfigDialog : DialogFragment() {
tv_padding_left.text = paddingLeft.toString()
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)
@ -158,9 +152,7 @@ class PaddingConfigDialog : DialogFragment() {
tv_padding_right.text = paddingRight.toString()
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)

@ -87,8 +87,7 @@ class ReadAloudDialog : DialogFragment() {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar?) {
requireContext().putPrefInt("ttsSpeechRate", seek_tts_SpeechRate.progress)
@ -101,8 +100,7 @@ class ReadAloudDialog : DialogFragment() {
tv_timer.text = requireContext().getString(R.string.timer_m, progress)
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar?) {
ReadAloudService.setTimer(requireContext(), seek_timer.progress)

@ -71,23 +71,17 @@ class ReadStyleDialog : DialogFragment() {
rg_page_anim.check(rg_page_anim[it].id)
}
}
ReadBookConfig.getConfig().let {
tv_text_bold.isSelected = it.textBold
seek_text_size.progress = it.textSize - 5
tv_text_size.text = it.textSize.toString()
seek_text_letter_spacing.progress = (it.letterSpacing * 10).toInt() + 5
tv_text_letter_spacing.text = it.letterSpacing.toString()
seek_line_size.progress = it.lineSpacingExtra
tv_line_size.text = it.lineSpacingExtra.toString()
}
upStyle()
setBg()
upBg()
}
private fun initOnClick() = with(ReadBookConfig.getConfig()) {
private fun initOnClick() {
tv_text_bold.onClick {
textBold = !textBold
tv_text_bold.isSelected = textBold
with(ReadBookConfig.getConfig()) {
textBold = !textBold
tv_text_bold.isSelected = textBold
}
postEvent(Bus.UP_CONFIG, false)
}
tv_text_font.onClick {
@ -121,73 +115,89 @@ class ReadStyleDialog : DialogFragment() {
}
seek_text_size.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
textSize = progress + 5
tv_text_size.text = textSize.toString()
ReadBookConfig.getConfig().textSize = progress + 5
tv_text_size.text = ReadBookConfig.getConfig().textSize.toString()
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)
}
})
iv_text_size_add.onClick {
textSize++
if (textSize > 50) textSize = 50
seek_text_size.progress = textSize - 5
tv_text_size.text = textSize.toString()
with(ReadBookConfig.getConfig()) {
textSize++
if (textSize > 50) textSize = 50
seek_text_size.progress = textSize - 5
tv_text_size.text = textSize.toString()
}
postEvent(Bus.UP_CONFIG, true)
}
iv_text_size_remove.onClick {
textSize--
if (textSize < 5) textSize = 5
seek_text_size.progress = textSize - 5
tv_text_size.text = textSize.toString()
with(ReadBookConfig.getConfig()) {
textSize--
if (textSize < 5) textSize = 5
seek_text_size.progress = textSize - 5
tv_text_size.text = textSize.toString()
}
postEvent(Bus.UP_CONFIG, true)
}
seek_text_letter_spacing.setOnSeekBarChangeListener(object :
SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
letterSpacing = (seek_text_letter_spacing.progress - 5) / 10f
tv_text_letter_spacing.text = letterSpacing.toString()
with(ReadBookConfig.getConfig()) {
letterSpacing = (seek_text_letter_spacing.progress - 5) / 10f
tv_text_letter_spacing.text = letterSpacing.toString()
}
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)
}
})
iv_text_letter_spacing_add.onClick {
letterSpacing += 0.1f
seek_text_letter_spacing.progress = (letterSpacing * 10).toInt() + 5
tv_text_letter_spacing.text = letterSpacing.toString()
with(ReadBookConfig.getConfig()) {
letterSpacing += 0.1f
seek_text_letter_spacing.progress = (letterSpacing * 10).toInt() + 5
tv_text_letter_spacing.text = letterSpacing.toString()
}
postEvent(Bus.UP_CONFIG, true)
}
iv_text_letter_spacing_remove.onClick {
letterSpacing -= 0.1f
seek_text_letter_spacing.progress = (letterSpacing * 10).toInt() + 5
tv_text_letter_spacing.text = letterSpacing.toString()
with(ReadBookConfig.getConfig()) {
letterSpacing -= 0.1f
seek_text_letter_spacing.progress = (letterSpacing * 10).toInt() + 5
tv_text_letter_spacing.text = letterSpacing.toString()
}
postEvent(Bus.UP_CONFIG, true)
}
seek_line_size.setOnSeekBarChangeListener(object :
SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
lineSpacingExtra = seek_line_size.progress
tv_line_size.text = lineSpacingExtra.toString()
with(ReadBookConfig.getConfig()) {
lineSpacingExtra = seek_line_size.progress
tv_line_size.text = lineSpacingExtra.toString()
}
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar?) {
postEvent(Bus.UP_CONFIG, true)
}
})
iv_line_size_add.onClick {
lineSpacingExtra++
tv_line_size.text = lineSpacingExtra.toString()
with(ReadBookConfig.getConfig()) {
lineSpacingExtra++
tv_line_size.text = lineSpacingExtra.toString()
}
postEvent(Bus.UP_CONFIG, true)
}
iv_line_size_remove.onClick {
lineSpacingExtra--
tv_line_size.text = lineSpacingExtra.toString()
with(ReadBookConfig.getConfig()) {
lineSpacingExtra--
tv_line_size.text = lineSpacingExtra.toString()
}
postEvent(Bus.UP_CONFIG, true)
}
rg_page_anim.onCheckedChange { _, checkedId ->
@ -218,6 +228,7 @@ class ReadStyleDialog : DialogFragment() {
if (ReadBookConfig.styleSelect != index) {
ReadBookConfig.styleSelect = index
ReadBookConfig.upBg()
upStyle()
upBg()
postEvent(Bus.UP_CONFIG, true)
}
@ -233,6 +244,18 @@ class ReadStyleDialog : DialogFragment() {
return true
}
private fun upStyle() {
ReadBookConfig.getConfig().let {
tv_text_bold.isSelected = it.textBold
seek_text_size.progress = it.textSize - 5
tv_text_size.text = it.textSize.toString()
seek_text_letter_spacing.progress = (it.letterSpacing * 10).toInt() + 5
tv_text_letter_spacing.text = it.letterSpacing.toString()
seek_line_size.progress = it.lineSpacingExtra
tv_line_size.text = it.lineSpacingExtra.toString()
}
}
private fun setBg() {
tv_bg0.setTextColor(ReadBookConfig.getConfig(0).textColor())
tv_bg1.setTextColor(ReadBookConfig.getConfig(1).textColor())

@ -64,7 +64,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
tool_bar.inflateMenu(R.menu.group_manage)
tool_bar.menu.applyTint(requireContext(), false)
tool_bar.setOnMenuItemClickListener(this)
adapter = GroupAdapter(requireContext(), this)
adapter = GroupAdapter(requireContext())
recycler_view.layoutManager = LinearLayoutManager(requireContext())
recycler_view.addItemDecoration(
DividerItemDecoration(requireContext(), RecyclerView.VERTICAL)
@ -129,14 +129,14 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
}.show().applyTint().requestInputMethod()
}
class GroupAdapter(context: Context, val dialog: GroupManageDialog) :
private inner class GroupAdapter(context: Context) :
SimpleRecyclerAdapter<String>(context, R.layout.item_group_manage) {
override fun convert(holder: ItemViewHolder, item: String, payloads: MutableList<Any>) {
with(holder.itemView) {
tv_group.text = item
tv_edit.onClick { dialog.editGroup(item) }
tv_del.onClick { dialog.viewModel.delGroup(item) }
tv_edit.onClick { editGroup(item) }
tv_del.onClick { viewModel.delGroup(item) }
}
}
}

@ -16,23 +16,24 @@
app:layout_constraintTop_toTopOf="parent"
app:title="搜索"/>
<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.dynamiclayout.DynamicFrameLayout
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/title_bar">
app:layout_constraintTop_toBottomOf="@id/refresh_progress_bar">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<io.legado.app.ui.widget.anima.RefreshProgressBar
android:id="@+id/refresh_progress_bar"
android:layout_width="match_parent"
android:layout_height="2dp" />
</io.legado.app.ui.widget.dynamiclayout.DynamicFrameLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton

Loading…
Cancel
Save