优化
This commit is contained in:
@@ -128,6 +128,7 @@ object PreferKey {
|
||||
const val showLastUpdateTime = "showLastUpdateTime"
|
||||
const val clearWebViewData = "clearWebViewData"
|
||||
const val onlyLatestBackup = "onlyLatestBackup"
|
||||
const val brightnessVwPos = "brightnessVwPos"
|
||||
|
||||
const val cPrimary = "colorPrimary"
|
||||
const val cAccent = "colorAccent"
|
||||
|
||||
@@ -451,6 +451,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
appCtx.putPrefBoolean(PreferKey.audioPlayWakeLock, value)
|
||||
}
|
||||
|
||||
var brightnessVwPos: Boolean
|
||||
get() = appCtx.getPrefBoolean(PreferKey.brightnessVwPos)
|
||||
set(value) {
|
||||
appCtx.putPrefBoolean(PreferKey.brightnessVwPos, value)
|
||||
}
|
||||
|
||||
fun detectClickArea() {
|
||||
if (clickActionTL * clickActionTC * clickActionTR
|
||||
* clickActionML * clickActionMC * clickActionMR
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.view.animation.Animation
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.SeekBar
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import io.legado.app.R
|
||||
@@ -208,6 +209,7 @@ class ReadMenu @JvmOverloads constructor(
|
||||
} else {
|
||||
titleBarAddition.gone()
|
||||
}
|
||||
upBrightnessVwPos()
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
@@ -366,7 +368,10 @@ class ReadMenu @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
vwBrightnessPosAdjust.setOnClickListener {
|
||||
AppConfig.brightnessVwPos = !AppConfig.brightnessVwPos
|
||||
upBrightnessVwPos()
|
||||
}
|
||||
//阅读进度
|
||||
seekReadPage.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
||||
|
||||
@@ -492,6 +497,7 @@ class ReadMenu @JvmOverloads constructor(
|
||||
progress = ReadBook.durPageIndex
|
||||
}
|
||||
}
|
||||
|
||||
"chapter" -> {
|
||||
max = ReadBook.chapterSize - 1
|
||||
progress = ReadBook.durChapterIndex
|
||||
@@ -515,6 +521,20 @@ class ReadMenu @JvmOverloads constructor(
|
||||
fabAutoPage.setColorFilter(textColor)
|
||||
}
|
||||
|
||||
private fun upBrightnessVwPos() {
|
||||
if (AppConfig.brightnessVwPos) {
|
||||
binding.root.modify()
|
||||
.clear(R.id.ll_brightness, ConstraintSet.LEFT)
|
||||
.rightToRightOf(R.id.ll_brightness, R.id.vw_menu_root)
|
||||
.commit()
|
||||
} else {
|
||||
binding.root.modify()
|
||||
.clear(R.id.ll_brightness, ConstraintSet.RIGHT)
|
||||
.leftToLeftOf(R.id.ll_brightness, R.id.vw_menu_root)
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
|
||||
interface CallBack {
|
||||
fun autoPage()
|
||||
fun openReplaceRule()
|
||||
|
||||
@@ -18,9 +18,8 @@ fun ConstraintLayout.modify(withAnim: Boolean = false): ConstraintModify.Constra
|
||||
class ConstraintModify(private val constraintLayout: ConstraintLayout) {
|
||||
|
||||
val begin: ConstraintBegin by lazy {
|
||||
ConstraintBegin(constraintLayout, applyConstraintSet).apply {
|
||||
applyConstraintSet.clone(constraintLayout)
|
||||
}
|
||||
applyConstraintSet.clone(constraintLayout)
|
||||
ConstraintBegin(constraintLayout, applyConstraintSet)
|
||||
}
|
||||
private val applyConstraintSet = ConstraintSet()
|
||||
private val resetConstraintSet = ConstraintSet()
|
||||
@@ -75,8 +74,8 @@ class ConstraintModify(private val constraintLayout: ConstraintLayout) {
|
||||
|
||||
/**
|
||||
* 清除某个控件的,某个关系
|
||||
* @param viewId
|
||||
* @param anchor
|
||||
* @param viewId 控件ID
|
||||
* @param anchor 要解除的关系
|
||||
* @return
|
||||
*/
|
||||
fun clear(viewId: Int, anchor: Int): ConstraintBegin {
|
||||
@@ -275,7 +274,9 @@ class ConstraintModify(private val constraintLayout: ConstraintLayout) {
|
||||
* 提交应用生效
|
||||
*/
|
||||
fun commit() {
|
||||
applyConstraintSet.applyTo(constraintLayout)
|
||||
constraintLayout.post {
|
||||
applyConstraintSet.applyTo(constraintLayout)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user