mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
fbdda40afa
commit
a2a8fd8831
@ -152,10 +152,11 @@ dependencies {
|
||||
implementation('androidx.constraintlayout:constraintlayout:2.1.3')
|
||||
implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
|
||||
implementation('androidx.viewpager2:viewpager2:1.0.0')
|
||||
implementation('androidx.webkit:webkit:1.4.0')
|
||||
|
||||
implementation('com.google.android.material:material:1.5.0')
|
||||
implementation('com.google.android.flexbox:flexbox:3.0.0')
|
||||
implementation('com.google.code.gson:gson:2.9.0')
|
||||
implementation('androidx.webkit:webkit:1.4.0')
|
||||
|
||||
//lifecycle
|
||||
def lifecycle_version = '2.4.1'
|
||||
|
@ -1,22 +1,5 @@
|
||||
package io.legado.app.constant
|
||||
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.utils.ColorUtils
|
||||
|
||||
enum class Theme {
|
||||
Dark, Light, Auto, Transparent, EInk;
|
||||
|
||||
companion object {
|
||||
fun getTheme() = when {
|
||||
AppConfig.isEInkMode -> EInk
|
||||
AppConfig.isNightTheme -> Dark
|
||||
else -> Light
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun fromBackground(backgroundColor: Int) =
|
||||
if (ColorUtils.isColorLight(backgroundColor)) Light
|
||||
else Dark
|
||||
|
||||
}
|
||||
}
|
@ -27,6 +27,16 @@ object ThemeConfig {
|
||||
ArrayList(cList)
|
||||
}
|
||||
|
||||
fun getTheme() = when {
|
||||
AppConfig.isEInkMode -> Theme.EInk
|
||||
AppConfig.isNightTheme -> Theme.Dark
|
||||
else -> Theme.Light
|
||||
}
|
||||
|
||||
fun isDarkTheme(): Boolean {
|
||||
return getTheme() == Theme.Dark
|
||||
}
|
||||
|
||||
fun applyDayNight(context: Context) {
|
||||
ReadBookConfig.upBg()
|
||||
applyTheme(context)
|
||||
@ -46,7 +56,7 @@ object ThemeConfig {
|
||||
}
|
||||
|
||||
fun getBgImage(context: Context, metrics: DisplayMetrics): Bitmap? {
|
||||
val bgCfg = when (Theme.getTheme()) {
|
||||
val bgCfg = when (getTheme()) {
|
||||
Theme.Light -> Pair(
|
||||
context.getPrefString(PreferKey.bgImage),
|
||||
context.getPrefInt(PreferKey.bgImageBlurring, 0)
|
||||
|
@ -148,6 +148,9 @@ class RssSourceEditActivity :
|
||||
private fun initView() {
|
||||
binding.recyclerView.setEdgeEffectColor(primaryColor)
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.composeView.setContent {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun upRecyclerView(source: RssSource? = viewModel.rssSource) {
|
||||
|
28
app/src/main/java/io/legado/app/ui/theme/AppTheme.kt
Normal file
28
app/src/main/java/io/legado/app/ui/theme/AppTheme.kt
Normal file
@ -0,0 +1,28 @@
|
||||
package io.legado.app.ui.theme
|
||||
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.darkColors
|
||||
import androidx.compose.material.lightColors
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import io.legado.app.help.config.ThemeConfig
|
||||
import io.legado.app.lib.theme.primaryColor
|
||||
import splitties.init.appCtx
|
||||
|
||||
|
||||
@Composable
|
||||
fun AppTheme(content: @Composable () -> Unit) {
|
||||
val colors = if (ThemeConfig.isDarkTheme()) {
|
||||
darkColors(
|
||||
primary = Color(appCtx.primaryColor),
|
||||
)
|
||||
} else {
|
||||
lightColors(
|
||||
primary = Color(appCtx.primaryColor),
|
||||
)
|
||||
}
|
||||
MaterialTheme(
|
||||
colors = colors,
|
||||
content = content
|
||||
)
|
||||
}
|
@ -9,6 +9,7 @@ import io.legado.app.constant.Theme
|
||||
import io.legado.app.data.appDb
|
||||
import io.legado.app.databinding.ActivityWelcomeBinding
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.config.ThemeConfig
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.help.storage.AppWebDav
|
||||
import io.legado.app.lib.theme.accentColor
|
||||
@ -61,7 +62,7 @@ open class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() {
|
||||
override fun upBackgroundImage() {
|
||||
if (getPrefBoolean(PreferKey.customWelcome)) {
|
||||
kotlin.runCatching {
|
||||
when (Theme.getTheme()) {
|
||||
when (ThemeConfig.getTheme()) {
|
||||
Theme.Dark -> getPrefString(PreferKey.welcomeImageDark)?.let { path ->
|
||||
val size = windowManager.windowSize
|
||||
BitmapUtils.decodeBitmap(path, size.widthPixels, size.heightPixels).let {
|
||||
|
@ -86,4 +86,9 @@
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_source_edit" />
|
||||
|
||||
<androidx.compose.ui.platform.ComposeView
|
||||
android:id="@+id/compose_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user