Don't follow to my position in case of launch by deep link.

This commit is contained in:
Daria Volvenkova 2017-04-06 17:39:03 +03:00
parent 8984d630b9
commit a36ed6cb69
10 changed files with 94 additions and 48 deletions

View file

@ -146,7 +146,9 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
p.m_hasMyPositionState = m_isCurrentModeInitialized;
p.m_initialMyPositionState = m_currentMode;
p.m_isChoosePositionMode = m_isChoosePositionMode;
p.m_isFirstLaunch = firstLaunch;
p.m_hints.m_isFirstLaunch = firstLaunch;
// TODO: Add initialization.
// p.m_hints.m_isLaunchByDeepLink = ...;
ASSERT(!m_guiPositions.empty(), ("GUI elements must be set-up before engine is created"));
p.m_widgetsInitInfo = m_guiPositions;

View file

@ -1,6 +1,7 @@
#include "drape_frontend/drape_engine.hpp"
#include "drape_frontend/message_subclasses.hpp"
#include "drape_frontend/visual_params.hpp"
#include "drape_frontend/my_position_controller.hpp"
#include "drape_frontend/gui/drape_gui.hpp"
@ -43,25 +44,40 @@ DrapeEngine::DrapeEngine(Params && params)
if (settings::Get("LastEnterBackground", lastEnterBackground))
timeInBackground = my::Timer::LocalTime() - lastEnterBackground;
FrontendRenderer::Params frParams(make_ref(m_threadCommutator), params.m_factory,
make_ref(m_textureManager), m_viewport,
MyPositionController::Params mpParams(mode,
timeInBackground,
params.m_isFirstLaunch,
params.m_isLaunchByDeepLink,
params.m_isRoutingActive,
params.m_isAutozoomEnabled,
bind(&DrapeEngine::MyPositionModeChanged, this, _1, _2));
FrontendRenderer::Params frParams(make_ref(m_threadCommutator),
params.m_factory,
make_ref(m_textureManager),
move(mpParams),
m_viewport,
bind(&DrapeEngine::ModelViewChanged, this, _1),
bind(&DrapeEngine::TapEvent, this, _1),
bind(&DrapeEngine::UserPositionChanged, this, _1),
bind(&DrapeEngine::MyPositionModeChanged, this, _1, _2),
mode, make_ref(m_requestedTiles),
move(params.m_overlaysShowStatsCallback), timeInBackground,
params.m_allow3dBuildings, params.m_trafficEnabled,
params.m_blockTapEvents, params.m_isFirstLaunch,
params.m_isRoutingActive, params.m_isAutozoomEnabled);
make_ref(m_requestedTiles),
move(params.m_overlaysShowStatsCallback),
params.m_allow3dBuildings,
params.m_trafficEnabled,
params.m_blockTapEvents);
m_frontend = make_unique_dp<FrontendRenderer>(move(frParams));
BackendRenderer::Params brParams(frParams.m_commutator, frParams.m_oglContextFactory,
frParams.m_texMng, params.m_model,
BackendRenderer::Params brParams(frParams.m_commutator,
frParams.m_oglContextFactory,
frParams.m_texMng,
params.m_model,
params.m_model.UpdateCurrentCountryFn(),
make_ref(m_requestedTiles), params.m_allow3dBuildings,
params.m_trafficEnabled, params.m_simplifiedTrafficColors);
make_ref(m_requestedTiles),
params.m_allow3dBuildings,
params.m_trafficEnabled,
params.m_simplifiedTrafficColors);
m_backend = make_unique_dp<BackendRenderer>(move(brParams));
m_widgetsInfo = move(params.m_info);

View file

@ -54,7 +54,8 @@ public:
bool blockTapEvents,
bool showChoosePositionMark,
vector<m2::TriangleD> && boundAreaTriangles,
bool firstLaunch,
bool isFirstLaunch,
bool isLaunchByDeepLink,
bool isRoutingActive,
bool isAutozoomEnabled,
bool simplifiedTrafficColors,
@ -73,7 +74,8 @@ public:
, m_blockTapEvents(blockTapEvents)
, m_showChoosePositionMark(showChoosePositionMark)
, m_boundAreaTriangles(move(boundAreaTriangles))
, m_isFirstLaunch(firstLaunch)
, m_isFirstLaunch(isFirstLaunch)
, m_isLaunchByDeepLink(isLaunchByDeepLink)
, m_isRoutingActive(isRoutingActive)
, m_isAutozoomEnabled(isAutozoomEnabled)
, m_simplifiedTrafficColors(simplifiedTrafficColors)
@ -95,6 +97,7 @@ public:
bool m_showChoosePositionMark;
vector<m2::TriangleD> m_boundAreaTriangles;
bool m_isFirstLaunch;
bool m_isLaunchByDeepLink;
bool m_isRoutingActive;
bool m_isAutozoomEnabled;
bool m_simplifiedTrafficColors;

View file

@ -150,9 +150,7 @@ FrontendRenderer::FrontendRenderer(Params && params)
ASSERT(m_tapEventInfoFn, ());
ASSERT(m_userPositionChangedFn, ());
m_myPositionController.reset(new MyPositionController(params.m_initMyPositionMode, params.m_timeInBackground,
params.m_firstLaunch, params.m_isRoutingActive,
params.m_isAutozoomEnabled, params.m_myPositionModeCallback));
m_myPositionController.reset(new MyPositionController(move(params.m_myPositionParams)));
StartThread();
}

View file

@ -73,39 +73,30 @@ public:
Params(ref_ptr<ThreadsCommutator> commutator,
ref_ptr<dp::OGLContextFactory> factory,
ref_ptr<dp::TextureManager> texMng,
MyPositionController::Params && myPositionParams,
Viewport viewport,
TModelViewChanged const & modelViewChangedFn,
TTapEventInfoFn const & tapEventFn,
TUserPositionChangedFn const & positionChangedFn,
location::TMyPositionModeChanged myPositionModeCallback,
location::EMyPositionMode initMode,
ref_ptr<RequestedTiles> requestedTiles,
OverlaysShowStatsCallback && overlaysShowStatsCallback,
double timeInBackground,
bool allow3dBuildings,
bool trafficEnabled,
bool blockTapEvents,
bool firstLaunch,
bool isRoutingActive,
bool isAutozoomEnabled)
bool blockTapEvents)
: BaseRenderer::Params(commutator, factory, texMng)
, m_myPositionParams(move(myPositionParams))
, m_viewport(viewport)
, m_modelViewChangedFn(modelViewChangedFn)
, m_tapEventFn(tapEventFn)
, m_positionChangedFn(positionChangedFn)
, m_myPositionModeCallback(myPositionModeCallback)
, m_initMyPositionMode(initMode)
, m_requestedTiles(requestedTiles)
, m_overlaysShowStatsCallback(move(overlaysShowStatsCallback))
, m_timeInBackground(timeInBackground)
, m_allow3dBuildings(allow3dBuildings)
, m_trafficEnabled(trafficEnabled)
, m_blockTapEvents(blockTapEvents)
, m_firstLaunch(firstLaunch)
, m_isRoutingActive(isRoutingActive)
, m_isAutozoomEnabled(isAutozoomEnabled)
{}
MyPositionController::Params m_myPositionParams;
Viewport m_viewport;
TModelViewChanged m_modelViewChangedFn;
TTapEventInfoFn m_tapEventFn;
@ -119,6 +110,7 @@ public:
bool m_trafficEnabled;
bool m_blockTapEvents;
bool m_firstLaunch;
bool m_isLaunchByDeepLink;
bool m_isRoutingActive;
bool m_isAutozoomEnabled;
};

View file

@ -123,14 +123,12 @@ double CalculateZoomBySpeed(double speed, bool isPerspectiveAllowed)
} // namespace
MyPositionController::MyPositionController(location::EMyPositionMode initMode, double timeInBackground,
bool isFirstLaunch, bool isRoutingActive, bool isAutozoomEnabled,
location::TMyPositionModeChanged const & fn)
MyPositionController::MyPositionController(Params && params)
: m_mode(location::PendingPosition)
, m_desiredInitMode(initMode)
, m_modeChangeCallback(fn)
, m_isFirstLaunch(isFirstLaunch)
, m_isInRouting(isRoutingActive)
, m_desiredInitMode(params.m_initMode)
, m_modeChangeCallback(move(params.m_myPositionModeCallback))
, m_isFirstLaunch(params.m_isFirstLaunch)
, m_isInRouting(params.m_isRoutingActive)
, m_needBlockAnimation(false)
, m_wasRotationInScaling(false)
, m_errorRadius(0.0)
@ -139,7 +137,7 @@ MyPositionController::MyPositionController(location::EMyPositionMode initMode, d
, m_oldPosition(m2::PointD::Zero())
, m_oldDrawDirection(0.0)
, m_enablePerspectiveInRouting(false)
, m_enableAutoZoomInRouting(isAutozoomEnabled)
, m_enableAutoZoomInRouting(params.m_isAutozoomEnabled)
, m_autoScale2d(GetScale(kDefaultAutoZoom))
, m_autoScale3d(m_autoScale2d)
, m_lastGPSBearing(false)
@ -161,7 +159,11 @@ MyPositionController::MyPositionController(location::EMyPositionMode initMode, d
m_mode = location::NotFollowNoPosition;
m_desiredInitMode = location::NotFollowNoPosition;
}
else if (timeInBackground >= kMaxTimeInBackgroundSec)
else if (params.m_isLaunchByDeepLink)
{
m_desiredInitMode = location::NotFollow;
}
else if (params.m_timeInBackground >= kMaxTimeInBackgroundSec)
{
m_desiredInitMode = location::Follow;
}

View file

@ -40,9 +40,34 @@ public:
TAnimationCreator const & parallelAnimCreator) = 0;
};
MyPositionController(location::EMyPositionMode initMode, double timeInBackground,
bool isFirstLaunch, bool isRoutingActive, bool isAutozoomEnabled,
location::TMyPositionModeChanged const & fn);
struct Params
{
Params(location::EMyPositionMode initMode,
double timeInBackground,
bool isFirstLaunch,
bool isLaunchByDeepLink,
bool isRoutingActive,
bool isAutozoomEnabled,
location::TMyPositionModeChanged && fn)
: m_initMode(initMode)
, m_timeInBackground(timeInBackground)
, m_isFirstLaunch(isFirstLaunch)
, m_isLaunchByDeepLink(isLaunchByDeepLink)
, m_isRoutingActive(isRoutingActive)
, m_isAutozoomEnabled(isAutozoomEnabled)
, m_myPositionModeCallback(move(fn))
{}
location::EMyPositionMode m_initMode;
double m_timeInBackground;
bool m_isFirstLaunch;
bool m_isLaunchByDeepLink;
bool m_isRoutingActive;
bool m_isAutozoomEnabled;
location::TMyPositionModeChanged m_myPositionModeCallback;
};
MyPositionController(Params && params);
~MyPositionController();
void UpdatePosition();

View file

@ -84,8 +84,10 @@ double getExactDPI(double contentScaleFactor)
p.m_surfaceWidth = width;
p.m_surfaceHeight = height;
p.m_visualScale = dp::VisualScale(getExactDPI(self.contentScaleFactor));
p.m_isFirstLaunch = [Alohalytics isFirstSession];
p.m_hints.m_isFirstLaunch = [Alohalytics isFirstSession];
// TODO: Add initialization.
// p.m_hints.m_isLaunchByDeepLink = ...;
[self.widgetsManager setupWidgets:p];
GetFramework().CreateDrapeEngine(make_ref(m_factory), move(p));

View file

@ -1812,7 +1812,8 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory,
params.m_visualScale, fontsScaleFactor, move(params.m_widgetsInitInfo),
make_pair(params.m_initialMyPositionState, params.m_hasMyPositionState),
move(myPositionModeChangedFn), allow3dBuildings, trafficEnabled, params.m_isChoosePositionMode,
params.m_isChoosePositionMode, GetSelectedFeatureTriangles(), params.m_isFirstLaunch,
params.m_isChoosePositionMode, GetSelectedFeatureTriangles(),
params.m_hints.m_isFirstLaunch, params.m_hints.m_isLaunchByDeepLink,
m_routingSession.IsActive() && m_routingSession.IsFollowing(), isAutozoomEnabled,
simplifiedTrafficColors, move(overlaysShowStatsFn));

View file

@ -440,6 +440,12 @@ private:
//@}
public:
struct DrapeHints
{
bool m_isFirstLaunch = false;
bool m_isLaunchByDeepLink = false;
};
struct DrapeCreationParams
{
float m_visualScale = 1.0f;
@ -451,8 +457,7 @@ public:
location::EMyPositionMode m_initialMyPositionState = location::PendingPosition;
bool m_isChoosePositionMode = false;
bool m_isFirstLaunch = false;
DrapeHints m_hints;
};
void CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory, DrapeCreationParams && params);