From f175567cde0bd9e9aaf911f5bd86c303d6421f6d Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Wed, 27 Jun 2018 16:33:36 -0400 Subject: [PATCH] Force selected time to be in the future --- .../java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt | 5 +++++ presentation/src/main/res/values/strings.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt index a3067713..4eb70813 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt @@ -478,6 +478,11 @@ class ComposeViewModel @Inject constructor( // Set the scheduled time view.scheduleSelectedIntent + .filter { scheduled -> + (scheduled > System.currentTimeMillis()).also { future -> + if (!future) context.toast(R.string.compose_scheduled_future) + } + } .autoDisposable(view.scope()) .subscribe { scheduled -> newState { copy(scheduled = scheduled) } } diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 4ecb2276..49ffd7f1 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -89,6 +89,7 @@ This is the start of your conversation. Say something nice! Contact card Scheduled for + Selected time must be in the future! Added to scheduled messages Write a message… Copy text