按键设置添加重置按钮

pull/1062/head
gedoor 3 years ago
parent 47106522bc
commit 0e79e92c84
  1. 19
      app/src/main/java/io/legado/app/ui/book/read/config/PageKeyDialog.kt
  2. 8
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt
  3. 31
      app/src/main/res/layout/dialog_page_key.xml
  4. 1
      app/src/main/res/values-ja-rJP/strings.xml
  5. 1
      app/src/main/res/values-pt-rBR/strings.xml
  6. 1
      app/src/main/res/values-zh-rHK/strings.xml
  7. 1
      app/src/main/res/values-zh-rTW/strings.xml
  8. 1
      app/src/main/res/values-zh/strings.xml
  9. 1
      app/src/main/res/values/strings.xml

@ -10,6 +10,7 @@ import io.legado.app.lib.theme.backgroundColor
import io.legado.app.utils.getPrefString
import io.legado.app.utils.hideSoftInput
import io.legado.app.utils.putPrefString
import splitties.views.onClick
class PageKeyDialog(context: Context) : Dialog(context, R.style.AppTheme_AlertDialog) {
@ -18,15 +19,21 @@ class PageKeyDialog(context: Context) : Dialog(context, R.style.AppTheme_AlertDi
init {
setContentView(binding.root)
binding.contentView.setBackgroundColor(context.backgroundColor)
binding.etPrev.setText(context.getPrefString(PreferKey.prevKeys))
binding.etNext.setText(context.getPrefString(PreferKey.nextKeys))
binding.tvOk.setOnClickListener {
context.putPrefString(PreferKey.prevKeys, binding.etPrev.text?.toString())
context.putPrefString(PreferKey.nextKeys, binding.etNext.text?.toString())
binding.run {
contentView.setBackgroundColor(context.backgroundColor)
etPrev.setText(context.getPrefString(PreferKey.prevKeys))
etNext.setText(context.getPrefString(PreferKey.nextKeys))
tvReset.onClick {
etPrev.setText("")
etNext.setText("")
}
tvOk.setOnClickListener {
context.putPrefString(PreferKey.prevKeys, etPrev.text?.toString())
context.putPrefString(PreferKey.nextKeys, etNext.text?.toString())
dismiss()
}
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
if (keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_DEL) {

@ -121,11 +121,9 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
bookGroupLiveData?.removeObservers(this)
bookGroupLiveData = appDb.bookGroupDao.liveDataShow().apply {
observe(viewLifecycleOwner) {
if (it.size != bookGroups.size) {
if (it != bookGroups) {
bookGroups = it
booksAdapter.notifyDataSetChanged()
} else {
}
}
}
@ -183,7 +181,8 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
override fun onItemClick(position: Int) {
if (position < bookGroups.size) {
val bookGroup = bookGroups[position]
groupId = bookGroup.groupId
initBooksData()
} else {
val book = books[position - bookGroups.size]
when (book.type) {
@ -200,6 +199,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
override fun onItemLongClick(position: Int) {
if (position < bookGroups.size) {
val bookGroup = bookGroups[position]
} else {
val book = books[position - bookGroups.size]

@ -51,11 +51,35 @@
android:textColor="@color/secondaryText"
android:text="@string/page_key_set_help" />
<TextView
android:id="@+id/tv_ok"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_reset"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector_fillet_btn_bg"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:text="@string/reset"
android:textColor="@color/primaryText" />
<Space
android:layout_width="3dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_ok"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/selector_fillet_btn_bg"
android:clickable="true"
android:focusable="true"
@ -64,4 +88,7 @@
android:paddingBottom="5dp"
android:text="@string/ok"
android:textColor="@color/primaryText" />
</LinearLayout>
</LinearLayout>

@ -844,4 +844,5 @@
<string name="style">样式</string>
<string name="group_style">分组样式</string>
<string name="export_file_name">导出文件名</string>
<string name="reset">重置</string>
</resources>

@ -844,4 +844,5 @@
<string name="style">Formato</string>
<string name="group_style">Formato de grupo</string>
<string name="export_file_name">Exportar o nome do arquivo</string>
<string name="reset">重置</string>
</resources>

@ -842,5 +842,6 @@
<string name="style">样式</string>
<string name="group_style">分组样式</string>
<string name="export_file_name">导出文件名</string>
<string name="reset">重置</string>
</resources>

@ -843,5 +843,6 @@
<string name="style">样式</string>
<string name="group_style">分组样式</string>
<string name="export_file_name">导出文件名</string>
<string name="reset">重置</string>
</resources>

@ -843,5 +843,6 @@
<string name="style">样式</string>
<string name="group_style">分组样式</string>
<string name="export_file_name">导出文件名</string>
<string name="reset">重置</string>
</resources>

@ -844,5 +844,6 @@
<string name="style">Style</string>
<string name="group_style">Group style</string>
<string name="export_file_name">Export file name</string>
<string name="reset">Reset</string>
</resources>

Loading…
Cancel
Save