From dcffa6287b7a3e68ca528bf67347401be05fd182 Mon Sep 17 00:00:00 2001 From: rapterjet2004 Date: Mon, 6 Jan 2025 20:28:57 -0600 Subject: [PATCH] Impl changes, unable to replicate 1.) Signed-off-by: rapterjet2004 --- .../talk/chat/viewmodels/ChatViewModel.kt | 7 +++- .../talk/ui/dialog/DateTimeCompose.kt | 32 +++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt b/app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt index ed349b5fc5..64b029ae66 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt @@ -150,6 +150,7 @@ class ChatViewModel @Inject constructor( object GetReminderStartState : ViewState open class GetReminderExistState(val reminder: Reminder) : ViewState + object GetReminderStateSet : ViewState private val _getReminderExistState: MutableLiveData = MutableLiveData(GetReminderStartState) @@ -310,6 +311,10 @@ class ChatViewModel @Inject constructor( ?.subscribe(GetReminderObserver()) } + fun overrideReminderState() { + _getReminderExistState.value = GetReminderStateSet + } + fun deleteReminder(user: User, roomToken: String, messageId: String, chatApiVersion: Int) { chatNetworkDataSource.deleteReminder(user, roomToken, messageId, chatApiVersion) .subscribeOn(Schedulers.io()) @@ -754,7 +759,7 @@ class ChatViewModel @Inject constructor( val model = ConversationModel.mapToConversationModel(it, userProvider.currentUser.blockingGet()) ConversationUtils.isNoteToSelfConversation(model) } - _getNoteToSelfAvailability.value = NoteToSelfAvailableState(noteToSelf.token!!) + _getNoteToSelfAvailability.value = NoteToSelfAvailableState(noteToSelf.token) } catch (e: NoSuchElementException) { _getNoteToSelfAvailability.value = NoteToSelfNotAvailableState Log.e(TAG, "Note to self not found $e") diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimeCompose.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimeCompose.kt index 25ed8cea85..a6119ca827 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimeCompose.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimeCompose.kt @@ -88,6 +88,9 @@ class DateTimeCompose(val bundle: Bundle) { @Inject lateinit var viewThemeUtils: ViewThemeUtils + // TODO, can't seem to replicate 1.) on Sow's comment + // TODO make an issue out of the problem I gave marcel + @Composable fun GetDateTimeDialog(shouldDismiss: MutableState, context: Context) { if (shouldDismiss.value) { @@ -144,7 +147,7 @@ class DateTimeCompose(val bundle: Bundle) { .weight(CUBED_PADDING) ) { Text( - "Delete", + stringResource(R.string.nc_delete), color = Color.Red ) } @@ -163,7 +166,7 @@ class DateTimeCompose(val bundle: Bundle) { modifier = Modifier .weight(CUBED_PADDING) ) { - Text("Set") + Text(stringResource(R.string.set)) } TextButton( @@ -173,7 +176,7 @@ class DateTimeCompose(val bundle: Bundle) { modifier = Modifier .weight(CUBED_PADDING) ) { - Text("Close") + Text(stringResource(R.string.close)) } } } @@ -215,7 +218,7 @@ class DateTimeCompose(val bundle: Bundle) { label = stringResource(R.string.later_today), timeString = laterTodayStr ) { - timeState.value = laterToday + setTime(laterToday) } } @@ -224,7 +227,7 @@ class DateTimeCompose(val bundle: Bundle) { label = stringResource(R.string.tomorrow), timeString = tomorrowStr ) { - timeState.value = tomorrow + setTime(tomorrow) } } @@ -233,7 +236,7 @@ class DateTimeCompose(val bundle: Bundle) { label = stringResource(R.string.this_weekend), timeString = thisWeekendStr ) { - timeState.value = thisWeekend + setTime(thisWeekend) } } @@ -241,19 +244,24 @@ class DateTimeCompose(val bundle: Bundle) { label = stringResource(R.string.next_week), timeString = nextWeekStr ) { - timeState.value = nextWeek + setTime(nextWeek) } HorizontalDivider() } + private fun setTime(localDateTime: LocalDateTime) { + timeState.value = localDateTime + chatViewModel.overrideReminderState() + } + @Composable private fun Header() { Row( modifier = Modifier .padding(INT_8.dp) ) { - Text("Remind Me Later", modifier = Modifier.weight(1f)) + Text(stringResource(R.string.nc_remind), modifier = Modifier.weight(1f)) val reminderState = chatViewModel.getReminderExistState .asFlow() @@ -269,6 +277,7 @@ class DateTimeCompose(val bundle: Bundle) { else -> {} } + if (timeState.value != LocalDateTime.ofEpochSecond(0, 0, ZoneOffset.MIN)) { Text(timeState.value.format(DateTimeFormatter.ofPattern(PATTERN))) } @@ -307,9 +316,12 @@ class DateTimeCompose(val bundle: Bundle) { val day = date.dayOfMonth val hour = timePickerState.hour val minute = timePickerState.minute - timeState.value = LocalDateTime.of(year, month, day, hour, minute) + val newTime = LocalDateTime.of(year, month, day, hour, minute) + setTime(newTime) + } else { - timeState.value = LocalDate.now().atTime(timePickerState.hour, timePickerState.minute) + val newTime = LocalDate.now().atTime(timePickerState.hour, timePickerState.minute) + setTime(newTime) } } Submission(shouldDismiss)