diff --git a/app/src/main/java/com/ivy/wallet/RootActivity.kt b/app/src/main/java/com/ivy/wallet/RootActivity.kt index 2369ebb5a2..6e886adbdd 100644 --- a/app/src/main/java/com/ivy/wallet/RootActivity.kt +++ b/app/src/main/java/com/ivy/wallet/RootActivity.kt @@ -184,11 +184,15 @@ class RootActivity : AppCompatActivity(), RootScreen { } private fun setupTimePicker() { - ivyContext.onShowTimePicker = { onTimePicked -> - val nowLocal = timeNowLocal() + ivyContext.onShowTimePicker = { initialTime, + onTimePicked -> + val nowLocal = initialTime ?: timeNowLocal().toLocalTime() + val is24Hour = android.text.format.DateFormat.is24HourFormat(this) + val timeFormat = if (is24Hour) TimeFormat.CLOCK_24H else TimeFormat.CLOCK_12H + val picker = MaterialTimePicker.Builder() - .setTimeFormat(TimeFormat.CLOCK_12H) + .setTimeFormat(timeFormat) .setHour(nowLocal.hour) .setMinute(nowLocal.minute) .build() diff --git a/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt b/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt index 3dd90b588c..508d5a40c2 100644 --- a/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt +++ b/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt @@ -385,7 +385,9 @@ private fun BoxWithConstraintsScope.UI( } }, onEditTime = { - ivyContext.timePicker { time -> + ivyContext.timePicker( + initialTime = dateTime?.toLocalTime() + ) { time -> onSetTime(time) } } diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/IvyWalletCtx.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/IvyWalletCtx.kt index 96c1ff477b..ceefa80674 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/IvyWalletCtx.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/IvyWalletCtx.kt @@ -114,7 +114,10 @@ class IvyWalletCtx @Inject constructor() : IvyContext() { initialDate: LocalDate?, onDatePicked: (LocalDate) -> Unit ) -> Unit - lateinit var onShowTimePicker: (onDatePicked: (LocalTime) -> Unit) -> Unit + lateinit var onShowTimePicker: ( + initialTime: LocalTime?, + onDatePicked: (LocalTime) -> Unit + ) -> Unit @Deprecated("Legacy code. Don't use it, please.") fun datePicker( @@ -127,8 +130,11 @@ class IvyWalletCtx @Inject constructor() : IvyContext() { } @Deprecated("Legacy code. Don't use it, please.") - fun timePicker(onTimePicked: (LocalTime) -> Unit) { - onShowTimePicker(onTimePicked) + fun timePicker( + initialTime: LocalTime?, + onTimePicked: (LocalTime) -> Unit + ) { + onShowTimePicker(initialTime, onTimePicked) } // Activity help ------------------------------------------------------------------------------- diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/DateTimeRow.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/DateTimeRow.kt index af639a9065..7fc77fc86a 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/DateTimeRow.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/components/DateTimeRow.kt @@ -48,7 +48,9 @@ fun DateTimeRow( text = dateTime.formatLocalTime(), iconStart = R.drawable.ic_date ) { - ivyContext.timePicker { + ivyContext.timePicker( + initialTime = dateTime.convertUTCtoLocal().toLocalTime() + ) { onSetDateTime(getTrueDate(dateTime.convertUTCtoLocal().toLocalDate(), it)) } }