Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MWMAlert.mm « BaseAlert « CustomAlert « Classes « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c6e522e047cfb20a6045878b49b7f4a1a4aa0941 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#import "MWMAlert.h"
#import "Common.h"
#import "MWMAlertViewController.h"
#import "MWMDefaultAlert.h"
#import "MWMDownloadTransitMapAlert.h"
#import "MWMEditorViralAlert.h"
#import "MWMFacebookAlert.h"
#import "MWMLocationAlert.h"
#import "MWMOsmAuthAlert.h"
#import "MWMPlaceDoesntExistAlert.h"
#import "MWMRateAlert.h"
#import "MWMRoutingDisclaimerAlert.h"

@implementation MWMAlert

+ (MWMAlert *)rateAlert { return [MWMRateAlert alert]; }
+ (MWMAlert *)locationAlert { return [MWMLocationAlert alert]; }
+ (MWMAlert *)facebookAlert { return [MWMFacebookAlert alert]; }
+ (MWMAlert *)point2PointAlertWithOkBlock:(TMWMVoidBlock)block needToRebuild:(BOOL)needToRebuild
{
  return [MWMDefaultAlert point2PointAlertWithOkBlock:block needToRebuild:needToRebuild];
}

+ (MWMAlert *)routingDisclaimerAlertWithInitialOrientation:(UIInterfaceOrientation)orientation
                                                   okBlock:(TMWMVoidBlock)block
{
  return [MWMRoutingDisclaimerAlert alertWithInitialOrientation:orientation okBlock:block];
}

+ (MWMAlert *)disabledLocationAlert { return [MWMDefaultAlert disabledLocationAlert]; }
+ (MWMAlert *)noWiFiAlertWithOkBlock:(TMWMVoidBlock)okBlock
{
  return [MWMDefaultAlert noWiFiAlertWithOkBlock:okBlock];
}

+ (MWMAlert *)noConnectionAlert { return [MWMDefaultAlert noConnectionAlert]; }
+ (MWMAlert *)migrationProhibitedAlert { return [MWMDefaultAlert migrationProhibitedAlert]; }
+ (MWMAlert *)deleteMapProhibitedAlert { return [MWMDefaultAlert deleteMapProhibitedAlert]; }
+ (MWMAlert *)unsavedEditsAlertWithOkBlock:(TMWMVoidBlock)okBlock
{
  return [MWMDefaultAlert unsavedEditsAlertWithOkBlock:okBlock];
}

+ (MWMAlert *)locationServiceNotSupportedAlert
{
  return [MWMDefaultAlert locationServiceNotSupportedAlert];
}

+ (MWMAlert *)locationNotFoundAlertWithOkBlock:(TMWMVoidBlock)okBlock
{
  return [MWMDefaultAlert locationNotFoundAlertWithOkBlock:okBlock];
}

+ (MWMAlert *)routingMigrationAlertWithOkBlock:(TMWMVoidBlock)okBlock
{
  return [MWMDefaultAlert routingMigrationAlertWithOkBlock:okBlock];
}

+ (MWMAlert *)downloaderAlertWithAbsentCountries:(storage::TCountriesVec const &)countries
                                            code:(routing::IRouter::ResultCode)code
                                     cancelBlock:(TMWMVoidBlock)cancelBlock
                                   downloadBlock:(TMWMDownloadBlock)downloadBlock
                           downloadCompleteBlock:(TMWMVoidBlock)downloadCompleteBlock
{
  return [MWMDownloadTransitMapAlert downloaderAlertWithMaps:countries
                                                        code:code
                                                 cancelBlock:cancelBlock
                                               downloadBlock:downloadBlock
                                       downloadCompleteBlock:downloadCompleteBlock];
}

+ (MWMAlert *)alert:(routing::IRouter::ResultCode)type
{
  switch (type)
  {
  case routing::IRouter::NoCurrentPosition: return [MWMDefaultAlert noCurrentPositionAlert];
  case routing::IRouter::StartPointNotFound: return [MWMDefaultAlert startPointNotFoundAlert];
  case routing::IRouter::EndPointNotFound: return [MWMDefaultAlert endPointNotFoundAlert];
  case routing::IRouter::PointsInDifferentMWM: return [MWMDefaultAlert pointsInDifferentMWMAlert];
  case routing::IRouter::RouteNotFound:
  case routing::IRouter::InconsistentMWMandRoute: return [MWMDefaultAlert routeNotFoundAlert];
  case routing::IRouter::RouteFileNotExist:
  case routing::IRouter::FileTooOld: return [MWMDefaultAlert routeFileNotExistAlert];
  case routing::IRouter::InternalError: return [MWMDefaultAlert internalRoutingErrorAlert];
  case routing::IRouter::Cancelled:
  case routing::IRouter::NoError:
  case routing::IRouter::NeedMoreMaps: return nil;
  }
}

+ (MWMAlert *)incorrectFeauturePositionAlert
{
  return [MWMDefaultAlert incorrectFeauturePositionAlert];
}

+ (MWMAlert *)internalErrorAlert { return [MWMDefaultAlert internalErrorAlert]; }
+ (MWMAlert *)notEnoughSpaceAlert { return [MWMDefaultAlert notEnoughSpaceAlert]; }
+ (MWMAlert *)invalidUserNameOrPasswordAlert
{
  return [MWMDefaultAlert invalidUserNameOrPasswordAlert];
}

+ (MWMAlert *)disableAutoDownloadAlertWithOkBlock:(TMWMVoidBlock)okBlock
{
  return [MWMDefaultAlert disableAutoDownloadAlertWithOkBlock:okBlock];
}

+ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(TMWMVoidBlock)okBlock
                                         cancelBlock:(TMWMVoidBlock)cancelBlock
{
  return [MWMDefaultAlert downloaderNoConnectionAlertWithOkBlock:okBlock cancelBlock:cancelBlock];
}

+ (MWMAlert *)downloaderNotEnoughSpaceAlert
{
  return [MWMDefaultAlert downloaderNotEnoughSpaceAlert];
}

+ (MWMAlert *)downloaderInternalErrorAlertWithOkBlock:(TMWMVoidBlock)okBlock
                                          cancelBlock:(TMWMVoidBlock)cancelBlock
{
  return [MWMDefaultAlert downloaderInternalErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock];
}

+ (MWMAlert *)downloaderNeedUpdateAlertWithOkBlock:(TMWMVoidBlock)okBlock
{
  return [MWMDefaultAlert downloaderNeedUpdateAlertWithOkBlock:okBlock];
}

+ (MWMAlert *)placeDoesntExistAlertWithBlock:(MWMStringBlock)block
{
  return [MWMPlaceDoesntExistAlert alertWithBlock:block];
}

+ (MWMAlert *)resetChangesAlertWithBlock:(TMWMVoidBlock)block
{
  return [MWMDefaultAlert resetChangesAlertWithBlock:block];
}

+ (MWMAlert *)deleteFeatureAlertWithBlock:(TMWMVoidBlock)block
{
  return [MWMDefaultAlert deleteFeatureAlertWithBlock:block];
}

+ (MWMAlert *)editorViralAlert { return [MWMEditorViralAlert alert]; }
+ (MWMAlert *)osmAuthAlert { return [MWMOsmAuthAlert alert]; }
+ (MWMAlert *)personalInfoWarningAlertWithBlock:(TMWMVoidBlock)block
{
  return [MWMDefaultAlert personalInfoWarningAlertWithBlock:block];
}

+ (MWMAlert *)trackWarningAlertWithCancelBlock:(TMWMVoidBlock)block
{
  return [MWMDefaultAlert trackWarningAlertWithCancelBlock:block];
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
  // Should override this method if you want custom relayout after rotation.
}

- (void)close { [self.alertController closeAlert]; }
- (void)setNeedsCloseAlertAfterEnterBackground
{
  [[NSNotificationCenter defaultCenter] addObserver:self
                                           selector:@selector(applicationDidEnterBackground)
                                               name:UIApplicationDidEnterBackgroundNotification
                                             object:nil];
}

- (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; }
- (void)applicationDidEnterBackground
{
  // Should close alert when application entered background.
  [self close];
}

- (void)rotate:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
  if (isIOS7 && [self respondsToSelector:@selector(setTransform:)])
  {
    [UIView animateWithDuration:duration
                     animations:^{
                       self.transform = rotation(toInterfaceOrientation);
                     }];
  }
  if ([self respondsToSelector:@selector(willRotateToInterfaceOrientation:)])
    [self willRotateToInterfaceOrientation:toInterfaceOrientation];
}

CGAffineTransform rotation(UIInterfaceOrientation orientation)
{
  switch (orientation)
  {
  case UIInterfaceOrientationLandscapeLeft: return CGAffineTransformMakeRotation(-M_PI_2);
  case UIInterfaceOrientationLandscapeRight: return CGAffineTransformMakeRotation(M_PI_2);
  case UIInterfaceOrientationPortraitUpsideDown: return CGAffineTransformMakeRotation(M_PI);
  case UIInterfaceOrientationUnknown:
  case UIInterfaceOrientationPortrait: return CGAffineTransformIdentity;
  }
}

- (void)addControllerViewToWindow
{
  UIWindow * window = UIApplication.sharedApplication.delegate.window;
  UIView * view = self.alertController.view;
  [window addSubview:view];
  view.frame = window.bounds;
}

- (void)setAlertController:(MWMAlertViewController *)alertController
{
  _alertController = alertController;
  UIView * view = alertController.view;
  UIView * ownerView = alertController.ownerViewController.view;
  view.frame = ownerView.bounds;
  [alertController.ownerViewController.view addSubview:view];
  [self addControllerViewToWindow];
  [self rotate:alertController.ownerViewController.interfaceOrientation duration:0.0];
  [view addSubview:self];
  self.frame = view.bounds;
}

- (void)layoutSubviews
{
  [super layoutSubviews];
  self.frame = self.superview.bounds;
}

@end