diff options
author | Aleksandr Zatsepin <alexzatsepin@users.noreply.github.com> | 2017-07-11 19:07:31 +0300 |
---|---|---|
committer | Arsentiy Milchakov <milcars@mapswithme.com> | 2017-07-11 19:07:31 +0300 |
commit | d9dd8f5eabd087df8fba219a6019e0768e65feea (patch) | |
tree | 0127833d30c22d1f259dfb7c6ad9377d9c164416 | |
parent | 5b11fb2ef785b8308b92cce3f7dbd9f275c4d644 (diff) |
Mapsme 4928 add start finish panel (#6551)beta-905
* [android] Fixed RoutingController
* [android] Changed routing bottom action panel UI and made it clickable
* [android] Added routing bottom menu listener handling
* [android] Added poi search for adding start/finish route points
17 files changed, 203 insertions, 120 deletions
diff --git a/android/res/drawable-hdpi/ic_search.png b/android/res/drawable-hdpi/ic_search.png Binary files differnew file mode 100644 index 0000000000..e3a9c3da95 --- /dev/null +++ b/android/res/drawable-hdpi/ic_search.png diff --git a/android/res/drawable-mdpi/ic_search.png b/android/res/drawable-mdpi/ic_search.png Binary files differnew file mode 100644 index 0000000000..c85aabdfd7 --- /dev/null +++ b/android/res/drawable-mdpi/ic_search.png diff --git a/android/res/drawable-xhdpi/ic_search.png b/android/res/drawable-xhdpi/ic_search.png Binary files differnew file mode 100644 index 0000000000..452a1a5ac7 --- /dev/null +++ b/android/res/drawable-xhdpi/ic_search.png diff --git a/android/res/drawable-xxhdpi/ic_search.png b/android/res/drawable-xxhdpi/ic_search.png Binary files differnew file mode 100644 index 0000000000..7d44209aa6 --- /dev/null +++ b/android/res/drawable-xxhdpi/ic_search.png diff --git a/android/res/drawable-xxxhdpi/ic_search.png b/android/res/drawable-xxxhdpi/ic_search.png Binary files differnew file mode 100644 index 0000000000..7223547b00 --- /dev/null +++ b/android/res/drawable-xxxhdpi/ic_search.png diff --git a/android/res/layout/routing_action_panel.xml b/android/res/layout/routing_action_panel.xml index 5a9deec7f4..2d7bb26724 100644 --- a/android/res/layout/routing_action_panel.xml +++ b/android/res/layout/routing_action_panel.xml @@ -1,54 +1,61 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="@dimen/height_block_base" android:background="?windowBackgroundForced"> - <TextView - android:id="@+id/tv__message" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_centerVertical="true" - android:layout_toLeftOf="@+id/btn__my_position_use" - android:layout_toStartOf="@id/btn__my_position_use" - android:textAppearance="@style/MwmTextAppearance.Body3" - android:layout_marginLeft="@dimen/margin_base" - android:layout_marginRight="@dimen/margin_base" - android:layout_marginTop="@dimen/routing_action_panel_margin_vert" - android:layout_marginBottom="@dimen/routing_action_panel_margin_vert" - tools:text="Add start point to plan a route."/> <LinearLayout - android:id="@id/btn__my_position_use" + android:id="@+id/btn__search_point" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="match_parent" + android:gravity="center_vertical" + android:background="?clickableBackground"> + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_search" + android:tint="?colorAccent" + android:layout_marginStart="@dimen/margin_base" + android:layout_marginLeft="@dimen/margin_base" + android:layout_marginEnd="@dimen/margin_base" + android:layout_marginRight="@dimen/margin_base"/> + <TextView + android:id="@+id/tv__message" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:textAppearance="@style/MwmTextAppearance.Body3" + android:layout_marginRight="@dimen/margin_base" + android:layout_marginEnd="@dimen/margin_base" + android:layout_marginTop="@dimen/routing_action_panel_margin_vert" + android:layout_marginBottom="@dimen/routing_action_panel_margin_vert" + android:textColor="?colorAccent" + tools:text="Add start point to plan a route."/> + </LinearLayout> + <LinearLayout + android:id="@+id/btn__my_position_use" android:orientation="horizontal" android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:paddingLeft="@dimen/margin_half" - android:paddingRight="@dimen/margin_half" - android:paddingTop="@dimen/margin_quarter" - android:paddingBottom="@dimen/margin_quarter" - android:layout_marginRight="@dimen/margin_half" - android:layout_marginEnd="@dimen/margin_half" - android:layout_alignParentRight="true" - android:layout_alignParentEnd="true" - android:layout_centerVertical="true" - android:gravity="center" + android:layout_height="match_parent" + android:gravity="center_vertical" android:background="?clickableBackground" android:visibility="gone" tools:visibility="visible"> + <View + android:layout_width="1dp" + android:layout_height="match_parent" + android:layout_marginBottom="@dimen/margin_half" + android:layout_marginTop="@dimen/margin_half" + android:background="?dividerHorizontal"/> <ImageView android:id="@+id/iv__icon" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="@dimen/margin_half" - android:layout_marginEnd="@dimen/margin_half" + android:layout_margin="@dimen/margin_base" android:src="@drawable/ic_my_location" - tools:tint="?android:colorAccent"/> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="@style/MwmTextAppearance.Button" - android:text="@string/button_use"/> + tools:tint="?colorAccent"/> </LinearLayout> -</RelativeLayout> +</LinearLayout> diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 4af6002cb8..51480bff58 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -56,6 +56,8 @@ import com.mapswithme.maps.editor.ReportFragment; import com.mapswithme.maps.location.CompassData; import com.mapswithme.maps.location.LocationHelper; import com.mapswithme.maps.routing.NavigationController; +import com.mapswithme.maps.routing.RoutePointInfo; +import com.mapswithme.maps.routing.RoutingBottomMenuListener; import com.mapswithme.maps.routing.RoutingController; import com.mapswithme.maps.routing.RoutingPlanFragment; import com.mapswithme.maps.routing.RoutingPlanInplaceController; @@ -118,7 +120,8 @@ public class MwmActivity extends BaseMwmFragmentActivity FloatingSearchToolbarController.VisibilityListener, NativeSearchListener, NavigationButtonsAnimationController.OnTranslationChangedListener, - RoutingPlanInplaceController.RoutingPlanListener + RoutingPlanInplaceController.RoutingPlanListener, + RoutingBottomMenuListener { public static final String EXTRA_TASK = "map_task"; public static final String EXTRA_LAUNCH_BY_DEEP_LINK = "launch_by_deep_link"; @@ -533,7 +536,7 @@ public class MwmActivity extends BaseMwmFragmentActivity if (!mIsFragmentContainer) { - mRoutingPlanInplaceController = new RoutingPlanInplaceController(this, this); + mRoutingPlanInplaceController = new RoutingPlanInplaceController(this, this, this); removeCurrentFragment(false); } @@ -2137,6 +2140,22 @@ public class MwmActivity extends BaseMwmFragmentActivity }).show(); } + @Override + public void onUseMyPositionAsStart() + { + RoutingController.get().setStartPoint(LocationHelper.INSTANCE.getMyPosition()); + } + + @Override + public void onSearchRoutePoint(@RoutePointInfo.RouteMarkType int pointType) + { + if (mNavigationController != null) + { + RoutingController.get().waitForPoiPick(pointType); + mNavigationController.performSearchClick(); + } + } + public static class ShowAuthorizationTask implements MapTask { @Override diff --git a/android/src/com/mapswithme/maps/routing/NavigationController.java b/android/src/com/mapswithme/maps/routing/NavigationController.java index bc88f92fb4..006ff56888 100644 --- a/android/src/com/mapswithme/maps/routing/NavigationController.java +++ b/android/src/com/mapswithme/maps/routing/NavigationController.java @@ -139,6 +139,11 @@ public class NavigationController implements TrafficManager.TrafficCallback, Vie mSearchWheel.onResume(); } + public boolean performSearchClick() + { + return mSearchWheel.performClick(); + } + private NavMenu createNavMenu() { return new NavMenu(mBottomFrame, new NavMenu.ItemClickListener<NavMenu.Item>() diff --git a/android/src/com/mapswithme/maps/routing/RoutingBottomMenuController.java b/android/src/com/mapswithme/maps/routing/RoutingBottomMenuController.java index 2963a666d0..8e42f75795 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingBottomMenuController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingBottomMenuController.java @@ -13,7 +13,6 @@ import android.support.v4.content.ContextCompat; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.text.TextUtils; -import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.Button; @@ -23,6 +22,7 @@ import android.widget.TextView; import com.mapswithme.maps.Framework; import com.mapswithme.maps.MwmActivity; import com.mapswithme.maps.R; +import com.mapswithme.maps.api.RoutePoint; import com.mapswithme.maps.bookmarks.data.MapObject; import com.mapswithme.maps.location.LocationHelper; import com.mapswithme.maps.taxi.TaxiAdapter; @@ -75,8 +75,12 @@ final class RoutingBottomMenuController implements View.OnClickListener @Nullable private TaxiInfo.Product mTaxiProduct; + @Nullable + private RoutingBottomMenuListener mListener; + @NonNull - static RoutingBottomMenuController newInstance(@NonNull Activity activity, @NonNull View frame) + static RoutingBottomMenuController newInstance(@NonNull Activity activity, @NonNull View frame, + @Nullable RoutingBottomMenuListener listener) { View altitudeChartFrame = getViewById(activity, frame, R.id.altitude_chart_panel); View taxiFrame = getViewById(activity, frame, R.id.taxi_panel); @@ -87,11 +91,9 @@ final class RoutingBottomMenuController implements View.OnClickListener View numbersFrame = getViewById(activity, frame, R.id.numbers); View actionFrame = getViewById(activity, frame, R.id.routing_action_frame); - return new RoutingBottomMenuController(activity, altitudeChartFrame, - taxiFrame, error, start, - altitudeChart, - altitudeDifference, - numbersFrame, actionFrame); + return new RoutingBottomMenuController(activity, altitudeChartFrame, taxiFrame, error, start, + altitudeChart, altitudeDifference, numbersFrame, + actionFrame, listener); } @NonNull @@ -110,7 +112,8 @@ final class RoutingBottomMenuController implements View.OnClickListener @NonNull ImageView altitudeChart, @NonNull TextView altitudeDifference, @NonNull View numbersFrame, - @NonNull View actionFrame) + @NonNull View actionFrame, + @Nullable RoutingBottomMenuListener listener) { mContext = context; mAltitudeChartFrame = altitudeChartFrame; @@ -123,17 +126,12 @@ final class RoutingBottomMenuController implements View.OnClickListener mActionFrame = actionFrame; mActionMessage = (TextView) actionFrame.findViewById(R.id.tv__message); mActionButton = actionFrame.findViewById(R.id.btn__my_position_use); - mActionIcon = (ImageView) mActionButton.findViewById(R.id.iv__icon); mActionButton.setOnClickListener(this); - mActionFrame.setOnTouchListener(new View.OnTouchListener() - { - @Override - public boolean onTouch(View v, MotionEvent event) - { - return !(UiUtils.isVisible(mActionButton) && UiUtils.isViewTouched(event, mActionButton)); - } - }); + View actionSearchButton = actionFrame.findViewById(R.id.btn__search_point); + actionSearchButton.setOnClickListener(this); + mActionIcon = (ImageView) mActionButton.findViewById(R.id.iv__icon); UiUtils.hide(mAltitudeChartFrame, mTaxiFrame, mActionFrame); + mListener = listener; } void showAltitudeChartAndRoutingDetails() @@ -183,6 +181,7 @@ final class RoutingBottomMenuController implements View.OnClickListener UiUtils.hide(mTaxiFrame, mError); UiUtils.show(mActionFrame); mActionMessage.setText(R.string.routing_add_start_point); + mActionMessage.setTag(RoutePointInfo.ROUTE_MARK_START); if (LocationHelper.INSTANCE.getMyPosition() != null) { UiUtils.show(mActionButton); @@ -202,6 +201,7 @@ final class RoutingBottomMenuController implements View.OnClickListener UiUtils.hide(mTaxiFrame, mError); UiUtils.show(mActionFrame); mActionMessage.setText(R.string.routing_add_finish_point); + mActionMessage.setTag(RoutePointInfo.ROUTE_MARK_FINISH); UiUtils.hide(mActionButton); } @@ -375,7 +375,16 @@ final class RoutingBottomMenuController implements View.OnClickListener switch (v.getId()) { case R.id.btn__my_position_use: - RoutingController.get().setStartPoint(LocationHelper.INSTANCE.getMyPosition()); + if (mListener != null) + mListener.onUseMyPositionAsStart(); + break; + case R.id.btn__search_point: + if (mListener != null) + { + @RoutePointInfo.RouteMarkType + int pointType = (Integer) mActionMessage.getTag(); + mListener.onSearchRoutePoint(pointType); + } break; } } diff --git a/android/src/com/mapswithme/maps/routing/RoutingBottomMenuListener.java b/android/src/com/mapswithme/maps/routing/RoutingBottomMenuListener.java new file mode 100644 index 0000000000..ba3a4615ab --- /dev/null +++ b/android/src/com/mapswithme/maps/routing/RoutingBottomMenuListener.java @@ -0,0 +1,7 @@ +package com.mapswithme.maps.routing; + +public interface RoutingBottomMenuListener +{ + void onUseMyPositionAsStart(); + void onSearchRoutePoint(@RoutePointInfo.RouteMarkType int type); +} diff --git a/android/src/com/mapswithme/maps/routing/RoutingController.java b/android/src/com/mapswithme/maps/routing/RoutingController.java index d4049fa051..c3a27aff58 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingController.java @@ -80,6 +80,7 @@ public class RoutingController implements TaxiManager.TaxiListener void updateBuildProgress(@IntRange(from = 0, to = 100) int progress, @Framework.RouterType int router); } + private static final int NO_WAITING_POI_PICK = -1; private static final RoutingController sInstance = new RoutingController(); private final Logger mLogger = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.ROUTING); @Nullable @@ -87,8 +88,8 @@ public class RoutingController implements TaxiManager.TaxiListener private BuildState mBuildState = BuildState.NONE; private State mState = State.NONE; - private boolean mWaitingPoiPick; - + @RoutePointInfo.RouteMarkType + private int mWaitingPoiPickType = NO_WAITING_POI_PICK; private int mLastBuildProgress; @Framework.RouterType private int mLastRouterType = Framework.nativeGetLastUsedRouter(); @@ -401,7 +402,10 @@ public class RoutingController implements TaxiManager.TaxiListener { mLogger.d(TAG, "start"); - if (!MapObject.isOfType(MapObject.MY_POSITION, getStartPoint())) + + MapObject my = LocationHelper.INSTANCE.getMyPosition(); + + if (my == null || MapObject.isOfType(MapObject.MY_POSITION, getStartPoint())) { Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_START_SUGGEST_REBUILD); AlohaHelper.logClick(AlohaHelper.ROUTING_START_SUGGEST_REBUILD); @@ -409,13 +413,6 @@ public class RoutingController implements TaxiManager.TaxiListener return; } - MapObject my = LocationHelper.INSTANCE.getMyPosition(); - if (my == null) - { - mRoutingListener.onRoutingEvent(ResultCodesHelper.NO_POSITION, null); - return; - } - Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_START); AlohaHelper.logClick(AlohaHelper.ROUTING_START); setState(State.NAVIGATION); @@ -433,7 +430,8 @@ public class RoutingController implements TaxiManager.TaxiListener public void addStop(@NonNull MapObject mapObject) { - Framework.nativeAddRoutePoint("", RoutePointInfo.ROUTE_MARK_INTERMEDIATE, 0, + Framework.nativeAddRoutePoint(""/* name */, RoutePointInfo.ROUTE_MARK_INTERMEDIATE, + 0/* intermediateIndex */, MapObject.isOfType(MapObject.MY_POSITION, mapObject), mapObject.getLat(), mapObject.getLon()); build(); @@ -470,7 +468,7 @@ public class RoutingController implements TaxiManager.TaxiListener } } - public void removeIntermediatePoints() + private void removeIntermediatePoints() { Framework.nativeRemoveIntermediateRoutePoints(); } @@ -528,7 +526,8 @@ public class RoutingController implements TaxiManager.TaxiListener @Override public void onClick(DialogInterface dialog, int which) { - setStartFromMyPosition(); + if (RoutingController.get().getStartPoint() == null) + setStartFromMyPosition(); } }); } @@ -545,8 +544,8 @@ public class RoutingController implements TaxiManager.TaxiListener { mLogger.d(TAG, "cancelInternal"); - setPointsInternal(null, null); - mWaitingPoiPick = false; + //noinspection WrongConstant + mWaitingPoiPickType = NO_WAITING_POI_PICK; mTaxiRequestHandled = false; setBuildState(BuildState.NONE); @@ -631,10 +630,13 @@ public class RoutingController implements TaxiManager.TaxiListener return mBuildState == BuildState.BUILT; } + public void waitForPoiPick(@RoutePointInfo.RouteMarkType int pointType){ + mWaitingPoiPickType = pointType; + } public boolean isWaitingPoiPick() { - return mWaitingPoiPick; + return mWaitingPoiPickType != NO_WAITING_POI_PICK; } public boolean isTaxiRequestHandled() @@ -689,7 +691,7 @@ public class RoutingController implements TaxiManager.TaxiListener public boolean hasStartPoint() { - return getEndPoint() != null; + return getStartPoint() != null; } public boolean hasEndPoint() @@ -705,26 +707,20 @@ public class RoutingController implements TaxiManager.TaxiListener private void setPointsInternal(@Nullable MapObject startPoint, @Nullable MapObject endPoint) { - if (startPoint == null) + if (startPoint != null) { - Framework.nativeRemoveRoutePoint(RoutePointInfo.ROUTE_MARK_START, 0); - } - else - { - Framework.nativeAddRoutePoint("", RoutePointInfo.ROUTE_MARK_START, 0, + Framework.nativeAddRoutePoint(""/* name */, RoutePointInfo.ROUTE_MARK_START, + 0/* intermediateIndex */, MapObject.isOfType(MapObject.MY_POSITION, startPoint), startPoint.getLat(), startPoint.getLon()); if (mContainer != null) mContainer.updateMenu(); } - if (endPoint == null) - { - Framework.nativeRemoveRoutePoint(RoutePointInfo.ROUTE_MARK_FINISH, 0); - } - else + if (endPoint != null) { - Framework.nativeAddRoutePoint("", RoutePointInfo.ROUTE_MARK_FINISH, 0, + Framework.nativeAddRoutePoint(""/* name */, RoutePointInfo.ROUTE_MARK_FINISH, + 0/* intermediateIndex */, MapObject.isOfType(MapObject.MY_POSITION, endPoint), endPoint.getLat(), endPoint.getLon()); if (mContainer != null) @@ -734,11 +730,8 @@ public class RoutingController implements TaxiManager.TaxiListener void checkAndBuildRoute() { - if (mContainer != null) - { - if (isWaitingPoiPick()) - showRoutePlan(); - } + if (isWaitingPoiPick()) + showRoutePlan(); if (getStartPoint() != null && getEndPoint() != null) build(); @@ -752,8 +745,6 @@ public class RoutingController implements TaxiManager.TaxiListener if (my == null) { mLogger.d(TAG, "setStartFromMyPosition: no my position - skip"); - - setPointsInternal(null, getEndPoint()); return false; } @@ -771,13 +762,22 @@ public class RoutingController implements TaxiManager.TaxiListener * @return {@code true} if the point was set. */ @SuppressWarnings("Duplicates") - public boolean setStartPoint(MapObject point) + public boolean setStartPoint(@Nullable MapObject point) { mLogger.d(TAG, "setStartPoint"); MapObject startPoint = getStartPoint(); MapObject endPoint = getEndPoint(); + boolean isSamePoint = MapObject.same(startPoint, point); + if (point != null) + { + Framework.nativeAddRoutePoint(""/* name */, RoutePointInfo.ROUTE_MARK_START, + 0/* intermediateIndex */, + MapObject.isOfType(MapObject.MY_POSITION, point), + point.getLat(), point.getLon()); + startPoint = getStartPoint(); + } - if (MapObject.same(startPoint, point)) + if (isSamePoint) { mLogger.d(TAG, "setStartPoint: skip the same starting point"); return false; @@ -812,12 +812,22 @@ public class RoutingController implements TaxiManager.TaxiListener * @return {@code true} if the point was set. */ @SuppressWarnings("Duplicates") - public boolean setEndPoint(MapObject point) + public boolean setEndPoint(@Nullable MapObject point) { mLogger.d(TAG, "setEndPoint"); MapObject startPoint = getStartPoint(); MapObject endPoint = getEndPoint(); - if (MapObject.same(endPoint, point)) + boolean isSamePoint = MapObject.same(endPoint, point); + if (point != null) + { + Framework.nativeAddRoutePoint(""/* name */, RoutePointInfo.ROUTE_MARK_FINISH, + 0/* intermediateIndex */, + MapObject.isOfType(MapObject.MY_POSITION, point), + point.getLat(), point.getLon()); + endPoint = getEndPoint(); + } + + if (isSamePoint) { if (getStartPoint() == null) return setStartFromMyPosition(); @@ -849,7 +859,7 @@ public class RoutingController implements TaxiManager.TaxiListener return true; } - void swapPoints() + private void swapPoints() { mLogger.d(TAG, "swapPoints"); @@ -886,14 +896,21 @@ public class RoutingController implements TaxiManager.TaxiListener public void onPoiSelected(@Nullable MapObject point) { - mWaitingPoiPick = false; + if (!isWaitingPoiPick()) + return; - if (point != null && point.getMapObjectType() == MapObject.MY_POSITION) + if (mWaitingPoiPickType != RoutePointInfo.ROUTE_MARK_FINISH + && mWaitingPoiPickType != RoutePointInfo.ROUTE_MARK_START) { - if (getStartPoint() == null) - setStartPoint(point); - else if (getEndPoint() == null) + throw new AssertionError("Only start and finish points can be added through search!"); + } + + if (point != null) + { + if (mWaitingPoiPickType == RoutePointInfo.ROUTE_MARK_FINISH) setEndPoint(point); + else + setStartPoint(point); } if (mContainer != null) @@ -901,6 +918,9 @@ public class RoutingController implements TaxiManager.TaxiListener mContainer.updateMenu(); showRoutePlan(); } + + //noinspection WrongConstant + mWaitingPoiPickType = NO_WAITING_POI_PICK; } public static CharSequence formatRoutingTime(Context context, int seconds, @DimenRes int unitsSize) diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java index 56e3d5d0a8..f2342bf8cd 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java @@ -5,6 +5,7 @@ import android.os.Bundle; import android.support.annotation.DrawableRes; import android.support.annotation.IdRes; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.view.View; import android.widget.CompoundButton; @@ -62,7 +63,8 @@ public class RoutingPlanController extends ToolbarController return rb; } - RoutingPlanController(View root, Activity activity) + RoutingPlanController(View root, Activity activity, + @Nullable RoutingBottomMenuListener listener) { super(root, activity); mFrame = root; @@ -119,7 +121,7 @@ public class RoutingPlanController extends ToolbarController mProgressBicycle = (WheelProgressView) progressFrame.findViewById(R.id.progress_bicycle); mProgressTaxi = (WheelProgressView) progressFrame.findViewById(R.id.progress_taxi); - mRoutingBottomMenuController = RoutingBottomMenuController.newInstance(mActivity, mFrame); + mRoutingBottomMenuController = RoutingBottomMenuController.newInstance(mActivity, mFrame, listener); } @Override diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java b/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java index dfd364d77a..a6c5c0f4e2 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java +++ b/android/src/com/mapswithme/maps/routing/RoutingPlanFragment.java @@ -24,9 +24,10 @@ public class RoutingPlanFragment extends BaseMwmFragment public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View res = inflater.inflate(R.layout.fragment_routing, container, false); - - mPlanController = new RoutingPlanController(res, getActivity()); - + RoutingBottomMenuListener listener = null; + if (getActivity() instanceof RoutingBottomMenuListener) + listener = (RoutingBottomMenuListener) getActivity(); + mPlanController = new RoutingPlanController(res, getActivity(), listener); return res; } diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanInplaceController.java b/android/src/com/mapswithme/maps/routing/RoutingPlanInplaceController.java index c392648496..f34b6e1d79 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingPlanInplaceController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingPlanInplaceController.java @@ -16,9 +16,10 @@ public class RoutingPlanInplaceController extends RoutingPlanController private RoutingPlanListener mRoutingPlanListener; public RoutingPlanInplaceController(@NonNull MwmActivity activity, - @Nullable RoutingPlanListener routingPlanListener) + @Nullable RoutingPlanListener routingPlanListener, + @Nullable RoutingBottomMenuListener listener) { - super(activity.findViewById(R.id.routing_plan_frame), activity); + super(activity.findViewById(R.id.routing_plan_frame), activity, listener); mRoutingPlanListener = routingPlanListener; } diff --git a/android/src/com/mapswithme/maps/routing/SearchWheel.java b/android/src/com/mapswithme/maps/routing/SearchWheel.java index 1341b01309..f19cdac033 100644 --- a/android/src/com/mapswithme/maps/routing/SearchWheel.java +++ b/android/src/com/mapswithme/maps/routing/SearchWheel.java @@ -211,6 +211,11 @@ class SearchWheel implements View.OnClickListener R.attr.colorAccent)); } + public boolean performClick() + { + return mSearchButton.performClick(); + } + @Override public void onClick(View v) { diff --git a/android/src/com/mapswithme/maps/search/SearchAdapter.java b/android/src/com/mapswithme/maps/search/SearchAdapter.java index f63c03fa0a..5e0069bbc8 100644 --- a/android/src/com/mapswithme/maps/search/SearchAdapter.java +++ b/android/src/com/mapswithme/maps/search/SearchAdapter.java @@ -220,7 +220,7 @@ class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.BaseViewHolder> @Override void processClick(SearchResult result, int order) { - mSearchFragment.showSingleResultOnMap(order); + mSearchFragment.showSingleResultOnMap(result, order); } } diff --git a/android/src/com/mapswithme/maps/search/SearchFragment.java b/android/src/com/mapswithme/maps/search/SearchFragment.java index dbce3e8e32..045c18e598 100644 --- a/android/src/com/mapswithme/maps/search/SearchFragment.java +++ b/android/src/com/mapswithme/maps/search/SearchFragment.java @@ -4,11 +4,11 @@ import android.content.Intent; import android.location.Location; import android.os.Build; import android.os.Bundle; +import android.support.annotation.CallSuper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CollapsingToolbarLayout; -import android.support.annotation.CallSuper; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; @@ -25,6 +25,7 @@ import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.R; import com.mapswithme.maps.base.BaseMwmFragment; import com.mapswithme.maps.base.OnBackPressListener; +import com.mapswithme.maps.bookmarks.data.MapObject; import com.mapswithme.maps.downloader.CountrySuggestFragment; import com.mapswithme.maps.downloader.MapManager; import com.mapswithme.maps.location.LocationHelper; @@ -106,7 +107,7 @@ public class SearchFragment extends BaseMwmFragment @Override protected boolean onStartSearchClick() { - if (!mFromRoutePlan) + if (!RoutingController.get().isWaitingPoiPick()) showAllResultsOnMap(); return true; } @@ -178,7 +179,6 @@ public class SearchFragment extends BaseMwmFragment private String mInitialQuery; @Nullable private HotelsFilter mInitialHotelsFilter; - private boolean mFromRoutePlan; private final LocationListener mLocationListener = new LocationListener.Simple() { @@ -432,7 +432,6 @@ public class SearchFragment extends BaseMwmFragment mInitialQuery = arguments.getString(SearchActivity.EXTRA_QUERY); mInitialHotelsFilter = arguments.getParcelable(SearchActivity.EXTRA_HOTELS_FILTER); - mFromRoutePlan = RoutingController.get().isWaitingPoiPick(); } private void hideSearch() @@ -460,10 +459,16 @@ public class SearchFragment extends BaseMwmFragment return false; } - private void processSelected() + private void processSelected(@NonNull SearchResult result) { - if (mFromRoutePlan) - RoutingController.get().onPoiSelected(null); + if (RoutingController.get().isWaitingPoiPick()) + { + SearchResult.Description description = result.description; + final MapObject point = new MapObject("", 0L, 0, MapObject.SEARCH, result.name, "", + description != null ? description.featureType : "", "", + result.lat, result.lon, "", null, null, "", null, null); + RoutingController.get().onPoiSelected(point); + } mToolbarController.deactivate(); @@ -471,14 +476,16 @@ public class SearchFragment extends BaseMwmFragment Utils.navigateToParent(getActivity()); } - void showSingleResultOnMap(int resultIndex) + void showSingleResultOnMap(@NonNull SearchResult result, int resultIndex) { final String query = getQuery(); SearchRecents.add(query); SearchEngine.cancelApiCall(); - SearchEngine.showResult(resultIndex); - processSelected(); + if (!RoutingController.get().isWaitingPoiPick()) + SearchEngine.showResult(resultIndex); + + processSelected(result); Statistics.INSTANCE.trackEvent(Statistics.EventName.SEARCH_ITEM_CLICKED); } @@ -600,7 +607,7 @@ public class SearchFragment extends BaseMwmFragment } mToolbarController.deactivate(); - if (mFromRoutePlan) + if (RoutingController.get().isWaitingPoiPick()) { RoutingController.get().onPoiSelected(null); final boolean isSearchActivity = getActivity() instanceof SearchActivity; |