mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -167,7 +167,7 @@
|
||||
android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden" />
|
||||
<!-- 书源编辑 -->
|
||||
<!-- 替换规则编辑 -->
|
||||
<activity
|
||||
android:name=".ui.replace.edit.ReplaceEditActivity"
|
||||
android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"
|
||||
|
||||
@@ -23,10 +23,7 @@ import io.legado.app.lib.theme.primaryColor
|
||||
import io.legado.app.lib.theme.primaryTextColor
|
||||
import io.legado.app.ui.book.explore.ExploreShowActivity
|
||||
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
|
||||
import io.legado.app.utils.applyTint
|
||||
import io.legado.app.utils.cnCompare
|
||||
import io.legado.app.utils.setEdgeEffectColor
|
||||
import io.legado.app.utils.startActivity
|
||||
import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
@@ -51,6 +48,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
|
||||
private val groups = linkedSetOf<String>()
|
||||
private var exploreFlowJob: Job? = null
|
||||
private var groupsMenu: SubMenu? = null
|
||||
private val softKeyBoardChangeListener = SoftKeyBoardChangeListener()
|
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||
setSupportToolbar(binding.titleBar.toolbar)
|
||||
@@ -58,6 +56,14 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
|
||||
initRecyclerView()
|
||||
initGroupData()
|
||||
upExploreData()
|
||||
softKeyBoardChangeListener.attach(requireActivity().window) {
|
||||
binding.root.setPaddingBottom(softKeyBoardChangeListener.keyBoardHeight)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
softKeyBoardChangeListener.unAttach()
|
||||
}
|
||||
|
||||
override fun onCompatCreateOptionsMenu(menu: Menu) {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package io.legado.app.utils
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.view.ViewTreeObserver
|
||||
import android.view.Window
|
||||
import splitties.systemservices.windowManager
|
||||
import kotlin.math.abs
|
||||
|
||||
class SoftKeyBoardChangeListener : ViewTreeObserver.OnGlobalLayoutListener {
|
||||
|
||||
private var window: Window? = null
|
||||
private var softKeyBoardChangeCallback: ((Boolean) -> Unit)? = null
|
||||
var keyBoardShowing = false
|
||||
private set
|
||||
var keyBoardHeight = 0
|
||||
|
||||
fun attach(window: Window, callback: ((Boolean) -> Unit)) {
|
||||
this.window = window
|
||||
window.decorView.viewTreeObserver.addOnGlobalLayoutListener(this)
|
||||
softKeyBoardChangeCallback = callback
|
||||
}
|
||||
|
||||
fun unAttach() {
|
||||
window?.decorView?.viewTreeObserver?.removeOnGlobalLayoutListener(this)
|
||||
window = null
|
||||
}
|
||||
|
||||
override fun onGlobalLayout() {
|
||||
window?.let {
|
||||
val rect = Rect()
|
||||
// 获取当前页面窗口的显示范围
|
||||
it.decorView.getWindowVisibleDisplayFrame(rect)
|
||||
val screenHeight = windowManager.windowSize.heightPixels
|
||||
val keyboardHeight = screenHeight - rect.bottom // 输入法的高度
|
||||
if (abs(keyboardHeight) > screenHeight / 5) {
|
||||
keyBoardShowing = true // 超过屏幕五分之一则表示弹出了输入法
|
||||
this.keyBoardHeight = abs(keyboardHeight)
|
||||
softKeyBoardChangeCallback?.invoke(true)
|
||||
} else {
|
||||
keyBoardShowing = false
|
||||
this.keyBoardHeight = 0
|
||||
softKeyBoardChangeCallback?.invoke(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -140,6 +140,10 @@ fun View.screenshot(): Bitmap? {
|
||||
}
|
||||
}
|
||||
|
||||
fun View.setPaddingBottom(bottom: Int) {
|
||||
setPadding(paddingLeft, paddingTop, paddingRight, bottom)
|
||||
}
|
||||
|
||||
fun SeekBar.progressAdd(int: Int) {
|
||||
progress += int
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user