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. 3
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt
  7. 11
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  8. 11
      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
@Parcelize
class Config(
var name: String = "",
var bgStr: String = "#EEEEEE",//白天背景
var bgStrNight: String = "#000000",//夜间背景
var bgStrEInk: String = "#FFFFFF",

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

@ -73,7 +73,7 @@ class AboutFragment : PreferenceFragmentCompat() {
}
private fun showQqGroups() {
alert(title = R.string.join_qq_group) {
alert(titleResource = R.string.join_qq_group) {
val names = arrayListOf<String>()
qqGroups.forEach {
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.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.lib.dialogs.alert
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.dialogs.*
import io.legado.app.lib.theme.bottomBackground
import io.legado.app.lib.theme.getPrimaryTextColor
import io.legado.app.lib.theme.getSecondaryTextColor
@ -99,6 +96,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
@SuppressLint("InflateParams")
private fun initData() = with(ReadBookConfig.durConfig) {
tv_name.text = name.ifBlank { "文字" }
sw_dark_status_icon.isChecked = curStatusIconDark()
adapter = BgAdapter(requireContext(), secondaryTextColor)
recycler_view.adapter = adapter
@ -115,7 +113,25 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
}
}
@SuppressLint("InflateParams")
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 ->
if (buttonView?.isPressed == true) {
setCurStatusIconDark(isChecked)

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

@ -176,8 +176,7 @@ class BookshelfFragment : VMBaseFragment<BookshelfViewModel>(R.layout.fragment_b
@SuppressLint("InflateParams")
private fun addBookByUrl() {
requireContext()
.alert(titleResource = R.string.add_book_url) {
alert(titleResource = R.string.add_book_url) {
var editText: AutoCompleteTextView? = null
customView {
layoutInflater.inflate(R.layout.dialog_edit_text, null).apply {

@ -125,15 +125,18 @@ class ReplaceRuleActivity :
}
override fun onClickMainAction() {
this@ReplaceRuleActivity
.alert(titleResource = R.string.draw, messageResource = R.string.sure_del) {
delSourceDialog()
}
})
}
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) {
dataInit = false

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

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

@ -9,6 +9,38 @@
android:orientation="vertical"
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
android:id="@+id/sw_dark_status_icon"
android:layout_width="match_parent"

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

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

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

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

Loading…
Cancel
Save