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
Expand Up @@ -659,6 +659,7 @@ synchronized void refresh() {
refreshStopFavorite();
refreshFilter();
refreshError();
refreshHideAllAlerts();
refreshHiddenAlerts();
refreshArrivalInfoVisibilityAndListeners();
refreshHeaderSize();
Expand Down Expand Up @@ -1388,6 +1389,91 @@ public boolean equals(Object obj) {
}
}

private HideAllAlert mHideAllAlert = null;

private static class HideAllAlert implements AlertList.Alert {
private final CharSequence mString;
private final Controller mController;

HideAllAlert(CharSequence seq, Controller controller) {
mString = seq;
mController = controller;
}

@Override
public String getId() {
return "STATIC: HIDE ALL ALERT";
}

@Override
public int getType() {

return TYPE_SHOW_HIDDEN_ALERTS;
}

@Override
public int getFlags() {
return FLAG_HASMORE;
}

@Override
public CharSequence getString() {
return mString;
}

@Override
public void onClick() {
ObaContract.ServiceAlerts.hideAllAlerts();
mController.refresh();
}

@Override
public int hashCode() {
return getId().hashCode();
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
HideAllAlert other = (HideAllAlert) obj;
return getId().equals(other.getId());
}
}

private void refreshHideAllAlerts() {
if (mController == null) {
return;
}
AlertList alerts = mController.getAlertList();

if (mHideAllAlert != null) {
alerts.remove(mHideAllAlert);
}

Comment on lines +1450 to +1453

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

If visibleAlertCount is 0, mHideAllAlert is removed from the list but the field is left non-null, so subsequent refreshes will keep calling alerts.remove(mHideAllAlert) on an object that's no longer in the adapter. It would be cleaner to set mHideAllAlert = null when the banner isn't shown.

Copilot uses AI. Check for mistakes.
// Count visible alerts (excluding response errors and special alerts)
int visibleAlertCount = 0;
for (int i = 0; i < alerts.getCount(); i++) {
AlertList.Alert alert = alerts.getItem(i);
int type = alert.getType();
if (type == AlertList.Alert.TYPE_ERROR || type == AlertList.Alert.TYPE_WARNING ||
type == AlertList.Alert.TYPE_INFO) {
visibleAlertCount++;
}
}
Comment on lines +1454 to +1463

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

visibleAlertCount currently counts any TYPE_ERROR/TYPE_WARNING/TYPE_INFO entries, which includes the "STATIC: RESPONSE ERROR" banner inserted by refreshError() (it returns TYPE_ERROR). This can cause the hide-all banner to appear even when the only alert is a response error, and clicking "hide all" won't clear that response error. Consider excluding ResponseError (or excluding alerts with getId() starting with "STATIC:") from the visible-alert count so the banner only appears when there are hideable service alerts.

Copilot uses AI. Check for mistakes.

// Show hide all button if there are visible alerts
if (visibleAlertCount > 0) {
CharSequence activeAlertsText = mContext.getResources().getQuantityString(
R.plurals.alert_filter_text, visibleAlertCount, visibleAlertCount);
CharSequence hideAllText = mContext.getResources().getString(R.string.alert_hide_all);
CharSequence combinedText = activeAlertsText + " " + hideAllText;

mHideAllAlert = new HideAllAlert(combinedText, mController);
alerts.insert(mHideAllAlert, 0);
}
Comment on lines +1466 to +1474

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

The filter banner UI uses alert_item.xml's @id/show_all_alerts TextView, whose text is hardcoded to @string/alert_filter_showall ("(show all)") and is what the adapter makes clickable. Since HideAllAlert reuses TYPE_SHOW_HIDDEN_ALERTS, the row will still display "(show all)" while executing hideAllAlerts() on click, and combinedText also embeds "(hide all)", likely resulting in contradictory/duplicated UI. To make this work, the adapter/layout needs a way to set the action label per alert (e.g., introduce a new alert type for hide-all or add an action-label field/method and set showAllView text accordingly), and avoid embedding the action label into the count text.

Copilot uses AI. Check for mistakes.
}

private void refreshHiddenAlerts() {
if (mController == null) {
return;
Expand Down
5 changes: 3 additions & 2 deletions onebusaway-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,15 @@
<string name="all_alert_hidden_snackbar_text">All alerts are now hidden</string>
<string name="alert_hidden_snackbar_action">UNDO</string>
<plurals name="alert_filter_text">
<item quantity="one">%1$d active alert is hidden</item>
<item quantity="one">%1$d active alert shown</item>
<!-- Entire element below should be on a single line if XML is reformatted - see #99 -->
<item quantity="other">
<xliff:g id="count">%1$d</xliff:g>
active alerts are hidden
active alerts shown
</item>
</plurals>
Comment on lines 424 to 431

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

alert_filter_text is used by refreshHiddenAlerts() to describe the number of hidden alerts (see ArrivalsListHeader.java:1490-1492), but it was changed here to say "shown". This will make the existing "show hidden alerts" banner display incorrect text (e.g., it will report hidden alerts as "shown"). Consider keeping alert_filter_text as the hidden-count text and introducing a new plurals resource for the visible/active alerts count used by the new hide-all banner.

Copilot uses AI. Check for mistakes.
<string name="alert_filter_showall">(show all)</string>
<string name="alert_hide_all">(hide all)</string>

<!-- Find -->
<string name="find_hint_nofavoritestops">Find a stop by entering its stop number in the search
Expand Down
Loading