From 9e73a2db9201f7f3afbda0034cd2de6436861b8e Mon Sep 17 00:00:00 2001 From: William Harris Date: Thu, 15 Jan 2026 06:27:08 +0000 Subject: [PATCH] fix: alert time on upcoming events --- .../quarck/calnotify/ui/EventDisplayMode.kt | 33 +++++++++++++++++ .../quarck/calnotify/ui/EventListAdapter.kt | 37 ++++++++++++++----- .../calnotify/ui/UpcomingEventsFragment.kt | 2 +- android/app/src/main/res/values/strings.xml | 1 + 4 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 android/app/src/main/java/com/github/quarck/calnotify/ui/EventDisplayMode.kt diff --git a/android/app/src/main/java/com/github/quarck/calnotify/ui/EventDisplayMode.kt b/android/app/src/main/java/com/github/quarck/calnotify/ui/EventDisplayMode.kt new file mode 100644 index 000000000..6a1f7d110 --- /dev/null +++ b/android/app/src/main/java/com/github/quarck/calnotify/ui/EventDisplayMode.kt @@ -0,0 +1,33 @@ +// +// Calendar Notifications Plus +// Copyright (C) 2025 William Harris (wharris+cnplus@upscalews.com) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + +package com.github.quarck.calnotify.ui + +/** + * Display mode for event lists, determining how events are rendered. + * + * - ACTIVE: Normal active events (shows "Snoozed until" if snoozed) + * - UPCOMING: Upcoming events before notification fires (shows "Alert at" for reminder time) + * - DISMISSED: Dismissed events (shows dismiss reason) + */ +enum class EventDisplayMode { + ACTIVE, + UPCOMING, + DISMISSED +} diff --git a/android/app/src/main/java/com/github/quarck/calnotify/ui/EventListAdapter.kt b/android/app/src/main/java/com/github/quarck/calnotify/ui/EventListAdapter.kt index a93433cf6..9ed2a955f 100644 --- a/android/app/src/main/java/com/github/quarck/calnotify/ui/EventListAdapter.kt +++ b/android/app/src/main/java/com/github/quarck/calnotify/ui/EventListAdapter.kt @@ -131,6 +131,7 @@ class EventListAdapter( private val changeString: String private val snoozeString: String private var currentSearchString: String? = null + private var displayMode: EventDisplayMode = EventDisplayMode.ACTIVE private var currentScrollPosition: Int = 0 @@ -349,15 +350,26 @@ class EventListAdapter( holder.eventTimeText.text = detail2 } - if (event.snoozedUntil != 0L) { - holder.snoozedUntilText?.text = - context.resources.getString(R.string.snoozed_until_string) + " " + eventFormatter.formatSnoozedUntil(event); - - holder.snoozedUntilText?.visibility = View.VISIBLE; - } - else { - holder.snoozedUntilText?.text = ""; - holder.snoozedUntilText?.visibility = View.GONE; + when { + // Upcoming events: show "Alert at X" (when the notification will fire) + displayMode == EventDisplayMode.UPCOMING -> { + holder.snoozedUntilText?.text = context.resources.getString( + R.string.alert_at, + eventFormatter.formatTimePoint(event.alertTime) + ) + holder.snoozedUntilText?.visibility = View.VISIBLE + } + // Active snoozed events: show "Snoozed until X" + event.snoozedUntil != 0L -> { + holder.snoozedUntilText?.text = + context.resources.getString(R.string.snoozed_until_string) + " " + eventFormatter.formatSnoozedUntil(event) + holder.snoozedUntilText?.visibility = View.VISIBLE + } + // Active non-snoozed events: hide the text + else -> { + holder.snoozedUntilText?.text = "" + holder.snoozedUntilText?.visibility = View.GONE + } } holder.calendarColor.color = @@ -386,8 +398,13 @@ class EventListAdapter( setEventsToDisplay() } - fun setEventsToDisplay(newEvents: Array? = null) = synchronized(this) { + fun setEventsToDisplay( + newEvents: Array? = null, + mode: EventDisplayMode = EventDisplayMode.ACTIVE + ) = synchronized(this) { + displayMode = mode + if (newEvents != null){ allEvents = newEvents events = newEvents; diff --git a/android/app/src/main/java/com/github/quarck/calnotify/ui/UpcomingEventsFragment.kt b/android/app/src/main/java/com/github/quarck/calnotify/ui/UpcomingEventsFragment.kt index 1a9d025a4..7181fdf40 100644 --- a/android/app/src/main/java/com/github/quarck/calnotify/ui/UpcomingEventsFragment.kt +++ b/android/app/src/main/java/com/github/quarck/calnotify/ui/UpcomingEventsFragment.kt @@ -137,7 +137,7 @@ class UpcomingEventsFragment : Fragment(), EventListCallback, SearchableFragment } activity?.runOnUiThread { - adapter.setEventsToDisplay(events) + adapter.setEventsToDisplay(events, EventDisplayMode.UPCOMING) updateEmptyState() refreshLayout.isRefreshing = false // Update search hint with new event count diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 2ba192112..c2eb8a1fd 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -39,6 +39,7 @@ ActivityTestButtonsAndToDo Snoozed until + Alert at %s CHANGE SNOOZE Settings