forked from organicmaps/organicmaps
[android] Added cancelling the navigation UI if an end point is reached or passed
This commit is contained in:
parent
ca0ea2d5ba
commit
a613b2e59f
8 changed files with 39 additions and 35 deletions
|
@ -1248,4 +1248,10 @@ Java_com_mapswithme_maps_Framework_nativeSetVisibleRect(JNIEnv * env, jclass, ji
|
|||
{
|
||||
frm()->SetVisibleViewport(m2::RectD(left, top, right, bottom));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeIsRouteFinished(JNIEnv * env, jclass)
|
||||
{
|
||||
return frm()->IsRouteFinished();
|
||||
}
|
||||
} // extern "C"
|
||||
|
|
|
@ -259,4 +259,7 @@ public class Framework
|
|||
public static native String nativeGetActiveObjectFormattedCuisine();
|
||||
|
||||
public static native void nativeSetVisibleRect(int left, int top, int right, int bottom);
|
||||
|
||||
// Navigation.
|
||||
public static native boolean nativeIsRouteFinished();
|
||||
}
|
||||
|
|
|
@ -745,7 +745,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
break;
|
||||
|
||||
case SEARCH:
|
||||
RoutingController.get().cancelPlanning();
|
||||
RoutingController.get().cancel();
|
||||
closeMenu(Statistics.EventName.TOOLBAR_SEARCH, AlohaHelper.TOOLBAR_SEARCH, new Runnable()
|
||||
{
|
||||
@Override
|
||||
|
@ -783,7 +783,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
break;
|
||||
|
||||
case DOWNLOADER:
|
||||
RoutingController.get().cancelPlanning();
|
||||
RoutingController.get().cancel();
|
||||
closeMenu(Statistics.EventName.MENU_DOWNLOADER, AlohaHelper.MENU_DOWNLOADER, new Runnable()
|
||||
{
|
||||
@Override
|
||||
|
@ -1072,8 +1072,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
return;
|
||||
}
|
||||
|
||||
if (!closePlacePage() && !closeSidePanel() &&
|
||||
(mNavigationController != null && !mNavigationController.cancel()) && !closePositionChooser())
|
||||
if (!closePlacePage() && !closeSidePanel() && !RoutingController.get().cancel()
|
||||
&& !closePositionChooser())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1720,6 +1720,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationCancelled()
|
||||
{
|
||||
if (mNavigationController != null)
|
||||
mNavigationController.stop(this);
|
||||
}
|
||||
|
||||
boolean isFirstStart()
|
||||
{
|
||||
boolean res = mFirstStart;
|
||||
|
|
|
@ -351,6 +351,17 @@ public enum LocationHelper
|
|||
for (LocationListener listener : mListeners)
|
||||
listener.onLocationUpdated(mSavedLocation);
|
||||
mListeners.finishIterate();
|
||||
|
||||
// TODO: consider to create callback mechanism to transfer 'ROUTE_IS_FINISHED' event from
|
||||
// the core to the platform code (https://jira.mail.ru/browse/MAPSME-3675),
|
||||
// because calling the native method 'nativeIsRouteFinished'
|
||||
// too often can result in poor UI performance.
|
||||
if (RoutingController.get().isNavigating() && Framework.nativeIsRouteFinished())
|
||||
{
|
||||
mLogger.d("End point is reached");
|
||||
restart();
|
||||
RoutingController.get().cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyLocationUpdated(LocationListener listener)
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.location.Location;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
|
@ -138,7 +139,6 @@ public class NavigationController implements TrafficManager.TrafficCallback
|
|||
{
|
||||
case STOP:
|
||||
RoutingController.get().cancel();
|
||||
stop(parent);
|
||||
break;
|
||||
case SETTINGS:
|
||||
parent.closeMenu(Statistics.EventName.ROUTING_SETTINGS, AlohaHelper.MENU_SETTINGS, new Runnable()
|
||||
|
@ -169,7 +169,7 @@ public class NavigationController implements TrafficManager.TrafficCallback
|
|||
});
|
||||
}
|
||||
|
||||
private void stop(MwmActivity parent)
|
||||
public void stop(MwmActivity parent)
|
||||
{
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_CLOSE);
|
||||
AlohaHelper.logClick(AlohaHelper.ROUTING_CLOSE);
|
||||
|
@ -221,7 +221,7 @@ public class NavigationController implements TrafficManager.TrafficCallback
|
|||
update(Framework.nativeGetRouteFollowingInfo());
|
||||
}
|
||||
|
||||
public void update(RoutingInfo info)
|
||||
public void update(@Nullable RoutingInfo info)
|
||||
{
|
||||
if (info == null)
|
||||
return;
|
||||
|
@ -316,17 +316,6 @@ public class NavigationController implements TrafficManager.TrafficCallback
|
|||
mSearchWheel.restoreState(savedInstanceState);
|
||||
}
|
||||
|
||||
public boolean cancel()
|
||||
{
|
||||
if (RoutingController.get().cancel())
|
||||
{
|
||||
final MwmActivity parent = ((MwmActivity) mFrame.getContext());
|
||||
stop(parent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnabled()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.mapswithme.maps.routing;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Rect;
|
||||
import android.support.annotation.DimenRes;
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.MainThread;
|
||||
|
@ -70,6 +69,7 @@ public class RoutingController
|
|||
void updatePoints();
|
||||
void onUberInfoReceived(@NonNull UberInfo info);
|
||||
void onUberError(@NonNull Uber.ErrorCode code);
|
||||
void onNavigationCancelled();
|
||||
|
||||
/**
|
||||
* @param progress progress to be displayed.
|
||||
|
@ -468,7 +468,6 @@ public class RoutingController
|
|||
|
||||
ThemeSwitcher.restart();
|
||||
Framework.nativeCloseRouting();
|
||||
LocationHelper.INSTANCE.restart();
|
||||
}
|
||||
|
||||
public boolean cancel()
|
||||
|
@ -493,6 +492,8 @@ public class RoutingController
|
|||
mContainer.showNavigation(false);
|
||||
mContainer.updateMenu();
|
||||
}
|
||||
if (mContainer != null)
|
||||
mContainer.onNavigationCancelled();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -500,19 +501,6 @@ public class RoutingController
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean cancelPlanning()
|
||||
{
|
||||
mLogger.d("cancelPlanning");
|
||||
|
||||
if (isPlanning())
|
||||
{
|
||||
cancel();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPlanning()
|
||||
{
|
||||
return mState == State.PREPARE;
|
||||
|
|
|
@ -194,7 +194,7 @@ public class RoutingPlanController extends ToolbarController implements SlotFram
|
|||
{
|
||||
AlohaHelper.logClick(AlohaHelper.ROUTING_CANCEL);
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_CANCEL);
|
||||
RoutingController.get().cancelPlanning();
|
||||
RoutingController.get().cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -64,7 +64,7 @@ public class RoutingPlanFragment extends BaseMwmFragment
|
|||
@Override
|
||||
public boolean onBackPressed()
|
||||
{
|
||||
return RoutingController.get().cancelPlanning();
|
||||
return RoutingController.get().cancel();
|
||||
}
|
||||
|
||||
public void restoreRoutingPanelState(@NonNull Bundle state)
|
||||
|
|
Loading…
Add table
Reference in a new issue