some updates

This commit is contained in:
2025-03-23 20:51:15 +03:00
parent ad6e413bbb
commit 3fdb574971
7 changed files with 69 additions and 34 deletions
@@ -43,7 +43,6 @@ import dev.meloda.fast.model.BaseError
import dev.meloda.fast.model.BottomNavigationItem import dev.meloda.fast.model.BottomNavigationItem
import dev.meloda.fast.navigation.MainGraph import dev.meloda.fast.navigation.MainGraph
import dev.meloda.fast.profile.navigation.profileScreen import dev.meloda.fast.profile.navigation.profileScreen
import dev.meloda.fast.ui.theme.LocalBottomPadding
import dev.meloda.fast.ui.theme.LocalHazeState import dev.meloda.fast.ui.theme.LocalHazeState
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
@@ -146,11 +145,11 @@ fun MainScreen(
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.padding(bottom = if (currentTheme.enableBlur) 0.dp else padding.calculateBottomPadding()) .padding(bottom = padding.calculateBottomPadding())
) { ) {
CompositionLocalProvider( CompositionLocalProvider(
LocalHazeState provides hazeState, LocalHazeState provides hazeState,
LocalBottomPadding provides if (currentTheme.enableBlur) padding.calculateBottomPadding() else 0.dp // LocalBottomPadding provides if (currentTheme.enableBlur) padding.calculateBottomPadding() else 0.dp
) { ) {
NavHost( NavHost(
navController = navController, navController = navController,
@@ -49,6 +49,11 @@ class LongPollingService : Service() {
throwable.printStackTrace() throwable.printStackTrace()
} }
if (throwable is LongPollException) {
// TODO: 23-Mar-25, Danil Nikolaev: restart LongPoll
return@CoroutineExceptionHandler
}
longPollController.updateCurrentState(LongPollState.Exception) longPollController.updateCurrentState(LongPollState.Exception)
longPollController.setStateToApply(LongPollState.Exception) longPollController.setStateToApply(LongPollState.Exception)
} }
@@ -142,7 +147,7 @@ class LongPollingService : Service() {
Log.d(STATE_TAG, "job started") Log.d(STATE_TAG, "job started")
return coroutineScope.launch { return coroutineScope.launch(coroutineContext) {
if (UserConfig.accessToken.isEmpty()) { if (UserConfig.accessToken.isEmpty()) {
throw NoAccessTokenException throw NoAccessTokenException
} }
+3 -3
View File
@@ -7,13 +7,13 @@ plugins {
group = "dev.meloda.fast.buildlogic" group = "dev.meloda.fast.buildlogic"
java { java {
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_21
} }
kotlin { kotlin {
compilerOptions { compilerOptions {
jvmTarget = JvmTarget.JVM_17 jvmTarget = JvmTarget.JVM_21
} }
} }
@@ -23,8 +23,8 @@ internal fun Project.configureKotlinAndroid(
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_21
} }
} }
@@ -33,8 +33,8 @@ internal fun Project.configureKotlinAndroid(
internal fun Project.configureKotlinJvm() { internal fun Project.configureKotlinJvm() {
extensions.configure<JavaPluginExtension> { extensions.configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_21
} }
configureKotlin<KotlinJvmProjectExtension>() configureKotlin<KotlinJvmProjectExtension>()
@@ -49,7 +49,7 @@ private inline fun <reified T : KotlinBaseExtension> Project.configureKotlin() =
is KotlinJvmProjectExtension -> compilerOptions is KotlinJvmProjectExtension -> compilerOptions
else -> TODO("Unsupported project extension $this ${T::class}") else -> TODO("Unsupported project extension $this ${T::class}")
}.apply { }.apply {
jvmTarget = JvmTarget.JVM_17 jvmTarget = JvmTarget.JVM_21
allWarningsAsErrors = warningsAsErrors.toBoolean() allWarningsAsErrors = warningsAsErrors.toBoolean()
freeCompilerArgs.addAll( freeCompilerArgs.addAll(
"-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlin.RequiresOptIn",
@@ -46,8 +46,6 @@ fun FriendsList(
val coroutineScope = rememberCoroutineScope() val coroutineScope = rememberCoroutineScope()
val friends = uiFriends.toList()
LazyColumn( LazyColumn(
modifier = modifier, modifier = modifier,
state = listState state = listState
@@ -58,7 +56,7 @@ fun FriendsList(
} }
items( items(
items = friends, items = uiFriends.toList(),
key = UiFriend::userId, key = UiFriend::userId,
) { friend -> ) { friend ->
FriendItem( FriendItem(
@@ -1,6 +1,5 @@
package dev.meloda.fast.messageshistory.presentation package dev.meloda.fast.messageshistory.presentation
import android.content.SharedPreferences
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateContentSize import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.Animatable import androidx.compose.animation.core.Animatable
@@ -78,7 +77,7 @@ import androidx.core.view.HapticFeedbackConstantsCompat
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil.compose.AsyncImage import coil.compose.AsyncImage
import dev.chrisbanes.haze.HazeState import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.hazeChild import dev.chrisbanes.haze.hazeEffect
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
import dev.chrisbanes.haze.materials.HazeMaterials import dev.chrisbanes.haze.materials.HazeMaterials
import dev.meloda.fast.datastore.AppSettings import dev.meloda.fast.datastore.AppSettings
@@ -90,6 +89,7 @@ import dev.meloda.fast.messageshistory.model.MessagesHistoryScreenState
import dev.meloda.fast.messageshistory.util.firstMessage import dev.meloda.fast.messageshistory.util.firstMessage
import dev.meloda.fast.messageshistory.util.indexOfMessageByCmId import dev.meloda.fast.messageshistory.util.indexOfMessageByCmId
import dev.meloda.fast.model.BaseError import dev.meloda.fast.model.BaseError
import dev.meloda.fast.ui.components.ErrorView
import dev.meloda.fast.ui.components.IconButton import dev.meloda.fast.ui.components.IconButton
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
@@ -119,8 +119,9 @@ fun MessagesHistoryRoute(
canPaginate = canPaginate, canPaginate = canPaginate,
showEmojiButton = showEmojiButton, showEmojiButton = showEmojiButton,
onBack = onBack, onBack = onBack,
onSessionExpiredLogOutButtonClicked = { onError(BaseError.SessionExpired) },
onChatMaterialsDropdownItemClicked = onChatMaterialsDropdownItemClicked, onChatMaterialsDropdownItemClicked = onChatMaterialsDropdownItemClicked,
onRefreshDropdownItemClicked = viewModel::onRefresh, onRefresh = viewModel::onRefresh,
onPaginationConditionsMet = viewModel::onPaginationConditionsMet, onPaginationConditionsMet = viewModel::onPaginationConditionsMet,
onMessageInputChanged = viewModel::onMessageInputChanged, onMessageInputChanged = viewModel::onMessageInputChanged,
onAttachmentButtonClicked = viewModel::onAttachmentButtonClicked, onAttachmentButtonClicked = viewModel::onAttachmentButtonClicked,
@@ -141,9 +142,9 @@ fun MessagesHistoryScreen(
canPaginate: Boolean = false, canPaginate: Boolean = false,
showEmojiButton: Boolean = false, showEmojiButton: Boolean = false,
onBack: () -> Unit = {}, onBack: () -> Unit = {},
onSessionExpiredLogOutButtonClicked: () -> Unit = {},
onChatMaterialsDropdownItemClicked: (peerId: Int, conversationMessageId: Int) -> Unit = { _, _ -> }, onChatMaterialsDropdownItemClicked: (peerId: Int, conversationMessageId: Int) -> Unit = { _, _ -> },
onRefreshDropdownItemClicked: () -> Unit = {}, onRefresh: () -> Unit = {},
onToggleAnimationsDropdownItemClicked: (Boolean) -> Unit = {},
onPaginationConditionsMet: () -> Unit = {}, onPaginationConditionsMet: () -> Unit = {},
onMessageInputChanged: (TextFieldValue) -> Unit = {}, onMessageInputChanged: (TextFieldValue) -> Unit = {},
onAttachmentButtonClicked: () -> Unit = {}, onAttachmentButtonClicked: () -> Unit = {},
@@ -154,7 +155,6 @@ fun MessagesHistoryScreen(
val coroutineScope = rememberCoroutineScope() val coroutineScope = rememberCoroutineScope()
val preferences: SharedPreferences = koinInject()
val currentTheme = LocalThemeConfig.current val currentTheme = LocalThemeConfig.current
val listState = rememberLazyListState() val listState = rememberLazyListState()
@@ -200,7 +200,7 @@ fun MessagesHistoryScreen(
modifier = Modifier modifier = Modifier
.then( .then(
if (currentTheme.enableBlur) { if (currentTheme.enableBlur) {
Modifier.hazeChild( Modifier.hazeEffect(
state = hazeState, state = hazeState,
style = HazeMaterials.thick() style = HazeMaterials.thick()
) )
@@ -237,8 +237,8 @@ fun MessagesHistoryScreen(
Text( Text(
text = text =
if (screenState.isLoading) stringResource(id = UiR.string.title_loading) if (screenState.isLoading) stringResource(id = UiR.string.title_loading)
else screenState.title, else screenState.title,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.headlineSmall style = MaterialTheme.typography.headlineSmall
@@ -282,7 +282,7 @@ fun MessagesHistoryScreen(
// TODO: 11/07/2024, Danil Nikolaev: to VM // TODO: 11/07/2024, Danil Nikolaev: to VM
// TODO: 23-Mar-25, Danil Nikolaev: crash if not messages (ex. new chat) // TODO: 23-Mar-25, Danil Nikolaev: crash if no messages (ex. new chat)
onChatMaterialsDropdownItemClicked( onChatMaterialsDropdownItemClicked(
screenState.conversationId, screenState.conversationId,
screenState.messages.firstMessage().conversationMessageId screenState.messages.firstMessage().conversationMessageId
@@ -294,7 +294,7 @@ fun MessagesHistoryScreen(
) )
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
onRefreshDropdownItemClicked() onRefresh()
dropDownMenuExpanded = false dropDownMenuExpanded = false
}, },
text = { text = {
@@ -323,6 +323,7 @@ fun MessagesHistoryScreen(
} }
} }
) { padding -> ) { padding ->
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
@@ -386,7 +387,9 @@ fun MessagesHistoryScreen(
IconButton( IconButton(
onClick = { onClick = {
if (AppSettings.General.enableHaptic) { if (AppSettings.General.enableHaptic) {
view.performHapticFeedback(HapticFeedbackConstantsCompat.REJECT) view.performHapticFeedback(
HapticFeedbackConstantsCompat.REJECT
)
} }
scope.launch { scope.launch {
for (i in 20 downTo 0 step 4) { for (i in 20 downTo 0 step 4) {
@@ -405,7 +408,9 @@ fun MessagesHistoryScreen(
}, },
onLongClick = { onLongClick = {
if (AppSettings.General.enableHaptic) { if (AppSettings.General.enableHaptic) {
view.performHapticFeedback(HapticFeedbackConstantsCompat.LONG_PRESS) view.performHapticFeedback(
HapticFeedbackConstantsCompat.LONG_PRESS
)
} }
onEmojiButtonLongClicked() onEmojiButtonLongClicked()
}, },
@@ -447,8 +452,11 @@ fun MessagesHistoryScreen(
Column(verticalArrangement = Arrangement.Bottom) { Column(verticalArrangement = Arrangement.Bottom) {
IconButton( IconButton(
onClick = { onClick = {
onAttachmentButtonClicked()
if (AppSettings.General.enableHaptic) { if (AppSettings.General.enableHaptic) {
view.performHapticFeedback(HapticFeedbackConstantsCompat.REJECT) view.performHapticFeedback(
HapticFeedbackConstantsCompat.REJECT
)
} }
scope.launch { scope.launch {
for (i in 20 downTo 0 step 4) { for (i in 20 downTo 0 step 4) {
@@ -484,7 +492,9 @@ fun MessagesHistoryScreen(
onClick = { onClick = {
if (screenState.actionMode == ActionMode.Record) { if (screenState.actionMode == ActionMode.Record) {
if (AppSettings.General.enableHaptic) { if (AppSettings.General.enableHaptic) {
view.performHapticFeedback(HapticFeedbackConstantsCompat.REJECT) view.performHapticFeedback(
HapticFeedbackConstantsCompat.REJECT
)
} }
scope.launch { scope.launch {
for (i in 20 downTo 0 step 4) { for (i in 20 downTo 0 step 4) {
@@ -535,9 +545,32 @@ fun MessagesHistoryScreen(
} }
} }
if (screenState.isLoading && screenState.messages.isEmpty()) { when {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center)) screenState.isLoading && screenState.messages.isEmpty() -> {
CircularProgressIndicator(modifier = Modifier.align(Alignment.Center))
}
baseError != null -> {
when (baseError) {
is BaseError.SessionExpired -> {
ErrorView(
text = stringResource(UiR.string.session_expired),
buttonText = stringResource(UiR.string.action_log_out),
onButtonClick = onSessionExpiredLogOutButtonClicked
)
}
is BaseError.SimpleError -> {
ErrorView(
text = baseError.message,
buttonText = stringResource(UiR.string.try_again),
onButtonClick = onRefresh
)
}
}
}
} }
} }
} }
} }
+2 -2
View File
@@ -9,8 +9,8 @@ agp = "8.9.0"
converterMoshi = "2.11.0" converterMoshi = "2.11.0"
eithernet = "2.0.0" eithernet = "2.0.0"
haze = "1.5.1" haze = "1.5.1"
kotlin = "2.1.10" kotlin = "2.1.20"
ksp = "2.1.10-1.0.31" ksp = "2.1.20-1.0.31"
compose-bom = "2025.03.00" compose-bom = "2025.03.00"
koin = "4.0.2" koin = "4.0.2"