Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback for Drop-In UI #383

Merged
merged 31 commits into from
Oct 28, 2017
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
aab25ac
Add feedback dialog modal
danesfeder Oct 17, 2017
41407f9
Add fab for feedback and reverse countdown progress bar
danesfeder Oct 17, 2017
03dc7fa
< API 21 support for theme colors
danesfeder Oct 17, 2017
868c506
Adjust for landscape layouts
danesfeder Oct 18, 2017
3944191
Merge branch 'master' into dan-bottomsheet-feedback
danesfeder Oct 18, 2017
b2adc0e
Handle landscape layout with GridLayoutManager
danesfeder Oct 18, 2017
97b8543
Merge branch 'master' into dan-bottomsheet-feedback
danesfeder Oct 18, 2017
896b677
Merge branch 'master' into dan-bottomsheet-feedback
danesfeder Oct 18, 2017
34305a2
Create click listener and callback to determine which feedback is cli…
danesfeder Oct 19, 2017
ad10e4c
Merge branch 'master' into dan-bottomsheet-feedback
danesfeder Oct 20, 2017
8a58432
Add updated feedback icons
danesfeder Oct 20, 2017
835470e
Merge branch 'dan-bottomsheet-feedback' of github.com:mapbox/mapbox-n…
danesfeder Oct 20, 2017
86c8fba
Merge branch 'master' into dan-bottomsheet-feedback
danesfeder Oct 20, 2017
41ca925
Merge branch 'master' into dan-bottomsheet-feedback
danesfeder Oct 20, 2017
2d9e4de
Merge branch 'dan-bottomsheet-feedback' of github.com:mapbox/mapbox-n…
danesfeder Oct 20, 2017
f2ac21f
Feedback System (#405)
electrostat Oct 20, 2017
e859ada
Dismiss the dialog when an item is clicked
danesfeder Oct 20, 2017
de2b6ee
Remove item size check
danesfeder Oct 20, 2017
6f4a3fc
Merge branch 'master' into dan-bottomsheet-feedback
danesfeder Oct 21, 2017
9363411
Add feedback item and update how we send via service
danesfeder Oct 23, 2017
bd2f284
Update bottomsheet toast
danesfeder Oct 23, 2017
8ce5a00
Feedback Queue Update
electrostat Oct 23, 2017
54f0aaf
Location -> RingBuffer
electrostat Oct 23, 2017
aa09c13
Add event to queue + rerouteDate
electrostat Oct 23, 2017
662848e
Location Timestamps + EventLocation
electrostat Oct 26, 2017
9785d05
Set Feedback Created
electrostat Oct 26, 2017
3fb2063
FeedbackID + UserID fixes
electrostat Oct 26, 2017
9e4a9ef
isMocked setting
electrostat Oct 26, 2017
d2de964
Merge branch 'master' into dan-bottomsheet-feedback
danesfeder Oct 27, 2017
bc91d0d
Update icons / telem
danesfeder Oct 28, 2017
d909550
Return if location null
danesfeder Oct 28, 2017
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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@ interface View {
int[] getMapPadding();

void setMapPadding(int left, int top, int right, int bottom);

void showFeedbackBottomSheet();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ void onDestinationUpdate(Point point) {
void onNavigationRunning() {
view.showInstructionView();
}

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 @@ -73,6 +76,7 @@ public class NavigationView extends CoordinatorLayout implements OnMapReadyCallb
private View sheetShadow;
private RecenterButton recenterBtn;
private FloatingActionButton soundFab;
private FloatingActionButton feedbackFab;

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

/**
* Creates a marker based on the
* {@link Point} destination coordinate.
*
* @param position where the marker should be placed
*/
@Override
public void addMarker(Point position) {
LatLng markerPosition = new LatLng(position.latitude(),
position.longitude());
map.addMarker(new MarkerOptions()
.position(markerPosition)
.icon(ThemeSwitcher.retrieveMapMarker(getContext())));
}

@Override
public void finishNavigationView() {
navigationListener.onNavigationFinished();
}

@Override
public void setMuted(boolean isMuted) {
navigationViewModel.setMuted(isMuted);
Expand Down Expand Up @@ -287,24 +311,20 @@ public void setMapPadding(int left, int top, int right, int bottom) {
map.setPadding(left, top, right, bottom);
}

/**
* Creates a marker based on the
* {@link Point} destination coordinate.
*
* @param position where the marker should be placed
*/
@Override
public void addMarker(Point position) {
LatLng markerPosition = new LatLng(position.latitude(),
position.longitude());
map.addMarker(new MarkerOptions()
.position(markerPosition)
.icon(ThemeSwitcher.retrieveMapMarker(getContext())));
public void showFeedbackBottomSheet() {
FeedbackBottomSheet.newInstance(this).show(
((FragmentActivity) getContext()).getSupportFragmentManager(), FeedbackBottomSheet.TAG);
}

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

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

public void startNavigation(Activity activity) {
Expand Down Expand Up @@ -366,6 +386,7 @@ private void bind() {
sheetShadow = findViewById(R.id.sheetShadow);
recenterBtn = findViewById(R.id.recenterBtn);
soundFab = findViewById(R.id.soundFab);
feedbackFab = findViewById(R.id.feedbackFab);
}

private void initViewModels() {
Expand Down Expand Up @@ -412,6 +433,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, "",
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_BAD_ROUTE;
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_INACCURATE_GPS;
import static com.mapbox.services.android.navigation.v5.navigation.FeedbackEvent.FEEDBACK_TYPE_NOT_ALLOWED_TURN;
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;

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_TURN, ""));
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("GPS\nInaccurate",
R.drawable.ic_gps, FEEDBACK_TYPE_INACCURATE_GPS, ""));
feedbackItems.add(new FeedbackItem("Bad\nRoute",
R.drawable.ic_wrong_directions, FEEDBACK_TYPE_BAD_ROUTE, ""));
}

@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