This commit is contained in:
Horis
2025-01-06 18:29:59 +08:00
parent 9bf7db4b55
commit 30c3a62eaa
9 changed files with 33 additions and 11 deletions

View File

@@ -21,6 +21,7 @@ import io.legado.app.utils.ArchiveUtils
import io.legado.app.utils.FileDoc
import io.legado.app.utils.applyTint
import io.legado.app.utils.hideSoftInput
import io.legado.app.utils.shouldHideSoftInput
import io.legado.app.utils.startActivity
import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding
@@ -51,7 +52,7 @@ abstract class BaseImportBookActivity<VM : ViewModel> : VMBaseActivity<ActivityI
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_DOWN) {
currentFocus?.let {
if (it is EditText) {
if (it.shouldHideSoftInput(ev)) {
it.clearFocus()
it.hideSoftInput()
}

View File

@@ -6,6 +6,7 @@ import android.net.Uri
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.MotionEvent
import android.widget.CheckBox
import android.widget.LinearLayout
import androidx.activity.result.contract.ActivityResultContracts
@@ -285,6 +286,17 @@ class BookInfoActivity :
}
}
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_DOWN) {
currentFocus?.let {
if (it === binding.tvIntro) {
it.clearFocus()
}
}
}
return super.dispatchTouchEvent(ev)
}
private fun refreshBook() {
upLoading(true)
viewModel.getBook()?.let {
@@ -485,6 +497,9 @@ class BookInfoActivity :
refreshLayout.isRefreshing = false
refreshBook()
}
refreshLayout?.setOnChildScrollUpCallback { _, _ ->
tvIntro.hasSelection()
}
}
private fun setSourceVariable() {
@@ -517,8 +532,9 @@ class BookInfoActivity :
}
val book = viewModel.getBook() ?: return@launch
val variable = withContext(IO) { book.getCustomVariable() }
val comment =
source.getDisplayVariableComment("""书籍变量可在js中通过book.getVariable("custom")获取""")
val comment = source.getDisplayVariableComment(
"""书籍变量可在js中通过book.getVariable("custom")获取"""
)
showDialogFragment(
VariableDialog(
getString(R.string.set_book_variable),

View File

@@ -47,6 +47,7 @@ import io.legado.app.utils.hideSoftInput
import io.legado.app.utils.isAbsUrl
import io.legado.app.utils.sendToClip
import io.legado.app.utils.setEdgeEffectColor
import io.legado.app.utils.shouldHideSoftInput
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.startActivity
import io.legado.app.utils.viewbindingdelegate.viewBinding
@@ -122,7 +123,7 @@ class BookshelfManageActivity :
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_DOWN) {
currentFocus?.let {
if (it is EditText) {
if (it.shouldHideSoftInput(ev)) {
it.clearFocus()
it.hideSoftInput()
}

View File

@@ -107,6 +107,7 @@ class SearchContentActivity :
if (ev.action == MotionEvent.ACTION_DOWN) {
currentFocus?.let {
if (it.shouldHideSoftInput(ev)) {
it.clearFocus()
it.hideSoftInput()
}
}

View File

@@ -62,6 +62,7 @@ import io.legado.app.utils.observeEvent
import io.legado.app.utils.sendToClip
import io.legado.app.utils.setEdgeEffectColor
import io.legado.app.utils.share
import io.legado.app.utils.shouldHideSoftInput
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.showHelp
import io.legado.app.utils.splitNotBlank
@@ -161,7 +162,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_DOWN) {
currentFocus?.let {
if (it is EditText) {
if (it.shouldHideSoftInput(ev)) {
it.clearFocus()
it.hideSoftInput()
}

View File

@@ -7,7 +7,6 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.MotionEvent
import android.widget.EditText
import androidx.activity.viewModels
import androidx.appcompat.widget.SearchView
import androidx.fragment.app.Fragment
@@ -30,6 +29,7 @@ import io.legado.app.ui.widget.dialog.WaitDialog
import io.legado.app.utils.applyTint
import io.legado.app.utils.gone
import io.legado.app.utils.hideSoftInput
import io.legado.app.utils.shouldHideSoftInput
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible
@@ -74,7 +74,7 @@ class TocActivity : VMBaseActivity<ActivityChapterListBinding, TocViewModel>(),
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_DOWN) {
currentFocus?.let {
if (it is EditText) {
if (it.shouldHideSoftInput(ev)) {
it.hideSoftInput()
}
}

View File

@@ -7,7 +7,6 @@ import android.text.format.DateUtils
import android.view.MenuItem
import android.view.MotionEvent
import android.view.ViewGroup
import android.widget.EditText
import androidx.activity.addCallback
import androidx.activity.viewModels
import androidx.core.view.ViewCompat
@@ -49,6 +48,7 @@ import io.legado.app.utils.isCreated
import io.legado.app.utils.navigationBarHeight
import io.legado.app.utils.observeEvent
import io.legado.app.utils.setEdgeEffectColor
import io.legado.app.utils.shouldHideSoftInput
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding
@@ -119,7 +119,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_DOWN) {
currentFocus?.let {
if (it is EditText) {
if (it.shouldHideSoftInput(ev)) {
it.clearFocus()
it.hideSoftInput()
}

View File

@@ -45,6 +45,7 @@ import io.legado.app.utils.launch
import io.legado.app.utils.readText
import io.legado.app.utils.sendToClip
import io.legado.app.utils.setEdgeEffectColor
import io.legado.app.utils.shouldHideSoftInput
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.showHelp
import io.legado.app.utils.splitNotBlank
@@ -129,7 +130,7 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_DOWN) {
currentFocus?.let {
if (it is EditText) {
if (it.shouldHideSoftInput(ev)) {
it.clearFocus()
it.hideSoftInput()
}

View File

@@ -42,6 +42,7 @@ import io.legado.app.utils.readText
import io.legado.app.utils.sendToClip
import io.legado.app.utils.setEdgeEffectColor
import io.legado.app.utils.share
import io.legado.app.utils.shouldHideSoftInput
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.showHelp
import io.legado.app.utils.splitNotBlank
@@ -120,7 +121,7 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_DOWN) {
currentFocus?.let {
if (it is EditText) {
if (it.shouldHideSoftInput(ev)) {
it.clearFocus()
it.hideSoftInput()
}