From 1e765d26fbb6ec6b14678dfb80d32031a009c302 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 30 Aug 2016 11:08:34 +0200 Subject: [PATCH] assistant: add done button on phonepad --- Classes/AssistantLinkView.m | 15 ++++++++++++++- Classes/AssistantView.m | 14 +++++++++----- Classes/SideMenuTableView.m | 25 ++++++++++++++++++++----- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/Classes/AssistantLinkView.m b/Classes/AssistantLinkView.m index e7b218c6f..d0093b185 100644 --- a/Classes/AssistantLinkView.m +++ b/Classes/AssistantLinkView.m @@ -18,7 +18,20 @@ - (void)viewDidLoad { [super viewDidLoad]; - [_activationCodeField addDoneButton]; + // every UITextField subviews with phone keyboard must be tweaked to have a done button + [self addDoneButtonRecursivelyInView:self.view]; +} + +- (void)addDoneButtonRecursivelyInView:(UIView *)subview { + for (UIView *child in [subview subviews]) { + if ([child isKindOfClass:UITextField.class]) { + UITextField *tf = (UITextField *)child; + if (tf.keyboardType == UIKeyboardTypePhonePad || tf.keyboardType == UIKeyboardTypeNumberPad) { + [tf addDoneButton]; + } + } + [self addDoneButtonRecursivelyInView:child]; + } } - (void)viewDidAppear:(BOOL)animated { diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 03c6a67d4..ec85127bd 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -392,17 +392,21 @@ static UICompositeViewDescription *compositeDescription = nil; countryButton.layer.masksToBounds = YES; // every UITextField subviews with phone keyboard must be tweaked to have a done button - for (UIView *child in [view subviews]) { - if ([child.class isSubclassOfClass:UITextField.class]) { + [self addDoneButtonRecursivelyInView:self.view]; + + [self prepareErrorLabels]; +} + +- (void)addDoneButtonRecursivelyInView:(UIView *)subview { + for (UIView *child in [subview subviews]) { + if ([child isKindOfClass:UITextField.class]) { UITextField *tf = (UITextField *)child; if (tf.keyboardType == UIKeyboardTypePhonePad || tf.keyboardType == UIKeyboardTypeNumberPad) { [tf addDoneButton]; } } + [self addDoneButtonRecursivelyInView:child]; } - - [self prepareErrorLabels]; - } - (void)fillDefaultValues { diff --git a/Classes/SideMenuTableView.m b/Classes/SideMenuTableView.m index ee2bbf78c..231b80b19 100644 --- a/Classes/SideMenuTableView.m +++ b/Classes/SideMenuTableView.m @@ -34,6 +34,10 @@ // remove separators between empty items, cf // http://stackoverflow.com/questions/1633966/can-i-force-a-uitableview-to-hide-the-separator-between-empty-cells self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; _sideMenuEntries = [[NSMutableArray alloc] init]; @@ -43,6 +47,16 @@ [PhoneMainView.instance changeCurrentView:AssistantView.compositeViewDescription]; }]]; + BOOL mustLink = ([LinphoneManager.instance lpConfigIntForKey:@"must_link_account_time"] > 0); + if (mustLink) { + [_sideMenuEntries + addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Link my account", nil) + tapBlock:^() { + [PhoneMainView.instance + changeCurrentView:AssistantLinkView.compositeViewDescription]; + }]]; + } + [_sideMenuEntries addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Settings", nil) tapBlock:^() { @@ -51,11 +65,12 @@ }]]; InAppProductsManager *iapm = LinphoneManager.instance.iapManager; if (iapm.enabled){ - [_sideMenuEntries addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Shop", nil) - tapBlock:^() { - [PhoneMainView.instance - changeCurrentView:ShopView.compositeViewDescription]; - }]]; + [_sideMenuEntries + addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Shop", nil) + tapBlock:^() { + [PhoneMainView.instance + changeCurrentView:ShopView.compositeViewDescription]; + }]]; } [_sideMenuEntries addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"About", nil) tapBlock:^() {