From 57f488b35363c57f6d4b01d2116b347c2313635f Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 30 Aug 2019 18:20:02 +0800 Subject: [PATCH] up --- .../app/ui/readbook/ReadBookActivity.kt | 9 ++- .../ui/readbook/config/BgTextConfigDiolog.kt | 6 +- .../app/ui/readbook/config/ReadStyleDialog.kt | 28 +++++++ .../main/res/layout/dialog_read_bg_text.xml | 76 ++++++++++++++++++- 4 files changed, 113 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index 46944a4ea..02f3bdfa6 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -27,10 +27,7 @@ import io.legado.app.receiver.TimeElectricityReceiver import io.legado.app.service.ReadAloudService import io.legado.app.ui.changesource.ChangeSourceDialog import io.legado.app.ui.chapterlist.ChapterListActivity -import io.legado.app.ui.readbook.config.MoreConfigDialog -import io.legado.app.ui.readbook.config.PaddingConfigDialog -import io.legado.app.ui.readbook.config.ReadAloudDialog -import io.legado.app.ui.readbook.config.ReadStyleDialog +import io.legado.app.ui.readbook.config.* import io.legado.app.ui.replacerule.ReplaceRuleActivity import io.legado.app.ui.sourceedit.SourceEditActivity import io.legado.app.ui.widget.page.ChapterProvider @@ -179,6 +176,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea PaddingConfigDialog().show(supportFragmentManager, "paddingConfig") } + fun showBgTextConfig() { + BgTextConfigDiolog().show(supportFragmentManager, "bgTextConfig") + } + override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.read_book, menu) return super.onCompatCreateOptionsMenu(menu) diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDiolog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDiolog.kt index 89feb7a7b..63923a093 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDiolog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDiolog.kt @@ -17,7 +17,7 @@ class BgTextConfigDiolog : DialogFragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View? { - return super.onCreateView(inflater, container, savedInstanceState) + return inflater.inflate(R.layout.dialog_read_bg_text, container) } override fun onStart() { @@ -38,6 +38,10 @@ class BgTextConfigDiolog : DialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + initData() } + private fun initData() { + + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt index 758e87fb5..82a633dd4 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt @@ -24,6 +24,7 @@ import kotlinx.android.synthetic.main.activity_read_book.* import kotlinx.android.synthetic.main.dialog_read_book_style.* import org.jetbrains.anko.sdk27.listeners.onCheckedChange import org.jetbrains.anko.sdk27.listeners.onClick +import org.jetbrains.anko.sdk27.listeners.onLongClick class ReadStyleDialog : DialogFragment() { @@ -205,30 +206,57 @@ class ReadStyleDialog : DialogFragment() { upBg() postEvent(Bus.UP_CONFIG, true) } + tv_bg0.onLongClick { + showBgTextConfig() + false + } tv_bg1.onClick { ReadBookConfig.styleSelect = 1 ReadBookConfig.upBg() upBg() postEvent(Bus.UP_CONFIG, true) } + tv_bg1.onLongClick { + showBgTextConfig() + false + } tv_bg2.onClick { ReadBookConfig.styleSelect = 2 ReadBookConfig.upBg() upBg() postEvent(Bus.UP_CONFIG, true) } + tv_bg2.onLongClick { + showBgTextConfig() + false + } tv_bg3.onClick { ReadBookConfig.styleSelect = 3 ReadBookConfig.upBg() upBg() postEvent(Bus.UP_CONFIG, true) } + tv_bg3.onLongClick { + showBgTextConfig() + false + } tv_bg4.onClick { ReadBookConfig.styleSelect = 4 ReadBookConfig.upBg() upBg() postEvent(Bus.UP_CONFIG, true) } + tv_bg4.onLongClick { + showBgTextConfig() + false + } + } + + private fun showBgTextConfig() { + val activity = activity + if (activity is ReadBookActivity) { + activity.showBgTextConfig() + } } private fun setBg() { diff --git a/app/src/main/res/layout/dialog_read_bg_text.xml b/app/src/main/res/layout/dialog_read_bg_text.xml index 1faa34fc2..b1fb23a81 100644 --- a/app/src/main/res/layout/dialog_read_bg_text.xml +++ b/app/src/main/res/layout/dialog_read_bg_text.xml @@ -1,12 +1,86 @@ + android:layout_height="match_parent" + android:padding="10dp"> + + + + + + + + + + + + + + + + + + \ No newline at end of file