forked from organicmaps/organicmaps
Merge pull request #6400 from igrechuhin/remove_router_saved_state
[remove_router_saved_state] [ios] Removed router state retain.
This commit is contained in:
commit
1cb6b0777b
6 changed files with 8 additions and 146 deletions
|
@ -22,7 +22,6 @@
|
|||
#import "MWMPlacePageData.h"
|
||||
#import "MWMPlacePageProtocol.h"
|
||||
#import "MWMRouter.h"
|
||||
#import "MWMRouterSavedState.h"
|
||||
#import "MWMSettings.h"
|
||||
#import "MWMStorage.h"
|
||||
#import "MWMTableViewController.h"
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#import "MWMPushNotifications.h"
|
||||
#import "MWMRoutePoint+CPP.h"
|
||||
#import "MWMRouter.h"
|
||||
#import "MWMRouterSavedState.h"
|
||||
#import "MWMSearch+CoreSpotlight.h"
|
||||
#import "MWMSettings.h"
|
||||
#import "MWMStorage.h"
|
||||
|
@ -561,7 +560,6 @@ using namespace osm_auth_ios;
|
|||
{
|
||||
LOG(LINFO, ("applicationWillResignActive - begin"));
|
||||
[self.mapViewController onGetFocus:NO];
|
||||
[MWMRouterSavedState store];
|
||||
// On some devices we have to free all belong-to-graphics memory
|
||||
// because of new OpenGL driver powered by Metal.
|
||||
if ([AppInfo sharedInfo].isMetalDriver)
|
||||
|
@ -618,7 +616,6 @@ using namespace osm_auth_ios;
|
|||
GetFramework().OnRecoverGLContext(static_cast<int>(size.x), static_cast<int>(size.y));
|
||||
}
|
||||
[MWMLocationManager applicationDidBecomeActive];
|
||||
[MWMRouterSavedState restore];
|
||||
[MWMSearch addCategoriesToSpotlight];
|
||||
[MWMKeyboard applicationDidBecomeActive];
|
||||
LOG(LINFO, ("applicationDidBecomeActive - end"));
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMNavigationDashboardManager.h"
|
||||
#import "MWMRoutePoint+CPP.h"
|
||||
#import "MWMRouterSavedState.h"
|
||||
#import "MWMSearch.h"
|
||||
#import "MWMSettings.h"
|
||||
#import "MWMStorage.h"
|
||||
|
@ -113,7 +112,7 @@ char const * kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeI
|
|||
+ (BOOL)isRouteFinished { return GetFramework().GetRoutingManager().IsRouteFinished(); }
|
||||
+ (BOOL)isRouteRebuildingOnly { return GetFramework().GetRoutingManager().IsRouteRebuildingOnly(); }
|
||||
+ (BOOL)isOnRoute { return GetFramework().GetRoutingManager().IsOnRoute(); }
|
||||
+ (NSArray<MWMRoutePoint *> *)routePoints
|
||||
+ (NSArray<MWMRoutePoint *> *)points
|
||||
{
|
||||
NSMutableArray<MWMRoutePoint *> * points = [@[] mutableCopy];
|
||||
auto const routePoints = GetFramework().GetRoutingManager().GetRoutePoints();
|
||||
|
@ -345,7 +344,6 @@ char const * kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeI
|
|||
{
|
||||
rm.FollowRoute();
|
||||
[[MWMMapViewControlsManager manager] onRouteStart];
|
||||
[MWMRouterSavedState store];
|
||||
[MWMThemeManager setAutoUpdates:YES];
|
||||
}
|
||||
else
|
||||
|
@ -404,7 +402,6 @@ char const * kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeI
|
|||
|
||||
[self clearAltitudeImagesData];
|
||||
GetFramework().GetRoutingManager().CloseRouting(removeRoutePoints);
|
||||
[MWMRouterSavedState remove];
|
||||
[MWMThemeManager setAutoUpdates:NO];
|
||||
[MapsAppDelegate.theApp showAlertIfRequired];
|
||||
}
|
||||
|
@ -480,24 +477,13 @@ char const * kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeI
|
|||
- (void)onLocationUpdate:(location::GpsInfo const &)info
|
||||
{
|
||||
auto const & routingManager = GetFramework().GetRoutingManager();
|
||||
if (routingManager.IsRoutingActive())
|
||||
{
|
||||
auto tts = [MWMTextToSpeech tts];
|
||||
if (routingManager.IsOnRoute() && tts.active)
|
||||
[tts playTurnNotifications];
|
||||
if (!routingManager.IsRoutingActive())
|
||||
return;
|
||||
auto tts = [MWMTextToSpeech tts];
|
||||
if (routingManager.IsOnRoute() && tts.active)
|
||||
[tts playTurnNotifications];
|
||||
|
||||
[self updateFollowingInfo];
|
||||
}
|
||||
else
|
||||
{
|
||||
auto state = [MWMRouterSavedState state];
|
||||
if (state.forceStateChange == MWMRouterForceStateChange::Rebuild)
|
||||
{
|
||||
state.forceStateChange = MWMRouterForceStateChange::Start;
|
||||
[MWMRouter setType:routerType(GetFramework().GetRoutingManager().GetLastUsedRouter())];
|
||||
[MWMRouter buildToPoint:state.restorePoint bestRouter:NO];
|
||||
}
|
||||
}
|
||||
[self updateFollowingInfo];
|
||||
}
|
||||
|
||||
#pragma mark - MWMFrameworkRouteBuilderObserver
|
||||
|
@ -505,7 +491,6 @@ char const * kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeI
|
|||
- (void)processRouteBuilderEvent:(routing::IRouter::ResultCode)code
|
||||
countries:(storage::TCountriesVec const &)absentCountries
|
||||
{
|
||||
MWMRouterSavedState * state = [MWMRouterSavedState state];
|
||||
MWMMapViewControlsManager * mapViewControlsManager = [MWMMapViewControlsManager manager];
|
||||
switch (code)
|
||||
{
|
||||
|
@ -513,10 +498,7 @@ char const * kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeI
|
|||
{
|
||||
auto & f = GetFramework();
|
||||
f.DeactivateMapSelection(true);
|
||||
if (state.forceStateChange == MWMRouterForceStateChange::Start)
|
||||
[MWMRouter start];
|
||||
else
|
||||
[mapViewControlsManager onRouteReady];
|
||||
[mapViewControlsManager onRouteReady];
|
||||
[self updateFollowingInfo];
|
||||
if (![MWMRouter isTaxi])
|
||||
[[MWMNavigationDashboardManager manager] setRouteBuilderProgress:100];
|
||||
|
@ -544,7 +526,6 @@ char const * kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeI
|
|||
[mapViewControlsManager onRouteError];
|
||||
break;
|
||||
}
|
||||
state.forceStateChange = MWMRouterForceStateChange::None;
|
||||
}
|
||||
|
||||
- (void)processRouteBuilderProgress:(CGFloat)progress
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
@class MWMRoutePoint;
|
||||
|
||||
enum class MWMRouterForceStateChange
|
||||
{
|
||||
None,
|
||||
Rebuild,
|
||||
Start
|
||||
};
|
||||
|
||||
@interface MWMRouterSavedState : NSObject
|
||||
|
||||
@property(nonatomic, readonly) MWMRoutePoint * restorePoint;
|
||||
@property(nonatomic) MWMRouterForceStateChange forceStateChange;
|
||||
|
||||
+ (instancetype)state;
|
||||
|
||||
+ (void)store;
|
||||
+ (void)remove;
|
||||
+ (void)restore;
|
||||
|
||||
@end
|
|
@ -1,84 +0,0 @@
|
|||
#import "MWMRouterSavedState.h"
|
||||
#import "MWMRoutePoint+CPP.h"
|
||||
#import "MWMRouter.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
static NSString * const kEndPointKey = @"endPoint";
|
||||
static NSString * const kETAKey = @"eta";
|
||||
|
||||
@implementation MWMRouterSavedState
|
||||
|
||||
+ (instancetype)state
|
||||
{
|
||||
static MWMRouterSavedState * state;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
state = [[super alloc] initState];
|
||||
});
|
||||
return state;
|
||||
}
|
||||
|
||||
- (instancetype)initState
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_forceStateChange = MWMRouterForceStateChange::None;
|
||||
NSDictionary * const stateDict =
|
||||
[NSDictionary dictionaryWithContentsOfURL:[[self class] stateFileURL]];
|
||||
if (stateDict)
|
||||
{
|
||||
m2::PointD point;
|
||||
NSUInteger size;
|
||||
NSGetSizeAndAlignment(@encode(m2::PointD), &size, NULL);
|
||||
NSData const * const endPointData = stateDict[kEndPointKey];
|
||||
NSDate * const eta = stateDict[kETAKey];
|
||||
if (endPointData && eta)
|
||||
{
|
||||
[endPointData getBytes:&point length:size];
|
||||
_restorePoint = [[MWMRoutePoint alloc] initWithPoint:point type:MWMRoutePointTypeFinish];
|
||||
if ([eta compare:[NSDate date]] == NSOrderedDescending)
|
||||
_forceStateChange = MWMRouterForceStateChange::Rebuild;
|
||||
}
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (void)store
|
||||
{
|
||||
Framework & f = GetFramework();
|
||||
if (![MWMRouter isOnRoute])
|
||||
return;
|
||||
location::FollowingInfo routeInfo;
|
||||
f.GetRoutingManager().GetRouteFollowingInfo(routeInfo);
|
||||
m2::PointD const endPoint = f.GetRoutingManager().GetRouteEndPoint();
|
||||
NSMutableDictionary * const stateDict = [NSMutableDictionary dictionary];
|
||||
NSUInteger size;
|
||||
NSGetSizeAndAlignment(@encode(m2::PointD), &size, nullptr);
|
||||
stateDict[kEndPointKey] = [NSData dataWithBytes:&endPoint length:size];
|
||||
stateDict[kETAKey] = [NSDate dateWithTimeIntervalSinceNow:routeInfo.m_time];
|
||||
[stateDict writeToURL:[self stateFileURL] atomically:YES];
|
||||
}
|
||||
|
||||
+ (void)remove
|
||||
{
|
||||
[[NSFileManager defaultManager] removeItemAtURL:[self stateFileURL] error:nil];
|
||||
}
|
||||
|
||||
+ (NSURL *)stateFileURL
|
||||
{
|
||||
return [NSURL
|
||||
fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"route_info.ini"]];
|
||||
}
|
||||
|
||||
+ (void)restore
|
||||
{
|
||||
if ([MWMRouter isRoutingActive])
|
||||
return;
|
||||
if ([MWMRouterSavedState state].forceStateChange == MWMRouterForceStateChange::None)
|
||||
[self remove];
|
||||
}
|
||||
|
||||
@end
|
|
@ -87,9 +87,6 @@
|
|||
340475641E081A4600C92850 /* MWMRouter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340475361E081A4600C92850 /* MWMRouter.mm */; };
|
||||
340475651E081A4600C92850 /* MWMRouter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340475361E081A4600C92850 /* MWMRouter.mm */; };
|
||||
340475661E081A4600C92850 /* MWMRouter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340475361E081A4600C92850 /* MWMRouter.mm */; };
|
||||
340475671E081A4600C92850 /* MWMRouterSavedState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340475381E081A4600C92850 /* MWMRouterSavedState.mm */; };
|
||||
340475681E081A4600C92850 /* MWMRouterSavedState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340475381E081A4600C92850 /* MWMRouterSavedState.mm */; };
|
||||
340475691E081A4600C92850 /* MWMRouterSavedState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 340475381E081A4600C92850 /* MWMRouterSavedState.mm */; };
|
||||
3404756A1E081A4600C92850 /* MWMSearch+CoreSpotlight.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3404753B1E081A4600C92850 /* MWMSearch+CoreSpotlight.mm */; };
|
||||
3404756B1E081A4600C92850 /* MWMSearch+CoreSpotlight.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3404753B1E081A4600C92850 /* MWMSearch+CoreSpotlight.mm */; };
|
||||
3404756C1E081A4600C92850 /* MWMSearch+CoreSpotlight.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3404753B1E081A4600C92850 /* MWMSearch+CoreSpotlight.mm */; };
|
||||
|
@ -1628,8 +1625,6 @@
|
|||
340475321E081A4600C92850 /* MWMNetworkPolicy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMNetworkPolicy.mm; sourceTree = "<group>"; };
|
||||
340475351E081A4600C92850 /* MWMRouter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMRouter.h; sourceTree = "<group>"; };
|
||||
340475361E081A4600C92850 /* MWMRouter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMRouter.mm; sourceTree = "<group>"; };
|
||||
340475371E081A4600C92850 /* MWMRouterSavedState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMRouterSavedState.h; sourceTree = "<group>"; };
|
||||
340475381E081A4600C92850 /* MWMRouterSavedState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMRouterSavedState.mm; sourceTree = "<group>"; };
|
||||
3404753A1E081A4600C92850 /* MWMSearch+CoreSpotlight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MWMSearch+CoreSpotlight.h"; sourceTree = "<group>"; };
|
||||
3404753B1E081A4600C92850 /* MWMSearch+CoreSpotlight.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "MWMSearch+CoreSpotlight.mm"; sourceTree = "<group>"; };
|
||||
3404753C1E081A4600C92850 /* MWMSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSearch.h; sourceTree = "<group>"; };
|
||||
|
@ -2827,8 +2822,6 @@
|
|||
34F5E0DA1E3F3ED300B1C415 /* MWMRoutePoint.h */,
|
||||
340475351E081A4600C92850 /* MWMRouter.h */,
|
||||
340475361E081A4600C92850 /* MWMRouter.mm */,
|
||||
340475371E081A4600C92850 /* MWMRouterSavedState.h */,
|
||||
340475381E081A4600C92850 /* MWMRouterSavedState.mm */,
|
||||
);
|
||||
path = Routing;
|
||||
sourceTree = "<group>";
|
||||
|
@ -5187,7 +5180,6 @@
|
|||
F6E2FDDF1E097BA00083EBEC /* MWMEditorViewController.mm in Sources */,
|
||||
F6E2FDB51E097BA00083EBEC /* MWMEditorAdditionalNamesHeader.mm in Sources */,
|
||||
F6E2FDC71E097BA00083EBEC /* MWMEditorNotesFooter.mm in Sources */,
|
||||
340475671E081A4600C92850 /* MWMRouterSavedState.mm in Sources */,
|
||||
F6E2FD641E097BA00083EBEC /* MWMMapDownloaderPlaceTableViewCell.mm in Sources */,
|
||||
3454D7C41E07F045004AF2AD /* UIButton+Orientation.mm in Sources */,
|
||||
F6E2FF2C1E097BA00083EBEC /* MWMSearchCell.mm in Sources */,
|
||||
|
@ -5487,7 +5479,6 @@
|
|||
F6E2FDB61E097BA00083EBEC /* MWMEditorAdditionalNamesHeader.mm in Sources */,
|
||||
F6E2FDC81E097BA00083EBEC /* MWMEditorNotesFooter.mm in Sources */,
|
||||
F6E2FD651E097BA00083EBEC /* MWMMapDownloaderPlaceTableViewCell.mm in Sources */,
|
||||
340475681E081A4600C92850 /* MWMRouterSavedState.mm in Sources */,
|
||||
F6E2FF2D1E097BA00083EBEC /* MWMSearchCell.mm in Sources */,
|
||||
3454D7C51E07F045004AF2AD /* UIButton+Orientation.mm in Sources */,
|
||||
3454D7E61E07F045004AF2AD /* UIView+RuntimeAttributes.mm in Sources */,
|
||||
|
@ -5869,7 +5860,6 @@
|
|||
340475511E081A4600C92850 /* fabric_logging_ios.mm in Sources */,
|
||||
349D1ADF1E2E325C004A2006 /* MWMBottomMenuViewController.mm in Sources */,
|
||||
849CF6E71DE842290024A8A5 /* MWMSearchNoResultsAlert.mm in Sources */,
|
||||
340475691E081A4600C92850 /* MWMRouterSavedState.mm in Sources */,
|
||||
3454D7E41E07F045004AF2AD /* UITextView+RuntimeAttributes.mm in Sources */,
|
||||
849CF6E91DE842290024A8A5 /* MWMCircularProgressView.mm in Sources */,
|
||||
34F407421E9E1AFF00E57AC0 /* RBBanner.swift in Sources */,
|
||||
|
|
Loading…
Add table
Reference in a new issue