feat: 夜间模式降低缩略图亮度
This commit is contained in:
parent
97d5bb1d9f
commit
87dde92dae
|
|
@ -7,6 +7,7 @@ import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.BrandingWatermark
|
import androidx.compose.material.icons.outlined.BrandingWatermark
|
||||||
import androidx.compose.material.icons.outlined.CalendarViewDay
|
import androidx.compose.material.icons.outlined.CalendarViewDay
|
||||||
import androidx.compose.material.icons.outlined.ExitToApp
|
import androidx.compose.material.icons.outlined.ExitToApp
|
||||||
|
import androidx.compose.material.icons.outlined.NightsStay
|
||||||
import androidx.compose.material.icons.outlined.PhotoSizeSelectActual
|
import androidx.compose.material.icons.outlined.PhotoSizeSelectActual
|
||||||
import androidx.compose.material.icons.outlined.SecurityUpdateWarning
|
import androidx.compose.material.icons.outlined.SecurityUpdateWarning
|
||||||
import androidx.compose.material.icons.outlined.StarOutline
|
import androidx.compose.material.icons.outlined.StarOutline
|
||||||
|
|
@ -104,6 +105,22 @@ fun HabitSettingsPage(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
prefsItem {
|
||||||
|
SwitchPref(
|
||||||
|
key = "imageDarkenWhenNightMode",
|
||||||
|
title = stringResource(id = R.string.settings_image_darken_when_night_mode),
|
||||||
|
defaultChecked = true,
|
||||||
|
leadingIcon = {
|
||||||
|
LeadingIcon {
|
||||||
|
AvatarIcon(
|
||||||
|
icon = Icons.Outlined.NightsStay,
|
||||||
|
size = Sizes.Small,
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
prefsItem {
|
prefsItem {
|
||||||
ListPref(
|
ListPref(
|
||||||
key = "default_sort_type",
|
key = "default_sort_type",
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberUpdatedState
|
import androidx.compose.runtime.rememberUpdatedState
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
|
import androidx.compose.ui.graphics.ColorMatrix
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import com.github.panpf.sketch.compose.AsyncImage
|
import com.github.panpf.sketch.compose.AsyncImage
|
||||||
|
|
@ -23,6 +25,7 @@ import com.huanchengfly.tieba.post.ui.page.photoview.PhotoViewActivity
|
||||||
import com.huanchengfly.tieba.post.ui.page.photoview.PhotoViewActivity.Companion.EXTRA_PHOTO_VIEW_DATA
|
import com.huanchengfly.tieba.post.ui.page.photoview.PhotoViewActivity.Companion.EXTRA_PHOTO_VIEW_DATA
|
||||||
import com.huanchengfly.tieba.post.utils.ImageUtil
|
import com.huanchengfly.tieba.post.utils.ImageUtil
|
||||||
import com.huanchengfly.tieba.post.utils.NetworkUtil
|
import com.huanchengfly.tieba.post.utils.NetworkUtil
|
||||||
|
import com.huanchengfly.tieba.post.utils.ThemeUtil
|
||||||
import com.huanchengfly.tieba.post.utils.appPreferences
|
import com.huanchengfly.tieba.post.utils.appPreferences
|
||||||
|
|
||||||
fun shouldLoadImage(context: Context, skipNetworkCheck: Boolean): Boolean {
|
fun shouldLoadImage(context: Context, skipNetworkCheck: Boolean): Boolean {
|
||||||
|
|
@ -71,11 +74,27 @@ fun NetworkImage(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val currentTheme by remember { ThemeUtil.themeState }
|
||||||
|
val isNightMode = remember(currentTheme) { ThemeUtil.isNightMode(currentTheme) }
|
||||||
|
val colorFilter = if (isNightMode && context.appPreferences.imageDarkenWhenNightMode) {
|
||||||
|
ColorFilter.colorMatrix(
|
||||||
|
ColorMatrix(
|
||||||
|
floatArrayOf(
|
||||||
|
1f, 0f, 0f, 0f, -35f,
|
||||||
|
0f, 1f, 0f, 0f, -35f,
|
||||||
|
0f, 0f, 1f, 0f, -35f,
|
||||||
|
0f, 0f, 0f, 1f, 0f
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else null
|
||||||
|
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
request = request,
|
request = request,
|
||||||
contentDescription = contentDescription,
|
contentDescription = contentDescription,
|
||||||
modifier = modifier.then(clickableModifier),
|
modifier = modifier.then(clickableModifier),
|
||||||
contentScale = contentScale,
|
contentScale = contentScale,
|
||||||
|
colorFilter = colorFilter,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,8 @@ open class AppPreferencesUtils private constructor(ctx: Context) {
|
||||||
|
|
||||||
var homePageScroll by DataStoreDelegates.boolean(defaultValue = false)
|
var homePageScroll by DataStoreDelegates.boolean(defaultValue = false)
|
||||||
|
|
||||||
|
var imageDarkenWhenNightMode by DataStoreDelegates.boolean(defaultValue = true)
|
||||||
|
|
||||||
var imageLoadType by DataStoreDelegates.string(
|
var imageLoadType by DataStoreDelegates.string(
|
||||||
key = "image_load_type",
|
key = "image_load_type",
|
||||||
defaultValue = "0"
|
defaultValue = "0"
|
||||||
|
|
@ -132,15 +134,13 @@ open class AppPreferencesUtils private constructor(ctx: Context) {
|
||||||
|
|
||||||
var oldTheme by DataStoreDelegates.string(key = "old_theme")
|
var oldTheme by DataStoreDelegates.string(key = "old_theme")
|
||||||
|
|
||||||
var oksignWorkId by DataStoreDelegates.string()
|
|
||||||
|
|
||||||
var oksignSlowMode by DataStoreDelegates.boolean(
|
var oksignSlowMode by DataStoreDelegates.boolean(
|
||||||
defaultValue = true,
|
defaultValue = true,
|
||||||
key = "oksign_slow_mode"
|
key = "oksign_slow_mode"
|
||||||
)
|
)
|
||||||
|
|
||||||
var oksignUseOfficialOksign by DataStoreDelegates.boolean(
|
var oksignUseOfficialOksign by DataStoreDelegates.boolean(
|
||||||
defaultValue = false,
|
defaultValue = true,
|
||||||
key = "oksign_use_official_oksign"
|
key = "oksign_use_official_oksign"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -724,4 +724,5 @@
|
||||||
<string name="button_clear_all">清除全部</string>
|
<string name="button_clear_all">清除全部</string>
|
||||||
<string name="title_dynamic_theme">动态取色</string>
|
<string name="title_dynamic_theme">动态取色</string>
|
||||||
<string name="desc_night_theme">夜间主题</string>
|
<string name="desc_night_theme">夜间主题</string>
|
||||||
|
<string name="settings_image_darken_when_night_mode">夜间模式压暗缩略图</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue