| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 6 #error "This file requires ARC support." |
| 7 #endif |
| 8 |
| 9 #import "Utility.h" |
| 10 |
| 11 @implementation Utility |
| 12 |
| 13 + (void)showAlert:(NSString*)title message:(NSString*)message { |
| 14 UIAlertView* alert; |
| 15 alert = [[UIAlertView alloc] init]; |
| 16 alert.title = title; |
| 17 alert.message = message; |
| 18 alert.delegate = nil; |
| 19 [alert addButtonWithTitle:@"OK"]; |
| 20 [alert show]; |
| 21 } |
| 22 |
| 23 + (BOOL)isInLandscapeMode { |
| 24 UIInterfaceOrientation orientation = [UIApplication sharedApplication] |
| 25 .statusBarOrientation; |
| 26 |
| 27 if ((orientation == UIInterfaceOrientationLandscapeLeft) || |
| 28 (orientation == UIInterfaceOrientationLandscapeRight)) { |
| 29 return YES; |
| 30 } |
| 31 return NO; |
| 32 } |
| 33 |
| 34 + (NSString*)appVersionNumberDisplayString { |
| 35 NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary]; |
| 36 |
| 37 NSString* majorVersion = |
| 38 [infoDictionary objectForKey:@"CFBundleShortVersionString"]; |
| 39 NSString* minorVersion = [infoDictionary objectForKey:@"CFBundleVersion"]; |
| 40 |
| 41 return [NSString |
| 42 stringWithFormat:@"Version %@ (%@)", majorVersion, minorVersion]; |
| 43 } |
| 44 |
| 45 // Get the rect in CLIENT screen of the status bar |
| 46 + (CGRect)statusBarFrameViewRect:(UIView*)view { |
| 47 CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame]; |
| 48 |
| 49 CGRect statusBarWindowRect = |
| 50 [view.window convertRect:statusBarFrame fromWindow:nil]; |
| 51 |
| 52 CGRect statusBarViewRect = |
| 53 [view convertRect:statusBarWindowRect fromView:nil]; |
| 54 |
| 55 return statusBarViewRect; |
| 56 } |
| 57 |
| 58 + (void)moveMouse:(ClientController*)controller |
| 59 at:(const webrtc::DesktopVector&)point { |
| 60 [controller mouseAction:point |
| 61 wheelDelta:webrtc::DesktopVector(0, 0) |
| 62 whichButton:0 |
| 63 buttonDown:NO]; |
| 64 } |
| 65 |
| 66 + (void)leftClickOn:(ClientController*)controller |
| 67 at:(const webrtc::DesktopVector&)point { |
| 68 [controller mouseAction:point |
| 69 wheelDelta:webrtc::DesktopVector(0, 0) |
| 70 whichButton:1 |
| 71 buttonDown:YES]; |
| 72 [controller mouseAction:point |
| 73 wheelDelta:webrtc::DesktopVector(0, 0) |
| 74 whichButton:1 |
| 75 buttonDown:NO]; |
| 76 } |
| 77 |
| 78 + (void)middleClickOn:(ClientController*)controller |
| 79 at:(const webrtc::DesktopVector&)point { |
| 80 [controller mouseAction:point |
| 81 wheelDelta:webrtc::DesktopVector(0, 0) |
| 82 whichButton:2 |
| 83 buttonDown:YES]; |
| 84 [controller mouseAction:point |
| 85 wheelDelta:webrtc::DesktopVector(0, 0) |
| 86 whichButton:2 |
| 87 buttonDown:NO]; |
| 88 } |
| 89 |
| 90 + (void)rightClickOn:(ClientController*)controller |
| 91 at:(const webrtc::DesktopVector&)point { |
| 92 [controller mouseAction:point |
| 93 wheelDelta:webrtc::DesktopVector(0, 0) |
| 94 whichButton:3 |
| 95 buttonDown:YES]; |
| 96 [controller mouseAction:point |
| 97 wheelDelta:webrtc::DesktopVector(0, 0) |
| 98 whichButton:3 |
| 99 buttonDown:NO]; |
| 100 } |
| 101 |
| 102 + (void)mouseScroll:(ClientController*)controller |
| 103 at:(const webrtc::DesktopVector&)point |
| 104 delta:(const webrtc::DesktopVector&)delta { |
| 105 [controller mouseAction:point wheelDelta:delta whichButton:0 buttonDown:NO]; |
| 106 } |
| 107 |
| 108 @end |
| OLD | NEW |