0001-Remove-pre-iOS5-compatibility-code-and-drop-the-rela.patch 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. From df42d0851e8cac95ff821025cac08f93871a1e93 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
  3. Date: Fri, 31 May 2013 13:51:46 +0200
  4. Subject: [PATCH] Remove pre-iOS5 compatibility code and drop the related
  5. warnings
  6. ---
  7. .../Controllers/IASKAppSettingsViewController.m | 169 +++++++++------------
  8. .../Controllers/IASKAppSettingsWebViewController.m | 65 +++-----
  9. 2 files changed, 95 insertions(+), 139 deletions(-)
  10. diff --git a/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m b/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m
  11. index 9a76673..e90d91f 100644
  12. --- a/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m
  13. +++ b/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m
  14. @@ -6,9 +6,9 @@
  15. // Luc Vandal, Edovia Inc., http://www.edovia.com
  16. // Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com
  17. // All rights reserved.
  18. -//
  19. -// It is appreciated but not required that you give credit to Luc Vandal and Ortwin Gentz,
  20. -// as the original authors of this code. You can give credit in a blog post, a tweet or on
  21. +//
  22. +// It is appreciated but not required that you give credit to Luc Vandal and Ortwin Gentz,
  23. +// as the original authors of this code. You can give credit in a blog post, a tweet or on
  24. // a info page of your app. Also, the original authors appreciate letting them know if you use this code.
  25. //
  26. // This code is licensed under the BSD license that is available at: http://www.opensource.org/licenses/bsd-license.php
  27. @@ -86,11 +86,11 @@ CGRect IASKCGRectSwap(CGRect rect);
  28. - (void)setFile:(NSString *)file {
  29. if (file != _file) {
  30. -
  31. +
  32. [_file release];
  33. _file = [file copy];
  34. }
  35. -
  36. +
  37. self.tableView.contentOffset = CGPointMake(0, 0);
  38. self.settingsReader = nil; // automatically initializes itself
  39. [_hiddenKeys release], _hiddenKeys = nil;
  40. @@ -149,7 +149,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  41. if ([self isPad]) {
  42. self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLineEtched;
  43. }
  44. - UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapToEndEdit:)];
  45. + UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapToEndEdit:)];
  46. tapGesture.cancelsTouchesInView = NO;
  47. [self.tableView addGestureRecognizer:tapGesture];
  48. [tapGesture release];
  49. @@ -169,24 +169,24 @@ CGRect IASKCGRectSwap(CGRect rect);
  50. // so reload that row
  51. NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
  52. if(selectedIndexPath) {
  53. - [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:selectedIndexPath]
  54. + [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:selectedIndexPath]
  55. withRowAnimation:UITableViewRowAnimationNone];
  56. // and reselect it, so we get the nice default deselect animation from UITableViewController
  57. [self.tableView selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
  58. }
  59. -
  60. +
  61. self.navigationItem.rightBarButtonItem = nil;
  62. if (_showDoneButton) {
  63. - UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
  64. - target:self
  65. + UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
  66. + target:self
  67. action:@selector(dismiss:)];
  68. self.navigationItem.rightBarButtonItem = buttonItem;
  69. [buttonItem release];
  70. - }
  71. + }
  72. if (!self.title) {
  73. self.title = NSLocalizedString(@"Settings", @"");
  74. }
  75. -
  76. +
  77. if ([self.settingsStore isKindOfClass:[IASKSettingsStoreUserDefaults class]]) {
  78. [[NSNotificationCenter defaultCenter] addObserver:self
  79. selector:@selector(userDefaultsDidChange)
  80. @@ -220,7 +220,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  81. // hide the keyboard
  82. [self.currentFirstResponder resignFirstResponder];
  83. -
  84. +
  85. [super viewDidDisappear:animated];
  86. }
  87. @@ -231,7 +231,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  88. - (void)didReceiveMemoryWarning {
  89. // Releases the view if it doesn't have a superview.
  90. [super didReceiveMemoryWarning];
  91. -
  92. +
  93. // Release any cached data, images, etc that aren't in use.
  94. }
  95. @@ -244,16 +244,16 @@ CGRect IASKCGRectSwap(CGRect rect);
  96. if (_hiddenKeys != theHiddenKeys) {
  97. NSSet *oldHiddenKeys = _hiddenKeys;
  98. _hiddenKeys = [theHiddenKeys retain];
  99. -
  100. - if (animated) {
  101. +
  102. + if (animated) {
  103. [self.tableView beginUpdates];
  104. -
  105. +
  106. NSMutableSet *showKeys = [NSMutableSet setWithSet:oldHiddenKeys];
  107. [showKeys minusSet:theHiddenKeys];
  108. -
  109. +
  110. NSMutableSet *hideKeys = [NSMutableSet setWithSet:theHiddenKeys];
  111. [hideKeys minusSet:oldHiddenKeys];
  112. -
  113. +
  114. // calculate rows to be deleted
  115. NSMutableArray *hideIndexPaths = [NSMutableArray array];
  116. for (NSString *key in hideKeys) {
  117. @@ -262,7 +262,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  118. [hideIndexPaths addObject:indexPath];
  119. }
  120. }
  121. -
  122. +
  123. // calculate sections to be deleted
  124. NSMutableIndexSet *hideSections = [NSMutableIndexSet indexSet];
  125. for (NSInteger section = 0; section < [self numberOfSectionsInTableView:self.tableView ]; section++) {
  126. @@ -276,11 +276,11 @@ CGRect IASKCGRectSwap(CGRect rect);
  127. [hideSections addIndex:section];
  128. }
  129. }
  130. -
  131. +
  132. // set the datasource
  133. self.settingsReader.hiddenKeys = theHiddenKeys;
  134. -
  135. -
  136. +
  137. +
  138. // calculate rows to be inserted
  139. NSMutableArray *showIndexPaths = [NSMutableArray array];
  140. for (NSString *key in showKeys) {
  141. @@ -289,7 +289,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  142. [showIndexPaths addObject:indexPath];
  143. }
  144. }
  145. -
  146. +
  147. // calculate sections to be inserted
  148. NSMutableIndexSet *showSections = [NSMutableIndexSet indexSet];
  149. for (NSInteger section = 0; section < [self.settingsReader numberOfSections]; section++) {
  150. @@ -303,7 +303,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  151. [showSections addIndex:section];
  152. }
  153. }
  154. -
  155. +
  156. UITableViewRowAnimation animation = animated ? UITableViewRowAnimationTop : UITableViewRowAnimationNone;
  157. [self.tableView deleteSections:hideSections withRowAnimation:animation];
  158. [self.tableView deleteRowsAtIndexPaths:hideIndexPaths withRowAnimation:animation];
  159. @@ -332,7 +332,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  160. [_settingsReader release], _settingsReader = nil;
  161. [_settingsStore release], _settingsStore = nil;
  162. [_hiddenKeys release], _hiddenKeys = nil;
  163. -
  164. +
  165. _delegate = nil;
  166. [super dealloc];
  167. @@ -344,7 +344,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  168. - (void)dismiss:(id)sender {
  169. [self.settingsStore synchronize];
  170. -
  171. +
  172. if (self.delegate && [self.delegate conformsToProtocol:@protocol(IASKSettingsDelegate)]) {
  173. [self.delegate settingsViewControllerDidEnd:self];
  174. }
  175. @@ -353,13 +353,13 @@ CGRect IASKCGRectSwap(CGRect rect);
  176. - (void)toggledValue:(id)sender {
  177. IASKSwitch *toggle = [[(IASKSwitch*)sender retain] autorelease];
  178. IASKSpecifier *spec = [_settingsReader specifierForKey:[toggle key]];
  179. -
  180. +
  181. if ([toggle isOn]) {
  182. if ([spec trueValue] != nil) {
  183. [self.settingsStore setObject:[spec trueValue] forKey:[toggle key]];
  184. }
  185. else {
  186. - [self.settingsStore setBool:YES forKey:[toggle key]];
  187. + [self.settingsStore setBool:YES forKey:[toggle key]];
  188. }
  189. }
  190. else {
  191. @@ -367,7 +367,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  192. [self.settingsStore setObject:[spec falseValue] forKey:[toggle key]];
  193. }
  194. else {
  195. - [self.settingsStore setBool:NO forKey:[toggle key]];
  196. + [self.settingsStore setBool:NO forKey:[toggle key]];
  197. }
  198. }
  199. [[NSNotificationCenter defaultCenter] postNotificationName:kIASKAppSettingChanged
  200. @@ -431,11 +431,11 @@ CGRect IASKCGRectSwap(CGRect rect);
  201. if ((result = [self.delegate settingsViewController:self tableView:tableView heightForHeaderForSection:section])) {
  202. return result;
  203. }
  204. -
  205. +
  206. }
  207. NSString *title;
  208. if ((title = [self tableView:tableView titleForHeaderInSection:section])) {
  209. - CGSize size = [title sizeWithFont:[UIFont boldSystemFontOfSize:[UIFont labelFontSize]]
  210. + CGSize size = [title sizeWithFont:[UIFont boldSystemFontOfSize:[UIFont labelFontSize]]
  211. constrainedToSize:CGSizeMake(tableView.frame.size.width - 2*kIASKHorizontalPaddingGroupTitles, INFINITY)
  212. lineBreakMode:NSLineBreakByWordWrapping];
  213. return size.height+kIASKVerticalPaddingGroupTitles;
  214. @@ -502,15 +502,15 @@ CGRect IASKCGRectSwap(CGRect rect);
  215. assert(nil != cell && "delegate must return a UITableViewCell for custom cell types");
  216. return cell;
  217. }
  218. -
  219. +
  220. UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:specifier.type];
  221. if(nil == cell) {
  222. cell = [[self newCellForIdentifier:specifier.type] autorelease];
  223. }
  224. -
  225. +
  226. if ([specifier.type isEqualToString:kIASKPSToggleSwitchSpecifier]) {
  227. cell.textLabel.text = specifier.title;
  228. -
  229. +
  230. id currentValue = [self.settingsStore objectForKey:specifier.key];
  231. BOOL toggleState;
  232. if (currentValue) {
  233. @@ -530,26 +530,26 @@ CGRect IASKCGRectSwap(CGRect rect);
  234. }
  235. else if ([specifier.type isEqualToString:kIASKPSMultiValueSpecifier]) {
  236. cell.textLabel.text = specifier.title;
  237. - cell.detailTextLabel.text = [[specifier titleForCurrentValue:[self.settingsStore objectForKey:specifier.key] != nil ?
  238. + cell.detailTextLabel.text = [[specifier titleForCurrentValue:[self.settingsStore objectForKey:specifier.key] != nil ?
  239. [self.settingsStore objectForKey:specifier.key] : specifier.defaultValue] description];
  240. }
  241. else if ([specifier.type isEqualToString:kIASKPSTitleValueSpecifier]) {
  242. cell.textLabel.text = specifier.title;
  243. id value = [self.settingsStore objectForKey:specifier.key] ? : specifier.defaultValue;
  244. -
  245. +
  246. NSString *stringValue;
  247. if (specifier.multipleValues || specifier.multipleTitles) {
  248. stringValue = [specifier titleForCurrentValue:value];
  249. } else {
  250. stringValue = [value description];
  251. }
  252. -
  253. +
  254. cell.detailTextLabel.text = stringValue;
  255. cell.userInteractionEnabled = NO;
  256. }
  257. else if ([specifier.type isEqualToString:kIASKPSTextFieldSpecifier]) {
  258. cell.textLabel.text = specifier.title;
  259. -
  260. +
  261. NSString *textValue = [self.settingsStore objectForKey:specifier.key] != nil ? [self.settingsStore objectForKey:specifier.key] : specifier.defaultStringValue;
  262. if (textValue && ![textValue isMemberOfClass:[NSString class]]) {
  263. textValue = [NSString stringWithFormat:@"%@", textValue];
  264. @@ -573,11 +573,11 @@ CGRect IASKCGRectSwap(CGRect rect);
  265. if (specifier.minimumValueImage.length > 0) {
  266. ((IASKPSSliderSpecifierViewCell*)cell).minImage.image = [UIImage imageWithContentsOfFile:[_settingsReader pathForImageNamed:specifier.minimumValueImage]];
  267. }
  268. -
  269. +
  270. if (specifier.maximumValueImage.length > 0) {
  271. ((IASKPSSliderSpecifierViewCell*)cell).maxImage.image = [UIImage imageWithContentsOfFile:[_settingsReader pathForImageNamed:specifier.maximumValueImage]];
  272. }
  273. -
  274. +
  275. IASKSlider *slider = ((IASKPSSliderSpecifierViewCell*)cell).slider;
  276. slider.minimumValue = specifier.minimumValue;
  277. slider.maximumValue = specifier.maximumValue;
  278. @@ -597,10 +597,10 @@ CGRect IASKCGRectSwap(CGRect rect);
  279. } else {
  280. cell.textLabel.text = specifier.title;
  281. }
  282. -
  283. +
  284. cell.imageView.image = specifier.cellImage;
  285. cell.imageView.highlightedImage = specifier.highlightedCellImage;
  286. -
  287. +
  288. if (![specifier.type isEqualToString:kIASKPSMultiValueSpecifier] && ![specifier.type isEqualToString:kIASKPSTitleValueSpecifier] && ![specifier.type isEqualToString:kIASKPSTextFieldSpecifier]) {
  289. cell.textLabel.textAlignment = specifier.textAlignment;
  290. }
  291. @@ -616,7 +616,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  292. if(nil == noSelectionTypes) {
  293. noSelectionTypes = [[NSSet setWithObjects:kIASKPSToggleSwitchSpecifier, kIASKPSSliderSpecifier, nil] retain];
  294. }
  295. -
  296. +
  297. IASKSpecifier *specifier = [self.settingsReader specifierForIndexPath:indexPath];
  298. if([noSelectionTypes containsObject:specifier.type]) {
  299. return nil;
  300. @@ -627,26 +627,26 @@ CGRect IASKCGRectSwap(CGRect rect);
  301. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  302. IASKSpecifier *specifier = [self.settingsReader specifierForIndexPath:indexPath];
  303. -
  304. +
  305. //switches and sliders can't be selected (should be captured by tableView:willSelectRowAtIndexPath: delegate method)
  306. assert(![[specifier type] isEqualToString:kIASKPSToggleSwitchSpecifier]);
  307. assert(![[specifier type] isEqualToString:kIASKPSSliderSpecifier]);
  308. if ([[specifier type] isEqualToString:kIASKPSMultiValueSpecifier]) {
  309. IASKSpecifierValuesViewController *targetViewController = [[self.viewList objectAtIndex:kIASKSpecifierValuesViewControllerIndex] objectForKey:@"viewController"];
  310. -
  311. +
  312. if (targetViewController == nil) {
  313. // the view controller has not been created yet, create it and set it to our viewList array
  314. // create a new dictionary with the new view controller
  315. NSMutableDictionary *newItemDict = [NSMutableDictionary dictionaryWithCapacity:3];
  316. [newItemDict addEntriesFromDictionary: [self.viewList objectAtIndex:kIASKSpecifierValuesViewControllerIndex]]; // copy the title and explain strings
  317. -
  318. +
  319. targetViewController = [[IASKSpecifierValuesViewController alloc] init];
  320. // add the new view controller to the dictionary and then to the 'viewList' array
  321. [newItemDict setObject:targetViewController forKey:@"viewController"];
  322. [self.viewList replaceObjectAtIndex:kIASKSpecifierValuesViewControllerIndex withObject:newItemDict];
  323. [targetViewController release];
  324. -
  325. +
  326. // load the view controll back in to push it
  327. targetViewController = [[self.viewList objectAtIndex:kIASKSpecifierValuesViewControllerIndex] objectForKey:@"viewController"];
  328. }
  329. @@ -661,7 +661,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  330. }
  331. else if ([[specifier type] isEqualToString:kIASKPSChildPaneSpecifier]) {
  332. -
  333. +
  334. Class vcClass = [specifier viewControllerClass];
  335. if (vcClass) {
  336. SEL initSelector = [specifier viewControllerSelector];
  337. @@ -680,30 +680,30 @@ CGRect IASKCGRectSwap(CGRect rect);
  338. [vc performSelector:@selector(release)];
  339. return;
  340. }
  341. -
  342. +
  343. if (nil == [specifier file]) {
  344. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  345. return;
  346. - }
  347. -
  348. + }
  349. +
  350. IASKAppSettingsViewController *targetViewController = [[self.viewList objectAtIndex:kIASKSpecifierChildViewControllerIndex] objectForKey:@"viewController"];
  351. -
  352. +
  353. if (targetViewController == nil) {
  354. // the view controller has not been created yet, create it and set it to our viewList array
  355. // create a new dictionary with the new view controller
  356. NSMutableDictionary *newItemDict = [NSMutableDictionary dictionaryWithCapacity:3];
  357. [newItemDict addEntriesFromDictionary: [self.viewList objectAtIndex:kIASKSpecifierChildViewControllerIndex]]; // copy the title and explain strings
  358. -
  359. +
  360. targetViewController = [[[self class] alloc] init];
  361. targetViewController.showDoneButton = NO;
  362. - targetViewController.settingsStore = self.settingsStore;
  363. + targetViewController.settingsStore = self.settingsStore;
  364. targetViewController.delegate = self.delegate;
  365. // add the new view controller to the dictionary and then to the 'viewList' array
  366. [newItemDict setObject:targetViewController forKey:@"viewController"];
  367. [self.viewList replaceObjectAtIndex:kIASKSpecifierChildViewControllerIndex withObject:newItemDict];
  368. [targetViewController release];
  369. -
  370. +
  371. // load the view controll back in to push it
  372. targetViewController = [[self.viewList objectAtIndex:kIASKSpecifierChildViewControllerIndex] objectForKey:@"viewController"];
  373. }
  374. @@ -714,7 +714,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  375. [[self navigationController] pushViewController:targetViewController animated:YES];
  376. } else if ([[specifier type] isEqualToString:kIASKOpenURLSpecifier]) {
  377. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  378. - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:specifier.file]];
  379. + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:specifier.file]];
  380. } else if ([[specifier type] isEqualToString:kIASKButtonSpecifier]) {
  381. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  382. if ([self.delegate respondsToSelector:@selector(settingsViewController:buttonTappedForSpecifier:)]) {
  383. @@ -739,7 +739,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  384. MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
  385. mailViewController.navigationBar.barStyle = self.navigationController.navigationBar.barStyle;
  386. mailViewController.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
  387. -
  388. +
  389. if ([specifier localizedObjectForKey:kIASKMailComposeSubject]) {
  390. [mailViewController setSubject:[specifier localizedObjectForKey:kIASKMailComposeSubject]];
  391. }
  392. @@ -757,7 +757,7 @@ CGRect IASKCGRectSwap(CGRect rect);
  393. if ([[specifier specifierDict] objectForKey:kIASKMailComposeBodyIsHTML]) {
  394. isHTML = [[[specifier specifierDict] objectForKey:kIASKMailComposeBodyIsHTML] boolValue];
  395. }
  396. -
  397. +
  398. if ([self.delegate respondsToSelector:@selector(settingsViewController:mailComposeBodyForSpecifier:)]) {
  399. [mailViewController setMessageBody:[self.delegate settingsViewController:self
  400. mailComposeBodyForSpecifier:specifier] isHTML:isHTML];
  401. @@ -768,29 +768,19 @@ CGRect IASKCGRectSwap(CGRect rect);
  402. }
  403. UIViewController<MFMailComposeViewControllerDelegate> *vc = nil;
  404. -
  405. +
  406. if ([self.delegate respondsToSelector:@selector(settingsViewController:viewControllerForMailComposeViewForSpecifier:)]) {
  407. vc = [self.delegate settingsViewController:self viewControllerForMailComposeViewForSpecifier:specifier];
  408. }
  409. -
  410. +
  411. if (vc == nil) {
  412. vc = self;
  413. }
  414. -
  415. +
  416. mailViewController.mailComposeDelegate = vc;
  417. -#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 50000)
  418. -#pragma message "Now that we're iOS5 and up, remove this workaround"
  419. -#endif
  420. - if([vc respondsToSelector:@selector(presentViewController:animated:completion:)]) {
  421. - [vc presentViewController:mailViewController
  422. - animated:YES
  423. - completion:nil];
  424. - } else {
  425. -#pragma clang diagnostic push
  426. -#pragma clang diagnostic ignored "-Wdeprecated-declarations"
  427. - [vc presentModalViewController:mailViewController animated:YES];
  428. -#pragma clang diagnostic pop
  429. - }
  430. + [vc presentViewController:mailViewController
  431. + animated:YES
  432. + completion:nil];
  433. [mailViewController release];
  434. } else {
  435. UIAlertView *alert = [[UIAlertView alloc]
  436. @@ -815,28 +805,17 @@ CGRect IASKCGRectSwap(CGRect rect);
  437. #pragma mark MFMailComposeViewControllerDelegate Function
  438. -(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
  439. -
  440. +
  441. // Forward the mail compose delegate
  442. if ([self.delegate respondsToSelector:@selector(settingsViewController:mailComposeController:didFinishWithResult:error:)]) {
  443. - [self.delegate settingsViewController:self
  444. - mailComposeController:controller
  445. - didFinishWithResult:result
  446. + [self.delegate settingsViewController:self
  447. + mailComposeController:controller
  448. + didFinishWithResult:result
  449. error:error];
  450. }
  451. -
  452. -#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 50000)
  453. -#pragma message "Now that we're iOS5 and up, remove this workaround"
  454. -#endif
  455. - if([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
  456. - [self dismissViewControllerAnimated:YES
  457. - completion:nil];
  458. - } else {
  459. -#pragma clang diagnostic push
  460. -#pragma clang diagnostic ignored "-Wdeprecated-declarations"
  461. - [self dismissModalViewControllerAnimated:YES];
  462. -#pragma clang diagnostic pop
  463. -
  464. - }
  465. +
  466. + [self dismissViewControllerAnimated:YES
  467. + completion:nil];
  468. }
  469. #pragma mark -
  470. @@ -885,8 +864,8 @@ static NSDictionary *oldUserDefaults = nil;
  471. }
  472. }
  473. [oldUserDefaults release], oldUserDefaults = [currentDict retain];
  474. -
  475. -
  476. +
  477. +
  478. for (UITableViewCell *cell in self.tableView.visibleCells) {
  479. if ([cell isKindOfClass:[IASKPSTextFieldSpecifierViewCell class]] && [((IASKPSTextFieldSpecifierViewCell*)cell).textField isFirstResponder]) {
  480. [indexPathsToUpdate removeObject:[self.tableView indexPathForCell:cell]];
  481. diff --git a/InAppSettingsKit/Controllers/IASKAppSettingsWebViewController.m b/InAppSettingsKit/Controllers/IASKAppSettingsWebViewController.m
  482. index d99da5c..4769b04 100644
  483. --- a/InAppSettingsKit/Controllers/IASKAppSettingsWebViewController.m
  484. +++ b/InAppSettingsKit/Controllers/IASKAppSettingsWebViewController.m
  485. @@ -6,9 +6,9 @@
  486. // Luc Vandal, Edovia Inc., http://www.edovia.com
  487. // Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com
  488. // All rights reserved.
  489. -//
  490. -// It is appreciated but not required that you give credit to Luc Vandal and Ortwin Gentz,
  491. -// as the original authors of this code. You can give credit in a blog post, a tweet or on
  492. +//
  493. +// It is appreciated but not required that you give credit to Luc Vandal and Ortwin Gentz,
  494. +// as the original authors of this code. You can give credit in a blog post, a tweet or on
  495. // a info page of your app. Also, the original authors appreciate letting them know if you use this code.
  496. //
  497. // This code is licensed under the BSD license that is available at: http://www.opensource.org/licenses/bsd-license.php
  498. @@ -42,18 +42,18 @@
  499. webView.autoresizingMask = UIViewAutoresizingFlexibleWidth |
  500. UIViewAutoresizingFlexibleHeight;
  501. webView.delegate = self;
  502. -
  503. +
  504. self.view = webView;
  505. }
  506. - (void)dealloc {
  507. [webView release], webView = nil;
  508. [url release], url = nil;
  509. -
  510. +
  511. [super dealloc];
  512. }
  513. -- (void)viewWillAppear:(BOOL)animated {
  514. +- (void)viewWillAppear:(BOOL)animated {
  515. [webView loadRequest:[NSURLRequest requestWithURL:self.url]];
  516. }
  517. @@ -72,7 +72,7 @@
  518. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
  519. NSURL *newURL = [request URL];
  520. -
  521. +
  522. // intercept mailto URL and send it to an in-app Mail compose view instead
  523. if ([[newURL scheme] isEqualToString:@"mailto"]) {
  524. @@ -80,7 +80,7 @@
  525. if (rawURLparts.count > 2) {
  526. return NO; // invalid URL
  527. }
  528. -
  529. +
  530. MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
  531. mailViewController.mailComposeDelegate = self;
  532. @@ -89,10 +89,10 @@
  533. if (defaultRecipient.length) {
  534. [toRecipients addObject:defaultRecipient];
  535. }
  536. -
  537. +
  538. if (rawURLparts.count == 2) {
  539. NSString *queryString = [rawURLparts objectAtIndex:1];
  540. -
  541. +
  542. NSArray *params = [queryString componentsSeparatedByString:@"&"];
  543. for (NSString *param in params) {
  544. NSArray *keyValue = [param componentsSeparatedByString:@"="];
  545. @@ -101,56 +101,46 @@
  546. }
  547. NSString *key = [[keyValue objectAtIndex:0] lowercaseString];
  548. NSString *value = [keyValue objectAtIndex:1];
  549. -
  550. +
  551. value = (NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
  552. (CFStringRef)value,
  553. CFSTR(""),
  554. kCFStringEncodingUTF8);
  555. [value autorelease];
  556. -
  557. +
  558. if ([key isEqualToString:@"subject"]) {
  559. [mailViewController setSubject:value];
  560. }
  561. -
  562. +
  563. if ([key isEqualToString:@"body"]) {
  564. [mailViewController setMessageBody:value isHTML:NO];
  565. }
  566. -
  567. +
  568. if ([key isEqualToString:@"to"]) {
  569. [toRecipients addObjectsFromArray:[value componentsSeparatedByString:@","]];
  570. }
  571. -
  572. +
  573. if ([key isEqualToString:@"cc"]) {
  574. NSArray *recipients = [value componentsSeparatedByString:@","];
  575. [mailViewController setCcRecipients:recipients];
  576. }
  577. -
  578. +
  579. if ([key isEqualToString:@"bcc"]) {
  580. NSArray *recipients = [value componentsSeparatedByString:@","];
  581. [mailViewController setBccRecipients:recipients];
  582. }
  583. }
  584. }
  585. -
  586. +
  587. [mailViewController setToRecipients:toRecipients];
  588. -
  589. -#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 50000)
  590. -#pragma message "Now that we're iOS5 and up, remove this workaround"
  591. -#endif
  592. - if([self respondsToSelector:@selector(presentViewController:animated:completion:)]) {
  593. +
  594. [self presentViewController:mailViewController
  595. animated:YES
  596. completion:nil];
  597. - } else {
  598. -#pragma clang diagnostic push
  599. -#pragma clang diagnostic ignored "-Wdeprecated-declarations"
  600. - [self presentModalViewController:mailViewController animated:YES];
  601. -#pragma clang diagnostic pop
  602. - }
  603. [mailViewController release];
  604. return NO;
  605. }
  606. -
  607. +
  608. // open inline if host is the same, otherwise, pass to the system
  609. if (![newURL host] || [[newURL host] isEqualToString:[self.url host]]) {
  610. return YES;
  611. @@ -160,21 +150,8 @@
  612. }
  613. - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
  614. -#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 50000)
  615. -#pragma message "Now that we're iOS5 and up, remove this workaround"
  616. -#endif
  617. - if([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
  618. - [self dismissViewControllerAnimated:YES
  619. - completion:nil];
  620. - } else {
  621. -#pragma clang diagnostic push
  622. -#pragma clang diagnostic ignored "-Wdeprecated-declarations"
  623. - [self dismissModalViewControllerAnimated:YES];
  624. -#pragma clang diagnostic pop
  625. -
  626. - }
  627. + [self dismissViewControllerAnimated:YES
  628. + completion:nil];
  629. }
  630. -
  631. -
  632. @end
  633. --
  634. 1.7.12.4 (Apple Git-37)