pull/457/head
gedoor 4 years ago
parent 05d2afaaed
commit 587b763675
  1. 1
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  2. 4
      app/src/main/java/io/legado/app/lib/dialogs/AndroidDialogs.kt
  3. 2
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  4. 24
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  6. 21
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  7. 15
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  8. 15
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  9. 2
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt
  10. 32
      app/src/main/res/layout/dialog_read_bg_text.xml
  11. 1
      app/src/main/res/values-zh-rHK/strings.xml
  12. 1
      app/src/main/res/values-zh-rTW/strings.xml
  13. 1
      app/src/main/res/values-zh/strings.xml
  14. 1
      app/src/main/res/values/strings.xml

@ -359,6 +359,7 @@ object ReadBookConfig {
@Keep @Keep
@Parcelize @Parcelize
class Config( class Config(
var name: String = "",
var bgStr: String = "#EEEEEE",//白天背景 var bgStr: String = "#EEEEEE",//白天背景
var bgStrNight: String = "#000000",//夜间背景 var bgStrNight: String = "#000000",//夜间背景
var bgStrEInk: String = "#FFFFFF", var bgStrEInk: String = "#FFFFFF",

@ -48,10 +48,10 @@ fun Context.alert(
} }
inline fun Fragment.alert( inline fun Fragment.alert(
title: Int? = null, titleResource: Int? = null,
message: Int? = null, message: Int? = null,
noinline init: (AlertBuilder<DialogInterface>.() -> Unit)? = null noinline init: (AlertBuilder<DialogInterface>.() -> Unit)? = null
) = requireActivity().alert(title, message, init) ) = requireActivity().alert(titleResource, message, init)
fun Context.alert( fun Context.alert(
titleResource: Int? = null, titleResource: Int? = null,

@ -73,7 +73,7 @@ class AboutFragment : PreferenceFragmentCompat() {
} }
private fun showQqGroups() { private fun showQqGroups() {
alert(title = R.string.join_qq_group) { alert(titleResource = R.string.join_qq_group) {
val names = arrayListOf<String>() val names = arrayListOf<String>()
qqGroups.forEach { qqGroups.forEach {
names.add(it.key) names.add(it.key)

@ -17,10 +17,7 @@ import io.legado.app.help.ReadBookConfig
import io.legado.app.help.http.HttpHelper import io.legado.app.help.http.HttpHelper
import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.*
import io.legado.app.lib.dialogs.customView
import io.legado.app.lib.dialogs.noButton
import io.legado.app.lib.dialogs.okButton
import io.legado.app.lib.theme.bottomBackground import io.legado.app.lib.theme.bottomBackground
import io.legado.app.lib.theme.getPrimaryTextColor import io.legado.app.lib.theme.getPrimaryTextColor
import io.legado.app.lib.theme.getSecondaryTextColor import io.legado.app.lib.theme.getSecondaryTextColor
@ -99,6 +96,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun initData() = with(ReadBookConfig.durConfig) { private fun initData() = with(ReadBookConfig.durConfig) {
tv_name.text = name.ifBlank { "文字" }
sw_dark_status_icon.isChecked = curStatusIconDark() sw_dark_status_icon.isChecked = curStatusIconDark()
adapter = BgAdapter(requireContext(), secondaryTextColor) adapter = BgAdapter(requireContext(), secondaryTextColor)
recycler_view.adapter = adapter recycler_view.adapter = adapter
@ -115,7 +113,25 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
} }
} }
@SuppressLint("InflateParams")
private fun initEvent() = with(ReadBookConfig.durConfig) { private fun initEvent() = with(ReadBookConfig.durConfig) {
iv_edit.onClick {
alert(R.string.style_name) {
var editText: AutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
editText = edit_view
}
}
okButton {
editText?.text?.toString()?.let {
tv_name.text = it
ReadBookConfig.durConfig.name = it
}
}
cancelButton()
}
}
sw_dark_status_icon.onCheckedChange { buttonView, isChecked -> sw_dark_status_icon.onCheckedChange { buttonView, isChecked ->
if (buttonView?.isPressed == true) { if (buttonView?.isPressed == true) {
setCurStatusIconDark(isChecked) setCurStatusIconDark(isChecked)

@ -165,7 +165,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun showTitleConfig() = ReadBookConfig.apply { private fun showTitleConfig() = ReadBookConfig.apply {
requireContext().alert(R.string.title) { alert(R.string.title) {
val rootView = LayoutInflater.from(requireContext()) val rootView = LayoutInflater.from(requireContext())
.inflate(R.layout.dialog_title_config, null).apply { .inflate(R.layout.dialog_title_config, null).apply {
rg_title_mode.checkByIndex(titleMode) rg_title_mode.checkByIndex(titleMode)

@ -176,18 +176,17 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun addBookByUrl() { private fun addBookByUrl() {
requireContext() alert(titleResource = R.string.add_book_url) {
.alert(titleResource = R.string.add_book_url) { var editText: AutoCompleteTextView? = null
var editText: AutoCompleteTextView? = null customView {
customView { layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply { editText = edit_view
editText = edit_view }
} }
okButton {
editText?.text?.toString()?.let {
viewModel.addBookByUrl(it)
} }
okButton {
editText?.text?.toString()?.let {
viewModel.addBookByUrl(it)
}
} }
noButton { } noButton { }
}.show().applyTint() }.show().applyTint()

@ -125,16 +125,19 @@ class ReplaceRuleActivity :
} }
override fun onClickMainAction() { override fun onClickMainAction() {
this@ReplaceRuleActivity delSourceDialog()
.alert(titleResource = R.string.draw, messageResource = R.string.sure_del) {
okButton { viewModel.delSelection(adapter.getSelection()) }
noButton { }
}
.show().applyTint()
} }
}) })
} }
private fun delSourceDialog() {
alert(titleResource = R.string.draw, messageResource = R.string.sure_del) {
okButton { viewModel.delSelection(adapter.getSelection()) }
noButton { }
}
.show().applyTint()
}
private fun observeReplaceRuleData(key: String? = null) { private fun observeReplaceRuleData(key: String? = null) {
dataInit = false dataInit = false
replaceRuleLiveData?.removeObservers(this) replaceRuleLiveData?.removeObservers(this)

@ -171,16 +171,19 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
} }
override fun onClickMainAction() { override fun onClickMainAction() {
this@RssSourceActivity delSourceDialog()
.alert(titleResource = R.string.draw, messageResource = R.string.sure_del) {
okButton { viewModel.delSelection(adapter.getSelection()) }
noButton { }
}
.show().applyTint()
} }
}) })
} }
private fun delSourceDialog() {
alert(titleResource = R.string.draw, messageResource = R.string.sure_del) {
okButton { viewModel.delSelection(adapter.getSelection()) }
noButton { }
}
.show().applyTint()
}
private fun upGroupMenu() { private fun upGroupMenu() {
groupMenu?.removeGroup(R.id.source_group) groupMenu?.removeGroup(R.id.source_group)
groups.sortedWith(Collator.getInstance(Locale.CHINESE)) groups.sortedWith(Collator.getInstance(Locale.CHINESE))

@ -87,7 +87,7 @@ class FontSelectDialog : BaseDialogFragment(),
when (item?.itemId) { when (item?.itemId) {
R.id.menu_default -> { R.id.menu_default -> {
val requireContext = requireContext() val requireContext = requireContext()
requireContext.alert(titleResource = R.string.system_typeface) { alert(titleResource = R.string.system_typeface) {
items( items(
requireContext.resources.getStringArray(R.array.system_typefaces).toList() requireContext.resources.getStringArray(R.array.system_typefaces).toList()
) { _, i -> ) { _, i ->

@ -9,6 +9,38 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="10dp"> android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/style_name"
android:textColor="@color/primaryText"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:textColor="@color/secondaryText"
tools:text="文字" />
<ImageView
android:id="@+id/iv_edit"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_edit"
app:tint="@color/secondaryText"
android:contentDescription="@string/edit" />
</LinearLayout>
<io.legado.app.lib.theme.view.ATESwitch <io.legado.app.lib.theme.view.ATESwitch
android:id="@+id/sw_dark_status_icon" android:id="@+id/sw_dark_status_icon"
android:layout_width="match_parent" android:layout_width="match_parent"

@ -774,5 +774,6 @@
<string name="auto_clear_expired">自动清除过期搜索数据</string> <string name="auto_clear_expired">自动清除过期搜索数据</string>
<string name="auto_clear_expired_summary">超过一天的搜索数据</string> <string name="auto_clear_expired_summary">超过一天的搜索数据</string>
<string name="re_segment">重新分段</string> <string name="re_segment">重新分段</string>
<string name="style_name">样式名称:</string>
</resources> </resources>

@ -774,5 +774,6 @@
<string name="auto_clear_expired">自动清除过期搜索数据</string> <string name="auto_clear_expired">自动清除过期搜索数据</string>
<string name="auto_clear_expired_summary">超过一天的搜索数据</string> <string name="auto_clear_expired_summary">超过一天的搜索数据</string>
<string name="re_segment">重新分段</string> <string name="re_segment">重新分段</string>
<string name="style_name">样式名称:</string>
</resources> </resources>

@ -777,5 +777,6 @@
<string name="auto_clear_expired">自动清除过期搜索数据</string> <string name="auto_clear_expired">自动清除过期搜索数据</string>
<string name="auto_clear_expired_summary">超过一天的搜索数据</string> <string name="auto_clear_expired_summary">超过一天的搜索数据</string>
<string name="re_segment">重新分段</string> <string name="re_segment">重新分段</string>
<string name="style_name">样式名称:</string>
</resources> </resources>

@ -780,5 +780,6 @@
<string name="auto_clear_expired">自动清除过期搜索数据</string> <string name="auto_clear_expired">自动清除过期搜索数据</string>
<string name="auto_clear_expired_summary">超过一天的搜索数据</string> <string name="auto_clear_expired_summary">超过一天的搜索数据</string>
<string name="re_segment">重新分段</string> <string name="re_segment">重新分段</string>
<string name="style_name">样式名称:</string>
</resources> </resources>

Loading…
Cancel
Save