为亮暗色模式添加底部按钮
This commit is contained in:
7 files changed
+44
-13
No files matched your search
@@ -23,6 +23,7 @@ import io.legato.kazusa.constant.PreferKey
|
|||||||
import io.legato.kazusa.databinding.ViewReadMenuBinding
|
import io.legato.kazusa.databinding.ViewReadMenuBinding
|
||||||
import io.legato.kazusa.help.config.AppConfig
|
import io.legato.kazusa.help.config.AppConfig
|
||||||
import io.legato.kazusa.help.config.LocalConfig
|
import io.legato.kazusa.help.config.LocalConfig
|
||||||
|
import io.legato.kazusa.help.config.ThemeConfig
|
||||||
import io.legato.kazusa.help.coroutine.Coroutine
|
import io.legato.kazusa.help.coroutine.Coroutine
|
||||||
import io.legato.kazusa.help.source.getSourceType
|
import io.legato.kazusa.help.source.getSourceType
|
||||||
import io.legato.kazusa.lib.dialogs.alert
|
import io.legato.kazusa.lib.dialogs.alert
|
||||||
@@ -470,6 +471,7 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
contentDescription = btn.description
|
contentDescription = btn.description
|
||||||
tooltipText = btn.description
|
tooltipText = btn.description
|
||||||
strokeWidth = 0
|
strokeWidth = 0
|
||||||
|
iconGravity = MaterialButton.ICON_GRAVITY_TEXT_START
|
||||||
setOnClickListener { btn.onClick() }
|
setOnClickListener { btn.onClick() }
|
||||||
btn.onLongClick?.let { longAction ->
|
btn.onLongClick?.let { longAction ->
|
||||||
setOnLongClickListener {
|
setOnLongClickListener {
|
||||||
@@ -478,8 +480,16 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
group.addView(button,
|
||||||
group.addView(button)
|
MaterialButtonGroup.LayoutParams(
|
||||||
|
LayoutParams.WRAP_CONTENT,
|
||||||
|
LayoutParams.WRAP_CONTENT
|
||||||
|
).apply {
|
||||||
|
weight = 1f
|
||||||
|
}
|
||||||
|
)
|
||||||
|
val lp = button.layoutParams as MaterialButtonGroup.LayoutParams
|
||||||
|
lp.overflowText = btn.description
|
||||||
buttonMap[btn.id] = button
|
buttonMap[btn.id] = button
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -522,6 +532,18 @@ class ReadMenu @JvmOverloads constructor(
|
|||||||
iconRes = R.drawable.ic_bookmark,
|
iconRes = R.drawable.ic_bookmark,
|
||||||
description = context.getString(R.string.bookmark),
|
description = context.getString(R.string.bookmark),
|
||||||
onClick = { runMenuOut { callBack.addBookmark() } }
|
onClick = { runMenuOut { callBack.addBookmark() } }
|
||||||
|
),
|
||||||
|
ToolButton(
|
||||||
|
id = "theme",
|
||||||
|
iconRes = if (AppConfig.isNightTheme) R.drawable.ic_daytime else R.drawable.ic_brightness,
|
||||||
|
description = context.getString(R.string.day_night_switch),
|
||||||
|
onClick = {
|
||||||
|
AppConfig.isNightTheme = !AppConfig.isNightTheme
|
||||||
|
ThemeConfig.applyDayNight(context)
|
||||||
|
buttonMap["theme"]?.setIconResource(
|
||||||
|
if (AppConfig.isNightTheme) R.drawable.ic_daytime else R.drawable.ic_brightness
|
||||||
|
)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class ToolButtonConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_too
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllButtonIds(): List<String> {
|
private fun getAllButtonIds(): List<String> {
|
||||||
return listOf("search", "auto_page", "catalog", "read_aloud", "setting", "addBookmark")
|
return listOf("search", "auto_page", "catalog", "read_aloud", "setting", "addBookmark", "theme")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getButtonInfo(id: String): Pair<Int, String> {
|
private fun getButtonInfo(id: String): Pair<Int, String> {
|
||||||
@@ -125,6 +125,7 @@ class ToolButtonConfigDialog : BaseBottomSheetDialogFragment(R.layout.dialog_too
|
|||||||
"read_aloud" -> R.drawable.ic_read_aloud to getString(R.string.read_aloud)
|
"read_aloud" -> R.drawable.ic_read_aloud to getString(R.string.read_aloud)
|
||||||
"setting" -> R.drawable.ic_settings to getString(R.string.setting)
|
"setting" -> R.drawable.ic_settings to getString(R.string.setting)
|
||||||
"addBookmark" -> R.drawable.ic_bookmark to getString(R.string.bookmark)
|
"addBookmark" -> R.drawable.ic_bookmark to getString(R.string.bookmark)
|
||||||
|
"theme" -> R.drawable.ic_daytime to getString(R.string.day_night_switch)
|
||||||
else -> R.drawable.ic_help to id
|
else -> R.drawable.ic_help to id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,14 +183,12 @@
|
|||||||
android:id="@+id/bottom_view"
|
android:id="@+id/bottom_view"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
app:overflowMode="menu"
|
||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:importantForAccessibility="no"
|
android:importantForAccessibility="no"
|
||||||
android:paddingVertical="8dp"
|
android:paddingVertical="8dp"
|
||||||
android:gravity="center"
|
|
||||||
android:paddingHorizontal="16dp"
|
android:paddingHorizontal="16dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"/>
|
||||||
|
|
||||||
</com.google.android.material.button.MaterialButtonGroup>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
app:strokeWidth="0dp"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginVertical="8dp">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="?attr/colorSurface"
|
||||||
|
android:foreground="?attr/selectableItemBackground"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingHorizontal="16dp"
|
android:paddingHorizontal="16dp"
|
||||||
@@ -43,3 +53,4 @@
|
|||||||
android:src="@drawable/ic_drag_handle" />
|
android:src="@drawable/ic_drag_handle" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
@@ -176,16 +176,13 @@
|
|||||||
android:id="@+id/bottom_view"
|
android:id="@+id/bottom_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:importantForAccessibility="no"
|
app:overflowMode="menu"
|
||||||
android:paddingVertical="8dp"
|
android:paddingVertical="8dp"
|
||||||
android:paddingHorizontal="16dp"
|
android:paddingHorizontal="16dp"
|
||||||
android:background="?attr/colorSurfaceContainer"
|
android:background="?attr/colorSurfaceContainer"
|
||||||
android:gravity="center"
|
android:orientation="horizontal"/>
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
|
|
||||||
</com.google.android.material.button.MaterialButtonGroup>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -1300,4 +1300,5 @@
|
|||||||
<string name="restart_required_message">此更改需要重启应用才能生效,是否立即重启?</string>
|
<string name="restart_required_message">此更改需要重启应用才能生效,是否立即重启?</string>
|
||||||
<string name="restart_later_message">更改将在下次启动应用时生效</string>
|
<string name="restart_later_message">更改将在下次启动应用时生效</string>
|
||||||
<string name="search_select_group">选择书源分组</string>
|
<string name="search_select_group">选择书源分组</string>
|
||||||
|
<string name="day_night_switch">深浅色模式开关</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1301,4 +1301,5 @@
|
|||||||
<string name="restart_required_message">修改该选项需要重启</string>
|
<string name="restart_required_message">修改该选项需要重启</string>
|
||||||
<string name="restart_later_message">稍后重启</string>
|
<string name="restart_later_message">稍后重启</string>
|
||||||
<string name="search_select_group">选择书源分组</string>
|
<string name="search_select_group">选择书源分组</string>
|
||||||
|
<string name="day_night_switch">深浅色模式开关</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in new issue
Block a user