diff --git a/app/src/main/java/com/bentonow/bentonow/Utils/ConstantUtils.java b/app/src/main/java/com/bentonow/bentonow/Utils/ConstantUtils.java index 6928181..fc58cb7 100644 --- a/app/src/main/java/com/bentonow/bentonow/Utils/ConstantUtils.java +++ b/app/src/main/java/com/bentonow/bentonow/Utils/ConstantUtils.java @@ -21,6 +21,6 @@ public enum optOpenAddOn {BUILDER, SUMMARY} public enum optMenuSelected {ON_DEMAND, ORDER_AHEAD, MENU_PREVIEW} - public enum optBearing {RIGHT, DOWN, LEFT, UP, NONE} + public enum optBearing {UP_RIGHT, RIGHT, DOWN_LEFT, DOWN, DOWN_RIGHT, LEFT, LEFT_UP, UP, NONE} } diff --git a/app/src/main/java/com/bentonow/bentonow/Utils/maps/LocationUtils.java b/app/src/main/java/com/bentonow/bentonow/Utils/maps/LocationUtils.java index b189f0d..7179585 100644 --- a/app/src/main/java/com/bentonow/bentonow/Utils/maps/LocationUtils.java +++ b/app/src/main/java/com/bentonow/bentonow/Utils/maps/LocationUtils.java @@ -46,7 +46,8 @@ public static String getStringSecondsLeft(int iSeconds) { int minutes = (iSeconds % 3600) / 60; int seconds = iSeconds % 60; - return String.format("%02d:%02d:%02d", hours, minutes, seconds); + // return String.format("%02d:%02d:%02d", hours, minutes, seconds); + return String.valueOf(minutes); } public static String getStreetAddress(Address mAddress) { @@ -160,7 +161,7 @@ public void onClick(View v) { public static ConstantUtils.optBearing getBearingFromRotation(double dRotation) { if (dRotation > 360) dRotation = 360; - return ConstantUtils.optBearing.values()[(int) Math.floor(dRotation / 90)]; + return ConstantUtils.optBearing.values()[(int) Math.floor(dRotation / 45)]; } public static double CalculationByDistance(LatLng StartP, LatLng EndP) { diff --git a/app/src/main/java/com/bentonow/bentonow/Utils/maps/MarkerAnimation.java b/app/src/main/java/com/bentonow/bentonow/Utils/maps/MarkerAnimation.java index 9e260c7..8ec983e 100644 --- a/app/src/main/java/com/bentonow/bentonow/Utils/maps/MarkerAnimation.java +++ b/app/src/main/java/com/bentonow/bentonow/Utils/maps/MarkerAnimation.java @@ -22,12 +22,13 @@ */ public class MarkerAnimation { - public static void animateMarkerToGB(final Marker marker, final LatLng finalPosition, final LatLngInterpolator latLngInterpolator) { + public static void animateMarkerToGB(final Marker marker, final LatLng finalPosition, float fRotation, final LatLngInterpolator latLngInterpolator) { + marker.setRotation(fRotation); final LatLng startPosition = marker.getPosition(); final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); final Interpolator interpolator = new AccelerateDecelerateInterpolator(); - final float durationInMs = 3000; + final float durationInMs = 2000; handler.post(new Runnable() { long elapsed; @@ -71,8 +72,39 @@ public void onAnimationUpdate(ValueAnimator animation) { } @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) - public static void animateMarkerToICS(Marker marker, LatLng finalPosition, float fRotation, final LatLngInterpolator latLngInterpolator) { - marker.setRotation(fRotation); + public static void animateMarkerToICS(Marker mMarkerDriver, LatLng finalPosition, float fRotation, final LatLngInterpolator latLngInterpolator, String sSnippet) { + // marker.setRotation(fRotation); + switch (LocationUtils.getBearingFromRotation(fRotation)) { + case UP_RIGHT: + mMarkerDriver.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_car_up_right)); + break; + case RIGHT: + mMarkerDriver.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_car)); + break; + case DOWN_RIGHT: + mMarkerDriver.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_car_down_righ)); + break; + case DOWN: + mMarkerDriver.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_car_down)); + break; + case DOWN_LEFT: + mMarkerDriver.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_car_down_left)); + break; + case LEFT: + mMarkerDriver.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_car_left)); + break; + case LEFT_UP: + mMarkerDriver.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_car_left_up)); + break; + case UP: + mMarkerDriver.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_car_up)); + break; + case NONE: + mMarkerDriver.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.marker_car)); + break; + } + mMarkerDriver.setSnippet(sSnippet); + mMarkerDriver.showInfoWindow(); TypeEvaluator typeEvaluator = new TypeEvaluator() { @Override @@ -81,7 +113,7 @@ public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) { } }; Property property = Property.of(Marker.class, LatLng.class, "position"); - ObjectAnimator animator = ObjectAnimator.ofObject(marker, property, typeEvaluator, finalPosition); + ObjectAnimator animator = ObjectAnimator.ofObject(mMarkerDriver, property, typeEvaluator, finalPosition); animator.setDuration(2000); animator.start(); } diff --git a/app/src/main/java/com/bentonow/bentonow/controllers/order/OrderStatusActivity.java b/app/src/main/java/com/bentonow/bentonow/controllers/order/OrderStatusActivity.java index 56034e6..6ce3ed4 100644 --- a/app/src/main/java/com/bentonow/bentonow/controllers/order/OrderStatusActivity.java +++ b/app/src/main/java/com/bentonow/bentonow/controllers/order/OrderStatusActivity.java @@ -68,8 +68,6 @@ public class OrderStatusActivity extends BaseFragmentActivity implements View.On private TextView txtDescriptionPickUp; private TextView txtOrderStatusTitle; private TextView txtOrderStatusDescription; - private TextView txtDriverName; - private TextView txtDriverEta; private ImageView menuItemLeft; private GoogleMap googleMap; @@ -96,9 +94,10 @@ public class OrderStatusActivity extends BaseFragmentActivity implements View.On private User mCurrentUser; private int iPositionStart = 0; private int iDurationDirections = 0; - private int iPadding = 100; + private int iPadding = 300; private double fRotation; private boolean bUseGoogleDirections; + private String sEta = ""; @Override protected void onCreate(Bundle savedInstanceState) { @@ -126,10 +125,10 @@ protected void onCreate(Bundle savedInstanceState) { public void run() { if (aListDriver.size() > iPositionStart && bUseGoogleDirections) { - double lon1 = LocationUtils.degToRad(mDriverLastLocation.latitude); - double lon2 = LocationUtils.degToRad(aListDriver.get(iPositionStart).latitude); - double lat1 = LocationUtils.degToRad(mDriverLastLocation.longitude); - double lat2 = LocationUtils.degToRad(aListDriver.get(iPositionStart).longitude); + double lon1 = LocationUtils.degToRad(mDriverLastLocation.longitude); + double lon2 = LocationUtils.degToRad(aListDriver.get(iPositionStart).longitude); + double lat1 = LocationUtils.degToRad(mDriverLastLocation.latitude); + double lat2 = LocationUtils.degToRad(aListDriver.get(iPositionStart).latitude); //iDuration = mWaypoint.getaSteps().get(iPositionStart).getDuration(); @@ -195,15 +194,15 @@ public void onSuccess(int statusCode, Header[] headers, String responseString) { try { iDurationDirections = (mWaypoint.getDuration() / aListDriver.size()) * 1000; } catch (Exception ex) { + iDurationDirections = 2000; } - iDurationDirections = 2000; DebugUtils.logDebug(TAG, "Duration in Millis:: " + iDurationDirections); runOnUiThread(new Runnable() { @Override public void run() { - getTxtDriverEta().setText(String.format(getString(R.string.order_status_eta), LocationUtils.getStringSecondsLeft(mWaypoint.getDuration()))); + sEta = String.format(getString(R.string.order_status_eta), LocationUtils.getStringSecondsLeft(mWaypoint.getDuration())); updateMapLocation(); } }); @@ -297,8 +296,6 @@ public void run() { getWrapperStatusDelivery().setVisibility(View.VISIBLE); getWrapperStatusPrep().setVisibility(View.GONE); - getTxtDriverName().setText("Driver: " + mOrder.getDriverName()); - getTxtIndicatorDelivery().setBackground(getResources().getDrawable(R.drawable.background_circle_green)); getTxtDescriptionDelivery().setTextColor(getResources().getColor(R.color.primary)); @@ -355,6 +352,9 @@ public void addMarker(CustomMarker customMarker, boolean bIsDriver) { Marker newMark = googleMap.addMarker(markerOption); + if (bIsDriver) + newMark.setTitle(mOrder.getDriverName()); + addMarkerToHashMap(customMarker, newMark); } @@ -378,7 +378,7 @@ public Marker findMarker(CustomMarker customMarker) { } public void animateMarker(CustomMarker customMarker, LatLng latlng, float fRotation) { - getTxtDriverEta().setText(String.format(getString(R.string.order_status_eta), LocationUtils.getStringSecondsLeft((iDurationDirections) / 1000 * (aListDriver.size() - iPositionStart)))); + sEta = String.format(getString(R.string.order_status_eta), LocationUtils.getStringSecondsLeft((iDurationDirections) / 1000 * (aListDriver.size() - iPositionStart))); // findMarker(customMarker).setSnippet(LocationUtils.getStringSecondsLeft((iDurationDirections) / 1000 * (aListDriver.size() - iPositionStart))); // findMarker(customMarker).showInfoWindow(); if (findMarker(customMarker) != null) { @@ -388,7 +388,7 @@ public void animateMarker(CustomMarker customMarker, LatLng latlng, float fRotat customMarker.setCustomMarkerLatitude(latlng.latitude); customMarker.setCustomMarkerLongitude(latlng.longitude); - MarkerAnimation.animateMarkerToICS(findMarker(customMarker), new LatLng(customMarker.getCustomMarkerLatitude(), customMarker.getCustomMarkerLongitude()), fRotation, latlonInter); + MarkerAnimation.animateMarkerToICS(findMarker(customMarker), new LatLng(customMarker.getCustomMarkerLatitude(), customMarker.getCustomMarkerLongitude()), fRotation, latlonInter, sEta); } } @@ -491,12 +491,7 @@ public void onSuccess(int statusCode, Header[] headers, String responseString) { mWaypoint = GoogleDirectionParser.parseDirections(responseString); if (mWaypoint != null) { - runOnUiThread(new Runnable() { - @Override - public void run() { - getTxtDriverEta().setText(LocationUtils.getStringSecondsLeft(mWaypoint.getDuration())); - } - }); + sEta = LocationUtils.getStringSecondsLeft(mWaypoint.getDuration()); } } @@ -529,6 +524,9 @@ public void onMapReady(GoogleMap map) { addMarker(getOrderMarker(), false); + cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(mOrderLocation.getLatitude(), mOrderLocation.getLongitude()), 17); + googleMap.animateCamera(cameraUpdate); + if (mDriverLocation != null) runOnUiThread(new Runnable() { @Override @@ -676,18 +674,6 @@ private TextView getTxtOrderStatusDescription() { return txtOrderStatusDescription; } - private TextView getTxtDriverName() { - if (txtDriverName == null) - txtDriverName = (TextView) findViewById(R.id.txt_driver_name); - return txtDriverName; - } - - private TextView getTxtDriverEta() { - if (txtDriverEta == null) - txtDriverEta = (TextView) findViewById(R.id.txt_driver_eta); - return txtDriverEta; - } - private class OrderStatusServiceConnection implements ServiceConnection { @Override public void onServiceConnected(ComponentName name, IBinder binder) { diff --git a/app/src/main/res/drawable-xxxhdpi/marker_car_down.png b/app/src/main/res/drawable-xxxhdpi/marker_car_down.png new file mode 100644 index 0000000..83bf39c Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/marker_car_down.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/marker_car_down_left.png b/app/src/main/res/drawable-xxxhdpi/marker_car_down_left.png new file mode 100644 index 0000000..b9be449 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/marker_car_down_left.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/marker_car_down_righ.png b/app/src/main/res/drawable-xxxhdpi/marker_car_down_righ.png new file mode 100644 index 0000000..165e497 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/marker_car_down_righ.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/marker_car_left.png b/app/src/main/res/drawable-xxxhdpi/marker_car_left.png new file mode 100644 index 0000000..647eeb3 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/marker_car_left.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/marker_car_left_up.png b/app/src/main/res/drawable-xxxhdpi/marker_car_left_up.png new file mode 100644 index 0000000..ad711ee Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/marker_car_left_up.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/marker_car_up.png b/app/src/main/res/drawable-xxxhdpi/marker_car_up.png new file mode 100644 index 0000000..ff7dd0a Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/marker_car_up.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/marker_car_up_right.png b/app/src/main/res/drawable-xxxhdpi/marker_car_up_right.png new file mode 100644 index 0000000..4c39a4f Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/marker_car_up_right.png differ diff --git a/app/src/main/res/layout/activity_order_status.xml b/app/src/main/res/layout/activity_order_status.xml index 5cef8a9..e1e0f86 100644 --- a/app/src/main/res/layout/activity_order_status.xml +++ b/app/src/main/res/layout/activity_order_status.xml @@ -354,37 +354,11 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - - - + android:layout_height="match_parent" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 07cf659..f931d8d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -34,7 +34,7 @@ %1$s, %2$s, %3$s-%4$s %1$s, %2$s %1$s - %2$s %3$s:%4$2s - ETA: %1$s + ETA: %1$s min %1$s, %2$s %1$s-%2$s