diff options
author | siqi <me@siqi.fr> | 2013-07-06 12:43:20 +0200 |
---|---|---|
committer | siqi <me@siqi.fr> | 2013-07-06 12:48:08 +0200 |
commit | eb25bb6dc4273bb6fc8511b751092899d545dcae (patch) | |
tree | 14e23777a510f2cfe42b6f8d753a36ffc69f612d /ios | |
parent | conflict (diff) | |
download | core-eb25bb6dc4273bb6fc8511b751092899d545dcae.tar.gz core-eb25bb6dc4273bb6fc8511b751092899d545dcae.zip |
various bug fixes & slideshow control pad
Change-Id: I4bda3506f3c37be12795c9ed5787df1e7ced9014
Diffstat (limited to 'ios')
-rw-r--r-- | ios/iosremote/.DS_Store | bin | 6148 -> 6148 bytes | |||
-rw-r--r-- | ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate | bin | 24288 -> 24273 bytes | |||
-rw-r--r-- | ios/iosremote/iosremote/Communication/Client.m | 2 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/CommandInterpreter.m | 24 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/SlideShow.h | 2 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/SlideShow.m | 44 | ||||
-rw-r--r-- | ios/iosremote/iosremote/Communication/pinValidation_vc.m | 20 | ||||
-rw-r--r-- | ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard | 32 | ||||
-rw-r--r-- | ios/iosremote/iosremote/serverList_vc.m | 25 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShowPreviewTable_vc.m | 21 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShowPreview_vc.h | 4 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShowPreview_vc.m | 26 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShow_vc.h | 3 | ||||
-rw-r--r-- | ios/iosremote/iosremote/slideShow_vc.m | 46 |
14 files changed, 159 insertions, 90 deletions
diff --git a/ios/iosremote/.DS_Store b/ios/iosremote/.DS_Store Binary files differindex 9940e912eb0c..eb479088abb0 100644 --- a/ios/iosremote/.DS_Store +++ b/ios/iosremote/.DS_Store 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 Binary files differindex 3c57b1fc40b0..ad798160caca 100644 --- a/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate +++ b/ios/iosremote/iosremote.xcodeproj/project.xcworkspace/xcuserdata/siqi.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/ios/iosremote/iosremote/Communication/Client.m b/ios/iosremote/iosremote/Communication/Client.m index a75bc6fcb5c3..c3cbb935fe11 100644 --- a/ios/iosremote/iosremote/Communication/Client.m +++ b/ios/iosremote/iosremote/Communication/Client.m @@ -175,7 +175,7 @@ int count = 0; case NSStreamEventHasBytesAvailable: { NSMutableData* data; - NSLog(@"NSStreamEventHasBytesAvailable"); +// NSLog(@"NSStreamEventHasBytesAvailable"); if(!data) { data = [[NSMutableData alloc] init]; } diff --git a/ios/iosremote/iosremote/Communication/CommandInterpreter.m b/ios/iosremote/iosremote/Communication/CommandInterpreter.m index f66e624b1677..5fc831d13310 100644 --- a/ios/iosremote/iosremote/Communication/CommandInterpreter.m +++ b/ios/iosremote/iosremote/Communication/CommandInterpreter.m @@ -20,10 +20,11 @@ @synthesize slideShow = _slideShow; -- (SlideShow*) slideshow{ - if (!self.slideShow) - self.slideShow = [[SlideShow alloc] init]; - return self.slideShow; +- (CommandInterpreter *) init +{ + self = [super init]; + self.slideShow = [[SlideShow alloc] init]; + return self; } - (BOOL) isSlideRunning { @@ -44,12 +45,12 @@ else if ([instruction isEqualToString:STATUS_PAIRING_PAIRED]){ [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_PAIRING_PAIRED object:nil]; + // @TODO take care of the trailing slideshow_started&slideshow_finished } else if([instruction isEqualToString:@"slideshow_started"]){ - NSLog(@"Interpreter: slideshow_started"); uint slideLength = [[command objectAtIndex:1] integerValue]; uint currentSlide = [[command objectAtIndex:2] integerValue]; - self.slideShow = [[SlideShow alloc] init]; + NSLog(@"Interpreter: slideshow_started with currentSlide: %u slideLength: %u", currentSlide, slideLength); [self.slideShow setSize:slideLength]; [self.slideShow setCurrentSlide:currentSlide]; @@ -63,8 +64,6 @@ self.slideShow = [[SlideShow alloc] init]; [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_CONNECTED_NOSLIDESHOW object:nil]; } else { - if (self.slideShow == nil) - return; if ([instruction isEqualToString:@"slide_updated"]) { NSLog(@"Interpreter: slide_updated"); uint newSlideNumber = [[command objectAtIndex:1] integerValue]; @@ -76,11 +75,18 @@ NSLog(@"Interpreter: slide_preview"); uint slideNumber = [[command objectAtIndex:1] integerValue]; NSString * imageData = [command objectAtIndex:2]; - [self.slideShow putImage:imageData AtIndex:slideNumber]; [[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_PREVIEW object:[NSNumber numberWithUnsignedInt:slideNumber]]; + if ([[command objectAtIndex:4] isEqualToString:@"slide_notes"]) + { + NSRange range; + range.location = 4; + range.length = [command count] - 4; + [self parse:[command subarrayWithRange:range]]; + } } else if ([instruction isEqualToString:@"slide_notes"]){ + NSLog(@"Interpreter: slide_notes"); uint slideNumber = [[command objectAtIndex:1] integerValue]; NSMutableString *notes = [[NSMutableString alloc] init]; for (int i = 2; i<command.count; ++i) { diff --git a/ios/iosremote/iosremote/Communication/SlideShow.h b/ios/iosremote/iosremote/Communication/SlideShow.h index 8d89533212e5..e49ba3f9e42d 100644 --- a/ios/iosremote/iosremote/Communication/SlideShow.h +++ b/ios/iosremote/iosremote/Communication/SlideShow.h @@ -15,7 +15,7 @@ @property uint size; @property uint currentSlide; -@property (nonatomic, strong) slideShowPreview_vc* delegate; +@property (nonatomic, strong) id delegate; - (void) putImage: (NSString *)img AtIndex: (uint) index; - (void) putNotes: (NSString *)notes AtIndex: (uint) index; diff --git a/ios/iosremote/iosremote/Communication/SlideShow.m b/ios/iosremote/iosremote/Communication/SlideShow.m index 70485695e75f..b06429eafbc8 100644 --- a/ios/iosremote/iosremote/Communication/SlideShow.m +++ b/ios/iosremote/iosremote/Communication/SlideShow.m @@ -9,7 +9,7 @@ #import "SlideShow.h" #import "Base64.h" -#import "slideShowPreview_vc.h" +#import "slideShow_vc.h" #import <dispatch/dispatch.h> @interface SlideShow() @@ -39,28 +39,30 @@ dispatch_queue_t backgroundQueue; _currentSlide = 0; backgroundQueue = dispatch_queue_create("org.libreoffice.iosremote.bgqueue", NULL); -// NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; + NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; -// self.slideShowImageReadyObserver =[[NSNotificationCenter defaultCenter] -// addObserverForName:@"storage_update_image_ready" -// object:nil -// queue:mainQueue -// usingBlock:^(NSNotification *note) { -// if ([[[note userInfo] objectForKey:@"index"] intValue] == self.lastRequestedImage) { -// [self.delegate.image setImage:[self getImageAtIndex:self.lastRequestedImage]]; -// self.lastRequestedImage = -1; -// } -// }]; + self.slideShowImageReadyObserver =[[NSNotificationCenter defaultCenter] + addObserverForName:@"storage_update_image_ready" + object:nil + queue:mainQueue + usingBlock:^(NSNotification *note) { + if ([[[note userInfo] objectForKey:@"index"] intValue] == self.lastRequestedImage) { +// NSLog(@"Load last requsted image"); + [[self.delegate slideView] setImage:[self getImageAtIndex:self.lastRequestedImage]]; + self.lastRequestedImage = -1; + } + }]; -// self.slideShowNoteReadyObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"storage_update_note_ready" -// object:nil -// queue:mainQueue -// usingBlock:^(NSNotification *note) { -// if ([[[note userInfo] objectForKey:@"index"] intValue] == self.lastRequestedNote) { -// [self.delegate.lecturer_notes loadHTMLString:[self getNotesAtIndex:self.lastRequestedNote] baseURL:nil]; -// self.lastRequestedNote = -1; -// } -// }]; + self.slideShowNoteReadyObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"storage_update_note_ready" + object:nil + queue:mainQueue + usingBlock:^(NSNotification *note) { +// NSLog(@"Load last requsted note"); + if ([[[note userInfo] objectForKey:@"index"] intValue] == self.lastRequestedNote) { + [[self.delegate lecturer_notes] loadHTMLString:[self getNotesAtIndex:self.lastRequestedNote] baseURL:nil]; + self.lastRequestedNote = -1; + } + }]; return self; } diff --git a/ios/iosremote/iosremote/Communication/pinValidation_vc.m b/ios/iosremote/iosremote/Communication/pinValidation_vc.m index 6c81043c14df..7a8c4d83ed36 100644 --- a/ios/iosremote/iosremote/Communication/pinValidation_vc.m +++ b/ios/iosremote/iosremote/Communication/pinValidation_vc.m @@ -39,6 +39,10 @@ // Do any additional setup after loading the view. self.comManager = [CommunicationManager sharedComManager]; [self.pinLabel setText:[NSString stringWithFormat:@"%@", [self.comManager getPairingPin]]]; +} + +- (void) viewDidAppear:(BOOL)animated +{ NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; self.slideShowPreviewStartObserver = [[NSNotificationCenter defaultCenter] addObserverForName:STATUS_PAIRING_PAIRED object:nil @@ -46,15 +50,15 @@ usingBlock:^(NSNotification *note) { [self performSegueWithIdentifier:@"pinValidated" sender:self ]; }]; + [super viewDidAppear:animated]; } -// -//- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ -// if ([segue.identifier isEqualToString:@"pinValidated"]) { -// slideShowPreview_vc *destViewController = segue.destinationViewController; -// destViewController.slideshow = [self.comManager.interpreter slideShow]; -// [destViewController.slideshow setDelegate:destViewController]; -// } -//} + +- (void) viewDidDisappear:(BOOL)animated +{ + [[NSNotificationCenter defaultCenter] removeObserver:self.slideShowPreviewStartObserver]; + [super viewDidDisappear:animated]; +} + - (void)didReceiveMemoryWarning { diff --git a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard index 2c477f85765b..28cf722aef00 100644 --- a/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard +++ b/ios/iosremote/iosremote/en.lproj/MainStoryboard_iPhone.storyboard @@ -194,21 +194,13 @@ <rect key="frame" x="0.0" y="64" width="320" height="504"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <subviews> - <imageView userInteractionEnabled="NO" contentMode="scaleToFill" id="bZq-z2-OKU"> + <imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" id="bZq-z2-OKU"> <rect key="frame" x="0.0" y="20" width="320" height="177"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/> </imageView> - <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="811-qk-UdS"> - <rect key="frame" x="20" y="317" width="280" height="167"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> - <string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string> - <fontDescription key="fontDescription" type="system" pointSize="14"/> - <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/> - </textView> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="XDZ-bs-OUM"> <rect key="frame" x="227" y="221" width="61" height="61"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/> <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/> <state key="normal" backgroundImage="released_next_button.png"> <color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/> @@ -236,17 +228,23 @@ <action selector="previousSlideAction:" destination="Ivv-3X-Nhr" eventType="touchUpInside" id="DAf-Qp-7KW"/> </connections> </button> + <webView contentMode="scaleToFill" id="xGi-A7-hat"> + <rect key="frame" x="20" y="333" width="280" height="151"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/> + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> + </webView> </subviews> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> </view> <navigationItem key="navigationItem" id="T79-lT-61m"/> <connections> - <outlet property="nextBtn" destination="XDZ-bs-OUM" id="tcL-xX-S8l"/> + <outlet property="lecturer_notes" destination="xGi-A7-hat" id="Cng-HM-0wW"/> + <outlet property="slideView" destination="bZq-z2-OKU" id="yu0-P8-F3v"/> </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="Uei-nM-J1S" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="620" y="1208"/> + <point key="canvasLocation" x="620" y="1109"/> </scene> <!--Slide Show Preview Table vc--> <scene sceneID="Tvi-bD-vMC"> @@ -300,7 +298,7 @@ </tableViewController> <placeholder placeholderIdentifier="IBFirstResponder" id="z5S-eI-1pb" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="1133" y="590"/> + <point key="canvasLocation" x="1133" y="648"/> </scene> <!--Navigation Controller--> <scene sceneID="yRe-s4-oKK"> @@ -323,7 +321,6 @@ <!--View Controller--> <scene sceneID="kRQ-fB-NKx"> <objects> - <placeholder placeholderIdentifier="IBFirstResponder" id="uCa-zh-PLh" userLabel="First Responder" sceneMemberID="firstResponder"/> <viewController id="HMh-Ba-7X9" sceneMemberID="viewController"> <view key="view" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="Swz-wK-30Z"> <rect key="frame" x="0.0" y="0.0" width="320" height="197"/> @@ -369,6 +366,7 @@ </view> <toolbarItems/> </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="uCa-zh-PLh" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> <point key="canvasLocation" x="1133" y="272"/> </scene> @@ -414,6 +412,8 @@ <relationships> <relationship kind="action" name="nextSlideAction:"/> <relationship kind="action" name="previousSlideAction:"/> + <relationship kind="outlet" name="lecturer_notes" candidateClass="UIWebView"/> + <relationship kind="outlet" name="slideView" candidateClass="UIImageView"/> </relationships> </class> </classes> @@ -425,4 +425,4 @@ <inferredMetricsTieBreakers> <segue reference="geL-Q8-f61"/> </inferredMetricsTieBreakers> -</document> +</document>
\ No newline at end of file diff --git a/ios/iosremote/iosremote/serverList_vc.m b/ios/iosremote/iosremote/serverList_vc.m index 141cadd7ed32..8433f55f61ca 100644 --- a/ios/iosremote/iosremote/serverList_vc.m +++ b/ios/iosremote/iosremote/serverList_vc.m @@ -52,22 +52,35 @@ self.comManager = [CommunicationManager sharedComManager]; self.serverTable.dataSource = self; self.serverTable.delegate = self; - +} + + +- (void) viewDidAppear:(BOOL)animated +{ NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; self.pinValidationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:STATUS_PAIRING_PINVALIDATION - object:nil - queue:mainQueue - usingBlock:^(NSNotification *note) { - [self performSegueWithIdentifier:@"pinValidation" sender:self ]; - }]; + object:nil + queue:mainQueue + usingBlock:^(NSNotification *note) { + [self performSegueWithIdentifier:@"pinValidation" sender:self ]; + }]; self.slideShowPreviewStartObserver = [[NSNotificationCenter defaultCenter] addObserverForName:STATUS_PAIRING_PAIRED object:nil queue:mainQueue usingBlock:^(NSNotification *note) { [self performSegueWithIdentifier:@"SlideShowPreview" sender:self ]; }]; + [super viewDidAppear:animated]; +} + +- (void) viewDidDisappear:(BOOL)animated +{ + [[NSNotificationCenter defaultCenter] removeObserver:self.slideShowPreviewStartObserver]; + [[NSNotificationCenter defaultCenter] removeObserver:self.pinValidationObserver]; + [super viewDidDisappear:animated]; } + -(void)viewWillAppear:(BOOL)animated { [self.serverTable reloadData]; diff --git a/ios/iosremote/iosremote/slideShowPreviewTable_vc.m b/ios/iosremote/iosremote/slideShowPreviewTable_vc.m index 0e3a5f619a26..76f33443064e 100644 --- a/ios/iosremote/iosremote/slideShowPreviewTable_vc.m +++ b/ios/iosremote/iosremote/slideShowPreviewTable_vc.m @@ -15,6 +15,8 @@ @property (nonatomic, weak) UIButton * startButton; @property (nonatomic, strong) NSArray * optionsArray; @property (nonatomic, strong) CommunicationManager * comManager; +@property (nonatomic, strong) id slideShowStartObserver; + @end @implementation slideShowPreviewTable_vc @@ -44,6 +46,24 @@ self.optionsArray = [NSArray arrayWithObjects:@"Lecturer's Notes", @"Timer", @"Pointer", nil]; self.comManager = [CommunicationManager sharedComManager]; self.comManager.delegate = self; + } + +- (void) viewDidAppear:(BOOL)animated +{ + NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; + self.slideShowStartObserver = [[NSNotificationCenter defaultCenter] addObserverForName:STATUS_CONNECTED_SLIDESHOW_RUNNING + object:nil + queue:mainQueue + usingBlock:^(NSNotification *note) { + [self.parentViewController performSegueWithIdentifier:@"slideShowSegue" sender:self]; + }]; + [super viewDidAppear:animated]; +} + +- (void) viewDidDisappear:(BOOL)animated +{ + [[NSNotificationCenter defaultCenter] removeObserver:self.slideShowStartObserver]; + [super viewDidDisappear:animated]; } - (void)didReceiveMemoryWarning @@ -118,7 +138,6 @@ -(IBAction)startPresentationAction:(id)sender { [[self.comManager transmitter] startPresentation]; - [self performSegueWithIdentifier:@"slideShowSegue" sender:self]; } - (UIButton *)startButton{ diff --git a/ios/iosremote/iosremote/slideShowPreview_vc.h b/ios/iosremote/iosremote/slideShowPreview_vc.h index b00a5065e500..ffa198b927b3 100644 --- a/ios/iosremote/iosremote/slideShowPreview_vc.h +++ b/ios/iosremote/iosremote/slideShowPreview_vc.h @@ -12,8 +12,4 @@ @interface slideShowPreview_vc : UITableViewController -@property (nonatomic, strong) SlideShow* slideshow; -@property (nonatomic, strong) id slideShowImageReadyObserver; -@property (nonatomic, strong) id slideShowNoteReadyObserver; - @end diff --git a/ios/iosremote/iosremote/slideShowPreview_vc.m b/ios/iosremote/iosremote/slideShowPreview_vc.m index 1090f8f61287..fa986e595331 100644 --- a/ios/iosremote/iosremote/slideShowPreview_vc.m +++ b/ios/iosremote/iosremote/slideShowPreview_vc.m @@ -8,19 +8,19 @@ #import "slideShowPreview_vc.h" #import "SlideShow.h" +#import "CommandInterpreter.h" #import "CommunicationManager.h" @interface slideShowPreview_vc () @property (nonatomic, strong) CommunicationManager* comManager; +@property (nonatomic, strong) SlideShow* slideshow; @end @implementation slideShowPreview_vc @synthesize slideshow = _slideshow; -@synthesize slideShowImageReadyObserver = _slideShowImageReadyObserver; -@synthesize slideShowNoteReadyObserver = _slideShowNoteReadyObserver; @synthesize comManager = _comManager; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil @@ -36,28 +36,8 @@ { [super viewDidLoad]; // Do any additional setup after loading the view. -// NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; -// NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; - -// self.slideShowImageReadyObserver =[center addObserverForName:MSG_SLIDE_CHANGED -// object:nil -// queue:mainQueue -// usingBlock:^(NSNotification *note) { -// NSLog(@"Getting slide: %u image to display: %@", self.slideshow.currentSlide, [self.slideshow getImageAtIndex:self.slideshow.currentSlide]); -// -// [self.image setImage:[self.slideshow getImageAtIndex:self.slideshow.currentSlide]]; -// [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:self.slideshow.currentSlide]baseURL:nil]; -// }]; -// -// self.slideShowNoteReadyObserver = [center addObserverForName:STATUS_CONNECTED_NOSLIDESHOW -// object:nil -// queue:mainQueue -// usingBlock:^(NSNotification *note) { -// [self.navigationController popViewControllerAnimated:YES]; -// }]; - -// [self.image setImage:[self.slideshow getImageAtIndex:0]]; self.comManager = [CommunicationManager sharedComManager]; + self.slideshow = [[self.comManager interpreter] slideShow]; } - (void)didReceiveMemoryWarning diff --git a/ios/iosremote/iosremote/slideShow_vc.h b/ios/iosremote/iosremote/slideShow_vc.h index 654b1dbac47e..fb6a3b251b08 100644 --- a/ios/iosremote/iosremote/slideShow_vc.h +++ b/ios/iosremote/iosremote/slideShow_vc.h @@ -13,4 +13,7 @@ - (IBAction)nextSlideAction:(id)sender; - (IBAction)previousSlideAction:(id)sender; +@property (weak, nonatomic) IBOutlet UIWebView *lecturer_notes; +@property (weak, nonatomic) IBOutlet UIImageView *slideView; + @end diff --git a/ios/iosremote/iosremote/slideShow_vc.m b/ios/iosremote/iosremote/slideShow_vc.m index 9570704266b4..8eebb2db8d39 100644 --- a/ios/iosremote/iosremote/slideShow_vc.m +++ b/ios/iosremote/iosremote/slideShow_vc.m @@ -7,18 +7,26 @@ // #import "slideShow_vc.h" +#import "SlideShow.h" #import "CommunicationManager.h" +#import "CommandInterpreter.h" #import "CommandTransmitter.h" @interface slideShow_vc () @property (nonatomic, strong) CommunicationManager *comManager; +@property (nonatomic, strong) id slideShowImageNoteReadyObserver; +@property (nonatomic, strong) id slideShowFinishedObserver; +@property (nonatomic, strong) SlideShow* slideshow; @end @implementation slideShow_vc @synthesize comManager = _comManager; +@synthesize slideShowImageNoteReadyObserver = _slideShowImageNoteReadyObserver; +@synthesize slideShowFinishedObserver = _slideShowFinishedObserver; +@synthesize slideshow = _slideshow; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { @@ -33,8 +41,44 @@ { [super viewDidLoad]; self.comManager = [CommunicationManager sharedComManager]; + self.slideshow = [self.comManager.interpreter slideShow]; + self.slideshow.delegate = self; } + +- (void) viewDidAppear:(BOOL)animated +{ + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + NSOperationQueue *mainQueue = [NSOperationQueue mainQueue]; + + self.slideShowImageNoteReadyObserver =[center addObserverForName:MSG_SLIDE_CHANGED + object:nil + queue:mainQueue + usingBlock:^(NSNotification *note) { + NSLog(@"Getting slide: %u image to display: %@", self.slideshow.currentSlide, [self.slideshow getImageAtIndex:self.slideshow.currentSlide]); + + [self.slideView setImage:[self.slideshow getImageAtIndex:self.slideshow.currentSlide]]; + [self.lecturer_notes loadHTMLString: [self.slideshow getNotesAtIndex:self.slideshow.currentSlide]baseURL:nil]; + }]; + + self.slideShowFinishedObserver = [center addObserverForName:STATUS_CONNECTED_NOSLIDESHOW + object:nil + queue:mainQueue + usingBlock:^(NSNotification *note) { + [self.navigationController popViewControllerAnimated:YES]; + }]; + [super viewDidAppear:animated]; +} + +- (void) viewDidDisappear:(BOOL)animated +{ + [[NSNotificationCenter defaultCenter] removeObserver:self.slideShowFinishedObserver]; + [[NSNotificationCenter defaultCenter] removeObserver:self.slideShowImageNoteReadyObserver]; + [super viewDidDisappear:animated]; +} + + + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; @@ -42,6 +86,8 @@ } - (void)viewDidUnload { + [self setLecturer_notes:nil]; + [self setSlideView:nil]; [super viewDidUnload]; } |