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 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#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) ViewController *viewController;
@end
......@@ -6,16 +6,22 @@
// 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/.
#import "libreoffice_sdremoteAppDelegate.h"
#import "AppDelegate.h"
@implementation libreoffice_sdremoteAppDelegate
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}
- (CMMotionManager *)motionManager
{
if (!motionManager) motionManager = [[CMMotionManager alloc] init];
return motionManager;
}
- (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.
......
......@@ -195,7 +195,7 @@ int count = 0;
}
}
}
NSLog(@"Command:%@", str);
// NSLog(@"Command:%@", str);
NSArray *commands = [str componentsSeparatedByString:@"\n"];
[self.receiver parse:commands];
data = nil;
......
......@@ -13,7 +13,7 @@
@interface CommandInterpreter : NSObject
@property (nonatomic, strong) SlideShow* slideShow;
@property (atomic, strong) SlideShow* slideShow;
- (void) parse:(NSArray *)cmd;
......
......@@ -20,6 +20,8 @@
@synthesize slideShow = _slideShow;
dispatch_queue_t backgroundQueue;
- (CommandInterpreter *) init
{
self = [super init];
......@@ -45,7 +47,7 @@
marker = 2;
}
else if ([instruction isEqualToString:STATUS_PAIRING_PAIRED]){
NSLog(@"Paired command: %@", command);
// NSLog(@"Paired command: %@", command);
[[NSNotificationCenter defaultCenter] postNotificationName:STATUS_PAIRING_PAIRED
object:nil];
marker = 2;
......@@ -77,14 +79,17 @@
marker = 3;
} else if ([instruction isEqualToString:@"slide_preview"]){
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]];
backgroundQueue = dispatch_queue_create("com.libreoffice.iosremote", NULL);
dispatch_async(backgroundQueue, ^(void) {
uint slideNumber = [[command objectAtIndex:1] integerValue];
NSString * imageData = [command objectAtIndex:2];
[self.slideShow putImage:imageData
AtIndex:slideNumber];
});
marker = 4;
} else if ([instruction isEqualToString:@"slide_notes"]){
NSLog(@"Interpreter: slide_notes");
backgroundQueue = dispatch_queue_create("com.libreoffice.iosremote", NULL);
uint slideNumber = [[command objectAtIndex:1] integerValue];
NSMutableString *notes = [[NSMutableString alloc] init];
for (int i = 2; i<command.count; ++i) {
......
......@@ -31,6 +31,7 @@
@synthesize secondaryDelegate = _secondaryDelegate;
dispatch_queue_t backgroundQueue;
NSLock *dictLock;
- (SlideShow *) init{
self = [super init];
......@@ -56,6 +57,7 @@ dispatch_queue_t backgroundQueue;
object:nil
queue:mainQueue
usingBlock:^(NSNotification *note) {
dispatch_async(backgroundQueue, ^(void) {
if ([[self.loadBuffer allKeysForObject:[NSNumber numberWithInt:[[[note userInfo] objectForKey:@"index"] intValue]]] count]) {
NSArray * tagArray = [self.loadBuffer allKeysForObject:[NSNumber numberWithInt:[[[note userInfo] objectForKey:@"index"] intValue]]];
for (NSNumber *tag in tagArray) {
......@@ -67,7 +69,9 @@ dispatch_queue_t backgroundQueue;
if ([view isKindOfClass:[UIImageView class]]){
UIImage *image = [self.imagesDictionary objectForKey:[self.loadBuffer objectForKey:tag]];
if (image) {
[(UIImageView *)view setImage:image];
dispatch_async(dispatch_get_main_queue(), ^{
[(UIImageView *)view setImage:image];
});
[self.loadBuffer removeObjectForKey:tag];
}
}
......@@ -75,27 +79,35 @@ dispatch_queue_t backgroundQueue;
// NSLog(@"Async notes");
NSString *note = [self.notesDictionary objectForKey:[self.loadBuffer objectForKey:tag]];
if (note) {
[(UIWebView *)view loadHTMLString:note baseURL:nil];
dispatch_async(dispatch_get_main_queue(), ^{
[(UIWebView *)view loadHTMLString:note baseURL:nil];
});
[self.loadBuffer removeObjectForKey:tag];
}
} else if ([view isKindOfClass:[UITableViewCell class]]){
UIImage *image = [self.imagesDictionary objectForKey:[self.loadBuffer objectForKey:tag]];
if (image){
UIImageView *imageView = (UIImageView *)[view viewWithTag:1];
[imageView setImage:image];
dispatch_async(dispatch_get_main_queue(), ^{
[imageView setImage:image];
});
[self.loadBuffer removeObjectForKey:tag];
}
}
}
}
});
}];
dictLock = [[NSLock alloc] init];
return self;
}
- (void) putImage: (NSString *)img AtIndex: (uint) index{
NSData* data = [NSData dataWithBase64String:img];
UIImage* image = [UIImage imageWithData:data];
[dictLock lock];
[self.imagesDictionary setObject:image forKey:[NSNumber numberWithUnsignedInt:index]];
[dictLock unlock];
[[NSNotificationCenter defaultCenter] postNotificationName:@"storage_update_ready"
object:nil
userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:index] forKey:@"index"]];
......
......@@ -8,6 +8,19 @@
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<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>
<string>org.libreoffice.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
......@@ -26,6 +39,8 @@
<true/>
<key>UIMainStoryboardFile</key>
<string>iPhone_autolayout</string>
<key>UIPrerenderedIcon</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
......
......@@ -8,11 +8,11 @@
#import <UIKit/UIKit.h>
#import "libreoffice_sdremoteAppDelegate.h"
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([libreoffice_sdremoteAppDelegate class]));
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
......@@ -8,6 +8,11 @@
#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>
@property (strong, nonatomic) IBOutlet UITableView *optionsTable;
......
......@@ -46,7 +46,7 @@
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// 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.delegate = self;
self.slidesRunning = NO;
......@@ -106,7 +106,11 @@
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
UISwitch *toggleSwitch = [[UISwitch alloc] init];
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.textLabel.text = [self.optionsArray objectAtIndex:indexPath.row];
......@@ -154,6 +158,14 @@
*/
-(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];
}
......
......@@ -12,6 +12,7 @@
#import "SlideShow.h"
#import "CommandTransmitter.h"
#import "SWRevealViewController.h"
#import "slideShowPreviewTable_vc.h"
#import <QuartzCore/CALayer.h>
#define TIMER_STATE_RUNNING 0
......@@ -42,6 +43,11 @@ dispatch_queue_t backgroundQueue;
self.slideshow = self.comManager.interpreter.slideShow;
self.slideshow.secondaryDelegate = self;
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
......
......@@ -13,6 +13,7 @@
- (IBAction)nextSlideAction:(id)sender;
- (IBAction)previousSlideAction:(id)sender;
- (IBAction)pointerAction:(id)sender;
- (IBAction)accPointerAction:(id)sender;
@property (weak, nonatomic) IBOutlet UIView *notesView;
@property (weak, nonatomic) IBOutlet UIWebView *lecturer_notes;
......@@ -20,4 +21,11 @@
@property (weak, nonatomic) IBOutlet UIImageView *secondarySlideView;
@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
//
// 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