Kaydet (Commit) a5f6c185 authored tarafından siqi's avatar siqi

accelormeter implemented but doesn't work well...

Change-Id: Ia5f2c1e706b21914ff483378e1bf8ffbdeb5eed6
üst 77826a48
...@@ -7,9 +7,16 @@ ...@@ -7,9 +7,16 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <CoreMotion/CoreMotion.h>
@interface libreoffice_sdremoteAppDelegate : UIResponder <UIApplicationDelegate> @class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate> {
CMMotionManager *motionManager;
}
@property (readonly) CMMotionManager *motionManager;
@property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@end @end
...@@ -6,16 +6,22 @@ ...@@ -6,16 +6,22 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "libreoffice_sdremoteAppDelegate.h" #import "AppDelegate.h"
@implementation libreoffice_sdremoteAppDelegate @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ {
// Override point for customization after application launch. // Override point for customization after application launch.
return YES; return YES;
} }
- (CMMotionManager *)motionManager
{
if (!motionManager) motionManager = [[CMMotionManager alloc] init];
return motionManager;
}
- (void)applicationWillResignActive:(UIApplication *)application - (void)applicationWillResignActive:(UIApplication *)application
{ {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
......
...@@ -195,7 +195,7 @@ int count = 0; ...@@ -195,7 +195,7 @@ int count = 0;
} }
} }
} }
NSLog(@"Command:%@", str); // NSLog(@"Command:%@", str);
NSArray *commands = [str componentsSeparatedByString:@"\n"]; NSArray *commands = [str componentsSeparatedByString:@"\n"];
[self.receiver parse:commands]; [self.receiver parse:commands];
data = nil; data = nil;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
@interface CommandInterpreter : NSObject @interface CommandInterpreter : NSObject
@property (nonatomic, strong) SlideShow* slideShow; @property (atomic, strong) SlideShow* slideShow;
- (void) parse:(NSArray *)cmd; - (void) parse:(NSArray *)cmd;
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
@synthesize slideShow = _slideShow; @synthesize slideShow = _slideShow;
dispatch_queue_t backgroundQueue;
- (CommandInterpreter *) init - (CommandInterpreter *) init
{ {
self = [super init]; self = [super init];
...@@ -45,7 +47,7 @@ ...@@ -45,7 +47,7 @@
marker = 2; marker = 2;
} }
else if ([instruction isEqualToString:STATUS_PAIRING_PAIRED]){ else if ([instruction isEqualToString:STATUS_PAIRING_PAIRED]){
NSLog(@"Paired command: %@", command); // NSLog(@"Paired command: %@", command);
[[NSNotificationCenter defaultCenter] postNotificationName:STATUS_PAIRING_PAIRED [[NSNotificationCenter defaultCenter] postNotificationName:STATUS_PAIRING_PAIRED
object:nil]; object:nil];
marker = 2; marker = 2;
...@@ -77,14 +79,17 @@ ...@@ -77,14 +79,17 @@
marker = 3; marker = 3;
} else if ([instruction isEqualToString:@"slide_preview"]){ } else if ([instruction isEqualToString:@"slide_preview"]){
NSLog(@"Interpreter: slide_preview"); NSLog(@"Interpreter: slide_preview");
uint slideNumber = [[command objectAtIndex:1] integerValue]; backgroundQueue = dispatch_queue_create("com.libreoffice.iosremote", NULL);
NSString * imageData = [command objectAtIndex:2]; dispatch_async(backgroundQueue, ^(void) {
[self.slideShow putImage:imageData uint slideNumber = [[command objectAtIndex:1] integerValue];
AtIndex:slideNumber]; NSString * imageData = [command objectAtIndex:2];
[[NSNotificationCenter defaultCenter] postNotificationName:MSG_SLIDE_PREVIEW object:[NSNumber numberWithUnsignedInt:slideNumber]]; [self.slideShow putImage:imageData
AtIndex:slideNumber];
});
marker = 4; marker = 4;
} else if ([instruction isEqualToString:@"slide_notes"]){ } else if ([instruction isEqualToString:@"slide_notes"]){
NSLog(@"Interpreter: slide_notes"); NSLog(@"Interpreter: slide_notes");
backgroundQueue = dispatch_queue_create("com.libreoffice.iosremote", NULL);
uint slideNumber = [[command objectAtIndex:1] integerValue]; uint slideNumber = [[command objectAtIndex:1] integerValue];
NSMutableString *notes = [[NSMutableString alloc] init]; NSMutableString *notes = [[NSMutableString alloc] init];
for (int i = 2; i<command.count; ++i) { for (int i = 2; i<command.count; ++i) {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
@synthesize secondaryDelegate = _secondaryDelegate; @synthesize secondaryDelegate = _secondaryDelegate;
dispatch_queue_t backgroundQueue; dispatch_queue_t backgroundQueue;
NSLock *dictLock;
- (SlideShow *) init{ - (SlideShow *) init{
self = [super init]; self = [super init];
...@@ -56,6 +57,7 @@ dispatch_queue_t backgroundQueue; ...@@ -56,6 +57,7 @@ dispatch_queue_t backgroundQueue;
object:nil object:nil
queue:mainQueue queue:mainQueue
usingBlock:^(NSNotification *note) { usingBlock:^(NSNotification *note) {
dispatch_async(backgroundQueue, ^(void) {
if ([[self.loadBuffer allKeysForObject:[NSNumber numberWithInt:[[[note userInfo] objectForKey:@"index"] intValue]]] count]) { if ([[self.loadBuffer allKeysForObject:[NSNumber numberWithInt:[[[note userInfo] objectForKey:@"index"] intValue]]] count]) {
NSArray * tagArray = [self.loadBuffer allKeysForObject:[NSNumber numberWithInt:[[[note userInfo] objectForKey:@"index"] intValue]]]; NSArray * tagArray = [self.loadBuffer allKeysForObject:[NSNumber numberWithInt:[[[note userInfo] objectForKey:@"index"] intValue]]];
for (NSNumber *tag in tagArray) { for (NSNumber *tag in tagArray) {
...@@ -67,7 +69,9 @@ dispatch_queue_t backgroundQueue; ...@@ -67,7 +69,9 @@ dispatch_queue_t backgroundQueue;
if ([view isKindOfClass:[UIImageView class]]){ if ([view isKindOfClass:[UIImageView class]]){
UIImage *image = [self.imagesDictionary objectForKey:[self.loadBuffer objectForKey:tag]]; UIImage *image = [self.imagesDictionary objectForKey:[self.loadBuffer objectForKey:tag]];
if (image) { if (image) {
[(UIImageView *)view setImage:image]; dispatch_async(dispatch_get_main_queue(), ^{
[(UIImageView *)view setImage:image];
});
[self.loadBuffer removeObjectForKey:tag]; [self.loadBuffer removeObjectForKey:tag];
} }
} }
...@@ -75,27 +79,35 @@ dispatch_queue_t backgroundQueue; ...@@ -75,27 +79,35 @@ dispatch_queue_t backgroundQueue;
// NSLog(@"Async notes"); // NSLog(@"Async notes");
NSString *note = [self.notesDictionary objectForKey:[self.loadBuffer objectForKey:tag]]; NSString *note = [self.notesDictionary objectForKey:[self.loadBuffer objectForKey:tag]];
if (note) { if (note) {
[(UIWebView *)view loadHTMLString:note baseURL:nil]; dispatch_async(dispatch_get_main_queue(), ^{
[(UIWebView *)view loadHTMLString:note baseURL:nil];
});
[self.loadBuffer removeObjectForKey:tag]; [self.loadBuffer removeObjectForKey:tag];
} }
} else if ([view isKindOfClass:[UITableViewCell class]]){ } else if ([view isKindOfClass:[UITableViewCell class]]){
UIImage *image = [self.imagesDictionary objectForKey:[self.loadBuffer objectForKey:tag]]; UIImage *image = [self.imagesDictionary objectForKey:[self.loadBuffer objectForKey:tag]];
if (image){ if (image){
UIImageView *imageView = (UIImageView *)[view viewWithTag:1]; UIImageView *imageView = (UIImageView *)[view viewWithTag:1];
[imageView setImage:image]; dispatch_async(dispatch_get_main_queue(), ^{
[imageView setImage:image];
});
[self.loadBuffer removeObjectForKey:tag]; [self.loadBuffer removeObjectForKey:tag];
} }
} }
} }
} }
});
}]; }];
dictLock = [[NSLock alloc] init];
return self; return self;
} }
- (void) putImage: (NSString *)img AtIndex: (uint) index{ - (void) putImage: (NSString *)img AtIndex: (uint) index{
NSData* data = [NSData dataWithBase64String:img]; NSData* data = [NSData dataWithBase64String:img];
UIImage* image = [UIImage imageWithData:data]; UIImage* image = [UIImage imageWithData:data];
[dictLock lock];
[self.imagesDictionary setObject:image forKey:[NSNumber numberWithUnsignedInt:index]]; [self.imagesDictionary setObject:image forKey:[NSNumber numberWithUnsignedInt:index]];
[dictLock unlock];
[[NSNotificationCenter defaultCenter] postNotificationName:@"storage_update_ready" [[NSNotificationCenter defaultCenter] postNotificationName:@"storage_update_ready"
object:nil object:nil
userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:index] forKey:@"index"]]; userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:index] forKey:@"index"]];
......
...@@ -8,6 +8,19 @@ ...@@ -8,6 +8,19 @@
<string>${PRODUCT_NAME}</string> <string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string> <string>${EXECUTABLE_NAME}</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>ic_launcher.png</string>
<string>ic_launcher@2x.png</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
</dict>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>org.libreoffice.${PRODUCT_NAME:rfc1034identifier}</string> <string>org.libreoffice.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
...@@ -26,6 +39,8 @@ ...@@ -26,6 +39,8 @@
<true/> <true/>
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>
<string>iPhone_autolayout</string> <string>iPhone_autolayout</string>
<key>UIPrerenderedIcon</key>
<true/>
<key>UIRequiredDeviceCapabilities</key> <key>UIRequiredDeviceCapabilities</key>
<array> <array>
<string>armv7</string> <string>armv7</string>
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "libreoffice_sdremoteAppDelegate.h" #import "AppDelegate.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@autoreleasepool { @autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([libreoffice_sdremoteAppDelegate class])); return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
} }
} }
...@@ -8,6 +8,11 @@ ...@@ -8,6 +8,11 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#define OPTION_TIMER @"Timer auto-start"
#define OPTION_POINTER @"Touch pointer"
#define KEY_TIMER @"TIMER_AUTOSTART_ENABLED"
#define KEY_POINTER @"TOUCH_POINTER_ENABLED"
@interface slideShowPreviewTable_vc : UITableViewController <UITableViewDataSource, UITableViewDelegate> @interface slideShowPreviewTable_vc : UITableViewController <UITableViewDataSource, UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *optionsTable; @property (strong, nonatomic) IBOutlet UITableView *optionsTable;
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
// Uncomment the following line to display an Edit button in the navigation bar for this view controller. // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem; // self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.optionsArray = [NSArray arrayWithObjects:@"Timer auto-start", nil]; self.optionsArray = [NSArray arrayWithObjects:OPTION_TIMER, OPTION_POINTER, nil];
self.comManager = [CommunicationManager sharedComManager]; self.comManager = [CommunicationManager sharedComManager];
self.comManager.delegate = self; self.comManager.delegate = self;
self.slidesRunning = NO; self.slidesRunning = NO;
...@@ -106,7 +106,11 @@ ...@@ -106,7 +106,11 @@
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
UISwitch *toggleSwitch = [[UISwitch alloc] init]; UISwitch *toggleSwitch = [[UISwitch alloc] init];
cell.accessoryView = [[UIView alloc] initWithFrame:toggleSwitch.frame]; cell.accessoryView = [[UIView alloc] initWithFrame:toggleSwitch.frame];
[toggleSwitch setOn:YES]; if (indexPath.row == 0) {
[toggleSwitch setOn:[[NSUserDefaults standardUserDefaults] boolForKey:KEY_TIMER]];
} else {
[toggleSwitch setOn:[[NSUserDefaults standardUserDefaults] boolForKey:KEY_POINTER]];
}
[cell.accessoryView addSubview:toggleSwitch]; [cell.accessoryView addSubview:toggleSwitch];
} }
cell.textLabel.text = [self.optionsArray objectAtIndex:indexPath.row]; cell.textLabel.text = [self.optionsArray objectAtIndex:indexPath.row];
...@@ -154,6 +158,14 @@ ...@@ -154,6 +158,14 @@
*/ */
-(IBAction)startPresentationAction:(id)sender { -(IBAction)startPresentationAction:(id)sender {
for (UITableViewCell *cell in self.tableView.visibleCells) {
UISwitch * toggle = [[[cell accessoryView] subviews] objectAtIndex:0];
if ([cell.textLabel.text isEqualToString:OPTION_TIMER])
[[NSUserDefaults standardUserDefaults] setBool:[toggle isOn] forKey:KEY_TIMER];
else if ([cell.textLabel.text isEqualToString:OPTION_POINTER])
[[NSUserDefaults standardUserDefaults] setBool:[toggle isOn] forKey:KEY_POINTER];
}
[[self.comManager transmitter] startPresentation]; [[self.comManager transmitter] startPresentation];
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#import "SlideShow.h" #import "SlideShow.h"
#import "CommandTransmitter.h" #import "CommandTransmitter.h"
#import "SWRevealViewController.h" #import "SWRevealViewController.h"
#import "slideShowPreviewTable_vc.h"
#import <QuartzCore/CALayer.h> #import <QuartzCore/CALayer.h>
#define TIMER_STATE_RUNNING 0 #define TIMER_STATE_RUNNING 0
...@@ -42,6 +43,11 @@ dispatch_queue_t backgroundQueue; ...@@ -42,6 +43,11 @@ dispatch_queue_t backgroundQueue;
self.slideshow = self.comManager.interpreter.slideShow; self.slideshow = self.comManager.interpreter.slideShow;
self.slideshow.secondaryDelegate = self; self.slideshow.secondaryDelegate = self;
self.state = TIMER_STATE_CLEARED; self.state = TIMER_STATE_CLEARED;
if ([[NSUserDefaults standardUserDefaults] boolForKey:KEY_TIMER]) {
UIButton *l = (UIButton *)[[self.slidesTable cellForRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]] viewWithTag:2];
[self stopWatchStart:l];
}
} }
- (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender - (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
- (IBAction)nextSlideAction:(id)sender; - (IBAction)nextSlideAction:(id)sender;
- (IBAction)previousSlideAction:(id)sender; - (IBAction)previousSlideAction:(id)sender;
- (IBAction)pointerAction:(id)sender; - (IBAction)pointerAction:(id)sender;
- (IBAction)accPointerAction:(id)sender;
@property (weak, nonatomic) IBOutlet UIView *notesView; @property (weak, nonatomic) IBOutlet UIView *notesView;
@property (weak, nonatomic) IBOutlet UIWebView *lecturer_notes; @property (weak, nonatomic) IBOutlet UIWebView *lecturer_notes;
...@@ -20,4 +21,11 @@ ...@@ -20,4 +21,11 @@
@property (weak, nonatomic) IBOutlet UIImageView *secondarySlideView; @property (weak, nonatomic) IBOutlet UIImageView *secondarySlideView;
@property (weak, nonatomic) IBOutlet UILabel *slideNumber; @property (weak, nonatomic) IBOutlet UILabel *slideNumber;
@property (weak, nonatomic) IBOutlet UIView *movingPointer;
@property (weak, nonatomic) IBOutlet UIImageView *touchPointerImage;
@property (weak, nonatomic) IBOutlet UIView *blockingView;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet UIScrollView *touchPointerScrollView;
@property (weak, nonatomic) IBOutlet UIButton *pointerBtn;
@end @end
//
// touchPointer_vc.h
// iosremote
//
// Created by Liu Siqi on 7/10/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface touchPointer_vc : UIViewController
- (IBAction)dismissModal:(id)sender;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@end
//
// touchPointer_vc.m
// iosremote
//
// Created by Liu Siqi on 7/10/13.
// Copyright (c) 2013 libreoffice. All rights reserved.
//
#import "touchPointer_vc.h"
#import "CommunicationManager.h"
#import "CommandTransmitter.h"
#import "CommandInterpreter.h"
#import "SlideShow.h"
#import <QuartzCore/QuartzCore.h>
@interface touchPointer_vc ()
@property (nonatomic, strong) CommunicationManager *comManager;
@end
@implementation touchPointer_vc
@synthesize comManager = _comManager;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.comManager = [CommunicationManager sharedComManager];
[self.comManager.interpreter.slideShow getContentAtIndex:self.comManager.interpreter.slideShow.currentSlide forView:self.imageView];
self.imageView.layer.shadowColor = [[UIColor blackColor] CGColor];
self.imageView.layer.shadowOpacity = 0.5;
self.imageView.layer.shadowRadius = 4.0;
self.imageView.layer.shadowOffset = CGSizeMake(3.0f, 3.0f);
self.imageView.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.imageView.bounds].CGPath;
self.imageView.clipsToBounds = NO;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)dismissModal:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewDidUnload {
[self setImageView:nil];
[super viewDidUnload];
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment