some updates

This commit is contained in:
2024-10-28 19:57:53 +03:00
parent 656fca46d7
commit 957ade0867
16 changed files with 87 additions and 64 deletions
@@ -69,7 +69,10 @@ class MainActivity : AppCompatActivity() {
val systemBarStyle = when (currentNightMode) { val systemBarStyle = when (currentNightMode) {
Configuration.UI_MODE_NIGHT_NO -> SystemBarStyle.light( Configuration.UI_MODE_NIGHT_NO -> SystemBarStyle.light(
Color.Transparent.toArgb(), Color.Transparent.toArgb(),
Color.Transparent.toArgb() if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M)
0
// MaterialTheme.colorScheme.background.toArgb()
else Color.Transparent.toArgb()
) )
Configuration.UI_MODE_NIGHT_YES -> SystemBarStyle.dark(Color.Transparent.toArgb()) Configuration.UI_MODE_NIGHT_YES -> SystemBarStyle.dark(Color.Transparent.toArgb())
@@ -197,6 +200,7 @@ class MainActivity : AppCompatActivity() {
val amoledDark by userSettings.enableAmoledDark.collectAsStateWithLifecycle() val amoledDark by userSettings.enableAmoledDark.collectAsStateWithLifecycle()
val enableBlur by userSettings.useBlur.collectAsStateWithLifecycle() val enableBlur by userSettings.useBlur.collectAsStateWithLifecycle()
val enableMultiline by userSettings.enableMultiline.collectAsStateWithLifecycle() val enableMultiline by userSettings.enableMultiline.collectAsStateWithLifecycle()
val useSystemFont by userSettings.useSystemFont.collectAsStateWithLifecycle()
val setDarkMode = isNeedToEnableDarkMode(darkMode = darkMode) val setDarkMode = isNeedToEnableDarkMode(darkMode = darkMode)
@@ -206,7 +210,8 @@ class MainActivity : AppCompatActivity() {
amoledDark, amoledDark,
enableBlur, enableBlur,
enableMultiline, enableMultiline,
setDarkMode setDarkMode,
useSystemFont
) { ) {
mutableStateOf( mutableStateOf(
ThemeConfig( ThemeConfig(
@@ -215,7 +220,8 @@ class MainActivity : AppCompatActivity() {
selectedColorScheme = 0, selectedColorScheme = 0,
amoledDark = amoledDark, amoledDark = amoledDark,
enableBlur = enableBlur, enableBlur = enableBlur,
enableMultiline = enableMultiline enableMultiline = enableMultiline,
useSystemFont = useSystemFont
) )
) )
} }
@@ -229,6 +235,7 @@ class MainActivity : AppCompatActivity() {
useDynamicColors = themeConfig.dynamicColors, useDynamicColors = themeConfig.dynamicColors,
selectedColorScheme = themeConfig.selectedColorScheme, selectedColorScheme = themeConfig.selectedColorScheme,
useAmoledBackground = themeConfig.amoledDark, useAmoledBackground = themeConfig.amoledDark,
useSystemFont = themeConfig.useSystemFont
) { ) {
RootScreen(viewModel = viewModel) RootScreen(viewModel = viewModel)
} }
@@ -191,7 +191,7 @@ object AppSettings {
var enableHaptic: Boolean var enableHaptic: Boolean
get() = get( get() = get(
SettingsKeys.KEY_DEBUG_ENABLE_HAPTIC, SettingsKeys.KEY_DEBUG_ENABLE_HAPTIC,
true SettingsKeys.DEFAULT_DEBUG_ENABLE_HAPTIC
) )
set(value) = put(SettingsKeys.KEY_DEBUG_ENABLE_HAPTIC, value) set(value) = put(SettingsKeys.KEY_DEBUG_ENABLE_HAPTIC, value)
@@ -202,6 +202,13 @@ object AppSettings {
).let(LogLevel::parse) ).let(LogLevel::parse)
set(level) = put(SettingsKeys.KEY_DEBUG_NETWORK_LOG_LEVEL, level.value) set(level) = put(SettingsKeys.KEY_DEBUG_NETWORK_LOG_LEVEL, level.value)
var useSystemFont: Boolean
get() = get(
SettingsKeys.KEY_DEBUG_USE_SYSTEM_FONT,
SettingsKeys.DEFAULT_DEBUG_USE_SYSTEM_FONT
)
set(value) = put(SettingsKeys.KEY_DEBUG_USE_SYSTEM_FONT, value)
var showDebugCategory: Boolean var showDebugCategory: Boolean
get() = get( get() = get(
SettingsKeys.KEY_SHOW_DEBUG_CATEGORY, SettingsKeys.KEY_SHOW_DEBUG_CATEGORY,
@@ -46,8 +46,11 @@ object SettingsKeys {
const val KEY_DEBUG_HIDE_DEBUG_LIST = "debug_hide_debug_list" const val KEY_DEBUG_HIDE_DEBUG_LIST = "debug_hide_debug_list"
const val KEY_ENABLE_ANIMATIONS_IN_MESSAGES = "debug_enable_animations_in_messages" const val KEY_ENABLE_ANIMATIONS_IN_MESSAGES = "debug_enable_animations_in_messages"
const val KEY_DEBUG_ENABLE_HAPTIC = "debug_enable_haptic" const val KEY_DEBUG_ENABLE_HAPTIC = "debug_enable_haptic"
const val DEFAULT_DEBUG_ENABLE_HAPTIC = true
const val KEY_DEBUG_NETWORK_LOG_LEVEL = "debug_network_log_level" const val KEY_DEBUG_NETWORK_LOG_LEVEL = "debug_network_log_level"
const val DEFAULT_NETWORK_LOG_LEVEL = 0 const val DEFAULT_NETWORK_LOG_LEVEL = 0
const val KEY_DEBUG_USE_SYSTEM_FONT = "debug_use_system_font"
const val DEFAULT_DEBUG_USE_SYSTEM_FONT = false
const val KEY_SHOW_DEBUG_CATEGORY = "show_debug_category" const val KEY_SHOW_DEBUG_CATEGORY = "show_debug_category"
@@ -24,6 +24,7 @@ interface UserSettings {
val useBlur: StateFlow<Boolean> val useBlur: StateFlow<Boolean>
val showEmojiButton: StateFlow<Boolean> val showEmojiButton: StateFlow<Boolean>
val showTimeInActionMessages: StateFlow<Boolean> val showTimeInActionMessages: StateFlow<Boolean>
val useSystemFont: StateFlow<Boolean>
val showDebugCategory: StateFlow<Boolean> val showDebugCategory: StateFlow<Boolean>
fun onUseContactNamesChanged(use: Boolean) fun onUseContactNamesChanged(use: Boolean)
@@ -44,6 +45,7 @@ interface UserSettings {
fun onUseBlurChanged(use: Boolean) fun onUseBlurChanged(use: Boolean)
fun onShowEmojiButtonChanged(show: Boolean) fun onShowEmojiButtonChanged(show: Boolean)
fun onShowTimeInActionMessagesChanged(show: Boolean) fun onShowTimeInActionMessagesChanged(show: Boolean)
fun onUseSystemFontChanged(use: Boolean)
fun onShowDebugCategoryChanged(show: Boolean) fun onShowDebugCategoryChanged(show: Boolean)
} }
@@ -68,6 +70,7 @@ class UserSettingsImpl : UserSettings {
override val showEmojiButton = MutableStateFlow(AppSettings.Debug.showEmojiButton) override val showEmojiButton = MutableStateFlow(AppSettings.Debug.showEmojiButton)
override val showTimeInActionMessages = override val showTimeInActionMessages =
MutableStateFlow(AppSettings.Debug.showTimeInActionMessages) MutableStateFlow(AppSettings.Debug.showTimeInActionMessages)
override val useSystemFont = MutableStateFlow(AppSettings.Debug.useSystemFont)
override val showDebugCategory = MutableStateFlow(AppSettings.Debug.showDebugCategory) override val showDebugCategory = MutableStateFlow(AppSettings.Debug.showDebugCategory)
override fun onUseContactNamesChanged(use: Boolean) { override fun onUseContactNamesChanged(use: Boolean) {
@@ -126,6 +129,10 @@ class UserSettingsImpl : UserSettings {
showTimeInActionMessages.value = show showTimeInActionMessages.value = show
} }
override fun onUseSystemFontChanged(use: Boolean) {
useSystemFont.value = use
}
override fun onShowDebugCategoryChanged(show: Boolean) { override fun onShowDebugCategoryChanged(show: Boolean) {
showDebugCategory.value = show showDebugCategory.value = show
} }
@@ -6,5 +6,6 @@ data class ThemeConfig(
val selectedColorScheme: Int, val selectedColorScheme: Int,
val amoledDark: Boolean, val amoledDark: Boolean,
val enableBlur: Boolean, val enableBlur: Boolean,
val enableMultiline: Boolean val enableMultiline: Boolean,
val useSystemFont: Boolean
) )
@@ -112,7 +112,8 @@ val LocalThemeConfig = compositionLocalOf {
selectedColorScheme = 0, selectedColorScheme = 0,
amoledDark = false, amoledDark = false,
enableBlur = false, enableBlur = false,
enableMultiline = false enableMultiline = false,
useSystemFont = false
) )
} }
@@ -137,6 +138,7 @@ fun AppTheme(
useDarkTheme: Boolean = false, useDarkTheme: Boolean = false,
useDynamicColors: Boolean = false, useDynamicColors: Boolean = false,
useAmoledBackground: Boolean = false, useAmoledBackground: Boolean = false,
useSystemFont: Boolean = false,
selectedColorScheme: Int = 0, selectedColorScheme: Int = 0,
content: @Composable () -> Unit content: @Composable () -> Unit
) { ) {
@@ -165,7 +167,10 @@ fun AppTheme(
} }
} }
val typography = MaterialTheme.typography.copy( val typography = if (useSystemFont) {
MaterialTheme.typography
} else {
MaterialTheme.typography.copy(
displayLarge = MaterialTheme.typography.displayLarge.copy(fontFamily = googleSansFonts), displayLarge = MaterialTheme.typography.displayLarge.copy(fontFamily = googleSansFonts),
displayMedium = MaterialTheme.typography.displayMedium.copy(fontFamily = googleSansFonts), displayMedium = MaterialTheme.typography.displayMedium.copy(fontFamily = googleSansFonts),
displaySmall = MaterialTheme.typography.displaySmall.copy(fontFamily = googleSansFonts), displaySmall = MaterialTheme.typography.displaySmall.copy(fontFamily = googleSansFonts),
@@ -174,8 +179,9 @@ fun AppTheme(
headlineSmall = MaterialTheme.typography.headlineSmall.copy(fontFamily = googleSansFonts), headlineSmall = MaterialTheme.typography.headlineSmall.copy(fontFamily = googleSansFonts),
bodyLarge = MaterialTheme.typography.bodyLarge.copy(fontFamily = robotoFonts), bodyLarge = MaterialTheme.typography.bodyLarge.copy(fontFamily = robotoFonts),
bodyMedium = MaterialTheme.typography.bodyMedium.copy(fontFamily = robotoFonts), bodyMedium = MaterialTheme.typography.bodyMedium.copy(fontFamily = robotoFonts),
bodySmall = MaterialTheme.typography.bodySmall.copy(fontFamily = robotoFonts) bodySmall = MaterialTheme.typography.bodySmall.copy(fontFamily = robotoFonts),
) )
}
val view = LocalView.current val view = LocalView.current
if (!view.isInEditMode) { if (!view.isInEditMode) {
@@ -4,7 +4,7 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="@android:color/white" android:fillColor="#ffffff"
android:fillType="evenOdd" android:fillType="evenOdd"
android:pathData="M19,12.87c0,-0.47 -0.34,-0.85 -0.8,-0.98C16.93,11.54 16,10.38 16,9V4l1,0c0.55,0 1,-0.45 1,-1c0,-0.55 -0.45,-1 -1,-1H7C6.45,2 6,2.45 6,3c0,0.55 0.45,1 1,1l1,0v5c0,1.38 -0.93,2.54 -2.2,2.89C5.34,12.02 5,12.4 5,12.87V13c0,0.55 0.45,1 1,1h4.98L11,21c0,0.55 0.45,1 1,1c0.55,0 1,-0.45 1,-1l-0.02,-7H18c0.55,0 1,-0.45 1,-1V12.87z" /> android:pathData="M19,12.87c0,-0.47 -0.34,-0.85 -0.8,-0.98C16.93,11.54 16,10.38 16,9V4l1,0c0.55,0 1,-0.45 1,-1c0,-0.55 -0.45,-1 -1,-1H7C6.45,2 6,2.45 6,3c0,0.55 0.45,1 1,1l1,0v5c0,1.38 -0.93,2.54 -2.2,2.89C5.34,12.02 5,12.4 5,12.87V13c0,0.55 0.45,1 1,1h4.98L11,21c0,0.55 0.45,1 1,1c0.55,0 1,-0.45 1,-1l-0.02,-7H18c0.55,0 1,-0.45 1,-1V12.87z" />
</vector> </vector>
@@ -311,10 +311,7 @@ fun ChatMaterialsScreen(
modifier = Modifier modifier = Modifier
.then( .then(
if (currentTheme.enableBlur) { if (currentTheme.enableBlur) {
Modifier.haze( Modifier.haze(state = hazeState)
state = hazeState,
style = hazeStyle
)
} else { } else {
Modifier Modifier
} }
@@ -349,10 +346,7 @@ fun ChatMaterialsScreen(
modifier = Modifier modifier = Modifier
.then( .then(
if (currentTheme.enableBlur) { if (currentTheme.enableBlur) {
Modifier.haze( Modifier.haze(state = hazeState)
state = hazeState,
style = hazeStyle
)
} else { } else {
Modifier Modifier
} }
@@ -5,7 +5,6 @@ import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut import androidx.compose.animation.fadeOut
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
@@ -39,7 +38,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@@ -130,24 +128,25 @@ fun ConversationItem(
.clip(CircleShape) .clip(CircleShape)
.background(MaterialTheme.colorScheme.primary) .background(MaterialTheme.colorScheme.primary)
) { ) {
Image( Icon(
modifier = Modifier modifier = Modifier
.align(Alignment.Center) .align(Alignment.Center)
.size(32.dp), .size(32.dp),
painter = painterResource(id = UiR.drawable.ic_round_bookmark_border_24), painter = painterResource(id = UiR.drawable.ic_round_bookmark_border_24),
contentDescription = "Favorites icon" contentDescription = "Favorites icon",
tint = Color.White
) )
} }
} else { } else {
val avatarImage = conversation.avatar?.getImage() val avatarImage = conversation.avatar?.getImage()
if (avatarImage is Painter) { if (avatarImage is Painter) {
Image( Icon(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.clip(CircleShape), .clip(CircleShape),
painter = avatarImage, painter = avatarImage,
contentDescription = "Avatar", contentDescription = "Avatar",
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onBackground) tint = MaterialTheme.colorScheme.onBackground
) )
} else { } else {
AsyncImage( AsyncImage(
@@ -173,12 +172,13 @@ fun ConversationItem(
.defaultMinSize(minWidth = 20.dp, minHeight = 20.dp) .defaultMinSize(minWidth = 20.dp, minHeight = 20.dp)
.background(MaterialTheme.colorScheme.outline) .background(MaterialTheme.colorScheme.outline)
) { ) {
Image( Icon(
modifier = Modifier modifier = Modifier
.height(14.dp) .height(14.dp)
.align(Alignment.Center), .align(Alignment.Center),
painter = painterResource(id = UiR.drawable.ic_round_push_pin_24), painter = painterResource(id = UiR.drawable.ic_round_push_pin_24),
contentDescription = "Pin icon" contentDescription = "Pin icon",
tint = Color.White
) )
} }
} }
@@ -228,12 +228,13 @@ fun ConversationItem(
.matchParentSize() .matchParentSize()
.background(BirthdayColor) .background(BirthdayColor)
) { ) {
Image( Icon(
modifier = Modifier modifier = Modifier
.align(Alignment.Center) .align(Alignment.Center)
.size(10.dp), .size(10.dp),
painter = painterResource(id = UiR.drawable.round_cake_24), painter = painterResource(id = UiR.drawable.round_cake_24),
contentDescription = "Birthday icon" contentDescription = "Birthday icon",
tint = Color.White
) )
} }
} }
@@ -270,11 +271,11 @@ fun ConversationItem(
conversation.attachmentImage?.getResourcePainter()?.let { painter -> conversation.attachmentImage?.getResourcePainter()?.let { painter ->
Column { Column {
Spacer(modifier = Modifier.height(4.dp)) Spacer(modifier = Modifier.height(4.dp))
Image( Icon(
modifier = Modifier.size(14.dp), modifier = Modifier.size(14.dp),
painter = painter, painter = painter,
contentDescription = "attachment image", contentDescription = "attachment image",
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onPrimaryContainer) tint = MaterialTheme.colorScheme.onPrimaryContainer
) )
} }
@@ -366,10 +366,7 @@ fun ConversationsScreen(
state = listState, state = listState,
maxLines = maxLines, maxLines = maxLines,
modifier = if (currentTheme.enableBlur) { modifier = if (currentTheme.enableBlur) {
Modifier.haze( Modifier.haze(state = hazeState)
state = hazeState,
style = HazeMaterials.thick()
)
} else { } else {
Modifier Modifier
}.fillMaxSize(), }.fillMaxSize(),
@@ -304,10 +304,7 @@ fun FriendsScreen(
FriendsList( FriendsList(
modifier = if (currentTheme.enableBlur) { modifier = if (currentTheme.enableBlur) {
Modifier.haze( Modifier.haze(state = hazeState)
state = hazeState,
style = HazeMaterials.thick()
)
} else { } else {
Modifier Modifier
}.fillMaxSize(), }.fillMaxSize(),
@@ -17,15 +17,12 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.haze
import dev.meloda.fast.messageshistory.model.UiItem import dev.meloda.fast.messageshistory.model.UiItem
import dev.meloda.fast.ui.theme.LocalThemeConfig import dev.meloda.fast.ui.theme.LocalThemeConfig
import dev.meloda.fast.ui.util.ImmutableList import dev.meloda.fast.ui.util.ImmutableList
import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.haze
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
import dev.chrisbanes.haze.materials.HazeMaterials
@OptIn(ExperimentalHazeMaterialsApi::class)
@Composable @Composable
fun MessagesList( fun MessagesList(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
@@ -45,10 +42,7 @@ fun MessagesList(
.fillMaxWidth() .fillMaxWidth()
.then( .then(
if (currentTheme.enableBlur) { if (currentTheme.enableBlur) {
Modifier.haze( Modifier.haze(state = hazeState)
state = hazeState,
style = HazeMaterials.regular()
)
} else Modifier } else Modifier
), ),
state = listState, state = listState,
@@ -238,6 +238,11 @@ class SettingsViewModelImpl(
userSettings.onShowTimeInActionMessagesChanged(show) userSettings.onShowTimeInActionMessagesChanged(show)
} }
SettingsKeys.KEY_DEBUG_USE_SYSTEM_FONT -> {
val use = newValue as? Boolean ?: SettingsKeys.DEFAULT_DEBUG_USE_SYSTEM_FONT
userSettings.onUseSystemFontChanged(use)
}
SettingsKeys.KEY_SHOW_DEBUG_CATEGORY -> { SettingsKeys.KEY_SHOW_DEBUG_CATEGORY -> {
val show = newValue as? Boolean ?: false val show = newValue as? Boolean ?: false
userSettings.onShowDebugCategoryChanged(show) userSettings.onShowDebugCategoryChanged(show)
@@ -409,7 +414,7 @@ class SettingsViewModelImpl(
) )
val debugEnableHaptic = SettingsItem.Switch( val debugEnableHaptic = SettingsItem.Switch(
key = SettingsKeys.KEY_DEBUG_ENABLE_HAPTIC, key = SettingsKeys.KEY_DEBUG_ENABLE_HAPTIC,
defaultValue = true, defaultValue = SettingsKeys.DEFAULT_DEBUG_ENABLE_HAPTIC,
title = UiText.Simple("Enable haptic") title = UiText.Simple("Enable haptic")
) )
@@ -435,6 +440,12 @@ class SettingsViewModelImpl(
} }
} }
val debugUseSystemFont = SettingsItem.Switch(
key = SettingsKeys.KEY_DEBUG_USE_SYSTEM_FONT,
defaultValue = SettingsKeys.DEFAULT_DEBUG_USE_SYSTEM_FONT,
title = UiText.Simple("Use system font")
)
val debugHideDebugList = SettingsItem.TitleText( val debugHideDebugList = SettingsItem.TitleText(
key = SettingsKeys.KEY_DEBUG_HIDE_DEBUG_LIST, key = SettingsKeys.KEY_DEBUG_HIDE_DEBUG_LIST,
title = UiText.Simple("Hide debug list") title = UiText.Simple("Hide debug list")
@@ -475,7 +486,8 @@ class SettingsViewModelImpl(
debugShowEmojiButton, debugShowEmojiButton,
debugShowTimeInActionMessages, debugShowTimeInActionMessages,
debugEnableHaptic, debugEnableHaptic,
debugNetworkLogLevel debugNetworkLogLevel,
debugUseSystemFont
).forEach(debugList::add) ).forEach(debugList::add)
debugList += debugHideDebugList debugList += debugHideDebugList
@@ -161,10 +161,7 @@ fun SettingsScreen(
modifier = Modifier modifier = Modifier
.then( .then(
if (themeConfig.enableBlur) { if (themeConfig.enableBlur) {
Modifier.haze( Modifier.haze(state = hazeState)
state = hazeState,
style = HazeMaterials.thick()
)
} else Modifier } else Modifier
) )
.fillMaxWidth() .fillMaxWidth()
+1 -1
View File
@@ -1,5 +1,5 @@
[versions] [versions]
minSdk = "24" minSdk = "23"
targetSdk = "35" targetSdk = "35"
compileSdk = "35" compileSdk = "35"
versionCode = "5" versionCode = "5"
+2 -2
View File
@@ -1,6 +1,6 @@
#Wed Aug 09 05:41:19 MSK 2023 #Mon Oct 28 18:41:43 MSK 2024
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists