diff --git a/iphone/Maps/MWMRecentTrackSettingsController.h b/iphone/Maps/MWMRecentTrackSettingsController.h new file mode 100644 index 0000000000..8a08bca1a7 --- /dev/null +++ b/iphone/Maps/MWMRecentTrackSettingsController.h @@ -0,0 +1,5 @@ +#import "TableViewController.h" + +@interface MWMRecentTrackSettingsController : TableViewController + +@end diff --git a/iphone/Maps/MWMRecentTrackSettingsController.mm b/iphone/Maps/MWMRecentTrackSettingsController.mm new file mode 100644 index 0000000000..a8a94727d7 --- /dev/null +++ b/iphone/Maps/MWMRecentTrackSettingsController.mm @@ -0,0 +1,40 @@ +#import "MWMRecentTrackSettingsController.h" +#import "SelectableCell.h" + +@interface MWMRecentTrackSettingsController () +@property (weak, nonatomic) IBOutlet SelectableCell * none; +@property (weak, nonatomic) IBOutlet SelectableCell * oneHour; +@property (weak, nonatomic) IBOutlet SelectableCell * twoHours; +@property (weak, nonatomic) IBOutlet SelectableCell * sixHours; +@property (weak, nonatomic) IBOutlet SelectableCell * twelveHours; +@property (weak, nonatomic) IBOutlet SelectableCell * oneDay; +@property (weak, nonatomic) SelectableCell * selectedCell; + +@end + +@implementation MWMRecentTrackSettingsController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + self.title = L(@"recent_track"); + self.none.accessoryType = UITableViewCellAccessoryCheckmark; + self.selectedCell = self.none; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + self.selectedCell.accessoryType = UITableViewCellAccessoryNone; + self.selectedCell = [tableView cellForRowAtIndexPath:indexPath]; + self.selectedCell.accessoryType = UITableViewCellAccessoryCheckmark; + self.selectedCell.selected = NO; +} + +- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section +{ + if (section != 0) + NSAssert(false, @"Incorrect sections count"); + return L(@"recent_track_help_text"); +} + +@end diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 1b4e1d23c3..bf13598111 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -706,6 +706,7 @@ F6BD33811B62403B00F2CE18 /* MWMRoutePreview.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6BD337E1B62403B00F2CE18 /* MWMRoutePreview.mm */; }; F6BD33841B6240F200F2CE18 /* MWMNavigationView.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6BD33831B6240F200F2CE18 /* MWMNavigationView.mm */; }; F6BD33871B62412E00F2CE18 /* MWMNavigationDashboardEntity.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6BD33861B62412E00F2CE18 /* MWMNavigationDashboardEntity.mm */; }; + F6C641B01C15BBE6008FCAF3 /* MWMRecentTrackSettingsController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6C641AF1C15BBE6008FCAF3 /* MWMRecentTrackSettingsController.mm */; }; F6C6FE201AD6BEA0009FDED7 /* MWMWatchLocationTracker.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6C6FE1F1AD6BEA0009FDED7 /* MWMWatchLocationTracker.mm */; }; F6C7B7121BA840A4004233F4 /* resources-xhdpi_clear in Resources */ = {isa = PBXBuildFile; fileRef = 4A23D1591B8B4DD700D4EB6F /* resources-xhdpi_clear */; }; F6C7B7131BA840A4004233F4 /* resources-xhdpi_dark in Resources */ = {isa = PBXBuildFile; fileRef = 4A7D89C31B2EBF3B00AC843E /* resources-xhdpi_dark */; }; @@ -734,6 +735,7 @@ F6ED13911B1EF96B0095C6DE /* MWMBookmarkDescriptionViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6ED13901B1EF96B0095C6DE /* MWMBookmarkDescriptionViewController.mm */; }; F6ED13931B1EFA2F0095C6DE /* MWMBookmarkDescriptionViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6ED13921B1EFA2F0095C6DE /* MWMBookmarkDescriptionViewController.xib */; }; F6F533A31B3C248900C1940B /* UIColor+MapsMeColor.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6F533A21B3C248900C1940B /* UIColor+MapsMeColor.mm */; }; + F6F6ACFC1C15C1010060FDD0 /* MWMRecentTrackSettingsController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6C641AF1C15BBE6008FCAF3 /* MWMRecentTrackSettingsController.mm */; }; F6F722F81AE1572400DA3DA1 /* MWMiPhonePortraitPlacePage.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6F722F71AE1572400DA3DA1 /* MWMiPhonePortraitPlacePage.mm */; }; F6FE2C0F1B03A006009814AA /* MWMPlacePageNavigationBar.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6FE2C0E1B03A006009814AA /* MWMPlacePageNavigationBar.mm */; }; F6FE2C111B03A016009814AA /* PlacePageNavigationBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6FE2C101B03A015009814AA /* PlacePageNavigationBar.xib */; }; @@ -1295,6 +1297,8 @@ F6BD33831B6240F200F2CE18 /* MWMNavigationView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMNavigationView.mm; sourceTree = ""; }; F6BD33851B62412E00F2CE18 /* MWMNavigationDashboardEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMNavigationDashboardEntity.h; sourceTree = ""; }; F6BD33861B62412E00F2CE18 /* MWMNavigationDashboardEntity.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMNavigationDashboardEntity.mm; sourceTree = ""; }; + F6C641AE1C15BBE6008FCAF3 /* MWMRecentTrackSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMRecentTrackSettingsController.h; sourceTree = ""; }; + F6C641AF1C15BBE6008FCAF3 /* MWMRecentTrackSettingsController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMRecentTrackSettingsController.mm; sourceTree = ""; }; F6C6FE1E1AD6BEA0009FDED7 /* MWMWatchLocationTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMWatchLocationTracker.h; sourceTree = ""; }; F6C6FE1F1AD6BEA0009FDED7 /* MWMWatchLocationTracker.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMWatchLocationTracker.mm; sourceTree = ""; }; F6C9343A1AE4F94A00DDC624 /* MWMAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMAnimator.h; sourceTree = ""; }; @@ -2796,6 +2800,8 @@ F668F6551BCD4507002D6FFC /* MWMTTSSettingsViewController.mm */, F63BA36F1BCD5B520044C504 /* MWMTTSLanguageViewController.h */, F63BA3701BCD5B520044C504 /* MWMTTSLanguageViewController.mm */, + F6C641AE1C15BBE6008FCAF3 /* MWMRecentTrackSettingsController.h */, + F6C641AF1C15BBE6008FCAF3 /* MWMRecentTrackSettingsController.mm */, 97508421199522D300A7457D /* SettingsAndMoreVC.h */, 97508422199522D300A7457D /* SettingsAndMoreVC.mm */, 978D4A231996B0EC00D72CA7 /* CommunityVC.h */, @@ -3467,6 +3473,7 @@ 34B16C451B72655D000D3A0D /* MWMPedestrianShareAlert.mm in Sources */, 347BAC6E1B736BA70010FF78 /* MWMSharePedestrianRoutesToastActivityItem.mm in Sources */, 34B82AD61B84746E00180497 /* MWMSearchSuggestionCell.mm in Sources */, + F6C641B01C15BBE6008FCAF3 /* MWMRecentTrackSettingsController.mm in Sources */, F6588E2F1B15D2BC00EE1E58 /* MWMBookmarkColorViewController.mm in Sources */, 349A358E1B53EABC009677EE /* MWMSearchDownloadMapRequestView.mm in Sources */, A32B6D4D1A14980500E54A65 /* iosOGLContextFactory.mm in Sources */, @@ -3618,6 +3625,7 @@ 6741A9DC1BF340DE002C974C /* MWMRoutePointLayout.mm in Sources */, 6741A9DD1BF340DE002C974C /* CountryTreeVC.mm in Sources */, 6741A9DE1BF340DE002C974C /* BadgeView.mm in Sources */, + F6F6ACFC1C15C1010060FDD0 /* MWMRecentTrackSettingsController.mm in Sources */, 6741A9DF1BF340DE002C974C /* MWMSearchHistoryClearCell.mm in Sources */, 6741A9E01BF340DE002C974C /* MWMDownloaderDialogHeader.mm in Sources */, 6741A9E11BF340DE002C974C /* MWMSearchTableView.mm in Sources */, diff --git a/iphone/Maps/Mapsme.storyboard b/iphone/Maps/Mapsme.storyboard index f1d2b0f5c3..ac18fe12a2 100644 --- a/iphone/Maps/Mapsme.storyboard +++ b/iphone/Maps/Mapsme.storyboard @@ -146,7 +146,6 @@ - @@ -158,11 +157,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iphone/Maps/Settings/SettingsViewController.mm b/iphone/Maps/Settings/SettingsViewController.mm index dc6a28be37..c1816abf26 100644 --- a/iphone/Maps/Settings/SettingsViewController.mm +++ b/iphone/Maps/Settings/SettingsViewController.mm @@ -24,7 +24,7 @@ extern NSString * const kTTSStatusWasChangedNotification = @"TTFStatusWasChanged typedef NS_ENUM(NSUInteger, Section) { SectionMetrics, - SectionZoomButtons, + SectionMap, SectionRouting, SectionCalibration, SectionAd, @@ -49,19 +49,9 @@ typedef NS_ENUM(NSUInteger, Section) bool adServerForbidden = false; (void)Settings::Get(kAdServerForbiddenKey, adServerForbidden); if (isIOSVersionLessThan(8) || adServerForbidden) - sections = {SectionMetrics, SectionZoomButtons, SectionRouting, SectionCalibration, SectionStatistics}; + sections = {SectionMetrics, SectionMap, SectionRouting, SectionCalibration, SectionStatistics}; else - sections = {SectionMetrics, SectionZoomButtons, SectionRouting, SectionCalibration, SectionAd, SectionStatistics}; -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; -} - -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; + sections = {SectionMetrics, SectionMap, SectionRouting, SectionCalibration, SectionAd, SectionStatistics}; } #pragma mark - Table view data source @@ -73,28 +63,36 @@ typedef NS_ENUM(NSUInteger, Section) - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - if (sections[section] == SectionMetrics || sections[section] == SectionRouting) + switch (sections[section]) + { + case SectionMetrics: + case SectionRouting: return 2; - else + case SectionMap: + case SectionAd: + case SectionStatistics: + case SectionCalibration: return 1; + } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell * cell = nil; - Section section = sections[indexPath.section]; - if (section == SectionMetrics) + switch (sections[indexPath.section]) + { + case SectionMetrics: { cell = [tableView dequeueReusableCellWithIdentifier:[SelectableCell className]]; Settings::Units units = Settings::Metric; (void)Settings::Get("Units", units); - BOOL selected = units == unitsForIndex(indexPath.row); - + BOOL const selected = units == unitsForIndex(indexPath.row); SelectableCell * customCell = (SelectableCell *)cell; customCell.accessoryType = selected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone; customCell.titleLabel.text = indexPath.row == 0 ? L(@"kilometres") : L(@"miles"); + break; } - else if (section == SectionAd) + case SectionAd: { cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]]; SwitchCell * customCell = (SwitchCell *)cell; @@ -103,8 +101,9 @@ typedef NS_ENUM(NSUInteger, Section) customCell.switchButton.on = !forbidden; customCell.titleLabel.text = L(@"showcase_settings_title"); customCell.delegate = self; + break; } - else if (section == SectionStatistics) + case SectionStatistics: { cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]]; SwitchCell * customCell = (SwitchCell *)cell; @@ -113,28 +112,29 @@ typedef NS_ENUM(NSUInteger, Section) customCell.switchButton.on = on; customCell.titleLabel.text = L(@"allow_statistics"); customCell.delegate = self; + break; } - else if (section == SectionZoomButtons) + case SectionMap: { - cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]]; - SwitchCell * customCell = (SwitchCell *)cell; - bool on = true; - (void)Settings::Get("ZoomButtonsEnabled", on); - customCell.switchButton.on = on; - customCell.titleLabel.text = L(@"pref_zoom_title"); - customCell.delegate = self; +// if (indexPath.row == 0) +// { +// cell = [tableView dequeueReusableCellWithIdentifier:[LinkCell className]]; +// LinkCell * linkCell = static_cast(cell); +// linkCell.titleLabel.text = L(@"recent_track"); +// } +// else +// { + cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]]; + SwitchCell * customCell = (SwitchCell *)cell; + bool on = true; + (void)Settings::Get("ZoomButtonsEnabled", on); + customCell.switchButton.on = on; + customCell.titleLabel.text = L(@"pref_zoom_title"); + customCell.delegate = self; +// } + break; } - else if (section == SectionCalibration) - { - cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]]; - SwitchCell * customCell = (SwitchCell *)cell; - bool on = false; - (void)Settings::Get("CompassCalibrationEnabled", on); - customCell.switchButton.on = on; - customCell.titleLabel.text = L(@"pref_calibration_title"); - customCell.delegate = self; - } - else if (section == SectionRouting) + case SectionRouting: { if (indexPath.row == 0) { @@ -150,6 +150,19 @@ typedef NS_ENUM(NSUInteger, Section) LinkCell * customCell = (LinkCell *)cell; customCell.titleLabel.text = L(@"pref_tts_language_title"); } + break; + } + case SectionCalibration: + { + cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]]; + SwitchCell * customCell = (SwitchCell *)cell; + bool on = false; + (void)Settings::Get("CompassCalibrationEnabled", on); + customCell.switchButton.on = on; + customCell.titleLabel.text = L(@"pref_calibration_title"); + customCell.delegate = self; + break; + } } return cell; } @@ -158,8 +171,6 @@ typedef NS_ENUM(NSUInteger, Section) { if (section == SectionStatistics) return L(@"allow_statistics_hint"); - else if (section == SectionZoomButtons) - return L(@"pref_zoom_summary"); return nil; } @@ -167,44 +178,46 @@ typedef NS_ENUM(NSUInteger, Section) { NSIndexPath * indexPath = [self.tableView indexPathForCell:cell]; Statistics * stat = [Statistics instance]; - Section section = sections[indexPath.section]; - if (section == SectionAd) + switch (sections[indexPath.section]) { + case SectionAd: [stat logEvent:kStatSettings - withParameters:@{kStatAction : kStatMoreApps, kStatValue : (value ? kStatOn : kStatOff)}]; + withParameters:@{kStatAction : kStatMoreApps, kStatValue : (value ? kStatOn : kStatOff)}]; Settings::Set(kAdForbiddenSettingsKey, (bool)!value); - } - else if (section == SectionStatistics) - { + break; + + case SectionStatistics: [stat logEvent:kStatEventName(kStatSettings, kStatToggleStatistics) - withParameters: - @{kStatAction : kStatToggleStatistics, kStatValue : (value ? kStatOn : kStatOff)}]; + withParameters: @{kStatAction : kStatToggleStatistics, kStatValue : (value ? kStatOn : kStatOff)}]; if (value) [stat enableOnNextAppLaunch]; else [stat disableOnNextAppLaunch]; - } - else if (section == SectionZoomButtons) - { + break; + + case SectionMap: [stat logEvent:kStatEventName(kStatSettings, kStatToggleZoomButtonsVisibility) withParameters:@{kStatValue : (value ? kStatVisible : kStatHidden)}]; Settings::Set("ZoomButtonsEnabled", (bool)value); [MapsAppDelegate theApp].mapViewController.controlsManager.zoomHidden = !value; - } - else if (section == SectionCalibration) - { + break; + + case SectionCalibration: [stat logEvent:kStatEventName(kStatSettings, kStatToggleCompassCalibration) withParameters:@{kStatValue : (value ? kStatOn : kStatOff)}]; Settings::Set("CompassCalibrationEnabled", (bool)value); - } - else if (section == SectionRouting) - { + break; + + case SectionRouting: [[Statistics instance] logEvent:kStatEventName(kStatSettings, kStatTTS) withParameters:@{kStatValue : value ? kStatOn : kStatOff}]; [[MWMTextToSpeech tts] setNeedToEnable:value]; [[NSNotificationCenter defaultCenter] postNotificationName:kTTSStatusWasChangedNotification - object:nil - userInfo:@{@"on" : @(value)}]; + object:nil userInfo:@{@"on" : @(value)}]; + break; + + case SectionMetrics: + break; } } @@ -215,8 +228,9 @@ Settings::Units unitsForIndex(NSInteger index) - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - Section section = sections[indexPath.section]; - if (section == SectionMetrics) + switch (sections[indexPath.section]) + { + case SectionMetrics: { Settings::Units units = unitsForIndex(indexPath.row); [[Statistics instance] logEvent:kStatEventName(kStatSettings, kStatChangeMeasureUnits) @@ -224,22 +238,43 @@ Settings::Units unitsForIndex(NSInteger index) Settings::Set("Units", units); [tableView reloadSections:[NSIndexSet indexSetWithIndex:SectionMetrics] withRowAnimation:UITableViewRowAnimationFade]; GetFramework().SetupMeasurementSystem(); + break; } - else if (section == SectionRouting && indexPath.row == 1) - { - [[Statistics instance] logEvent:kStatEventName(kStatSettings, kStatTTS) + case SectionRouting: + if (indexPath.row == 1) + { + [[Statistics instance] logEvent:kStatEventName(kStatSettings, kStatTTS) withParameters:@{kStatAction : kStatChangeLanguage}]; + [self performSegueWithIdentifier:@"SettingsToTTSSegue" sender:nil]; + } + break; + + case SectionMap: +// if (indexPath.row == 0) +// [self performSegueWithIdentifier:@"SettingsToRecentTrackSegue" sender:nil]; +// break; + case SectionAd: + case SectionCalibration: + case SectionStatistics: + break; } } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { - if (section == SectionMetrics) + switch (sections[section]) + { + case SectionMetrics: return L(@"measurement_units"); - else if (section == SectionRouting) + case SectionRouting: return L(@"prefs_group_route"); - else + case SectionMap: + return L(@"prefs_group_map"); + case SectionCalibration: + case SectionAd: + case SectionStatistics: return nil; + } } @end