Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -386,8 +398,13 @@ class EventListAdapter(
setEventsToDisplay()
}

fun setEventsToDisplay(newEvents: Array<EventAlertRecord>? = null) = synchronized(this) {
fun setEventsToDisplay(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Search resets display mode losing alert time text

Medium Severity

The setSearchText function calls setEventsToDisplay() without passing the mode parameter. Since setEventsToDisplay defaults to EventDisplayMode.ACTIVE and unconditionally sets displayMode = mode, searching in the Upcoming Events tab resets displayMode from UPCOMING to ACTIVE. This causes the "Alert at X" text to disappear for all filtered results, breaking the core feature this PR is meant to implement.

Additional Locations (1)

Fix in Cursor Fix in Web

newEvents: Array<EventAlertRecord>? = null,
mode: EventDisplayMode = EventDisplayMode.ACTIVE
) = synchronized(this) {

displayMode = mode

if (newEvents != null){
allEvents = newEvents
events = newEvents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<string name="title_activity_activity_test_buttons_and_to_do" translatable="false">ActivityTestButtonsAndToDo</string>

<string name="snoozed_until_string">Snoozed until </string>
<string name="alert_at">Alert at %s</string>
<string name="card_view_btn_change">CHANGE</string>
<string name="card_view_btn_snooze">SNOOZE</string>
<string name="settings_name">Settings</string>
Expand Down
Loading