From 9d4a76f0c2d8074e61b712165340d18e91332a52 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 15 Jan 2016 16:47:46 +0100 Subject: [PATCH] misc: add ANIMATED macro --- Classes/AssistantView.m | 2 +- Classes/CallOutgoingView.m | 4 +-- Classes/CallView.m | 12 +++---- Classes/LinphoneCoreSettingsStore.m | 16 ++++----- Classes/LinphoneUI/TabBarView.m | 2 +- Classes/LinphoneUI/UIBouncingView.m | 4 +-- Classes/Log.h | 2 -- Classes/PhoneMainView.m | 50 ++++++++++------------------- Classes/Utils/Utils.h | 3 ++ Resources/linphonerc-factory | 2 -- 10 files changed, 38 insertions(+), 59 deletions(-) diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 2e35d179b..75a726982 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -285,7 +285,7 @@ static UICompositeViewDescription *compositeDescription = nil; } // Animation - if (animation && [[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"] == true) { + if (animation && ANIMATED) { CATransition *trans = [CATransition animation]; [trans setType:kCATransitionPush]; [trans setDuration:0.35]; diff --git a/Classes/CallOutgoingView.m b/Classes/CallOutgoingView.m index 723e5ef4e..420b4cdea 100644 --- a/Classes/CallOutgoingView.m +++ b/Classes/CallOutgoingView.m @@ -93,9 +93,9 @@ static UICompositeViewDescription *compositeDescription = nil; - (IBAction)onRoutesClick:(id)sender { if ([_routesView isHidden]) { - [self hideRoutes:FALSE animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; + [self hideRoutes:FALSE animated:ANIMATED]; } else { - [self hideRoutes:TRUE animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; + [self hideRoutes:TRUE animated:ANIMATED]; } } diff --git a/Classes/CallView.m b/Classes/CallView.m index 464deeb10..d613473f9 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -674,9 +674,9 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { - (IBAction)onNumpadClick:(id)sender { if ([_numpadView isHidden]) { - [self hidePad:FALSE animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; + [self hidePad:FALSE animated:ANIMATED]; } else { - [self hidePad:TRUE animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; + [self hidePad:TRUE animated:ANIMATED]; } } @@ -703,9 +703,9 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { - (IBAction)onRoutesClick:(id)sender { if ([_routesView isHidden]) { - [self hideRoutes:FALSE animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; + [self hideRoutes:FALSE animated:ANIMATED]; } else { - [self hideRoutes:TRUE animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; + [self hideRoutes:TRUE animated:ANIMATED]; } } @@ -731,9 +731,9 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { - (IBAction)onOptionsClick:(id)sender { if ([_optionsView isHidden]) { - [self hideOptions:FALSE animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; + [self hideOptions:FALSE animated:ANIMATED]; } else { - [self hideOptions:TRUE animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; + [self hideOptions:TRUE animated:ANIMATED]; } } diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index fdf02aa8d..820adb1a9 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -364,17 +364,13 @@ // advanced section { - [self setBool:[lm lpConfigBoolForKey:@"debugenable_preference" withDefault:NO] - forKey:@"debugenable_preference"]; - [self setBool:[lm lpConfigBoolForKey:@"animations_preference" withDefault:NO] forKey:@"animations_preference"]; - [self setBool:[lm lpConfigBoolForKey:@"backgroundmode_preference" withDefault:NO] - forKey:@"backgroundmode_preference"]; - [self setBool:[lm lpConfigBoolForKey:@"start_at_boot_preference" withDefault:NO] - forKey:@"start_at_boot_preference"]; - [self setBool:[lm lpConfigBoolForKey:@"autoanswer_notif_preference" withDefault:NO] - forKey:@"autoanswer_notif_preference"]; + [self setBool:[lm lpConfigBoolForKey:@"debugenable_preference"] forKey:@"debugenable_preference"]; + [self setBool:ANIMATED forKey:@"animations_preference"]; + [self setBool:[lm lpConfigBoolForKey:@"backgroundmode_preference"] forKey:@"backgroundmode_preference"]; + [self setBool:[lm lpConfigBoolForKey:@"start_at_boot_preference"] forKey:@"start_at_boot_preference"]; + [self setBool:[lm lpConfigBoolForKey:@"autoanswer_notif_preference"] forKey:@"autoanswer_notif_preference"]; [self setBool:[lm lpConfigBoolForKey:@"show_msg_in_notif" withDefault:YES] forKey:@"show_msg_in_notif"]; - [self setBool:[lm lpConfigBoolForKey:@"enable_first_login_view_preference" withDefault:NO] + [self setBool:[lm lpConfigBoolForKey:@"enable_first_login_view_preference"] forKey:@"enable_first_login_view_preference"]; LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(lc); if (parsed != NULL) { diff --git a/Classes/LinphoneUI/TabBarView.m b/Classes/LinphoneUI/TabBarView.m index 9899e059c..ed3c10e1b 100644 --- a/Classes/LinphoneUI/TabBarView.m +++ b/Classes/LinphoneUI/TabBarView.m @@ -131,7 +131,7 @@ : -selectedNewFrame.size.height /*hide it if none is selected*/)))); } - CGFloat delay = [[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"] ? 0.3 : 0; + CGFloat delay = ANIMATED ? 0.3 : 0; [UIView animateWithDuration:delay animations:^{ _selectedButtonImage.frame = selectedNewFrame; diff --git a/Classes/LinphoneUI/UIBouncingView.m b/Classes/LinphoneUI/UIBouncingView.m index df2cf3490..9a6946596 100644 --- a/Classes/LinphoneUI/UIBouncingView.m +++ b/Classes/LinphoneUI/UIBouncingView.m @@ -34,7 +34,7 @@ INIT_WITH_COMMON_CF { } - (void)settingsUpdate:(NSNotification *)notif { - if ([[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"] == false) { + if (ANIMATED == false) { [self stopAnimating:NO]; } else { if (![self isHidden]) { @@ -105,7 +105,7 @@ INIT_WITH_COMMON_CF { } [self setHidden:FALSE]; - if ([[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"] == true) { + if (ANIMATED) { if (animated) { [self appearAnimation:kAppearAnimation target:self diff --git a/Classes/Log.h b/Classes/Log.h index becc2e538..b79034b48 100644 --- a/Classes/Log.h +++ b/Classes/Log.h @@ -26,8 +26,6 @@ #define LOGE(...) LOGV(ORTP_ERROR, __VA_ARGS__) #define LOGF(...) LOGV(ORTP_FATAL, __VA_ARGS__) -#define IPAD (LinphoneManager.runningOnIpad) - @interface LinphoneLogger : NSObject { } diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index f25ded396..36897925b 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -78,7 +78,7 @@ static RootViewManager *rootViewManagerInstance = nil; currentViewController = newMainView; LinphoneAppDelegate *delegate = (LinphoneAppDelegate *)[UIApplication sharedApplication].delegate; - if ([[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"] == true) { + if (ANIMATED) { [UIView transitionWithView:delegate.window duration:0.3 options:UIViewAnimationOptionTransitionFlipFromLeft | UIViewAnimationOptionAllowAnimatedContent @@ -544,14 +544,26 @@ static RootViewManager *rootViewManagerInstance = nil; [mainViewController setFullscreen:enabled]; } +- (UIViewController *)popCurrentView { + NSMutableArray *viewStack = [RootViewManager instance].viewDescriptionStack; + if ([viewStack count] > 1) { + LOGI(@"PhoneMainView: Popping view %@, going to %@", currentView, viewStack.lastObject); + [viewStack removeLastObject]; + [self _changeCurrentView:[viewStack lastObject] + transition:[PhoneMainView getBackwardTransition] + animated:ANIMATED]; + return [mainViewController getCurrentViewController]; + } + LOGW(@"PhoneMainView: Trying to pop view but none stacked!"); + return nil; +} + - (void)changeCurrentView:(UICompositeViewDescription *)view { [self changeCurrentView:view push:TRUE]; } - (void)changeCurrentView:(UICompositeViewDescription *)view push:(BOOL)push { - [self changeCurrentView:view - push:push - animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; + [self changeCurrentView:view push:push animated:ANIMATED]; } - (void)changeCurrentView:(UICompositeViewDescription *)view push:(BOOL)push animated:(BOOL)animated { @@ -562,24 +574,10 @@ static RootViewManager *rootViewManagerInstance = nil; [self _changeCurrentView:view transition:nil animated:animated]; } -- (BOOL)isUnauthorizedView:(UICompositeViewDescription *)view { - return [[LinphoneManager.instance lpConfigStringForKey:@"unauthorized_views"] containsString:view.name]; -} - - (UIViewController *)_changeCurrentView:(UICompositeViewDescription *)view transition:(CATransition *)transition animated:(BOOL)animated { PhoneMainView *vc = [[RootViewManager instance] setViewControllerForDescription:view]; - - if ([self isUnauthorizedView:view]) { - NSString *fallback = [LinphoneManager.instance lpConfigStringForKey:@"fallback_view"]; - UICompositeViewDescription *fallback_view = DialerView.compositeViewDescription; - if (fallback && [NSClassFromString(fallback) respondsToSelector:@selector(compositeViewDescription)]) { - fallback_view = [NSClassFromString(fallback) performSelector:@selector(compositeViewDescription)]; - } - LOGW(@"Trying to access unauthorized view %@, going back to %@", view.name, fallback_view.name); - view = fallback_view; - } if (![view equal:vc.currentView] || vc != self) { LOGI(@"Change current view to %@", view.name); if (animated && transition == nil) @@ -605,7 +603,7 @@ static RootViewManager *rootViewManagerInstance = nil; } return [self _changeCurrentView:[viewStack lastObject] transition:[PhoneMainView getBackwardTransition] - animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; + animated:ANIMATED]; } - (UICompositeViewDescription *)firstView { @@ -617,20 +615,6 @@ static RootViewManager *rootViewManagerInstance = nil; return view; } -- (UIViewController *)popCurrentView { - NSMutableArray *viewStack = [RootViewManager instance].viewDescriptionStack; - if ([viewStack count] > 1) { - LOGI(@"PhoneMainView: Pop view"); - [viewStack removeLastObject]; - [self _changeCurrentView:[viewStack lastObject] - transition:[PhoneMainView getBackwardTransition] - animated:[[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"]]; - return [mainViewController getCurrentViewController]; - } - LOGW(@"PhoneMainView: Trying to pop view but none stacked!"); - return nil; -} - - (void)displayCallError:(LinphoneCall *)call message:(NSString *)message { const char *lUserNameChars = linphone_address_get_username(linphone_call_get_remote_address(call)); NSString *lUserName = diff --git a/Classes/Utils/Utils.h b/Classes/Utils/Utils.h index af581620b..b39e90e45 100644 --- a/Classes/Utils/Utils.h +++ b/Classes/Utils/Utils.h @@ -19,6 +19,9 @@ #import "LinphoneManager.h" +#define IPAD (LinphoneManager.runningOnIpad) +#define ANIMATED ([LinphoneManager.instance lpConfigBoolForKey:@"animations_preference"]) + @interface LinphoneUtils : NSObject + (BOOL)findAndResignFirstResponder:(UIView*)view; diff --git a/Resources/linphonerc-factory b/Resources/linphonerc-factory index 77e05a713..b59c2071e 100644 --- a/Resources/linphonerc-factory +++ b/Resources/linphonerc-factory @@ -17,8 +17,6 @@ display_filter_auto_rotate=0 #contact_filter_on_default_domain=1 #use_phone_number=0 send_logs_include_linphonerc_and_chathistory=0 -fallback_view=DialerView -unauthorized_views=FirstView [assistant] username_regex=^[a-z0-9_.\-]*$