[guides on map] guides layer is disabled after 8 hours in background

This commit is contained in:
Arsentiy Milchakov 2020-05-08 08:51:57 +03:00 committed by Daria Volvenkova
parent 92cabc4a19
commit 81f70e02b0
3 changed files with 14 additions and 3 deletions

View file

@ -155,7 +155,8 @@ char const kShowDebugInfo[] = "DebugInfo";
char const kICUDataFile[] = "icudt57l.dat";
#endif
double const kLargeFontsScaleFactor = 1.6;
auto constexpr kLargeFontsScaleFactor = 1.6;
auto constexpr kGuidesEnabledInBackgroundMaxHours = 8;
size_t constexpr kMaxTrafficCacheSizeBytes = 64 /* Mb */ * 1024 * 1024;
// TODO!
@ -1499,8 +1500,15 @@ void Framework::EnterForeground()
m_startForegroundTime = base::Timer::LocalTime();
if (m_drapeEngine != nullptr && m_startBackgroundTime != 0.0)
{
auto const timeInBackground = m_startForegroundTime - m_startBackgroundTime;
m_drapeEngine->SetTimeInBackground(timeInBackground);
auto const secondsInBackground = m_startForegroundTime - m_startBackgroundTime;
m_drapeEngine->SetTimeInBackground(secondsInBackground);
if (m_guidesManager.IsEnabled() &&
secondsInBackground / 60 / 60 > kGuidesEnabledInBackgroundMaxHours)
{
m_guidesManager.SetEnabled(false);
SaveGuidesEnabled(false);
}
}
m_trafficManager.OnEnterForeground();

View file

@ -215,6 +215,7 @@ protected:
drape_ptr<df::DrapeEngine> m_drapeEngine;
// Time in seconds.
double m_startForegroundTime = 0.0;
double m_startBackgroundTime = 0.0;

View file

@ -26,6 +26,8 @@ GuidesManager::GuidesState GuidesManager::GetState() const
void GuidesManager::SetStateListener(GuidesStateChangedFn const & onStateChanged)
{
m_onStateChanged = onStateChanged;
if (m_onStateChanged != nullptr)
m_onStateChanged(m_state);
}
void GuidesManager::UpdateViewport(ScreenBase const & screen)