forked from organicmaps/organicmaps
[android] Differentiate restore and start/cancel navigation and planning
Signed-off-by: Arnaud Vergnet <arnaud.vergnet@mailo.com>
This commit is contained in:
parent
c434af7dc6
commit
6eada4f35d
2 changed files with 88 additions and 40 deletions
|
@ -549,7 +549,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (!TextUtils.isEmpty(mSearchController.getQuery()))
|
||||
{
|
||||
// Close all panels and tool bars (including search) but do not stop search backend
|
||||
closeFloatingToolbarsAndPanels(false, false);
|
||||
closeFloatingToolbars(false, false);
|
||||
// Do not show the search tool bar if we are planning or navigating
|
||||
if (!RoutingController.get().isNavigating() && !RoutingController.get().isPlanning())
|
||||
{
|
||||
|
@ -564,7 +564,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
public void showPositionChooser(boolean isBusiness, boolean applyPosition)
|
||||
{
|
||||
closeFloatingToolbarsAndPanels(false);
|
||||
closeFloatingToolbarsAndPanels(false, true);
|
||||
UiUtils.show(mPositionChooser);
|
||||
setFullscreen(true);
|
||||
Framework.nativeTurnOnChoosePositionMode(isBusiness, applyPosition);
|
||||
|
@ -739,15 +739,20 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
return false;
|
||||
}
|
||||
|
||||
private void closeFloatingToolbarsAndPanels(boolean clearSearchText)
|
||||
private void closeFloatingToolbarsAndPanels(boolean clearSearchText, boolean stopSearch)
|
||||
{
|
||||
closeFloatingToolbarsAndPanels(clearSearchText, true);
|
||||
closeFloatingPanels();
|
||||
closeFloatingToolbars(clearSearchText, stopSearch);
|
||||
}
|
||||
|
||||
private void closeFloatingToolbarsAndPanels(boolean clearSearchText, boolean stopSearch)
|
||||
private void closeFloatingPanels()
|
||||
{
|
||||
closeMenu();
|
||||
closePlacePage();
|
||||
}
|
||||
|
||||
private void closeFloatingToolbars(boolean clearSearchText, boolean stopSearch)
|
||||
{
|
||||
closeBookmarkCategoryToolbar();
|
||||
closePositionChooser();
|
||||
closeSearchToolbar(clearSearchText, stopSearch);
|
||||
|
@ -1586,7 +1591,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
Context context = getApplicationContext();
|
||||
if (show)
|
||||
{
|
||||
closeFloatingToolbarsAndPanels(false, false);
|
||||
if (mIsTabletLayout)
|
||||
{
|
||||
replaceFragment(RoutingPlanFragment.class, null, completionListener);
|
||||
|
@ -1610,7 +1614,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
}
|
||||
else
|
||||
{
|
||||
closeFloatingToolbarsAndPanels(true, true);
|
||||
if (mIsTabletLayout)
|
||||
{
|
||||
adjustCompassAndTraffic(UiUtils.getStatusBarHeight(getApplicationContext()));
|
||||
|
@ -1690,7 +1693,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
mOnmapDownloader.updateState(false);
|
||||
if (show)
|
||||
{
|
||||
closeFloatingToolbarsAndPanels(false, false);
|
||||
if (mFilterController != null)
|
||||
mFilterController.show(false);
|
||||
}
|
||||
|
@ -1735,10 +1737,23 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
@Override
|
||||
public void onNavigationStarted()
|
||||
{
|
||||
closeFloatingToolbarsAndPanels(true, true);
|
||||
ThemeSwitcher.INSTANCE.restart(isMapRendererActive());
|
||||
mNavigationController.start(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlanningCancelled()
|
||||
{
|
||||
closeFloatingToolbarsAndPanels(true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlanningStarted()
|
||||
{
|
||||
closeFloatingToolbarsAndPanels(true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddedStop()
|
||||
{
|
||||
|
|
|
@ -65,6 +65,8 @@ public class RoutingController implements Initializable<Void>
|
|||
void updateMenu();
|
||||
void onNavigationCancelled();
|
||||
void onNavigationStarted();
|
||||
void onPlanningCancelled();
|
||||
void onPlanningStarted();
|
||||
void onAddedStop();
|
||||
void onRemovedStop();
|
||||
void onResetToPlanningState();
|
||||
|
@ -248,16 +250,21 @@ public class RoutingController implements Initializable<Void>
|
|||
}
|
||||
|
||||
private void showRoutePlan()
|
||||
{
|
||||
showRoutePlan(null, null);
|
||||
}
|
||||
|
||||
private void showRoutePlan(final @Nullable MapObject startPoint, final @Nullable MapObject endPoint)
|
||||
{
|
||||
if (mContainer != null)
|
||||
mContainer.showRoutePlan(true, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
{
|
||||
mContainer.showRoutePlan(true, () -> {
|
||||
if (startPoint == null || endPoint == null)
|
||||
updatePlan();
|
||||
}
|
||||
else
|
||||
build();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void attach(@NonNull Container container)
|
||||
|
@ -456,18 +463,7 @@ public class RoutingController implements Initializable<Void>
|
|||
if (startPoint != null || endPoint != null)
|
||||
setPointsInternal(startPoint, endPoint);
|
||||
|
||||
if (mContainer != null)
|
||||
mContainer.showRoutePlan(true, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (startPoint == null || endPoint == null)
|
||||
updatePlan();
|
||||
else
|
||||
build();
|
||||
}
|
||||
});
|
||||
startPlanning(startPoint, endPoint);
|
||||
}
|
||||
|
||||
public void start()
|
||||
|
@ -488,12 +484,8 @@ public class RoutingController implements Initializable<Void>
|
|||
|
||||
setState(State.NAVIGATION);
|
||||
|
||||
if (mContainer != null)
|
||||
{
|
||||
mContainer.showRoutePlan(false, null);
|
||||
mContainer.showNavigation(true);
|
||||
mContainer.onNavigationStarted();
|
||||
}
|
||||
cancelPlanning();
|
||||
startNavigation();
|
||||
|
||||
Framework.nativeFollowRoute();
|
||||
LocationHelper.INSTANCE.restart();
|
||||
|
@ -536,12 +528,11 @@ public class RoutingController implements Initializable<Void>
|
|||
return;
|
||||
|
||||
setState(State.PREPARE);
|
||||
cancelNavigation();
|
||||
startPlanning();
|
||||
if (mContainer != null)
|
||||
{
|
||||
mContainer.showNavigation(false);
|
||||
mContainer.showRoutePlan(true, null);
|
||||
mContainer.updateMenu();
|
||||
mContainer.onNavigationCancelled();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -638,8 +629,7 @@ public class RoutingController implements Initializable<Void>
|
|||
mLogger.d(TAG, "cancel: planning");
|
||||
|
||||
cancelInternal();
|
||||
if (mContainer != null)
|
||||
mContainer.showRoutePlan(false, null);
|
||||
cancelPlanning();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -648,13 +638,11 @@ public class RoutingController implements Initializable<Void>
|
|||
mLogger.d(TAG, "cancel: navigating");
|
||||
|
||||
cancelInternal();
|
||||
cancelNavigation();
|
||||
if (mContainer != null)
|
||||
{
|
||||
mContainer.showNavigation(false);
|
||||
mContainer.updateMenu();
|
||||
}
|
||||
if (mContainer != null)
|
||||
mContainer.onNavigationCancelled();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -662,6 +650,51 @@ public class RoutingController implements Initializable<Void>
|
|||
return false;
|
||||
}
|
||||
|
||||
public void startPlanning()
|
||||
{
|
||||
if (mContainer != null)
|
||||
{
|
||||
showRoutePlan();
|
||||
mContainer.onPlanningStarted();
|
||||
}
|
||||
}
|
||||
|
||||
public void startPlanning(final @Nullable MapObject startPoint, final @Nullable MapObject endPoint)
|
||||
{
|
||||
if (mContainer != null)
|
||||
{
|
||||
showRoutePlan(startPoint, endPoint);
|
||||
mContainer.onPlanningStarted();
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelPlanning()
|
||||
{
|
||||
if (mContainer != null)
|
||||
{
|
||||
mContainer.showRoutePlan(false, null);
|
||||
mContainer.onPlanningCancelled();
|
||||
}
|
||||
}
|
||||
|
||||
public void startNavigation()
|
||||
{
|
||||
if (mContainer != null)
|
||||
{
|
||||
mContainer.showNavigation(true);
|
||||
mContainer.onNavigationStarted();
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelNavigation()
|
||||
{
|
||||
if (mContainer != null)
|
||||
{
|
||||
mContainer.showNavigation(false);
|
||||
mContainer.onNavigationCancelled();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlanning()
|
||||
{
|
||||
return mState == State.PREPARE;
|
||||
|
|
Loading…
Add table
Reference in a new issue