From 556f0fe9c4b23876b05d6422834bd1b018c9a5b0 Mon Sep 17 00:00:00 2001 From: siqi Date: Sun, 7 Jul 2013 01:41:53 +0200 Subject: auto start if slideshow is running Change-Id: I814971373827763a4ea9ede02ad245fb86369acb --- ios/iosremote/iosremote.xcodeproj/project.pbxproj | 28 +++++++----- .../UserInterfaceState.xcuserstate | Bin 25404 -> 27164 bytes .../iosremote/Communication/CommandInterpreter.m | 8 +++- .../iosremote/Communication/CommunicationManager.m | 3 +- .../en.lproj/MainStoryboard_iPhone.storyboard | 50 ++++++++++++++++----- ios/iosremote/iosremote/serverList_vc.m | 9 +++- ios/iosremote/iosremote/slideShowPreviewTable_vc.m | 19 ++++++++ ios/iosremote/iosremote/slideShow_vc.h | 1 + ios/iosremote/iosremote/slideShow_vc.m | 17 ++++++- 9 files changed, 109 insertions(+), 26 deletions(-) (limited to 'ios') diff --git a/ios/iosremote/iosremote.xcodeproj/project.pbxproj b/ios/iosremote/iosremote.xcodeproj/project.pbxproj index 3f41f43cf017..60a42bc0aa62 100644 --- a/ios/iosremote/iosremote.xcodeproj/project.pbxproj +++ b/ios/iosremote/iosremote.xcodeproj/project.pbxproj @@ -44,13 +44,13 @@ 5753DD8F1781EA0300DB71BB /* serverList_vc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = serverList_vc.m; sourceTree = ""; }; 5753DD9717834D7100DB71BB /* newServer_vc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = newServer_vc.h; sourceTree = ""; }; 5753DD9817834D7100DB71BB /* newServer_vc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = newServer_vc.m; sourceTree = ""; }; - 57867A531787172A00EBBE52 /* impress.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = impress.jpeg; sourceTree = ""; }; + 57867A531787172A00EBBE52 /* impress.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = impress.jpeg; path = iosremote/impress.jpeg; sourceTree = ""; }; 57867A551787385800EBBE52 /* slideShow_vc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = slideShow_vc.h; sourceTree = ""; }; 57867A561787385800EBBE52 /* slideShow_vc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = slideShow_vc.m; sourceTree = ""; }; - 57867A581787510700EBBE52 /* pushed_next_button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pushed_next_button.png; sourceTree = ""; }; - 57867A591787510700EBBE52 /* released_next_button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = released_next_button.png; sourceTree = ""; }; - 57867A5C178752CD00EBBE52 /* pushed_previous_button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pushed_previous_button.png; sourceTree = ""; }; - 57867A5D178752CD00EBBE52 /* released_previous_button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = released_previous_button.png; sourceTree = ""; }; + 57867A581787510700EBBE52 /* pushed_next_button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = pushed_next_button.png; path = iosremote/pushed_next_button.png; sourceTree = ""; }; + 57867A591787510700EBBE52 /* released_next_button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = released_next_button.png; path = iosremote/released_next_button.png; sourceTree = ""; }; + 57867A5C178752CD00EBBE52 /* pushed_previous_button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = pushed_previous_button.png; path = iosremote/pushed_previous_button.png; sourceTree = ""; }; + 57867A5D178752CD00EBBE52 /* released_previous_button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = released_previous_button.png; path = iosremote/released_previous_button.png; sourceTree = ""; }; 57B152971764703500EECC67 /* Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Base64.h; path = iosremote/Base64.h; sourceTree = ""; }; 57B152981764703500EECC67 /* Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Base64.m; path = iosremote/Base64.m; sourceTree = ""; }; 57B1529D176486C300EECC67 /* CommandTransmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandTransmitter.h; sourceTree = ""; }; @@ -105,9 +105,22 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 57AEEDAA1788D7B2007F4F97 /* Assets */ = { + isa = PBXGroup; + children = ( + 57867A581787510700EBBE52 /* pushed_next_button.png */, + 57867A591787510700EBBE52 /* released_next_button.png */, + 57867A5C178752CD00EBBE52 /* pushed_previous_button.png */, + 57867A5D178752CD00EBBE52 /* released_previous_button.png */, + 57867A531787172A00EBBE52 /* impress.jpeg */, + ); + name = Assets; + sourceTree = ""; + }; 57C6E3E6175E06E800E8BC5F = { isa = PBXGroup; children = ( + 57AEEDAA1788D7B2007F4F97 /* Assets */, BE9EBD061765BF0800283FD2 /* CoreImage.framework */, 57B152971764703500EECC67 /* Base64.h */, 57B152981764703500EECC67 /* Base64.m */, @@ -164,11 +177,6 @@ 57C6E3F9175E06E800E8BC5F /* Supporting Files */ = { isa = PBXGroup; children = ( - 57867A581787510700EBBE52 /* pushed_next_button.png */, - 57867A591787510700EBBE52 /* released_next_button.png */, - 57867A5C178752CD00EBBE52 /* pushed_previous_button.png */, - 57867A5D178752CD00EBBE52 /* released_previous_button.png */, - 57867A531787172A00EBBE52 /* impress.jpeg */, 57C6E3FA175E06E800E8BC5F /* iosremote-Info.plist */, 57C6E3FB175E06E800E8BC5F /* InfoPlist.strings */, 57C6E3FE175E06E800E8BC5F /* main.m */, diff --git a/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate b/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate index b24f87d1b9c5..cf19dc73e8ac 100644 Binary files a/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate and b/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ios/iosremote/iosremote/Communication/CommandInterpreter.m b/ios/iosremote/iosremote/Communication/CommandInterpreter.m index 4d184d49b0d7..27c93fdb1dd1 100644 --- a/ios/iosremote/iosremote/Communication/CommandInterpreter.m +++ b/ios/iosremote/iosremote/Communication/CommandInterpreter.m @@ -43,9 +43,15 @@ object:nil]; } else if ([instruction isEqualToString:STATUS_PAIRING_PAIRED]){ + NSLog(@"Paired command: %@", command); [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_PAIRING_PAIRED object:nil]; - // @TODO take care of the trailing slideshow_started&slideshow_finished + if ([command objectAtIndex:2] && [[command objectAtIndex:2] isEqualToString:@"slideshow_started"]){ + NSRange range; + range.location = 2; + range.length = [command count] - 2; + [self parse:[command subarrayWithRange:range]]; + } } else if([instruction isEqualToString:@"slideshow_started"]){ uint slideLength = [[command objectAtIndex:1] integerValue]; diff --git a/ios/iosremote/iosremote/Communication/CommunicationManager.m b/ios/iosremote/iosremote/Communication/CommunicationManager.m index 36753879d330..1ac878dfb4a1 100644 --- a/ios/iosremote/iosremote/Communication/CommunicationManager.m +++ b/ios/iosremote/iosremote/Communication/CommunicationManager.m @@ -49,7 +49,8 @@ - (void) connectionStatusHandler:(NSNotification *)note { - [self.delegate disableSpinner]; + if ([self.delegate respondsToSelector:@selector(disableSpinner)]) + [self.delegate disableSpinner]; if([[note name] isEqualToString:@"connection.status.connected"]){ if (self.state!=CONNECTED){ NSLog(@"Connected"); diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard index cf386715e764..5186c531bc75 100644 --- a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard +++ b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard @@ -205,7 +205,7 @@ - + @@ -252,30 +252,57 @@ - + + + + + + + + + + + + - + + - - + + + + - + + + - - - + + - + + + + @@ -438,7 +465,7 @@ - + YnBsaXN0MDDUAQIDBAUGPj9YJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK4HCBMU GR4fIyQsLzI4O1UkbnVsbNUJCgsMDQ4PEBESVk5TU2l6ZVYkY2xhc3NcTlNJbWFnZUZsYWdzVk5TUmVw @@ -4924,6 +4951,7 @@ AAAAAAAEAQAAAAAAAABCAAAAAAAAAAAAAAAAAAQO4w + diff --git a/ios/iosremote/iosremote/serverList_vc.m b/ios/iosremote/iosremote/serverList_vc.m index fb8b1203f218..44853f435e6c 100644 --- a/ios/iosremote/iosremote/serverList_vc.m +++ b/ios/iosremote/iosremote/serverList_vc.m @@ -54,7 +54,6 @@ self.serverTable.delegate = self; } - - (void) viewDidAppear:(BOOL)animated { NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; @@ -70,10 +69,15 @@ usingBlock:^(NSNotification *note) { [self performSegueWithIdentifier:@"SlideShowPreview" sender:self ]; }]; - [self.comManager setDelegate:self]; [super viewDidAppear:animated]; } +- (void) viewWillDisappear:(BOOL)animated +{ + [self disableSpinner]; + [super viewWillDisappear:animated]; +} + - (void) viewDidDisappear:(BOOL)animated { [[NSNotificationCenter defaultCenter] removeObserver:self.slideShowPreviewStartObserver]; @@ -84,6 +88,7 @@ -(void)viewWillAppear:(BOOL)animated { + [self.comManager setDelegate:self]; [self.serverTable reloadData]; [super viewWillAppear:animated]; } diff --git a/ios/iosremote/iosremote/slideShowPreviewTable_vc.m b/ios/iosremote/iosremote/slideShowPreviewTable_vc.m index 76f33443064e..9fc54d7022a8 100644 --- a/ios/iosremote/iosremote/slideShowPreviewTable_vc.m +++ b/ios/iosremote/iosremote/slideShowPreviewTable_vc.m @@ -25,6 +25,8 @@ @synthesize optionsTable = _optionsTable; @synthesize optionsArray = _optionsArray; +BOOL RUNNING = NO; + - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; @@ -46,10 +48,23 @@ self.optionsArray = [NSArray arrayWithObjects:@"Lecturer's Notes", @"Timer", @"Pointer", nil]; self.comManager = [CommunicationManager sharedComManager]; self.comManager.delegate = self; + NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; + self.slideShowStartObserver = [[NSNotificationCenter defaultCenter] addObserverForName:STATUS_CONNECTED_SLIDESHOW_RUNNING + object:nil + queue:mainQueue + usingBlock:^(NSNotification *note) { + RUNNING = YES; + }]; + } - (void) viewDidAppear:(BOOL)animated { + if (RUNNING){ + NSLog(@"Running..."); + RUNNING = NO; + [self.parentViewController performSegueWithIdentifier:@"slideShowSegue" sender:self]; + } NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; self.slideShowStartObserver = [[NSNotificationCenter defaultCenter] addObserverForName:STATUS_CONNECTED_SLIDESHOW_RUNNING object:nil @@ -63,6 +78,8 @@ - (void) viewDidDisappear:(BOOL)animated { [[NSNotificationCenter defaultCenter] removeObserver:self.slideShowStartObserver]; + self.slideShowStartObserver = nil; + RUNNING = NO; [super viewDidDisappear:animated]; } @@ -179,6 +196,8 @@ - (void)viewDidUnload { [self setOptionsTable:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self.slideShowStartObserver]; + self.slideShowStartObserver = nil; [super viewDidUnload]; } @end diff --git a/ios/iosremote/iosremote/slideShow_vc.h b/ios/iosremote/iosremote/slideShow_vc.h index fb6a3b251b08..44362cf467e3 100644 --- a/ios/iosremote/iosremote/slideShow_vc.h +++ b/ios/iosremote/iosremote/slideShow_vc.h @@ -15,5 +15,6 @@ @property (weak, nonatomic) IBOutlet UIWebView *lecturer_notes; @property (weak, nonatomic) IBOutlet UIImageView *slideView; +@property (weak, nonatomic) IBOutlet UILabel *slideNumber; @end diff --git a/ios/iosremote/iosremote/slideShow_vc.m b/ios/iosremote/iosremote/slideShow_vc.m index 8af3469f3d91..81872b1c1f07 100644 --- a/ios/iosremote/iosremote/slideShow_vc.m +++ b/ios/iosremote/iosremote/slideShow_vc.m @@ -46,8 +46,19 @@ [self.slideView setImage:[self.slideshow getImageAtIndex:self.slideshow.currentSlide]]; [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:self.slideshow.currentSlide]baseURL:nil]; + [self.slideNumber setText:[NSString stringWithFormat:@"%u/%u", [self.slideshow currentSlide]+1, [self.slideshow size]]]; - [self.lecturer_notes setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"lines.png"]]]; + UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"End" + style:UIBarButtonItemStyleBordered + target:self + action:@selector(handleBack:)]; + self.navigationItem.leftBarButtonItem = backButton; +} + +- (void) handleBack:(id)sender +{ + [self.comManager.transmitter stopPresentation]; + [self.navigationController popViewControllerAnimated:YES]; } @@ -64,6 +75,9 @@ [self.slideView setImage:[self.slideshow getImageAtIndex:self.slideshow.currentSlide]]; [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:self.slideshow.currentSlide]baseURL:nil]; + + [self.slideNumber setText:[NSString stringWithFormat:@"%u/%u", [self.slideshow currentSlide]+1, [self.slideshow size]]]; + }]; self.slideShowFinishedObserver = [center addObserverForName:STATUS_CONNECTED_NOSLIDESHOW @@ -93,6 +107,7 @@ - (void)viewDidUnload { [self setLecturer_notes:nil]; [self setSlideView:nil]; + [self setSlideNumber:nil]; [super viewDidUnload]; } -- cgit