pull/66/head
kunfei 5 years ago
parent 572c5957a2
commit c2df639f94
  1. 15
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  2. 10
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt

@ -20,17 +20,14 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.book.read.Help import io.legado.app.ui.book.read.Help
import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.widget.font.FontSelectDialog import io.legado.app.ui.widget.font.FontSelectDialog
import io.legado.app.utils.getPrefInt import io.legado.app.utils.*
import io.legado.app.utils.postEvent
import io.legado.app.utils.progressAdd
import io.legado.app.utils.putPrefInt
import kotlinx.android.synthetic.main.activity_book_read.* import kotlinx.android.synthetic.main.activity_book_read.*
import kotlinx.android.synthetic.main.dialog_read_book_style.* import kotlinx.android.synthetic.main.dialog_read_book_style.*
import org.jetbrains.anko.sdk27.listeners.onCheckedChange import org.jetbrains.anko.sdk27.listeners.onCheckedChange
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.sdk27.listeners.onLongClick import org.jetbrains.anko.sdk27.listeners.onLongClick
class ReadStyleDialog : DialogFragment() { class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack {
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -263,4 +260,12 @@ class ReadStyleDialog : DialogFragment() {
else -> bg0.borderColor = requireContext().accentColor else -> bg0.borderColor = requireContext().accentColor
} }
} }
override val curFontPath: String
get() = requireContext().getPrefString(PreferKey.readBookFont) ?: ""
override fun selectFile(path: String) {
requireContext().putPrefString(PreferKey.readBookFont, path)
postEvent(Bus.UP_CONFIG, true)
}
} }

@ -141,13 +141,13 @@ class FontSelectDialog : DialogFragment(),
file.absolutePath.let { file.absolutePath.let {
val pf = parentFragment val pf = parentFragment
if (pf is CallBack) { if (pf is CallBack) {
if (it != pf.curPath) { if (it != pf.curFontPath) {
pf.selectFile(it) pf.selectFile(it)
} }
} }
val activity = activity val activity = activity
if (activity is CallBack) { if (activity is CallBack) {
if (it != activity.curPath) { if (it != activity.curFontPath) {
activity.selectFile(it) activity.selectFile(it)
} }
} }
@ -158,11 +158,11 @@ class FontSelectDialog : DialogFragment(),
override fun curFilePath(): String { override fun curFilePath(): String {
val pf = parentFragment val pf = parentFragment
if (pf is CallBack) { if (pf is CallBack) {
return pf.curPath return pf.curFontPath
} }
val activity = activity val activity = activity
if (activity is CallBack) { if (activity is CallBack) {
return activity.curPath return activity.curFontPath
} }
return "" return ""
} }
@ -185,6 +185,6 @@ class FontSelectDialog : DialogFragment(),
interface CallBack { interface CallBack {
fun selectFile(path: String) fun selectFile(path: String)
val curPath: String val curFontPath: String
} }
} }
Loading…
Cancel
Save