[cleanup] [ios] Fixed hardcoded self class references.

This commit is contained in:
Ilya Grechuhin 2017-01-10 17:14:29 +03:00
parent 7fc41500e5
commit 49ad147b2e
25 changed files with 56 additions and 56 deletions

View file

@ -246,9 +246,9 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
if (cat)
{
[Statistics logEvent:kStatEventName(kStatBookmarks, kStatExport)];
NSMutableString * catName = @(cat->GetName().c_str());
NSString * catName = @(cat->GetName().c_str());
if (![catName length])
[catName setString:@"MapsMe"];
catName = @"MapsMe";
NSString * filePath = @(cat->GetFileName().c_str());
NSMutableString * kmzFile = [NSMutableString stringWithString:filePath];

View file

@ -33,7 +33,7 @@
{
UIView * circleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, diameter, diameter)];
circleView.backgroundColor = [UIColor clearColor];
CircleView * circle = [[CircleView alloc] initWithFrame:CGRectMake(0.5, 0.5, diameter - 1, diameter - 1) andColor:color];
CircleView * circle = [[self alloc] initWithFrame:CGRectMake(0.5, 0.5, diameter - 1, diameter - 1) andColor:color];
[circleView addSubview:circle];
return circleView;
}

View file

@ -59,7 +59,7 @@ static Tcolor const g_color [] =
for (size_t i = 0; i < 8; ++i)
{
UIButton * button = [[UIButton alloc] initWithFrame:CGRectMake(BORDERMARGIN + (i % 4) * (buttonDiameter + BUTTONMARGIN), BORDERMARGIN + (i / 4) * (buttonDiameter + BUTTONMARGINHEIGHT) + HEADERHEIGHT + LINEHEIGHT, buttonDiameter, buttonDiameter)];
UIColor * c = [ColorPickerView buttonColor:i];
UIColor * c = [[self class] buttonColor:i];
if (i != selectedIndex)
[button setBackgroundImage:[CircleView createCircleImageWith:buttonDiameter andColor:c] forState:UIControlStateNormal];
else

View file

@ -50,7 +50,7 @@ CGFloat const kTopOffset = 25.;
self = [super init];
if (self)
{
[[NSBundle mainBundle] loadNibNamed:[MWMDropDown className] owner:self options:nil];
[[NSBundle mainBundle] loadNibNamed:[[self class] className] owner:self options:nil];
self.superview = view;
}
return self;

View file

@ -219,7 +219,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
TMWMVoidBlock action = ^{
GetFramework().SwitchMyPositionNextMode();
};
return [MWMDefaultAlert defaultAlertWithTitle:L(@"dialog_routing_location_turn_on")
return [self defaultAlertWithTitle:L(@"dialog_routing_location_turn_on")
message:L(@"dialog_routing_location_unknown_turn_on")
rightButtonTitle:L(@"turn_on")
leftButtonTitle:L(@"later")

View file

@ -26,7 +26,7 @@ namespace
+ (nonnull instancetype)alert
{
MWMEditorViralAlert * alert = [[[NSBundle mainBundle] loadNibNamed:[MWMEditorViralAlert className] owner:nil options:nil] firstObject];
MWMEditorViralAlert * alert = [[[NSBundle mainBundle] loadNibNamed:[self className] owner:nil options:nil] firstObject];
alert.indexOfMessage = rand() % kMessages.size();
NSString * message = kMessages[alert.indexOfMessage];
if (alert.indexOfMessage == 1)

View file

@ -12,7 +12,7 @@ extern NSString * const kMap2GoogleLoginSegue;
+ (instancetype)alert
{
MWMOsmAuthAlert * alert = [[[NSBundle mainBundle] loadNibNamed:[MWMOsmAuthAlert className] owner:nil options:nil] firstObject];
MWMOsmAuthAlert * alert = [[[NSBundle mainBundle] loadNibNamed:[self className] owner:nil options:nil] firstObject];
return alert;
}

View file

@ -14,7 +14,7 @@
+ (instancetype)alertWithBlock:(MWMStringBlock)block
{
MWMPlaceDoesntExistAlert * alert =
[[[NSBundle mainBundle] loadNibNamed:[MWMPlaceDoesntExistAlert className]
[[[NSBundle mainBundle] loadNibNamed:[self className]
owner:nil
options:nil] firstObject];
alert.block = block;

View file

@ -22,7 +22,7 @@ NSString * const kStatisticsEvent = @"Mobile Internet Settings Alert";
{
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatOpen}];
MWMMobileInternetAlert * alert =
[[[NSBundle mainBundle] loadNibNamed:[MWMMobileInternetAlert className] owner:nil options:nil]
[[[NSBundle mainBundle] loadNibNamed:[self className] owner:nil options:nil]
firstObject];
alert.completionBlock = block;
return alert;

View file

@ -20,7 +20,7 @@ static NSString * const kStatisticsEvent = @"Routing Disclaimer Alert";
{
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatOpen}];
MWMRoutingDisclaimerAlert * alert =
[[[NSBundle mainBundle] loadNibNamed:[MWMRoutingDisclaimerAlert className]
[[[NSBundle mainBundle] loadNibNamed:[self className]
owner:nil
options:nil] firstObject];
NSString * message = [NSString stringWithFormat:@"%@\n\n%@\n\n%@\n\n%@\n\n%@",

View file

@ -23,7 +23,7 @@ NSString * const kStatisticsEvent = @"Search No Results Alert";
{
[Statistics logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatOpen}];
MWMSearchNoResultsAlert * alert = [
[[NSBundle mainBundle] loadNibNamed:[MWMSearchNoResultsAlert className] owner:nil options:nil]
[[NSBundle mainBundle] loadNibNamed:[self className] owner:nil options:nil]
firstObject];
return alert;
}

View file

@ -21,14 +21,14 @@ NSUInteger const kWordsPerSecond = 3;
+ (void)showWithText:(NSString *)text
{
MWMToast * toast = [MWMToast toast];
MWMToast * toast = [self toast];
toast.label.text = text;
toast.label.textColor = [UIColor blackPrimaryText];
toast.rootView.backgroundColor = [UIColor toastBackground];
[toast show];
}
+ (BOOL)affectsStatusBar { return [MWMToast toast].rootView.superview != nil; }
+ (BOOL)affectsStatusBar { return [self toast].rootView.superview != nil; }
+ (UIStatusBarStyle)preferredStatusBarStyle
{
setStatusBarBackgroundColor([UIColor clearColor]);
@ -50,7 +50,7 @@ NSUInteger const kWordsPerSecond = 3;
self = [super init];
if (self)
{
[[NSBundle mainBundle] loadNibNamed:[MWMToast className] owner:self options:nil];
[[NSBundle mainBundle] loadNibNamed:[[self class] className] owner:self options:nil];
self.rootView.translatesAutoresizingMaskIntoConstraints = NO;
}
return self;

View file

@ -24,7 +24,7 @@ UINib * const progressViewNib =
+ (nonnull instancetype)downloaderProgressForParentView:(nonnull UIView *)parentView
{
MWMCircularProgress * progress = [[MWMCircularProgress alloc] initWithParentView:parentView];
MWMCircularProgress * progress = [[self alloc] initWithParentView:parentView];
progress.rootView.suspendRefreshProgress = YES;

View file

@ -72,7 +72,7 @@ vector<pair<string, string>> availableLanguages()
{
_availableLanguages = availableLanguages();
NSString * saved = [MWMTextToSpeech savedLanguage];
NSString * saved = [[self class] savedLanguage];
NSString * preferedLanguageBcp47;
if (saved.length)
preferedLanguageBcp47 = saved;
@ -131,10 +131,10 @@ vector<pair<string, string>> availableLanguages()
+ (BOOL)isTTSEnabled { return [[NSUserDefaults standardUserDefaults] boolForKey:kIsTTSEnabled]; }
+ (void)setTTSEnabled:(BOOL)enabled
{
if ([MWMTextToSpeech isTTSEnabled] == enabled)
if ([self isTTSEnabled] == enabled)
return;
if (!enabled)
[[MWMTextToSpeech tts] setActive:NO];
[[self tts] setActive:NO];
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
[ud setBool:enabled forKey:kIsTTSEnabled];
[ud synchronize];
@ -142,12 +142,12 @@ vector<pair<string, string>> availableLanguages()
object:nil
userInfo:nil];
if (enabled)
[[MWMTextToSpeech tts] setActive:YES];
[[self tts] setActive:YES];
}
- (void)setActive:(BOOL)active
{
if (![MWMTextToSpeech isTTSEnabled] || self.active == active)
if (![[self class] isTTSEnabled] || self.active == active)
return;
if (active && ![self isValid])
[self createSynthesizer];
@ -155,7 +155,7 @@ vector<pair<string, string>> availableLanguages()
GetFramework().EnableTurnNotifications(active ? true : false);
runAsyncOnMainQueue(^{
[[NSNotificationCenter defaultCenter]
postNotificationName:[MWMTextToSpeech ttsStatusNotificationKey]
postNotificationName:[[self class] ttsStatusNotificationKey]
object:nil
userInfo:nil];
});
@ -163,7 +163,7 @@ vector<pair<string, string>> availableLanguages()
- (BOOL)active
{
return [MWMTextToSpeech isTTSEnabled] && GetFramework().AreTurnNotificationsEnabled() ? YES : NO;
return [[self class] isTTSEnabled] && GetFramework().AreTurnNotificationsEnabled() ? YES : NO;
}
+ (NSString *)savedLanguage
@ -176,7 +176,7 @@ vector<pair<string, string>> availableLanguages()
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
self.speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
self.speechSynthesizer.delegate = self;
[self createVoice:[MWMTextToSpeech savedLanguage]];
[self createVoice:[[self class] savedLanguage]];
});
// TODO(vbykoianko) Use [NSLocale preferredLanguages] instead of [AVSpeechSynthesisVoice
// currentLanguageCode].

View file

@ -5,7 +5,7 @@
+ (void)segueFrom:(UIViewController *)source to:(UIViewController *)destination
{
[[[MWMSegue alloc] initWithIdentifier:@"" source:source destination:destination] perform];
[[[self alloc] initWithIdentifier:@"" source:source destination:destination] perform];
}
- (void)perform

View file

@ -15,7 +15,7 @@ using TObservers = NSHashTable<__kindof TObserver>;
@implementation MWMKeyboard
+ (void)applicationDidBecomeActive { [MWMKeyboard manager]; }
+ (void)applicationDidBecomeActive { [self manager]; }
+ (MWMKeyboard *)manager
{
static MWMKeyboard * manager;
@ -47,17 +47,17 @@ using TObservers = NSHashTable<__kindof TObserver>;
}
- (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; }
+ (CGFloat)keyboardHeight { return [MWMKeyboard manager].keyboardHeight; }
+ (CGFloat)keyboardHeight { return [self manager].keyboardHeight; }
#pragma mark - Add/Remove Observers
+ (void)addObserver:(id<MWMKeyboardObserver>)observer
{
[[MWMKeyboard manager].observers addObject:observer];
[[self manager].observers addObject:observer];
}
+ (void)removeObserver:(id<MWMKeyboardObserver>)observer
{
[[MWMKeyboard manager].observers removeObject:observer];
[[self manager].observers removeObject:observer];
}
#pragma mark - Notifications

View file

@ -128,7 +128,7 @@ void checkFlurryLogStatus(FlurryEventRecordStatus status)
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^
{
instance = [[Statistics alloc] init];
instance = [[self alloc] init];
});
return instance;
}

View file

@ -202,7 +202,7 @@ void setPermissionRequested()
+ (void)addObserver:(TObserver)observer
{
runAsyncOnMainQueue(^{
MWMLocationManager * manager = [MWMLocationManager manager];
MWMLocationManager * manager = [self manager];
[manager.observers addObject:observer];
[manager processLocationUpdate:manager.lastLocationInfo];
});
@ -211,7 +211,7 @@ void setPermissionRequested()
+ (void)removeObserver:(TObserver)observer
{
runAsyncOnMainQueue(^{
[[MWMLocationManager manager].observers removeObject:observer];
[[self manager].observers removeObject:observer];
});
}
@ -220,13 +220,13 @@ void setPermissionRequested()
+ (void)applicationDidBecomeActive
{
if (isPermissionRequested() || ![Alohalytics isFirstSession])
[MWMLocationManager manager].started = YES;
[self manager].started = YES;
}
+ (void)applicationWillResignActive
{
BOOL const keepRunning = isPermissionRequested() && keepRunningInBackground();
MWMLocationManager * manager = [MWMLocationManager manager];
MWMLocationManager * manager = [self manager];
CLLocationManager * locationManager = manager.locationManager;
if ([locationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)])
[locationManager setAllowsBackgroundLocationUpdates:keepRunning];
@ -237,7 +237,7 @@ void setPermissionRequested()
+ (CLLocation *)lastLocation
{
MWMLocationManager * manager = [MWMLocationManager manager];
MWMLocationManager * manager = [self manager];
if (!manager.started || !manager.lastLocationInfo ||
manager.lastLocationInfo.horizontalAccuracy < 0 ||
manager.lastLocationStatus != location::TLocationError::ENoError)
@ -247,12 +247,12 @@ void setPermissionRequested()
+ (location::TLocationError)lastLocationStatus
{
return [MWMLocationManager manager].lastLocationStatus;
return [self manager].lastLocationStatus;
}
+ (CLHeading *)lastHeading
{
MWMLocationManager * manager = [MWMLocationManager manager];
MWMLocationManager * manager = [self manager];
if (!manager.started || !manager.lastHeadingInfo || manager.lastHeadingInfo.headingAccuracy < 0)
return nil;
return manager.lastHeadingInfo;
@ -337,7 +337,7 @@ void setPermissionRequested()
+ (void)setMyPositionMode:(location::EMyPositionMode)mode
{
MWMLocationManager * manager = [MWMLocationManager manager];
MWMLocationManager * manager = [self manager];
[manager.predictor setMyPositionMode:mode];
[manager processLocationStatus:manager.lastLocationStatus];
auto const & f = GetFramework();

View file

@ -63,7 +63,7 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
+ (BOOL)isTaxi { return GetFramework().GetRouter() == routing::RouterType::Taxi; }
+ (void)startRouting
{
auto router = [MWMRouter router];
auto router = [self router];
if (![self isTaxi])
{
[router start];
@ -88,7 +88,7 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
+ (void)stopRouting
{
[[MWMRouter router] stop];
[[self router] stop];
[MWMNavigationDashboardManager manager].taxiDataSource = nil;
}
@ -191,7 +191,7 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
auto const & startPoint = self.startPoint.Point();
auto const & finishPoint = self.finishPoint.Point();
// Taxi can't be used as best router.
if (bestRouter && ![MWMRouter isTaxi])
if (bestRouter && ![[self class] isTaxi])
self.type = GetFramework().GetBestRouter(startPoint, finishPoint);
f.BuildRoute(startPoint, finishPoint, isP2P, 0 /* timeoutSec */);
f.SetRouteStartPoint(startPoint, isMarkerPoint(self.startPoint));
@ -261,7 +261,7 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
- (void)doStop
{
// Don't save taxi routing type as default.
if ([MWMRouter isTaxi])
if ([[self class] isTaxi])
GetFramework().SetRouter(routing::RouterType::Vehicle);
[self clearAltitudeImagesData];
@ -288,7 +288,7 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
- (void)routeAltitudeImageForSize:(CGSize)size completion:(MWMImageHeightBlock)block
{
dispatch_async(self.renderAltitudeImagesQueue, ^{
if (![MWMRouter hasRouteAltitude])
if (![[self class] hasRouteAltitude])
return;
CGFloat const screenScale = [UIScreen mainScreen].scale;
CGSize const scaledSize = {.width = size.width * screenScale,
@ -380,7 +380,7 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
else
[mapViewControlsManager onRouteReady];
[self updateFollowingInfo];
if (![MWMRouter isTaxi])
if (![[self class] isTaxi])
[[MWMNavigationDashboardManager manager] setRouteBuilderProgress:100];
mapViewControlsManager.searchHidden = YES;
@ -409,7 +409,7 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
- (void)processRouteBuilderProgress:(CGFloat)progress
{
if (![MWMRouter isTaxi])
if (![[self class] isTaxi])
[[MWMNavigationDashboardManager manager] setRouteBuilderProgress:progress];
}
@ -433,14 +433,14 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi
code:code
cancelBlock:^{
if (code != routing::IRouter::NeedMoreMaps)
[[MWMRouter router] stop];
[[[self class] router] stop];
}
downloadBlock:^(storage::TCountriesVec const & downloadCountries, TMWMVoidBlock onSuccess) {
[MWMStorage downloadNodes:downloadCountries
onSuccess:onSuccess];
}
downloadCompleteBlock:^{
[[MWMRouter router] rebuildWithBestRouter:NO];
[[[self class] router] rebuildWithBestRouter:NO];
}];
}
else

View file

@ -25,7 +25,7 @@ static NSString * const kETAKey = @"eta";
{
_forceStateChange = MWMRouterForceStateChange::None;
NSDictionary * const stateDict =
[NSDictionary dictionaryWithContentsOfURL:[MWMRouterSavedState stateFileURL]];
[NSDictionary dictionaryWithContentsOfURL:[[self class] stateFileURL]];
if (stateDict)
{
m2::PointD point;
@ -58,12 +58,12 @@ static NSString * const kETAKey = @"eta";
NSGetSizeAndAlignment(@encode(m2::PointD), &size, nullptr);
stateDict[kEndPointKey] = [NSData dataWithBytes:&endPoint length:size];
stateDict[kETAKey] = [NSDate dateWithTimeIntervalSinceNow:routeInfo.m_time];
[stateDict writeToURL:[MWMRouterSavedState stateFileURL] atomically:YES];
[stateDict writeToURL:[self stateFileURL] atomically:YES];
}
+ (void)remove
{
[[NSFileManager defaultManager] removeItemAtURL:[MWMRouterSavedState stateFileURL] error:nil];
[[NSFileManager defaultManager] removeItemAtURL:[self stateFileURL] error:nil];
}
+ (NSURL *)stateFileURL
@ -77,7 +77,7 @@ static NSString * const kETAKey = @"eta";
if (GetFramework().IsRoutingActive())
return;
if ([MWMRouterSavedState state].forceStateChange == MWMRouterForceStateChange::None)
[MWMRouterSavedState remove];
[self remove];
}
@end

View file

@ -14,7 +14,7 @@
+ (instancetype)header:(TMWMVoidBlock)toggleBlock
{
MWMEditorAdditionalNamesHeader * h = [[[NSBundle mainBundle] loadNibNamed:[MWMEditorAdditionalNamesHeader className] owner:nil options:nil]
MWMEditorAdditionalNamesHeader * h = [[[NSBundle mainBundle] loadNibNamed:[self className] owner:nil options:nil]
firstObject];
h.label.localizedText = L(@"place_name").uppercaseString;
h.toggleBlock = toggleBlock;

View file

@ -10,7 +10,7 @@
+ (instancetype)footerForController:(UIViewController *)controller
{
MWMEditorNotesFooter * f = [[[NSBundle mainBundle] loadNibNamed:[MWMEditorNotesFooter className] owner:nil options:nil]
MWMEditorNotesFooter * f = [[[NSBundle mainBundle] loadNibNamed:[self className] owner:nil options:nil]
firstObject];
f.controller = controller;
[f setNeedsLayout];

View file

@ -120,7 +120,7 @@ NSString * titleForButton(EButton type, BOOL isSelected)
{
if (view.subviews.count)
return;
MWMActionBarButton * button = [[[NSBundle mainBundle] loadNibNamed:[MWMActionBarButton className] owner:nil options:nil] firstObject];
MWMActionBarButton * button = [[[NSBundle mainBundle] loadNibNamed:[self className] owner:nil options:nil] firstObject];
button.delegate = delegate;
button.type = type;
[view addSubview:button];

View file

@ -75,7 +75,7 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar
+ (MWMSearchHotelsFilterViewController *)controller
{
NSString * identifier = [MWMSearchHotelsFilterViewController className];
NSString * identifier = [self className];
return static_cast<MWMSearchHotelsFilterViewController *>(
[self controllerWithIdentifier:identifier]);
}

View file

@ -21,7 +21,7 @@ CGFloat constexpr kExtraCompactHeight = 52;
+ (instancetype)viewWithImage:(UIImage *)image title:(NSString *)title text:(NSString *)text
{
MWMSearchNoResults * view =
[[[NSBundle mainBundle] loadNibNamed:[MWMSearchNoResults className] owner:nil options:nil]
[[[NSBundle mainBundle] loadNibNamed:[self className] owner:nil options:nil]
firstObject];
view.image.image = image;
if (title)