forked from organicmaps/organicmaps
[android] Added routing action panel behavior
This commit is contained in:
parent
3e03f492ea
commit
3bc2665a74
7 changed files with 190 additions and 8 deletions
|
@ -17,6 +17,8 @@
|
|||
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"
|
||||
|
|
|
@ -152,6 +152,9 @@
|
|||
<dimen name="altitude_chart_image_height">40dp</dimen>
|
||||
<dimen name="altitude_chart_image_width">232dp</dimen>
|
||||
|
||||
<!-- Routing action panel -->
|
||||
<dimen name="routing_action_panel_margin_vert">14dp</dimen>
|
||||
|
||||
<!-- Gallery-->
|
||||
<dimen name="placepage_hotel_gallery_height">100dp</dimen>
|
||||
<dimen name="placepage_hotel_gallery_width">150dp</dimen>
|
||||
|
|
|
@ -1612,6 +1612,33 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
if (controller.isPlanning() || controller.isBuilding() || controller.isErrorEncountered())
|
||||
{
|
||||
if (!controller.hasStartPoint())
|
||||
{
|
||||
needsStartPoint();
|
||||
showLineFrame(true, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
adjustRuler(0, 0);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!controller.hasEndPoint())
|
||||
{
|
||||
needsFinishPoint();
|
||||
showLineFrame(true, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
adjustRuler(0, 0);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
showLineFrame(false, new Runnable()
|
||||
{
|
||||
@Override
|
||||
|
@ -1627,6 +1654,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
return;
|
||||
}
|
||||
|
||||
hideRoutingActionFrame();
|
||||
showLineFrame(true, new Runnable()
|
||||
{
|
||||
@Override
|
||||
|
@ -1640,6 +1668,48 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
completion.run();
|
||||
}
|
||||
|
||||
private void needsStartPoint()
|
||||
{
|
||||
if (mIsFragmentContainer)
|
||||
{
|
||||
RoutingPlanFragment fragment = (RoutingPlanFragment) getFragment(RoutingPlanFragment.class);
|
||||
if (fragment != null)
|
||||
fragment.needsStartPoint();
|
||||
}
|
||||
else
|
||||
{
|
||||
mRoutingPlanInplaceController.needsStartPoint();
|
||||
}
|
||||
}
|
||||
|
||||
private void needsFinishPoint()
|
||||
{
|
||||
if (mIsFragmentContainer)
|
||||
{
|
||||
RoutingPlanFragment fragment = (RoutingPlanFragment) getFragment(RoutingPlanFragment.class);
|
||||
if (fragment != null)
|
||||
fragment.needsFinishPoint();
|
||||
}
|
||||
else
|
||||
{
|
||||
mRoutingPlanInplaceController.needsFinishPoint();
|
||||
}
|
||||
}
|
||||
|
||||
private void hideRoutingActionFrame()
|
||||
{
|
||||
if (mIsFragmentContainer)
|
||||
{
|
||||
RoutingPlanFragment fragment = (RoutingPlanFragment) getFragment(RoutingPlanFragment.class);
|
||||
if (fragment != null)
|
||||
fragment.hideActionFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
mRoutingPlanInplaceController.hideActionFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void showLineFrame(boolean show, @Nullable Runnable completion)
|
||||
{
|
||||
mMainMenu.showLineFrame(show, completion);
|
||||
|
@ -1674,6 +1744,14 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (mIsFragmentContainer)
|
||||
{
|
||||
replaceFragment(RoutingPlanFragment.class, null, completionListener);
|
||||
if (!RoutingController.get().hasStartPoint())
|
||||
{
|
||||
needsStartPoint();
|
||||
}
|
||||
else if (!RoutingController.get().hasEndPoint())
|
||||
{
|
||||
needsFinishPoint();
|
||||
}
|
||||
adjustTraffic(UiUtils.dimen(R.dimen.panel_width), UiUtils.getStatusBarHeight(getApplicationContext()));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.support.annotation.StringRes;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
@ -35,7 +36,7 @@ import com.mapswithme.util.statistics.Statistics;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
final class RoutingBottomMenuController
|
||||
final class RoutingBottomMenuController implements View.OnClickListener
|
||||
{
|
||||
private static final String STATE_ALTITUDE_CHART_SHOWN = "altitude_chart_shown";
|
||||
private static final String STATE_TAXI_INFO = "taxi_info";
|
||||
|
@ -56,6 +57,14 @@ final class RoutingBottomMenuController
|
|||
private final TextView mAltitudeDifference;
|
||||
@NonNull
|
||||
private final View mNumbersFrame;
|
||||
@NonNull
|
||||
private final View mActionFrame;
|
||||
@NonNull
|
||||
private final TextView mActionMessage;
|
||||
@NonNull
|
||||
private final View mActionButton;
|
||||
@NonNull
|
||||
private final ImageView mActionIcon;
|
||||
|
||||
@Nullable
|
||||
private UberInfo mUberInfo;
|
||||
|
@ -69,7 +78,8 @@ final class RoutingBottomMenuController
|
|||
@NonNull Button start,
|
||||
@NonNull ImageView altitudeChart,
|
||||
@NonNull TextView altitudeDifference,
|
||||
@NonNull View numbersFrame)
|
||||
@NonNull View numbersFrame,
|
||||
@NonNull View actionFrame)
|
||||
{
|
||||
mContext = context;
|
||||
mAltitudeChartFrame = altitudeChartFrame;
|
||||
|
@ -79,12 +89,25 @@ final class RoutingBottomMenuController
|
|||
mAltitudeChart = altitudeChart;
|
||||
mAltitudeDifference = altitudeDifference;
|
||||
mNumbersFrame = numbersFrame;
|
||||
UiUtils.hide(mAltitudeChartFrame, mUberFrame);
|
||||
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));
|
||||
}
|
||||
});
|
||||
UiUtils.hide(mAltitudeChartFrame, mUberFrame, mActionFrame);
|
||||
}
|
||||
|
||||
void showAltitudeChartAndRoutingDetails()
|
||||
{
|
||||
UiUtils.hide(mError, mUberFrame);
|
||||
UiUtils.hide(mError, mUberFrame, mActionFrame);
|
||||
|
||||
showRouteAltitudeChart();
|
||||
showRoutingDetails();
|
||||
|
@ -124,6 +147,28 @@ final class RoutingBottomMenuController
|
|||
UiUtils.show(mUberFrame);
|
||||
}
|
||||
|
||||
void needsStartPoint()
|
||||
{
|
||||
UiUtils.show(mActionFrame, mActionButton);
|
||||
mActionMessage.setText(R.string.routing_add_start_point);
|
||||
Drawable icon = ContextCompat.getDrawable(mContext, R.drawable.ic_my_location);
|
||||
int colorAccent = ContextCompat.getColor(mContext,
|
||||
UiUtils.getStyledResourceId(mContext, R.attr.colorAccent));
|
||||
mActionIcon.setImageDrawable(Graphics.tint(icon, colorAccent));
|
||||
}
|
||||
|
||||
void needsFinishPoint()
|
||||
{
|
||||
UiUtils.show(mActionFrame);
|
||||
mActionMessage.setText(R.string.routing_add_finish_point);
|
||||
UiUtils.hide(mActionButton);
|
||||
}
|
||||
|
||||
void hideActionFrame()
|
||||
{
|
||||
UiUtils.hide(mActionFrame);
|
||||
}
|
||||
|
||||
void setStartButton()
|
||||
{
|
||||
if (RoutingController.get().isTaxiRouterType())
|
||||
|
@ -220,10 +265,10 @@ final class RoutingBottomMenuController
|
|||
mAltitudeDifference.setText(String.format(Locale.getDefault(), "%d %s",
|
||||
limits.maxRouteAltitude - limits.minRouteAltitude,
|
||||
limits.isMetricUnits ? meter : foot));
|
||||
Drawable icon = ContextCompat.getDrawable(mAltitudeDifference.getContext(),
|
||||
Drawable icon = ContextCompat.getDrawable(mContext,
|
||||
R.drawable.ic_altitude_difference);
|
||||
int colorAccent = ContextCompat.getColor(mAltitudeDifference.getContext(),
|
||||
UiUtils.getStyledResourceId(mAltitudeDifference.getContext(), R.attr.colorAccent));
|
||||
int colorAccent = ContextCompat.getColor(mContext,
|
||||
UiUtils.getStyledResourceId(mContext, R.attr.colorAccent));
|
||||
mAltitudeDifference.setCompoundDrawablesWithIntrinsicBounds(Graphics.tint(icon, colorAccent),
|
||||
null, null, null);
|
||||
UiUtils.show(mAltitudeDifference);
|
||||
|
@ -260,4 +305,15 @@ final class RoutingBottomMenuController
|
|||
Location location = LocationHelper.INSTANCE.getLastKnownLocation();
|
||||
Statistics.INSTANCE.trackUber(from, to, location, isUberInstalled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
switch (v.getId())
|
||||
{
|
||||
case R.id.btn__my_position_use:
|
||||
RoutingController.get().setStartPoint(LocationHelper.INSTANCE.getMyPosition());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -647,6 +647,16 @@ public class RoutingController
|
|||
return mEndPoint;
|
||||
}
|
||||
|
||||
public boolean hasStartPoint()
|
||||
{
|
||||
return mStartPoint != null;
|
||||
}
|
||||
|
||||
public boolean hasEndPoint()
|
||||
{
|
||||
return mEndPoint != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
RoutingInfo getCachedRoutingInfo()
|
||||
{
|
||||
|
@ -809,6 +819,8 @@ public class RoutingController
|
|||
|
||||
setPointsInternal();
|
||||
checkAndBuildRoute();
|
||||
if (mContainer != null)
|
||||
mContainer.updateMenu();
|
||||
}
|
||||
|
||||
public void setRouterType(@Framework.RouterType int router)
|
||||
|
|
|
@ -161,11 +161,12 @@ public class RoutingPlanController extends ToolbarController implements SlotFram
|
|||
ImageView altitudeChart = (ImageView) getViewById(R.id.altitude_chart);
|
||||
TextView altitudeDifference = (TextView) getViewById(R.id.altitude_difference);
|
||||
View numbersFrame = getViewById(R.id.numbers);
|
||||
View actionFrame = getViewById(R.id.routing_action_frame);
|
||||
mRoutingBottomMenuController = new RoutingBottomMenuController(activity, altitudeChartFrame,
|
||||
uberFrame, error, start,
|
||||
altitudeChart,
|
||||
altitudeDifference,
|
||||
numbersFrame);
|
||||
numbersFrame, actionFrame);
|
||||
|
||||
mToggle.setImageDrawable(mToggleImage);
|
||||
mToggle.setOnClickListener(new View.OnClickListener()
|
||||
|
@ -456,4 +457,19 @@ public class RoutingPlanController extends ToolbarController implements SlotFram
|
|||
{
|
||||
mToggleListener = listener;
|
||||
}
|
||||
|
||||
public void needsStartPoint()
|
||||
{
|
||||
mRoutingBottomMenuController.needsStartPoint();
|
||||
}
|
||||
|
||||
public void needsFinishPoint()
|
||||
{
|
||||
mRoutingBottomMenuController.needsFinishPoint();
|
||||
}
|
||||
|
||||
public void hideActionFrame()
|
||||
{
|
||||
mRoutingBottomMenuController.hideActionFrame();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,4 +77,19 @@ public class RoutingPlanFragment extends BaseMwmFragment
|
|||
{
|
||||
mPlanController.saveRoutingPanelState(outState);
|
||||
}
|
||||
|
||||
public void needsStartPoint()
|
||||
{
|
||||
mPlanController.needsStartPoint();
|
||||
}
|
||||
|
||||
public void needsFinishPoint()
|
||||
{
|
||||
mPlanController.needsFinishPoint();
|
||||
}
|
||||
|
||||
public void hideActionFrame()
|
||||
{
|
||||
mPlanController.hideActionFrame();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue