From 851dbab39084af7533fba2512e80e55ce8524d92 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 1 Feb 2012 14:52:17 +0100 Subject: [PATCH] New UI --- Classes/BuschJaegerMainView.h | 19 +-- Classes/BuschJaegerMainView.m | 86 +++++++++---- Classes/BuschJaegerMainView.xib | 211 ++++++++++++++++++++------------ 3 files changed, 210 insertions(+), 106 deletions(-) diff --git a/Classes/BuschJaegerMainView.h b/Classes/BuschJaegerMainView.h index 00dff40d1..aaa562b47 100644 --- a/Classes/BuschJaegerMainView.h +++ b/Classes/BuschJaegerMainView.h @@ -30,22 +30,27 @@ UIView* videoView; UIImageView* imageView; UIButton* startCall; - UIHangUpButton* stopCall; - UIHangUpButton* declineCall; + UIButton* takeCall; + UIHangUpButton* decline; + UIHangUpButton* endOrRejectCall; UIToggleButton* mute; - UILightButton* lights; + UIDigitButton* lights; UIDigitButton* openDoor; } @property (nonatomic, retain) IBOutlet UIView* videoView; @property (nonatomic, retain) IBOutlet UIImageView* imageView; @property (nonatomic, retain) IBOutlet UIButton* startCall; -@property (nonatomic, retain) IBOutlet UIHangUpButton* stopCall; -@property (nonatomic, retain) IBOutlet UIHangUpButton* declineCall; +@property (nonatomic, retain) IBOutlet UIButton* takeCall; +@property (nonatomic, retain) IBOutlet UIHangUpButton* decline; +@property (nonatomic, retain) IBOutlet UIHangUpButton* endOrRejectCall; @property (nonatomic, retain) IBOutlet UIToggleButton* mute; -@property (nonatomic, retain) IBOutlet UILightButton* lights; +@property (nonatomic, retain) IBOutlet UIDigitButton* lights; @property (nonatomic, retain) IBOutlet UIDigitButton* openDoor; +@property (nonatomic, retain) IBOutlet UIView* dialerControls; +@property (nonatomic, retain) IBOutlet UIView* incallControls; -- (IBAction)acceptCall:(id)sender; +- (IBAction)takeCall:(id)sender; +- (IBAction)startCall:(id)sender; @end diff --git a/Classes/BuschJaegerMainView.m b/Classes/BuschJaegerMainView.m index 4104b129a..63859381f 100644 --- a/Classes/BuschJaegerMainView.m +++ b/Classes/BuschJaegerMainView.m @@ -19,14 +19,16 @@ #import "BuschJaegerMainView.h" #include "linphonecore.h" +#import @implementation BuschJaegerMainView @synthesize videoView; @synthesize imageView; @synthesize startCall; -@synthesize stopCall; -@synthesize declineCall; +@synthesize takeCall; +@synthesize decline; +@synthesize endOrRejectCall; @synthesize mute; @synthesize lights; @synthesize openDoor; @@ -39,12 +41,43 @@ #pragma mark - View lifecycle +-(void) createGradientForButton:(UIButton*) button withTopColor:(UIColor*)topColor bottomColor:(UIColor*)bottomColor { + CAGradientLayer* gradient = [CAGradientLayer layer]; + gradient.frame = button.bounds; + gradient.colors = [NSArray arrayWithObjects:topColor.CGColor, bottomColor.CGColor, nil]; + [button.layer insertSublayer:gradient below:button.imageView.layer]; +} + - (void)viewDidLoad { [super viewDidLoad]; [openDoor initWithNumber:'1']; - [lights initWithOnImage:[UIImage imageNamed:@"icon5"] offImage:[UIImage imageNamed:@"icon6"] debugName:"LIGHT_BTN"]; + [lights initWithNumber:'2']; + + /* init gradients */ + { + UIColor* col1 = [UIColor colorWithRed:32.0/255 green:45.0/255 blue:62.0/255 alpha:1.0]; + UIColor* col2 = [UIColor colorWithRed:18.0/255 green:26.0/255 blue:41.0/255 alpha:1.0]; + + [self createGradientForButton:startCall withTopColor:col1 bottomColor:col2]; + [self createGradientForButton:openDoor withTopColor:col1 bottomColor:col2]; + [self createGradientForButton:lights withTopColor:col1 bottomColor:col2]; + [self createGradientForButton:mute withTopColor:col1 bottomColor:col2]; + } + { + UIColor* col1 = [UIColor colorWithRed:153.0/255 green:48.0/255 blue:48.0/255 alpha:1.0]; + UIColor* col2 = [UIColor colorWithRed:66.0/255 green:15.0/255 blue:15.0/255 alpha:1.0]; + + [self createGradientForButton:endOrRejectCall withTopColor:col1 bottomColor:col2]; + [self createGradientForButton:decline withTopColor:col1 bottomColor:col2]; + } + { + UIColor* col1 = [UIColor colorWithRed:91.0/255 green:161.0/255 blue:89.0/255 alpha:1.0]; + UIColor* col2 = [UIColor colorWithRed:25.0/255 green:54.0/255 blue:24.0/255 alpha:1.0]; + + [self createGradientForButton:takeCall withTopColor:col1 bottomColor:col2]; + } } - (void)viewDidUnload @@ -63,6 +96,12 @@ - (void) viewDidAppear:(BOOL)animated { [[LinphoneManager instance] setRegistrationDelegate:self]; [[UIApplication sharedApplication] setIdleTimerDisabled:NO]; + + [LinphoneManager set:startCall hidden:NO withName:"START_CALL_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:takeCall hidden:YES withName:"START_CALL_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:mute hidden:NO withName:"MUTE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:decline hidden:YES withName:"DECLINE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:endOrRejectCall hidden:YES withName:"END_BTN" andReason:__FUNCTION__]; } - (void) displayCall:(LinphoneCall *)call InProgressFromUI:(UIViewController *)viewCtrl forUser:(NSString *)username withDisplayName:(NSString *)displayName { @@ -71,21 +110,30 @@ } - (void) displayDialerFromUI:(UIViewController *)viewCtrl forUser:(NSString *)username withDisplayName:(NSString *)displayName { - [LinphoneManager set:stopCall hidden:YES withName:"STOP_CALL_BTN" andReason:__FUNCTION__]; [LinphoneManager set:startCall hidden:NO withName:"START_CALL_BTN" andReason:__FUNCTION__]; - [LinphoneManager set:videoView hidden:YES withName:"VIDEO_VIEW" andReason:__FUNCTION__]; - [LinphoneManager set:declineCall hidden:YES withName:"DECLINE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:takeCall hidden:YES withName:"START_CALL_BTN" andReason:__FUNCTION__]; [LinphoneManager set:mute hidden:NO withName:"MUTE_BTN" andReason:__FUNCTION__]; - - // [LinphoneManager set:imageView hidden:NO withName:"IMAGE_VIEW" andReason:__FUNCTION__]; + [LinphoneManager set:decline hidden:YES withName:"DECLINE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:endOrRejectCall hidden:YES withName:"END_BTN" andReason:__FUNCTION__]; + [[UIApplication sharedApplication] setIdleTimerDisabled:NO]; } - (void) displayInCall:(LinphoneCall *)call FromUI:(UIViewController *)viewCtrl forUser:(NSString *)username withDisplayName:(NSString *)displayName { - + [LinphoneManager set:startCall hidden:YES withName:"START_CALL_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:takeCall hidden:YES withName:"START_CALL_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:mute hidden:NO withName:"MUTE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:decline hidden:YES withName:"DECLINE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:endOrRejectCall hidden:NO withName:"END_BTN" andReason:__FUNCTION__]; } - (void) displayIncomingCall:(LinphoneCall *)call NotificationFromUI:(UIViewController *)viewCtrl forUser:(NSString *)username withDisplayName:(NSString *)displayName { + [LinphoneManager set:startCall hidden:YES withName:"START_CALL_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:takeCall hidden:NO withName:"START_CALL_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:mute hidden:YES withName:"MUTE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:decline hidden:NO withName:"DECLINE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:endOrRejectCall hidden:YES withName:"END_BTN" andReason:__FUNCTION__]; + if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] && [UIApplication sharedApplication].applicationState != UIApplicationStateActive) { // Create a new notification @@ -102,22 +150,16 @@ [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; } } - - [LinphoneManager set:stopCall hidden:YES withName:"STOP_CALL_BTN" andReason:__FUNCTION__]; - [LinphoneManager set:startCall hidden:NO withName:"START_CALL_BTN" andReason:__FUNCTION__]; - [LinphoneManager set:videoView hidden:NO withName:"VIDEO_VIEW" andReason:__FUNCTION__]; - [LinphoneManager set:declineCall hidden:NO withName:"DECLINE_BTN" andReason:__FUNCTION__]; - [LinphoneManager set:mute hidden:YES withName:"MUTE_BTN" andReason:__FUNCTION__]; - + linphone_call_enable_camera(call, FALSE); } - (void) displayVideoCall:(LinphoneCall *)call FromUI:(UIViewController *)viewCtrl forUser:(NSString *)username withDisplayName:(NSString *)displayName { - [LinphoneManager set:stopCall hidden:NO withName:"STOP_CALL_BTN" andReason:__FUNCTION__]; [LinphoneManager set:startCall hidden:YES withName:"START_CALL_BTN" andReason:__FUNCTION__]; - [LinphoneManager set:videoView hidden:NO withName:"VIDEO_VIEW" andReason:__FUNCTION__]; - [LinphoneManager set:declineCall hidden:YES withName:"DECLINE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:takeCall hidden:YES withName:"START_CALL_BTN" andReason:__FUNCTION__]; [LinphoneManager set:mute hidden:NO withName:"MUTE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:decline hidden:YES withName:"DECLINE_BTN" andReason:__FUNCTION__]; + [LinphoneManager set:endOrRejectCall hidden:NO withName:"END_BTN" andReason:__FUNCTION__]; } - (void) displayStatus:(NSString *)message { @@ -144,7 +186,7 @@ } -- (IBAction)acceptCall:(id)sender { +- (IBAction)takeCall:(id)sender { const MSList* calls = linphone_core_get_calls([LinphoneManager getLc]); while(calls) { @@ -155,7 +197,9 @@ } calls = calls->next; } - +} + +- (IBAction)startCall:(id)sender { // no pending call, call adapter NSString* s = [NSString stringWithFormat:@"sip:100000001@%@", [[NSUserDefaults standardUserDefaults] stringForKey:@"adapter_ip_preference"]]; const char* adapter = [s cStringUsingEncoding:[NSString defaultCStringEncoding]]; diff --git a/Classes/BuschJaegerMainView.xib b/Classes/BuschJaegerMainView.xib index e877cbc0d..5c5b34312 100644 --- a/Classes/BuschJaegerMainView.xib +++ b/Classes/BuschJaegerMainView.xib @@ -11,13 +11,13 @@ 933 - IBUIView IBProxyObject + IBUIImageView IBUIViewController IBUICustomObject - IBUIImageView - IBUIWindow IBUIButton + IBUIWindow + IBUIView com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -57,11 +57,11 @@ - -2147483374 + 274 {320, 431} - + _NS:196 3 @@ -80,9 +80,9 @@ _NS:225 - - 1 - MC40Mjc0NTA5ODA0IDAuODUwOTgwMzkyMiAwLjA4NjI3NDUwOTgAA + + 3 + MCAwAA NO IBCocoaTouchFramework @@ -100,7 +100,7 @@ 3 MC41AA - + NSImage icon1.png @@ -114,6 +114,29 @@ 16 + + + 292 + {{0, 432}, {79, 48}} + + + + _NS:225 + + NO + IBCocoaTouchFramework + 0 + 0 + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + + + -2147483356 @@ -122,10 +145,7 @@ _NS:225 - - 1 - MC43MDEzNDE3MTIgMC4wOTg1MDMwODEzNCAwAA - + NO IBCocoaTouchFramework 0 @@ -151,10 +171,7 @@ _NS:225 - - 2 - MC4wNTQ5MDE5NjA3OCAwLjA4MjM1Mjk0MTE4IDAuMTI5NDExNzY0NwA - + NO IBCocoaTouchFramework 0 @@ -181,7 +198,7 @@ _NS:225 - + NO IBCocoaTouchFramework 0 @@ -191,10 +208,11 @@ - + NSImage icon5.png + NSImage icon6.png @@ -210,7 +228,7 @@ _NS:225 - + NO IBCocoaTouchFramework 0 @@ -233,7 +251,7 @@ _NS:225 - + NO IBCocoaTouchFramework 0 @@ -297,12 +315,12 @@ - acceptCall: + startCall: 7 - 42 + 63 @@ -341,11 +359,11 @@ - lights + imageView - + - 31 + 30 @@ -355,6 +373,14 @@ 32 + + + lights + + + + 31 + openDoor @@ -363,14 +389,6 @@ 33 - - - stopCall - - - - 35 - startCall @@ -381,19 +399,27 @@ - declineCall + decline - 45 + 59 - imageView + endOrRejectCall - + - 30 + 60 + + + + takeCall + + + + 61 @@ -420,6 +446,15 @@ 44 + + + takeCall: + + + 7 + + 62 + @@ -471,6 +506,7 @@ + @@ -481,10 +517,15 @@ VideoView - 10 - + 12 + - Light + + + 7 + + + StopCall 9 @@ -492,18 +533,18 @@ Mute + + 10 + + + Light + 8 OpenDoor - - 7 - - - StopCall - 6 @@ -517,9 +558,10 @@ Decline call - 12 - + 57 + + AcceptCall @@ -529,7 +571,7 @@ UIResponder com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - UILightButton + UIDigitButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin IBBuiltInLabel-Red @@ -544,6 +586,9 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin IBBuiltInLabel-Red + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + IBBuiltInLabel-Red com.apple.InterfaceBuilder.IBCocoaTouchPlugin IBBuiltInLabel-Red @@ -563,7 +608,7 @@ - 45 + 63 @@ -592,39 +637,57 @@ BuschJaegerMainView UIViewController - - acceptCall: - id - - - acceptCall: - - acceptCall: + + id + id + + + + startCall: id - + + takeCall: + id + + - UIHangUpButton + UIHangUpButton + UIView + UIHangUpButton UIImageView - UILightButton + UIView + UIDigitButton UIToggleButton UIDigitButton UIButton - UIHangUpButton + UIButton UIView - - declineCall + + decline + UIHangUpButton + + + dialerControls + UIView + + + endOrRejectCall UIHangUpButton imageView UIImageView + + incallControls + UIView + lights - UILightButton + UIDigitButton mute @@ -638,9 +701,9 @@ startCall UIButton - - stopCall - UIHangUpButton + + takeCall + UIButton videoView @@ -850,14 +913,6 @@ ./Classes/UIHangUpButton.h - - UILightButton - UIToggleButton - - IBProjectSource - ./Classes/UILightButton.h - - UIMuteButton UIToggleButton