Fix crash

Fix #1017
This commit is contained in:
MM20 2024-08-12 14:42:20 +02:00
parent 56014794fc
commit 1a4f4d5e96
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
2 changed files with 5 additions and 2 deletions

View File

@ -3,7 +3,6 @@ package de.mm20.launcher2.searchactions.builders
import android.content.Context
import de.mm20.launcher2.searchactions.R
import de.mm20.launcher2.searchactions.TextClassificationResult
import de.mm20.launcher2.searchactions.actions.MessageAction
import de.mm20.launcher2.searchactions.actions.ScheduleEventAction
import de.mm20.launcher2.searchactions.actions.SearchAction
import de.mm20.launcher2.searchactions.actions.SearchActionIcon
@ -28,7 +27,10 @@ class ScheduleEventActionBuilder(
time = classifiedQuery.time
)
}
if (classifiedQuery.timespan != null && classifiedQuery.timespan.seconds > 86400) {
// Time spans that are shorter than 24 hours are already handled by the TimerActionBuilder
if (classifiedQuery.timespan != null && classifiedQuery.timespan.seconds > 86400
&& classifiedQuery.timespan.seconds < 3153600000
) {
val datetime = LocalDateTime.now().plus(classifiedQuery.timespan)
return ScheduleEventAction(
context.getString(R.string.search_action_event),

View File

@ -18,6 +18,7 @@ class TimerActionBuilder(
override val icon: SearchActionIcon = SearchActionIcon.Timer
override fun build(context: Context, classifiedQuery: TextClassificationResult): SearchAction? {
// Maximum time span for a timer is 24 hours, see https://developer.android.com/reference/android/provider/AlarmClock#EXTRA_LENGTH
if (classifiedQuery.timespan != null && classifiedQuery.timespan.seconds <= 86400) {
return TimerAction(
context.getString(R.string.search_action_timer), classifiedQuery.timespan