Skip to content

Commit

Permalink
Feedback for Drop-In UI (#383)
Browse files Browse the repository at this point in the history
* Add feedback dialog modal

* Add fab for feedback and reverse countdown progress bar

* < API 21 support for theme colors

* Adjust for landscape layouts

* Handle landscape layout with GridLayoutManager

* Create click listener and callback to determine which feedback is clicked

* Add updated feedback icons

* Feedback System (#405)

* Method Creation

- started method creation for handling feedback events
- need to test reroute solution and move on to update and cancel functionality

* Add feedback types

* Update + Cancel

- added functionality for update and cancel methods
- still needs testing and tweaking

* Tweak code to match reroute

- code now matches how reroute functions
- may add handling of multiple feedback events at once later in the system

* Checkstyle fix from conflict resolution

- fixed sisngle line checkstyle issue

* Fix merge conflict

* Dismiss the dialog when an item is clicked

* Remove item size check

* Add feedback item and update how we send via service

* Update bottomsheet toast

* Feedback Queue Update

- renamed method
- added feedback location collect to onLocation listener
- created new methods to handle updating feedback and reroute queues

* Location -> RingBuffer

- change from using Location in updateFeedbackQueue and updateRerouteQueue to using a Ringbuffer

* Add event to queue + rerouteDate

- change sessionstate method name to match variable
- add feedbackevent to queue
- update reroute date when creating sessionstate

* Location Timestamps + EventLocation

- make test data timestamps the current time for the events
- use sessionstate.eventLocation to store location at time fo feedback event trigger

* Set Feedback Created

- force set of feedback created to event trigger
- tested multiple events

* FeedbackID + UserID fixes

- send feedbackID to feedbackevent creation
- obtain and send vendorID as User ID for feedbackevents

* isMocked setting

- set isMocked to appropriate setting based on conditions for feedbackevents

* Update icons / telem

* Return if location null
  • Loading branch information
danesfeder authored Oct 28, 2017
1 parent 884af21 commit cc9eef8
Show file tree
Hide file tree
Showing 63 changed files with 917 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/md_grey_200" />
<solid android:color="#EEEEEE"/>

<corners android:radius="8dp"/>

Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ext {
]

version = [
mapboxMapSdk : '5.1.4',
mapboxMapSdk : '5.2.0-beta.3',
// TODO Fix mapboxServices version when releasing next version of MAS (2.2.7)
mapboxServices : '2.3.0-SNAPSHOT',
locationLayerPlugin: '0.1.0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ interface View {
void finishNavigationView();

void setMuted(boolean isMuted);

void showFeedbackBottomSheet();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ void onRouteUpdate(DirectionsRoute directionsRoute) {
void onDestinationUpdate(Point point) {
view.addMarker(point);
}

void onFeedbackClick() {
view.showFeedbackBottomSheet();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerMode;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
import com.mapbox.services.android.navigation.ui.v5.camera.NavigationCamera;
import com.mapbox.services.android.navigation.ui.v5.feedback.FeedbackBottomSheet;
import com.mapbox.services.android.navigation.ui.v5.feedback.FeedbackItem;
import com.mapbox.services.android.navigation.ui.v5.feedback.FeedbackBottomSheetListener;
import com.mapbox.services.android.navigation.ui.v5.instruction.InstructionView;
import com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute;
import com.mapbox.services.android.navigation.ui.v5.route.RouteViewModel;
Expand Down Expand Up @@ -59,7 +62,7 @@
* </p>
*/
public class NavigationView extends CoordinatorLayout implements OnMapReadyCallback, MapboxMap.OnScrollListener,
NavigationContract.View {
NavigationContract.View, FeedbackBottomSheetListener {

private MapView mapView;
private InstructionView instructionView;
Expand All @@ -68,6 +71,7 @@ public class NavigationView extends CoordinatorLayout implements OnMapReadyCallb
private ImageButton cancelBtn;
private RecenterButton recenterBtn;
private FloatingActionButton soundFab;
private FloatingActionButton feedbackFab;

private NavigationPresenter navigationPresenter;
private NavigationViewModel navigationViewModel;
Expand Down Expand Up @@ -231,11 +235,6 @@ public void drawRoute(DirectionsRoute directionsRoute) {
mapRoute.addRoute(directionsRoute);
}

@Override
public void setMuted(boolean isMuted) {
navigationViewModel.setMuted(isMuted);
}

/**
* Creates a marker based on the
* {@link Point} destination coordinate.
Expand All @@ -256,6 +255,27 @@ public void finishNavigationView() {
navigationListener.onNavigationFinished();
}

@Override
public void setMuted(boolean isMuted) {
navigationViewModel.setMuted(isMuted);
}

@Override
public void showFeedbackBottomSheet() {
FeedbackBottomSheet.newInstance(this).show(
((FragmentActivity) getContext()).getSupportFragmentManager(), FeedbackBottomSheet.TAG);
}

@Override
public void onFeedbackSelected(FeedbackItem feedbackItem) {
navigationViewModel.updateFeedback(feedbackItem);
}

@Override
public void onFeedbackDismissed() {
navigationViewModel.cancelFeedback();
}

public void startNavigation(Activity activity) {
routeViewModel.extractLaunchData(activity);
}
Expand Down Expand Up @@ -310,6 +330,7 @@ private void bind() {
cancelBtn = findViewById(R.id.cancelBtn);
recenterBtn = findViewById(R.id.recenterBtn);
soundFab = findViewById(R.id.soundFab);
feedbackFab = findViewById(R.id.feedbackFab);
}

private void initViewModels() {
Expand Down Expand Up @@ -344,6 +365,13 @@ public void onClick(View view) {
navigationPresenter.onMuteClick(instructionView.toggleMute());
}
});
feedbackFab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
navigationPresenter.onFeedbackClick();
navigationViewModel.recordFeedback();
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
import android.content.SharedPreferences;
import android.location.Location;
import android.preference.PreferenceManager;
import android.text.TextUtils;

import com.mapbox.directions.v5.models.DirectionsRoute;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.services.android.navigation.ui.v5.feedback.FeedbackItem;
import com.mapbox.services.android.navigation.ui.v5.instruction.InstructionModel;
import com.mapbox.services.android.navigation.ui.v5.summary.SummaryModel;
import com.mapbox.services.android.navigation.ui.v5.voice.InstructionPlayer;
import com.mapbox.services.android.navigation.ui.v5.voice.NavigationInstructionPlayer;
import com.mapbox.services.android.navigation.v5.milestone.MilestoneEventListener;
import com.mapbox.services.android.navigation.v5.navigation.FeedbackEvent;
import com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation;
import com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions;
import com.mapbox.services.android.navigation.v5.navigation.NavigationConstants;
Expand All @@ -43,6 +46,7 @@ public class NavigationViewModel extends AndroidViewModel implements LifecycleOb
private NavigationInstructionPlayer instructionPlayer;
private DecimalFormat decimalFormat;
private SharedPreferences preferences;
private String feedbackId;

public NavigationViewModel(Application application) {
super(application);
Expand Down Expand Up @@ -112,7 +116,7 @@ public void onMilestoneEvent(RouteProgress routeProgress, String instruction, in

/**
* Listener used to determine is navigation is running / not running.
*
* <p>
* In {@link NavigationView}, views will be shown when true. When false,
* the {@link android.app.Activity} will be destroyed.
*
Expand All @@ -132,6 +136,25 @@ public MapboxNavigation getNavigation() {
return navigation;
}

void recordFeedback() {
feedbackId = navigation.recordFeedback(FeedbackEvent.FEEDBACK_TYPE_GENERAL_ISSUE, "",
FeedbackEvent.FEEDBACK_SOURCE_UI);
}

void updateFeedback(FeedbackItem feedbackItem) {
if (!TextUtils.isEmpty(feedbackId)) {
navigation.updateFeedback(feedbackId, feedbackItem.getFeedbackType(), feedbackItem.getDescription());
feedbackId = null;
}
}

void cancelFeedback() {
if (!TextUtils.isEmpty(feedbackId)) {
navigation.cancelFeedback(feedbackId);
feedbackId = null;
}
}

void updateRoute(DirectionsRoute route) {
startNavigation(route);
isOffRoute.setValue(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.mapbox.services.android.navigation.ui.v5.feedback;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.mapbox.services.android.navigation.ui.v5.R;

import java.util.ArrayList;
import java.util.List;

import static com.mapbox.services.android.navigation.v5.navigation.FeedbackEvent.FEEDBACK_TYPE_CONFUSING_INSTRUCTION;
import static com.mapbox.services.android.navigation.v5.navigation.FeedbackEvent.FEEDBACK_TYPE_GENERAL_ISSUE;
import static com.mapbox.services.android.navigation.v5.navigation.FeedbackEvent.FEEDBACK_TYPE_NOT_ALLOWED;
import static com.mapbox.services.android.navigation.v5.navigation.FeedbackEvent.FEEDBACK_TYPE_REPORT_TRAFFIC;
import static com.mapbox.services.android.navigation.v5.navigation.FeedbackEvent.FEEDBACK_TYPE_ROAD_CLOSED;
import static com.mapbox.services.android.navigation.v5.navigation.FeedbackEvent.FEEDBACK_TYPE_ROUTING_ERROR;

public class FeedbackAdapter extends RecyclerView.Adapter<FeedbackViewHolder> {

private List<FeedbackItem> feedbackItems = new ArrayList<>();

FeedbackAdapter() {
feedbackItems.add(new FeedbackItem("Road\nClosed",
R.drawable.ic_road_closed, FEEDBACK_TYPE_ROAD_CLOSED, ""));
feedbackItems.add(new FeedbackItem("Not\nAllowed",
R.drawable.ic_no_turn_allowed, FEEDBACK_TYPE_NOT_ALLOWED, ""));
feedbackItems.add(new FeedbackItem("Report\nTraffic",
R.drawable.ic_traffic, FEEDBACK_TYPE_REPORT_TRAFFIC, ""));
feedbackItems.add(new FeedbackItem("Confusing\nInstruction",
R.drawable.ic_confusing_directions, FEEDBACK_TYPE_CONFUSING_INSTRUCTION, ""));
feedbackItems.add(new FeedbackItem("General\nIssue",
R.drawable.ic_map_error, FEEDBACK_TYPE_GENERAL_ISSUE, ""));
feedbackItems.add(new FeedbackItem("Bad\nRoute",
R.drawable.ic_wrong_directions, FEEDBACK_TYPE_ROUTING_ERROR, ""));
}

@Override
public FeedbackViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.feedback_viewholder_layout, parent, false);
return new FeedbackViewHolder(view);
}

@Override
public void onBindViewHolder(FeedbackViewHolder viewHolder, int position) {
viewHolder.setFeedbackImage(feedbackItems.get(position).getFeedbackImageId());
viewHolder.setFeedbackText(feedbackItems.get(position).getFeedbackText());
}

@Override
public int getItemCount() {
return feedbackItems.size();
}

FeedbackItem getFeedbackItem(int feedbackPosition) {
if (feedbackPosition < feedbackItems.size()) {
return feedbackItems.get(feedbackPosition);
} else {
return null;
}
}
}
Loading

0 comments on commit cc9eef8

Please sign in to comment.