From 33a9b3c3b3001b074ecffdfc79d30f325933b7f4 Mon Sep 17 00:00:00 2001 From: Alexander Boriskov Date: Tue, 4 Aug 2020 20:16:15 +0300 Subject: [PATCH] [iOS] Booking improvements stats https://jira.mail.ru/browse/MAPSME-14207 --- .../AlertController/MWMAlertViewController.h | 1 + .../AlertController/MWMAlertViewController.mm | 5 ++- .../Classes/CustomAlert/BaseAlert/MWMAlert.h | 1 + .../Classes/CustomAlert/BaseAlert/MWMAlert.mm | 7 ++++ .../DefaultAlert/MWMDefaultAlert.h | 1 + .../DefaultAlert/MWMDefaultAlert.mm | 11 +++++ .../Common/Statistics/StatisticsStrings.h | 11 +++++ iphone/Maps/Core/Search/MWMSearch.mm | 20 +++++++++ .../UI/Search/DatePickerViewController.swift | 9 +++- .../MWMSearchHotelsFilterViewController.mm | 8 ++-- .../Search/GuestsPickerViewController.swift | 13 ++++++ .../UI/Search/GuestsPickerViewController.xib | 16 +++++++- .../Maps/UI/Search/MWMSearchManager+Filter.mm | 2 + iphone/Maps/UI/Search/MWMSearchManager.mm | 41 +++++++++++++++++++ iphone/Maps/UI/Search/SearchBar.swift | 4 ++ iphone/Maps/UI/Search/ValueStepperView.swift | 4 +- 16 files changed, 144 insertions(+), 10 deletions(-) diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h index a356904129..431677e190 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h @@ -18,6 +18,7 @@ - (void)presentLocationServiceNotSupportedAlert; - (void)presentLocationNotFoundAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock; - (void)presentNoConnectionAlert; +- (void)presentSearchQuickFilterNoConnectionAlert; - (void)presentDeleteMapProhibitedAlert; - (void)presentUnsavedEditsAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock; - (void)presentNoWiFiAlertWithOkBlock:(nullable MWMVoidBlock)okBlock andCancelBlock:(nullable MWMVoidBlock)cancelBlock; diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm index c84e4e3732..a7c6217c8b 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm @@ -71,6 +71,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController } - (void)presentNoConnectionAlert { [self displayAlert:[MWMAlert noConnectionAlert]]; } +- (void)presentSearchQuickFilterNoConnectionAlert { + [self displayAlert:[MWMAlert searchQuickFilterNoConnectionAlert]]; +} - (void)presentDeleteMapProhibitedAlert { [self displayAlert:[MWMAlert deleteMapProhibitedAlert]]; } - (void)presentUnsavedEditsAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock { @@ -273,7 +276,7 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController if (!isOwnerLoaded) { return; } - + // TODO(igrechuhin): Remove this check on location manager refactoring. // Workaround for current location manager duplicate error alerts. if ([alert isKindOfClass:[MWMLocationAlert class]]) diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h index 205a33c043..3098ef937d 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h @@ -9,6 +9,7 @@ + (MWMAlert *)disabledLocationAlert; + (MWMAlert *)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock; + (MWMAlert *)noConnectionAlert; ++ (MWMAlert *)searchQuickFilterNoConnectionAlert; + (MWMAlert *)deleteMapProhibitedAlert; + (MWMAlert *)unsavedEditsAlertWithOkBlock:(MWMVoidBlock)okBlock; + (MWMAlert *)locationServiceNotSupportedAlert; diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm index 3753af8a12..cedadc630a 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm @@ -35,6 +35,13 @@ } + (MWMAlert *)noConnectionAlert { return [MWMDefaultAlert noConnectionAlert]; } ++ (MWMAlert *)searchQuickFilterNoConnectionAlert { + return [MWMDefaultAlert searchQuickFilterNoConnectionAlertWithOkBlock:^{ + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] + options:@{} + completionHandler:NULL]; + }]; +} + (MWMAlert *)deleteMapProhibitedAlert { return [MWMDefaultAlert deleteMapProhibitedAlert]; } + (MWMAlert *)unsavedEditsAlertWithOkBlock:(MWMVoidBlock)okBlock { diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h index b2cae7df20..71fdc49c36 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h @@ -19,6 +19,7 @@ + (instancetype)disabledLocationAlert; + (instancetype)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock; + (instancetype)noConnectionAlert; ++ (instancetype)searchQuickFilterNoConnectionAlertWithOkBlock:(MWMVoidBlock)okBlock; + (instancetype)deleteMapProhibitedAlert; + (instancetype)unsavedEditsAlertWithOkBlock:(MWMVoidBlock)okBlock; + (instancetype)locationServiceNotSupportedAlert; diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm index 0c893ca60d..f6290cc9ce 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm @@ -88,6 +88,17 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; return alert; } ++ (instancetype)searchQuickFilterNoConnectionAlertWithOkBlock:(MWMVoidBlock)okBlock { + MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"choose_dates_online_only_dialog_message") + message:nil + rightButtonTitle:L(@"choose_dates_online_only_dialog_cta") + leftButtonTitle:L(@"cancel") + rightButtonAction:okBlock + statisticsEvent:@"No Connection Alert"]; + [alert setNeedsCloseAlertAfterEnterBackground]; + return alert; +} + + (instancetype)deleteMapProhibitedAlert { MWMDefaultAlert * alert = diff --git a/iphone/Maps/Common/Statistics/StatisticsStrings.h b/iphone/Maps/Common/Statistics/StatisticsStrings.h index c4e965dfcb..3d83033dcf 100644 --- a/iphone/Maps/Common/Statistics/StatisticsStrings.h +++ b/iphone/Maps/Common/Statistics/StatisticsStrings.h @@ -477,6 +477,17 @@ static NSString *const kStatSearchRestaurants = @"Search.Restaurants"; static NSString *const kStatSearchSponsoredSelect = @"Search_SponsoredCategory_selected"; static NSString *const kStatSearchSponsoredShow = @"Search_SponsoredCategory_shown"; static NSString *const kStatSearchTabSelected = @"Search_Tab_selected"; +static NSString *const kStatSearchQuickFilterOpen = @"Search_QuickFilter_Open"; +static NSString *const kStatSearchQuickFilterClick = @"Search_QuickFilter_Click"; +static NSString *const kStatSearchQuickFilterApply = @"Search_QuickFilter_Apply"; +static NSString *const kStatSearchQuickFilterError = @"Search_QuickFilter_Click_error"; +static NSString *const kStatSearchContextAreaClick = @"Search_ContextArea_Click"; +static NSString *const kStatSearchRooms = @"rooms"; +static NSString *const kStatSearchAdults = @"adults"; +static NSString *const kStatSearchChildren = @"children"; +static NSString *const kStatSearchInfants = @"infants"; +static NSString *const kStatList = @"list"; +static NSString *const kStatFilter = @"filter"; static NSString *const kStatSelectMap = @"Select map"; static NSString *const kStatSelectResult = @"Select result"; static NSString *const kStatSelectTab = @"Select tab"; diff --git a/iphone/Maps/Core/Search/MWMSearch.mm b/iphone/Maps/Core/Search/MWMSearch.mm index 891974b174..6e372fc4a7 100644 --- a/iphone/Maps/Core/Search/MWMSearch.mm +++ b/iphone/Maps/Core/Search/MWMSearch.mm @@ -273,6 +273,26 @@ booking::filter::Tasks MakeBookingFilterTasks(booking::filter::Params &&availabi + (void)updateHotelFilterWithParams:(MWMHotelParams *)params { [MWMSearch manager].filter = params; [[MWMSearch manager] update]; + + std::string priceCategory = strings::JoinAny(params.price, ',', [](auto const & item) { + return std::to_string(static_cast(item)); + }); + std::string types = strings::JoinAny(params.types, ',', [](auto const & item) { + return std::to_string(static_cast(item)); + }); + + [Statistics logEvent:kStatSearchFilterApply withParameters:@{kStatCategory: kStatHotel, + kStatSearchRooms: @(params.numberOfRooms), + kStatSearchAdults: @(params.numberOfAdults), + kStatSearchChildren: @(params.numberOfChildren), + kStatSearchInfants: @(params.numberOfInfants), + kStatDate: + @[params.checkInDate ? params.checkInDate : kStatNone, + params.checkOutDate ? params.checkOutDate : kStatNone], + kStatRating: @(static_cast(params.rating)), + kStatPriceCategory: @(priceCategory.c_str()), + kStatTypes: @(types.c_str()) + }]; } - (void)reset { diff --git a/iphone/Maps/UI/Search/DatePickerViewController.swift b/iphone/Maps/UI/Search/DatePickerViewController.swift index 040eea3a83..52b8c86fb8 100644 --- a/iphone/Maps/UI/Search/DatePickerViewController.swift +++ b/iphone/Maps/UI/Search/DatePickerViewController.swift @@ -3,6 +3,7 @@ import DatePicker @objc protocol DatePickerViewControllerDelegate: AnyObject { func datePicker(_ datePicker: DatePickerViewController, didSelectStartDate startDate:Date, endDate:Date) + func datePickerDidClick(_ datePicker: DatePickerViewController, didSelectStartDate startDate: Date?, endDate: Date?) func datePickerDidCancel(_ datePicker: DatePickerViewController) } @@ -17,7 +18,7 @@ import DatePicker @IBOutlet var cancelButton: UIButton! @IBOutlet var datePickerView: DatePickerView! - @objc var delegate: DatePickerViewControllerDelegate? + @objc weak var delegate: DatePickerViewControllerDelegate? lazy var dateFormatter: DateFormatter = { let formatter = DateFormatter() @@ -61,6 +62,7 @@ extension DatePickerViewController: DatePickerViewDelegate { } else { numberOfDaysLabel.text = nil } + delegate?.datePickerDidClick(self, didSelectStartDate: view.startDate, endDate: view.endDate) } guard let startDate = view.startDate else { @@ -72,7 +74,10 @@ extension DatePickerViewController: DatePickerViewDelegate { if date > startDate && view.endDate == nil { guard Calendar.current.dateComponents([.day], from: startDate, to: date).day! <= 30 else { - MWMAlertViewController.activeAlert().presentDefaultAlert(withTitle: "TODO: can't select more than 30 days", message: nil, rightButtonTitle: L("ok"), leftButtonTitle: nil, rightButtonAction: nil) + MWMAlertViewController.activeAlert().presentDefaultAlert(withTitle: L("30_days_limit_dialog"), + message: nil, rightButtonTitle: L("ok"), + leftButtonTitle: nil, + rightButtonAction: nil) return } view.endDate = date diff --git a/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm b/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm index 4406f5341b..948a33a23a 100644 --- a/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm +++ b/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm @@ -157,7 +157,8 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [Statistics logEvent:kStatSearchFilterOpen withParameters:@{kStatCategory: kStatHotel}]; + [Statistics logEvent:kStatSearchFilterOpen withParameters:@{kStatCategory: kStatHotel, + kStatNetwork: [Statistics connectionTypeString]}]; [self.tableView reloadData]; [self refreshAppearance]; [self setNeedsStatusBarAppearanceUpdate]; @@ -200,7 +201,6 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar - (IBAction)applyAction { - [Statistics logEvent:kStatSearchFilterApply withParameters:@{kStatCategory: kStatHotel}]; [MWMEye bookingFilterUsed]; [self.delegate hotelsFilterViewController:self didSelectParams:[self getSelectedHotelParams]]; } @@ -388,8 +388,8 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar case ftypes::IsHotelChecker::Type::Resort: typeString = kStatResort; break; case ftypes::IsHotelChecker::Type::Count: break; } - [Statistics logEvent:kStatSearchFilterClick - withParameters:@{kStatCategory: kStatHotel, kStatType: typeString}]; + [Statistics logEvent:kStatSearchFilterClick withParameters:@{kStatCategory: kStatHotel, + kStatType: typeString}]; m_selectedTypes.emplace(type); } diff --git a/iphone/Maps/UI/Search/GuestsPickerViewController.swift b/iphone/Maps/UI/Search/GuestsPickerViewController.swift index e1b3c4a372..c0800cb9b9 100644 --- a/iphone/Maps/UI/Search/GuestsPickerViewController.swift +++ b/iphone/Maps/UI/Search/GuestsPickerViewController.swift @@ -4,6 +4,11 @@ adults: Int, children: Int, infants: Int) + func guestPickerDidClick(_ guestsPicker: GuestsPickerViewController, + didSelectRooms rooms: Int, + adults: Int, + children: Int, + infants: Int) func guestsPickerDidCancel(_ guestsPicker: GuestsPickerViewController) } @@ -56,4 +61,12 @@ @IBAction func onCancel(_ sender: UIButton) { delegate?.guestsPickerDidCancel(self) } + + @IBAction func onStepperValueChanged(_ sender: Any) { + delegate?.guestPickerDidClick(self, + didSelectRooms: roomsStepper.value, + adults: adultsStepper.value, + children: childrenStepper.value, + infants: infantsStepper.value) + } } diff --git a/iphone/Maps/UI/Search/GuestsPickerViewController.xib b/iphone/Maps/UI/Search/GuestsPickerViewController.xib index bf4981109f..b14a0386fb 100644 --- a/iphone/Maps/UI/Search/GuestsPickerViewController.xib +++ b/iphone/Maps/UI/Search/GuestsPickerViewController.xib @@ -1,9 +1,9 @@ - + - + @@ -101,6 +101,9 @@ + + + @@ -159,6 +162,9 @@ + + + @@ -217,6 +223,9 @@ + + +