Skip to content

Commit

Permalink
Fix #215 - Add occupancy (#948)
Browse files Browse the repository at this point in the history
* Use vector icon for occupancy
* Switch LinearLayouts to ConstraintLayouts to hold occupancy views
* Realign chevron in vehicle marker balloon - Caveat - "the actual position of the view stays at the original position (before translation), it will be translated only visually. Thereby, onClick events will be only triggered from within the old position. See https://stackoverflow.com/a/51652722/937715."  This is ok for us because the entire layout is one giant hit target based on what the Google Maps API supports for marker balloons, so we can't even detect the hit target for the chevron itself.
* Parse responses for arrivals-and-departures-for-stop, trip-details, and trips-for-route APIs
* Add occupancy visibility and color unit tests - Note that directing inflating views doesn't seem to work in unit tests with getContext() or getTargetContext() so we'll use the adapter here instead to do it for us
* Add occupancy content description utility method and unit tests
* Add "About occupancy" menu option for arrivals list
* Add real-time occupancy About placeholder text - This should be replaced with icons after the design is finalized
* Reformat XML and add tools text
* Also do cleanup for hard-coded strings for debugging, extra imports, whitespace
  • Loading branch information
barbeau authored Jan 7, 2019
1 parent 256e0fc commit 885ae37
Show file tree
Hide file tree
Showing 38 changed files with 7,125 additions and 456 deletions.
30 changes: 30 additions & 0 deletions icons/occupancy_icons/occupancy-24px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions onebusaway-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ android {

multiDexEnabled true

vectorDrawables.useSupportLibrary = true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -423,6 +425,7 @@ dependencies {
}
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'android.arch.lifecycle:common-java8:1.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'commons-io:commons-io:2.4'
// Open311 client library
implementation 'edu.usf.cutr:open311client:1.0.9'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@
*/
package org.onebusaway.android.map.googlemapsv2;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.GradientDrawable;
import android.location.Location;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.amazon.geo.mapsv2.AmazonMap;
import com.amazon.geo.mapsv2.model.BitmapDescriptor;
import com.amazon.geo.mapsv2.model.BitmapDescriptorFactory;
Expand All @@ -39,27 +54,14 @@
import org.onebusaway.android.io.elements.ObaTrip;
import org.onebusaway.android.io.elements.ObaTripDetails;
import org.onebusaway.android.io.elements.ObaTripStatus;
import org.onebusaway.android.io.elements.OccupancyState;
import org.onebusaway.android.io.request.ObaTripsForRouteResponse;
import org.onebusaway.android.ui.TripDetailsActivity;
import org.onebusaway.android.ui.TripDetailsListFragment;
import org.onebusaway.android.util.ArrivalInfoUtils;
import org.onebusaway.android.util.MathUtils;
import org.onebusaway.android.util.UIUtils;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.GradientDrawable;
import android.location.Location;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -901,6 +903,7 @@ public View getInfoContents(Marker marker) {
TextView lastUpdatedView = (TextView) view.findViewById(R.id.last_updated);
ImageView moreView = (ImageView) view.findViewById(R.id.trip_more_info);
moreView.setColorFilter(r.getColor(R.color.switch_thumb_normal_material_dark));
ViewGroup occupancyView = view.findViewById(R.id.occupancy);

// Get route/trip details
ObaTrip trip = mLastResponse.getTrip(status.getActiveTripId());
Expand Down Expand Up @@ -967,6 +970,16 @@ public View getInfoContents(Marker marker) {
mMarkerRefreshHandler.postDelayed(mMarkerRefresh, MARKER_REFRESH_PERIOD);
}

if (status.getRealtimeOccupancy() != null) {
// Real-time occupancy data
UIUtils.setOccupancyVisibilityAndColor(occupancyView, status.getRealtimeOccupancy(), OccupancyState.REALTIME);
UIUtils.setOccupancyContentDescription(occupancyView, status.getRealtimeOccupancy(), OccupancyState.REALTIME);
} else {
// Hide occupancy by setting null value
UIUtils.setOccupancyVisibilityAndColor(occupancyView, null, OccupancyState.REALTIME);
UIUtils.setOccupancyContentDescription(occupancyView, null, OccupancyState.REALTIME);
}

return view;
}

Expand Down
Loading

0 comments on commit 885ae37

Please sign in to comment.