Skip to content

Commit 40630b8

Browse files
committed
Fixing issues in review
1 parent d437798 commit 40630b8

6 files changed

Lines changed: 55 additions & 13 deletions

File tree

onebusaway-android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ dependencies {
255255
implementation 'com.github.OneBusAway:pelias-client-library:v1.1.0'
256256
implementation 'androidx.appcompat:appcompat:1.7.0'
257257
implementation 'com.google.firebase:firebase-messaging:24.1.0'
258-
implementation 'androidx.test.ext:junit:1.3.0'
258+
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
259259
// Google Play Services Maps (only for Google flavor)
260260
googleImplementation 'com.google.android.gms:play-services-maps:19.0.0'
261261
// MapLibre GL Native (only for MapLibre flavor)

onebusaway-android/src/androidTest/java/org/onebusaway/android/util/test/ArrivalInfoUtilsTest.java

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void tearDown() {
6363
* @throws Exception
6464
*/
6565
@Test
66-
public void TestShowAllByDefault() throws Exception {
66+
public void testShowAllByDefault() throws Exception {
6767
long now = System.currentTimeMillis();
6868

6969
ObaArrivalInfo scheduledOnly = createArrival(
@@ -96,7 +96,7 @@ public void TestShowAllByDefault() throws Exception {
9696
* @throws Exception
9797
*/
9898
@Test
99-
public void TestHideScheduledWithBothKinds() throws Exception {
99+
public void testHideScheduledWithBothKinds() throws Exception {
100100
prefs.edit().putBoolean(hideScheduledKey, true).commit();
101101

102102
long now = System.currentTimeMillis();
@@ -133,7 +133,7 @@ public void TestHideScheduledWithBothKinds() throws Exception {
133133
* @throws Exception
134134
*/
135135
@Test
136-
public void TestHideScheduleWithAllSchedule() throws Exception {
136+
public void testHideScheduledWithAllScheduled() throws Exception {
137137
prefs.edit().putBoolean(hideScheduledKey, true).commit();
138138

139139
long now = System.currentTimeMillis();
@@ -162,6 +162,47 @@ public void TestHideScheduleWithAllSchedule() throws Exception {
162162
}
163163

164164

165+
/**
166+
* Verifies that when a route filter is applied and the "hide scheduled arrivals"
167+
* preference is enabled, scheduled-only arrivals within the filtered set are
168+
* excluded from the result.
169+
*/
170+
@Test
171+
public void testHideScheduledWithRouteFilter() throws Exception {
172+
prefs.edit().putBoolean(hideScheduledKey, true).commit();
173+
174+
long now = System.currentTimeMillis();
175+
176+
ObaArrivalInfo scheduledRoute8 = createArrival(
177+
"1_100", "8", "Downtown", "STOP_1",
178+
now + 10 * 60_000L, 0L,
179+
now + 10 * 60_000L, 0L,
180+
false
181+
);
182+
183+
ObaArrivalInfo realtimeRoute49 = createArrival(
184+
"1_200", "49", "Uptown", "STOP_1",
185+
now + 12 * 60_000L, now + 13 * 60_000L,
186+
now + 12 * 60_000L, now + 13 * 60_000L,
187+
true
188+
);
189+
190+
ObaArrivalInfo[] arrivals = new ObaArrivalInfo[]{scheduledRoute8, realtimeRoute49};
191+
192+
ArrayList<String> filter = new ArrayList<>();
193+
filter.add("1_100");
194+
filter.add("1_200");
195+
196+
ArrayList<ArrivalInfo> result = ArrivalInfoUtils.convertObaArrivalInfo(
197+
context, arrivals, filter, now, false
198+
);
199+
200+
assertEquals(1, result.size());
201+
assertEquals("49", result.get(0).getInfo().getShortName());
202+
assertTrue(result.get(0).getPredicted());
203+
}
204+
205+
165206
private ObaArrivalInfo createArrival(String routeId,
166207
String shortName,
167208
String headsign,

onebusaway-android/src/main/java/org/onebusaway/android/ui/ArrivalsListFragment.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -616,13 +616,15 @@ public void onPrepareOptionsMenu(Menu menu) {
616616
}
617617

618618
MenuItem menuItemScheduledArrivals = menu.findItem(R.id.toggle_scheduled_arrivals);
619-
boolean hideScheduled = Application.getPrefs()
620-
.getBoolean(getString(R.string.preference_key_hide_scheduled_arrivals), false);
621-
title = hideScheduled ?
622-
getString(R.string.stop_info_option_show_scheduled_arrivals) :
623-
getString(R.string.stop_info_option_hide_scheduled_arrivals);
624-
menuItemScheduledArrivals.setTitle(title);
625-
menuItemScheduledArrivals.setTitleCondensed(title);
619+
if (menuItemScheduledArrivals != null) {
620+
boolean hideScheduled = Application.getPrefs()
621+
.getBoolean(getString(R.string.preference_key_hide_scheduled_arrivals), false);
622+
title = hideScheduled ?
623+
getString(R.string.stop_info_option_show_scheduled_arrivals) :
624+
getString(R.string.stop_info_option_hide_scheduled_arrivals);
625+
menuItemScheduledArrivals.setTitle(title);
626+
menuItemScheduledArrivals.setTitleCondensed(title);
627+
}
626628

627629
if (mExternalHeader) {
628630
// If we're using an external header, it means that this fragment is being shown

onebusaway-android/src/main/res/menu-v14/arrivals_list.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
android:title="@string/stop_info_option_night_light"/>
5555
<item android:id="@+id/hide_alerts"
5656
android:title="@string/stop_info_option_hide_alerts"/>
57-
android:title="@string/stop_info_option_hide_alerts"/>
5857
<item android:id="@+id/toggle_scheduled_arrivals"
5958
android:title="@string/stop_info_option_hide_scheduled_arrivals"/>
6059
</group>

onebusaway-android/src/main/res/values/donottranslate.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
<string name="preferences_key_user_denied_location_permissions">preferences_key_user_denied_location_permissions</string>
7474
<string name="preference_key_push_firebase_data">preference_key_push_firebase_data</string>
7575
<string name="preferences_display_test_alerts">preferences_display_test_alerts</string>
76+
<string name="preference_key_hide_scheduled_arrivals">preference_key_hide_scheduled_arrivals</string>
7677
<!-- Regions API URL -->
7778
<string name="regions_api_url">https://regions.onebusaway.org/regions-v3.json</string>
7879

onebusaway-android/src/main/res/values/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@
434434
<!-- Hide/Show scheduled arrivals/departures -->
435435
<string name="stop_info_option_hide_scheduled_arrivals">Hide scheduled arrivals/departures</string>
436436
<string name="stop_info_option_show_scheduled_arrivals">Show scheduled arrivals/departures</string>
437-
<string name="preference_key_hide_scheduled_arrivals">preference_key_hide_scheduled_arrivals</string>
438437

439438
<!-- Find -->
440439
<string name="find_hint_nofavoritestops">Find a stop by entering its stop number in the search

0 commit comments

Comments
 (0)