mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
app/src/main/res/drawable/ic_swap_horiz.xml
Normal file
10
app/src/main/res/drawable/ic_swap_horiz.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector android:height="24dp"
|
||||
android:tint="#000000"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24"
|
||||
android:width="24dp"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M6.99,11L3,15l3.99,4v-3H14v-2H6.99v-3zM21,9l-3.99,-4v3H10v2h7.01v3L21,9z" />
|
||||
</vector>
|
||||
@@ -2,6 +2,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/vw_menu_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
@@ -73,10 +74,11 @@
|
||||
android:id="@+id/ll_brightness"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/transparent30"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bottom_menu"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/title_bar"
|
||||
@@ -93,7 +95,8 @@
|
||||
|
||||
<io.legado.app.ui.widget.seekbar.VerticalSeekBarWrapper
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<io.legado.app.ui.widget.seekbar.VerticalSeekBar
|
||||
android:id="@+id/seek_brightness"
|
||||
@@ -104,6 +107,15 @@
|
||||
|
||||
</io.legado.app.ui.widget.seekbar.VerticalSeekBarWrapper>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/vw_brightness_pos_adjust"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_margin="8dp"
|
||||
android:contentDescription="@string/adjust_pos"
|
||||
android:src="@drawable/ic_swap_horiz"
|
||||
app:tint="@color/white" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@@ -294,7 +306,8 @@
|
||||
android:contentDescription="@string/chapter_list"
|
||||
android:focusable="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="7dp">
|
||||
android:paddingBottom="7dp"
|
||||
tools:ignore="VisualLintBounds">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_catalog"
|
||||
@@ -335,7 +348,8 @@
|
||||
android:contentDescription="@string/read_aloud"
|
||||
android:focusable="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="7dp">
|
||||
android:paddingBottom="7dp"
|
||||
tools:ignore="VisualLintBounds">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_read_aloud"
|
||||
@@ -376,7 +390,8 @@
|
||||
android:contentDescription="@string/interface_setting"
|
||||
android:focusable="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="7dp">
|
||||
android:paddingBottom="7dp"
|
||||
tools:ignore="VisualLintBounds">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_font"
|
||||
@@ -417,7 +432,8 @@
|
||||
android:contentDescription="@string/setting"
|
||||
android:focusable="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="7dp">
|
||||
android:paddingBottom="7dp"
|
||||
tools:ignore="VisualLintBounds">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/iv_setting"
|
||||
|
||||
@@ -1103,4 +1103,5 @@
|
||||
<string name="load_word_count">Cargar palabras del libro</string>
|
||||
<string name="replace_exclude_scope">排除范围,选填书名或者书源 URL</string>
|
||||
<string name="format_js_rule">格式化规则(formatJs)</string>
|
||||
<string name="adjust_pos">调整位置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1106,4 +1106,5 @@
|
||||
<string name="load_word_count">Load word count</string>
|
||||
<string name="replace_exclude_scope">排除范围,选填书名或者书源 URL</string>
|
||||
<string name="format_js_rule">格式化规则(formatJs)</string>
|
||||
<string name="adjust_pos">调整位置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1106,4 +1106,5 @@
|
||||
<string name="load_word_count">Carregar os palavras do livro</string>
|
||||
<string name="replace_exclude_scope">排除范围,选填书名或者书源 URL</string>
|
||||
<string name="format_js_rule">格式化规则(formatJs)</string>
|
||||
<string name="adjust_pos">调整位置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1103,4 +1103,5 @@
|
||||
<string name="load_word_count">加載字數</string>
|
||||
<string name="replace_exclude_scope">排除范围,选填书名或者书源 URL</string>
|
||||
<string name="format_js_rule">格式化规则(formatJs)</string>
|
||||
<string name="adjust_pos">调整位置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1105,4 +1105,5 @@
|
||||
<string name="load_word_count">加載字數</string>
|
||||
<string name="replace_exclude_scope">排除范围,选填书名或者书源 URL</string>
|
||||
<string name="format_js_rule">格式化规则(formatJs)</string>
|
||||
<string name="adjust_pos">调整位置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1105,4 +1105,5 @@
|
||||
<string name="load_word_count">加载字数</string>
|
||||
<string name="replace_exclude_scope">排除范围,选填书名或者书源 URL</string>
|
||||
<string name="format_js_rule">格式化规则(formatJs)</string>
|
||||
<string name="adjust_pos">调整位置</string>
|
||||
</resources>
|
||||
|
||||
@@ -1106,4 +1106,5 @@
|
||||
<string name="load_word_count">Load word count</string>
|
||||
<string name="replace_exclude_scope">排除范围,选填书名或者书源 URL</string>
|
||||
<string name="format_js_rule">格式化规则(formatJs)</string>
|
||||
<string name="adjust_pos">调整位置</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user