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 all 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
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