You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2012/09/21 17:16:14 UTC
[1/11] ios commit: bin/uncrustify.sh --all
Updated Branches:
refs/heads/master 360eab9b6 -> ecf289cc9
bin/uncrustify.sh --all
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/ecf289cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/ecf289cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/ecf289cc
Branch: refs/heads/master
Commit: ecf289cc959f7b416462fdd2414d89e17e754ae8
Parents: 360eab9
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Sep 21 11:15:39 2012 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Sep 21 11:15:39 2012 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 5 +-
CordovaLib/Classes/CDVAccelerometer.h | 14 +-
CordovaLib/Classes/CDVAccelerometer.m | 75 +-
CordovaLib/Classes/CDVAvailability.h | 51 +-
CordovaLib/Classes/CDVBattery.h | 19 +-
CordovaLib/Classes/CDVBattery.m | 71 +-
CordovaLib/Classes/CDVCamera.h | 33 +-
CordovaLib/Classes/CDVCamera.m | 535 ++--
CordovaLib/Classes/CDVCapture.h | 51 +-
CordovaLib/Classes/CDVCapture.m | 658 ++--
CordovaLib/Classes/CDVCommandDelegate.h | 12 +-
CordovaLib/Classes/CDVConnection.h | 11 +-
CordovaLib/Classes/CDVConnection.m | 127 +-
CordovaLib/Classes/CDVContact.h | 107 +-
CordovaLib/Classes/CDVContact.m | 2622 ++++++++-------
CordovaLib/Classes/CDVContacts.h | 79 +-
CordovaLib/Classes/CDVContacts.m | 671 ++--
CordovaLib/Classes/CDVCordovaView.h | 10 +-
CordovaLib/Classes/CDVCordovaView.m | 15 +-
CordovaLib/Classes/CDVDebug.h | 8 +-
CordovaLib/Classes/CDVDebugConsole.h | 8 +-
CordovaLib/Classes/CDVDebugConsole.m | 8 +-
CordovaLib/Classes/CDVDevice.h | 11 +-
CordovaLib/Classes/CDVDevice.m | 35 +-
CordovaLib/Classes/CDVEcho.h | 4 +-
CordovaLib/Classes/CDVEcho.m | 6 +-
CordovaLib/Classes/CDVFile.h | 119 +-
CordovaLib/Classes/CDVFile.m | 1785 +++++-----
CordovaLib/Classes/CDVFileTransfer.h | 38 +-
CordovaLib/Classes/CDVFileTransfer.m | 429 ++--
CordovaLib/Classes/CDVInvokedUrlCommand.h | 38 +-
CordovaLib/Classes/CDVInvokedUrlCommand.m | 26 +-
CordovaLib/Classes/CDVLocalStorage.h | 32 +-
CordovaLib/Classes/CDVLocalStorage.m | 299 +-
CordovaLib/Classes/CDVLocation.h | 68 +-
CordovaLib/Classes/CDVLocation.m | 434 ++--
CordovaLib/Classes/CDVLogger.h | 6 +-
CordovaLib/Classes/CDVLogger.m | 13 +-
CordovaLib/Classes/CDVNotification.h | 15 +-
CordovaLib/Classes/CDVNotification.m | 100 +-
CordovaLib/Classes/CDVPlugin.h | 29 +-
CordovaLib/Classes/CDVPlugin.m | 111 +-
CordovaLib/Classes/CDVPluginResult.h | 67 +-
CordovaLib/Classes/CDVPluginResult.m | 129 +-
CordovaLib/Classes/CDVReachability.h | 61 +-
CordovaLib/Classes/CDVReachability.m | 327 +-
CordovaLib/Classes/CDVSound.h | 101 +-
CordovaLib/Classes/CDVSound.m | 615 ++--
CordovaLib/Classes/CDVSplashScreen.h | 12 +-
CordovaLib/Classes/CDVSplashScreen.m | 20 +-
CordovaLib/Classes/CDVURLProtocol.h | 28 +-
CordovaLib/Classes/CDVURLProtocol.m | 77 +-
CordovaLib/Classes/CDVViewController.h | 39 +-
CordovaLib/Classes/CDVViewController.m | 649 ++--
CordovaLib/Classes/CDVWhitelist.h | 12 +-
CordovaLib/Classes/CDVWhitelist.m | 101 +-
CordovaLib/Classes/NSArray+Comparisons.h | 7 +-
CordovaLib/Classes/NSArray+Comparisons.m | 13 +-
CordovaLib/Classes/NSData+Base64.h | 18 +-
CordovaLib/Classes/NSData+Base64.m | 374 +--
CordovaLib/Classes/NSDictionary+Extensions.h | 26 +-
CordovaLib/Classes/NSDictionary+Extensions.m | 176 +-
CordovaLib/Classes/NSMutableArray+QueueAdditions.h | 13 +-
CordovaLib/Classes/NSMutableArray+QueueAdditions.m | 30 +-
CordovaLib/Classes/UIDevice+Extensions.h | 10 +-
CordovaLib/Classes/UIDevice+Extensions.m | 19 +-
CordovaLib/Classes/compatibility/0.9.6/CDV.h | 9 +-
CordovaLib/Classes/compatibility/0.9.6/CDVPlugin.h | 27 +-
CordovaLib/Classes/compatibility/0.9.6/CDVPlugin.m | 5 +-
CordovaLib/Classes/compatibility/1.5.0/CDV.h | 9 +-
CordovaLib/Classes/compatibility/1.5.0/CDVPlugin.h | 5 +-
CordovaLib/Classes/debugview/CDVDebugWebView.h | 23 +-
CordovaLib/Classes/debugview/CDVDebugWebView.m | 121 +-
.../Classes/debugview/WebScriptDebugDelegate.h | 87 +-
CordovaLib/Classes/deprecated/CDVDeprecated.h | 22 +-
CordovaLib/Classes/deprecated/CDVDeprecated.m | 6 +-
CordovaLib/CordovaLibApp/AppDelegate.h | 8 +-
CordovaLib/CordovaLibApp/AppDelegate.m | 49 +-
CordovaLib/CordovaLibApp/ViewController.h | 4 +-
CordovaLib/CordovaLibApp/ViewController.m | 8 +-
CordovaLib/CordovaLibApp/main.m | 7 +-
CordovaLib/CordovaLibTests/CDVBase64Tests.m | 14 +-
CordovaLib/CordovaLibTests/CDVContactsTests.m | 20 +-
CordovaLib/CordovaLibTests/CDVFakeFileManager.h | 8 +-
CordovaLib/CordovaLibTests/CDVFakeFileManager.m | 16 +-
CordovaLib/CordovaLibTests/CDVFileTransferTests.m | 54 +-
.../CordovaLibTests/CDVInvokedUrlCommandTests.m | 23 +-
CordovaLib/CordovaLibTests/CDVLocalStorageTests.m | 65 +-
.../CDVPluginResultJSONSerializationTests.m | 134 +-
CordovaLib/CordovaLibTests/CDVWebViewTest.h | 16 +-
CordovaLib/CordovaLibTests/CDVWebViewTest.m | 44 +-
CordovaLib/CordovaLibTests/CDVWhitelistTests.m | 222 +-
.../project/__TESTING__/Classes/AppDelegate.h | 13 +-
.../project/__TESTING__/Classes/AppDelegate.m | 82 +-
.../__TESTING__/Classes/MainViewController.h | 4 +-
.../__TESTING__/Classes/MainViewController.m | 59 +-
bin/templates/project/__TESTING__/main.m | 12 +-
97 files changed, 6371 insertions(+), 6517 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index b46e2bf..fef0f8d 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -54,4 +54,3 @@
#import "UIDevice+Extensions.h"
#import "JSONKit.h"
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVAccelerometer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAccelerometer.h b/CordovaLib/Classes/CDVAccelerometer.h
old mode 100755
new mode 100644
index 50f8a48..044ca53
--- a/CordovaLib/Classes/CDVAccelerometer.h
+++ b/CordovaLib/Classes/CDVAccelerometer.h
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -20,11 +20,9 @@
#import <UIKit/UIKit.h>
#import "CDVPlugin.h"
-
-
-@interface CDVAccelerometer : CDVPlugin<UIAccelerometerDelegate>
+@interface CDVAccelerometer : CDVPlugin <UIAccelerometerDelegate>
{
- double x;
+ double x;
double y;
double z;
NSTimeInterval timestamp;
@@ -33,11 +31,9 @@
@property (readonly, assign) BOOL isRunning;
@property (nonatomic, strong) NSString* callbackId;
-- (CDVAccelerometer*) init;
+- (CDVAccelerometer*)init;
- (void)start:(CDVInvokedUrlCommand*)command;
- (void)stop:(CDVInvokedUrlCommand*)command;
@end
-
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVAccelerometer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAccelerometer.m b/CordovaLib/Classes/CDVAccelerometer.m
index 7d82758..9e26014 100644
--- a/CordovaLib/Classes/CDVAccelerometer.m
+++ b/CordovaLib/Classes/CDVAccelerometer.m
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -17,29 +17,25 @@
under the License.
*/
-
#import "CDVAccelerometer.h"
-@interface CDVAccelerometer () {
-}
+@interface CDVAccelerometer () {}
@property (readwrite, assign) BOOL isRunning;
@end
-
@implementation CDVAccelerometer
@synthesize callbackId, isRunning;
// defaults to 10 msec
-#define kAccelerometerInterval 40
+#define kAccelerometerInterval 40
// g constant: -9.81 m/s^2
-#define kGravitionalConstant -9.81
+#define kGravitionalConstant -9.81
-- (CDVAccelerometer*) init
+- (CDVAccelerometer*)init
{
self = [super init];
- if (self)
- {
+ if (self) {
x = 0;
y = 0;
z = 0;
@@ -50,46 +46,46 @@
return self;
}
-- (void) dealloc {
+- (void)dealloc
+{
[self stop:nil];
}
- (void)start:(CDVInvokedUrlCommand*)command
{
NSString* cbId = command.callbackId;
- NSTimeInterval desiredFrequency_num = kAccelerometerInterval;
- UIAccelerometer* pAccel = [UIAccelerometer sharedAccelerometer];
- // accelerometer expects fractional seconds, but we have msecs
- pAccel.updateInterval = desiredFrequency_num / 1000;
+ NSTimeInterval desiredFrequency_num = kAccelerometerInterval;
+ UIAccelerometer* pAccel = [UIAccelerometer sharedAccelerometer];
+
+ // accelerometer expects fractional seconds, but we have msecs
+ pAccel.updateInterval = desiredFrequency_num / 1000;
self.callbackId = cbId;
- if(!self.isRunning)
- {
- pAccel.delegate = self;
- self.isRunning = YES;
- }
+ if (!self.isRunning) {
+ pAccel.delegate = self;
+ self.isRunning = YES;
+ }
}
- (void)stop:(CDVInvokedUrlCommand*)command
{
- UIAccelerometer* theAccelerometer = [UIAccelerometer sharedAccelerometer];
- theAccelerometer.delegate = nil;
- self.isRunning = NO;
+ UIAccelerometer* theAccelerometer = [UIAccelerometer sharedAccelerometer];
+
+ theAccelerometer.delegate = nil;
+ self.isRunning = NO;
}
/**
* Picks up accel updates from device and stores them in this class
*/
-- (void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
+- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
- if(self.isRunning)
- {
+ if (self.isRunning) {
x = acceleration.x;
y = acceleration.y;
z = acceleration.z;
timestamp = ([[NSDate date] timeIntervalSince1970] * 1000);
[self returnAccelInfo];
-
- }
+ }
}
- (void)returnAccelInfo
@@ -98,33 +94,34 @@
NSString* jsString = nil;
// Create an acceleration object
- NSMutableDictionary *accelProps = [NSMutableDictionary dictionaryWithCapacity:4];
- [accelProps setValue:[NSNumber numberWithDouble:x*kGravitionalConstant] forKey:@"x"];
- [accelProps setValue:[NSNumber numberWithDouble:y*kGravitionalConstant] forKey:@"y"];
- [accelProps setValue:[NSNumber numberWithDouble:z*kGravitionalConstant] forKey:@"z"];
+ NSMutableDictionary* accelProps = [NSMutableDictionary dictionaryWithCapacity:4];
+
+ [accelProps setValue:[NSNumber numberWithDouble:x * kGravitionalConstant] forKey:@"x"];
+ [accelProps setValue:[NSNumber numberWithDouble:y * kGravitionalConstant] forKey:@"y"];
+ [accelProps setValue:[NSNumber numberWithDouble:z * kGravitionalConstant] forKey:@"z"];
[accelProps setValue:[NSNumber numberWithDouble:timestamp] forKey:@"timestamp"];
-
+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:accelProps];
[result setKeepCallback:[NSNumber numberWithBool:YES]];
jsString = [result toSuccessCallbackString:self.callbackId];
- [self writeJavascript:jsString];
+ [self writeJavascript:jsString];
}
// TODO: Consider using filtering to isolate instantaneous data vs. gravity data -jm
-/*
+/*
#define kFilteringFactor 0.1
-
+
// Use a basic low-pass filter to keep only the gravity component of each axis.
grav_accelX = (acceleration.x * kFilteringFactor) + ( grav_accelX * (1.0 - kFilteringFactor));
grav_accelY = (acceleration.y * kFilteringFactor) + ( grav_accelY * (1.0 - kFilteringFactor));
grav_accelZ = (acceleration.z * kFilteringFactor) + ( grav_accelZ * (1.0 - kFilteringFactor));
-
+
// Subtract the low-pass value from the current value to get a simplified high-pass filter
instant_accelX = acceleration.x - ( (acceleration.x * kFilteringFactor) + (instant_accelX * (1.0 - kFilteringFactor)) );
instant_accelY = acceleration.y - ( (acceleration.y * kFilteringFactor) + (instant_accelY * (1.0 - kFilteringFactor)) );
instant_accelZ = acceleration.z - ( (acceleration.z * kFilteringFactor) + (instant_accelZ * (1.0 - kFilteringFactor)) );
-
+
*/
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVAvailability.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAvailability.h b/CordovaLib/Classes/CDVAvailability.h
index 4b73e9f..7f272dd 100644
--- a/CordovaLib/Classes/CDVAvailability.h
+++ b/CordovaLib/Classes/CDVAvailability.h
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -17,24 +17,23 @@
under the License.
*/
-#define __CORDOVA_0_9_6 906
-#define __CORDOVA_1_0_0 10000
-#define __CORDOVA_1_1_0 10100
-#define __CORDOVA_1_2_0 10200
-#define __CORDOVA_1_3_0 10300
-#define __CORDOVA_1_4_0 10400
-#define __CORDOVA_1_4_1 10401
-#define __CORDOVA_1_5_0 10500
-#define __CORDOVA_1_6_0 10600
-#define __CORDOVA_1_6_1 10601
-#define __CORDOVA_1_7_0 10700
-#define __CORDOVA_1_8_0 10800
-#define __CORDOVA_1_8_1 10801
-#define __CORDOVA_1_9_0 10900
-#define __CORDOVA_2_0_0 20000
-#define __CORDOVA_2_1_0 20100
-#define __CORDOVA_NA 99999 /* not available */
-
+#define __CORDOVA_0_9_6 906
+#define __CORDOVA_1_0_0 10000
+#define __CORDOVA_1_1_0 10100
+#define __CORDOVA_1_2_0 10200
+#define __CORDOVA_1_3_0 10300
+#define __CORDOVA_1_4_0 10400
+#define __CORDOVA_1_4_1 10401
+#define __CORDOVA_1_5_0 10500
+#define __CORDOVA_1_6_0 10600
+#define __CORDOVA_1_6_1 10601
+#define __CORDOVA_1_7_0 10700
+#define __CORDOVA_1_8_0 10800
+#define __CORDOVA_1_8_1 10801
+#define __CORDOVA_1_9_0 10900
+#define __CORDOVA_2_0_0 20000
+#define __CORDOVA_2_1_0 20100
+#define __CORDOVA_NA 99999 /* not available */
/*
#if CORDOVA_VERSION_MIN_REQUIRED >= __CORDOVA_1_7_0
@@ -47,9 +46,9 @@
#define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_2_1_0
#endif
-/*
+/*
Returns YES if it is at least version specified as NSString(X)
- Usage:
+ Usage:
if (IsAtLeastiOSVersion(@"5.1")) {
// do something for iOS 5.1 or greater
}
@@ -61,7 +60,7 @@
#define CDV_IsIPhone5() ([[UIScreen mainScreen] bounds].size.height == 568 && [[UIScreen mainScreen] bounds].size.width == 320)
/* Return the string version of the decimal version */
-#define CDV_VERSION [NSString stringWithFormat:@"%d.%d.%d", \
- (CORDOVA_VERSION_MIN_REQUIRED / 10000), \
- (CORDOVA_VERSION_MIN_REQUIRED % 10000) / 100, \
- (CORDOVA_VERSION_MIN_REQUIRED % 10000) % 100 ]
\ No newline at end of file
+#define CDV_VERSION [NSString stringWithFormat:@"%d.%d.%d", \
+ (CORDOVA_VERSION_MIN_REQUIRED / 10000), \
+ (CORDOVA_VERSION_MIN_REQUIRED % 10000) / 100, \
+ (CORDOVA_VERSION_MIN_REQUIRED % 10000) % 100]
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVBattery.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVBattery.h b/CordovaLib/Classes/CDVBattery.h
index 88656b4..ba26c3a 100644
--- a/CordovaLib/Classes/CDVBattery.h
+++ b/CordovaLib/Classes/CDVBattery.h
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -20,12 +20,11 @@
#import <Foundation/Foundation.h>
#import "CDVPlugin.h"
-
@interface CDVBattery : CDVPlugin {
- UIDeviceBatteryState state;
- float level;
+ UIDeviceBatteryState state;
+ float level;
bool isPlugged;
- NSString* callbackId;
+ NSString* callbackId;
}
@property (nonatomic) UIDeviceBatteryState state;
@@ -33,9 +32,9 @@
@property (nonatomic) bool isPlugged;
@property (strong) NSString* callbackId;
-- (void) updateBatteryStatus:(NSNotification*)notification;
-- (NSDictionary*) getBatteryStatus;
-- (void) start:(CDVInvokedUrlCommand*)command;
-- (void) stop:(CDVInvokedUrlCommand*)command;
+- (void)updateBatteryStatus:(NSNotification*)notification;
+- (NSDictionary*)getBatteryStatus;
+- (void)start:(CDVInvokedUrlCommand*)command;
+- (void)stop:(CDVInvokedUrlCommand*)command;
- (void)dealloc;
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVBattery.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVBattery.m b/CordovaLib/Classes/CDVBattery.m
index 278b78b..f032ebe 100644
--- a/CordovaLib/Classes/CDVBattery.m
+++ b/CordovaLib/Classes/CDVBattery.m
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -17,19 +17,16 @@
under the License.
*/
-
#import "CDVBattery.h"
-
-@interface CDVBattery(PrivateMethods)
-- (void) updateOnlineStatus;
+@interface CDVBattery (PrivateMethods)
+- (void)updateOnlineStatus;
@end
@implementation CDVBattery
@synthesize state, level, callbackId, isPlugged;
-
/* determining type of event occurs on JavaScript side
- (void) updateBatteryLevel:(NSNotification*)notification
{
@@ -60,66 +57,65 @@
}
*/
-- (void) updateBatteryStatus: (NSNotification*)notification
+- (void)updateBatteryStatus:(NSNotification*)notification
{
NSDictionary* batteryData = [self getBatteryStatus];
+
if (self.callbackId) {
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:batteryData];
[result setKeepCallbackAsBool:YES];
[super writeJavascript:[result toSuccessCallbackString:self.callbackId]];
}
-
}
-/* Get the current battery status and level. Status will be unknown and level will be -1.0 if
+
+/* Get the current battery status and level. Status will be unknown and level will be -1.0 if
* monitoring is turned off.
*/
-- (NSDictionary*) getBatteryStatus
+- (NSDictionary*)getBatteryStatus
{
UIDevice* currentDevice = [UIDevice currentDevice];
UIDeviceBatteryState currentState = [currentDevice batteryState];
-
+
isPlugged = FALSE; // UIDeviceBatteryStateUnknown or UIDeviceBatteryStateUnplugged
- if (currentState == UIDeviceBatteryStateCharging || currentState == UIDeviceBatteryStateFull) {
+ if ((currentState == UIDeviceBatteryStateCharging) || (currentState == UIDeviceBatteryStateFull)) {
isPlugged = TRUE;
}
float currentLevel = [currentDevice batteryLevel];
-
- if (currentLevel != self.level || currentState != self.state) {
-
+
+ if ((currentLevel != self.level) || (currentState != self.state)) {
self.level = currentLevel;
self.state = currentState;
}
-
+
// W3C spec says level must be null if it is unknown
NSObject* w3cLevel = nil;
- if (currentState == UIDeviceBatteryStateUnknown || currentLevel == -1.0) {
+ if ((currentState == UIDeviceBatteryStateUnknown) || (currentLevel == -1.0)) {
w3cLevel = [NSNull null];
- }
- else {
- w3cLevel = [NSNumber numberWithFloat:(currentLevel*100)];
+ } else {
+ w3cLevel = [NSNumber numberWithFloat:(currentLevel * 100)];
}
NSMutableDictionary* batteryData = [NSMutableDictionary dictionaryWithCapacity:2];
- [batteryData setObject: [NSNumber numberWithBool: isPlugged] forKey:@"isPlugged"];
- [batteryData setObject: w3cLevel forKey:@"level"];
+ [batteryData setObject:[NSNumber numberWithBool:isPlugged] forKey:@"isPlugged"];
+ [batteryData setObject:w3cLevel forKey:@"level"];
return batteryData;
}
/* turn on battery monitoring*/
-- (void) start:(CDVInvokedUrlCommand*)command
+- (void)start:(CDVInvokedUrlCommand*)command
{
self.callbackId = command.callbackId;
-
- if ( [UIDevice currentDevice].batteryMonitoringEnabled == NO) {
+
+ if ([UIDevice currentDevice].batteryMonitoringEnabled == NO) {
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
- name:UIDeviceBatteryStateDidChangeNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
- name:UIDeviceBatteryLevelDidChangeNotification object:nil];
- }
-
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
+ name:UIDeviceBatteryStateDidChangeNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
+ name:UIDeviceBatteryLevelDidChangeNotification object:nil];
+ }
}
+
/* turn off battery monitoring */
-- (void) stop:(CDVInvokedUrlCommand*)command
+- (void)stop:(CDVInvokedUrlCommand*)command
{
// callback one last time to clear the callback function on JS side
if (self.callbackId) {
@@ -131,24 +127,21 @@
[[UIDevice currentDevice] setBatteryMonitoringEnabled:NO];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryStateDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryLevelDidChangeNotification object:nil];
-
-
}
-- (CDVPlugin*) initWithWebView:(UIWebView*)theWebView
+- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
{
self = (CDVBattery*)[super initWithWebView:theWebView];
if (self) {
- self.state = UIDeviceBatteryStateUnknown;
+ self.state = UIDeviceBatteryStateUnknown;
self.level = -1.0;
-
}
return self;
}
- (void)dealloc
{
- [self stop:nil];
+ [self stop:nil];
}
@end
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVCamera.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.h b/CordovaLib/Classes/CDVCamera.h
index 536b442..64a9d9e 100644
--- a/CordovaLib/Classes/CDVCamera.h
+++ b/CordovaLib/Classes/CDVCamera.h
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -21,8 +21,8 @@
#import "CDVPlugin.h"
enum CDVDestinationType {
- DestinationTypeDataUrl = 0,
- DestinationTypeFileUri
+ DestinationTypeDataUrl = 0,
+ DestinationTypeFileUri
};
typedef NSUInteger CDVDestinationType;
@@ -40,9 +40,7 @@ enum CDVMediaType {
typedef NSUInteger CDVMediaType;
@interface CDVCameraPicker : UIImagePickerController
-{
-}
-
+{}
@property (assign) NSInteger quality;
@property (copy) NSString* callbackId;
@@ -57,16 +55,14 @@ typedef NSUInteger CDVMediaType;
@property (strong) UIWebView* webView;
@property (assign) BOOL popoverSupported;
-
@end
// ======================================================================= //
-@interface CDVCamera : CDVPlugin<UIImagePickerControllerDelegate,
- UINavigationControllerDelegate,
- UIPopoverControllerDelegate>
-{
-}
+@interface CDVCamera : CDVPlugin <UIImagePickerControllerDelegate,
+ UINavigationControllerDelegate,
+ UIPopoverControllerDelegate>
+{}
@property (strong) CDVCameraPicker* pickerController;
@@ -80,9 +76,9 @@ typedef NSUInteger CDVMediaType;
* options:
* quality: integer between 1 and 100
*/
-- (void) takePicture:(CDVInvokedUrlCommand*)command;
-- (void) postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url;
-- (void) cleanup:(CDVInvokedUrlCommand*)command;
+- (void)takePicture:(CDVInvokedUrlCommand*)command;
+- (void)postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url;
+- (void)cleanup:(CDVInvokedUrlCommand*)command;
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
@@ -91,9 +87,6 @@ typedef NSUInteger CDVMediaType;
- (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize;
- (UIImage*)imageCorrectedForCaptureOrientation:(UIImage*)anImage;
-- (void) closePicker:(CDVCameraPicker*)picker __attribute__((deprecated));
+- (void)closePicker:(CDVCameraPicker*)picker __attribute__((deprecated));
@end
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m
index 6ad2eb5..3cb5829 100644
--- a/CordovaLib/Classes/CDVCamera.m
+++ b/CordovaLib/Classes/CDVCamera.m
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -23,7 +23,7 @@
#import "NSDictionary+Extensions.h"
#import <MobileCoreServices/UTCoreTypes.h>
-#define CDV_PHOTO_PREFIX @"cdv_photo_"
+#define CDV_PHOTO_PREFIX @"cdv_photo_"
static NSSet* org_apache_cordova_validArrowDirections;
@@ -35,17 +35,17 @@ static NSSet* org_apache_cordova_validArrowDirections;
@implementation CDVCamera
-+ (void) initialize
++ (void)initialize
{
- org_apache_cordova_validArrowDirections = [[NSSet alloc] initWithObjects: [NSNumber numberWithInt:UIPopoverArrowDirectionUp], [NSNumber numberWithInt:UIPopoverArrowDirectionDown],[NSNumber numberWithInt:UIPopoverArrowDirectionLeft], [NSNumber numberWithInt:UIPopoverArrowDirectionRight], [NSNumber numberWithInt:UIPopoverArrowDirectionAny], nil];
+ org_apache_cordova_validArrowDirections = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:UIPopoverArrowDirectionUp], [NSNumber numberWithInt:UIPopoverArrowDirectionDown], [NSNumber numberWithInt:UIPopoverArrowDirectionLeft], [NSNumber numberWithInt:UIPopoverArrowDirectionRight], [NSNumber numberWithInt:UIPopoverArrowDirectionAny], nil];
}
@synthesize hasPendingOperation, pickerController;
-- (BOOL) popoverSupported
+- (BOOL)popoverSupported
{
- return ( NSClassFromString(@"UIPopoverController") != nil) &&
- (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
+ return (NSClassFromString(@"UIPopoverController") != nil) &&
+ (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
}
/* takePicture arguments:
@@ -61,42 +61,41 @@ static NSSet* org_apache_cordova_validArrowDirections;
* 8 correctOrientation
* 9 saveToPhotoAlbum
*/
-- (void) takePicture:(CDVInvokedUrlCommand*)command
+- (void)takePicture:(CDVInvokedUrlCommand*)command
{
NSString* callbackId = command.callbackId;
NSArray* arguments = command.arguments;
+
self.hasPendingOperation = NO;
- NSString* sourceTypeString = [arguments objectAtIndex:2];
- UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; // default
- if (sourceTypeString != nil)
- {
- sourceType = (UIImagePickerControllerSourceType)[sourceTypeString intValue];
- }
-
- bool hasCamera = [UIImagePickerController isSourceTypeAvailable:sourceType];
- if (!hasCamera) {
- NSLog(@"Camera.getPicture: source type %d not available.", sourceType);
- CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: @"no camera available"];
+ NSString* sourceTypeString = [arguments objectAtIndex:2];
+ UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; // default
+ if (sourceTypeString != nil) {
+ sourceType = (UIImagePickerControllerSourceType)[sourceTypeString intValue];
+ }
+
+ bool hasCamera = [UIImagePickerController isSourceTypeAvailable:sourceType];
+ if (!hasCamera) {
+ NSLog(@"Camera.getPicture: source type %d not available.", sourceType);
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"no camera available"];
[self writeJavascript:[result toErrorCallbackString:callbackId]];
return;
-
- }
+ }
bool allowEdit = [[arguments objectAtIndex:7] boolValue];
NSNumber* targetWidth = [arguments objectAtIndex:3];
NSNumber* targetHeight = [arguments objectAtIndex:4];
NSNumber* mediaValue = [arguments objectAtIndex:6];
- CDVMediaType mediaType = (mediaValue) ? [mediaValue intValue] : MediaTypePicture;
-
+ CDVMediaType mediaType = (mediaValue) ?[mediaValue intValue] : MediaTypePicture;
+
CGSize targetSize = CGSizeMake(0, 0);
- if (targetWidth != nil && targetHeight != nil) {
+ if ((targetWidth != nil) && (targetHeight != nil)) {
targetSize = CGSizeMake([targetWidth floatValue], [targetHeight floatValue]);
}
-
+
CDVCameraPicker* cameraPicker = [[CDVCameraPicker alloc] init];
self.pickerController = cameraPicker;
-
+
cameraPicker.delegate = self;
cameraPicker.sourceType = sourceType;
cameraPicker.allowsEditing = allowEdit; // THIS IS ALL IT TAKES FOR CROPPING - jm
@@ -106,30 +105,28 @@ static NSSet* org_apache_cordova_validArrowDirections;
// we need to capture this state for memory warnings that dealloc this object
cameraPicker.webView = self.webView;
cameraPicker.popoverSupported = [self popoverSupported];
-
+
cameraPicker.correctOrientation = [[arguments objectAtIndex:8] boolValue];
cameraPicker.saveToPhotoAlbum = [[arguments objectAtIndex:9] boolValue];
-
- cameraPicker.encodingType = ([arguments objectAtIndex:5]) ? [[arguments objectAtIndex:5] intValue] : EncodingTypeJPEG;
-
- cameraPicker.quality = ([arguments objectAtIndex:0]) ? [[arguments objectAtIndex:0] intValue] : 50;
- cameraPicker.returnType = ([arguments objectAtIndex:1]) ? [[arguments objectAtIndex:1] intValue] : DestinationTypeFileUri;
-
+
+ cameraPicker.encodingType = ([arguments objectAtIndex:5]) ?[[arguments objectAtIndex:5] intValue] : EncodingTypeJPEG;
+
+ cameraPicker.quality = ([arguments objectAtIndex:0]) ?[[arguments objectAtIndex:0] intValue] : 50;
+ cameraPicker.returnType = ([arguments objectAtIndex:1]) ?[[arguments objectAtIndex:1] intValue] : DestinationTypeFileUri;
+
if (sourceType == UIImagePickerControllerSourceTypeCamera) {
// we only allow taking pictures (no video) in this api
- cameraPicker.mediaTypes = [NSArray arrayWithObjects: (NSString*) kUTTypeImage, nil];
+ cameraPicker.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage, nil];
} else if (mediaType == MediaTypeAll) {
- cameraPicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: sourceType];
+ cameraPicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
} else {
- NSArray* mediaArray = [NSArray arrayWithObjects: (NSString*) (mediaType == MediaTypeVideo ? kUTTypeMovie : kUTTypeImage), nil];
+ NSArray* mediaArray = [NSArray arrayWithObjects:(NSString*)(mediaType == MediaTypeVideo ? kUTTypeMovie:kUTTypeImage), nil];
cameraPicker.mediaTypes = mediaArray;
}
-
- if ([self popoverSupported] && sourceType != UIImagePickerControllerSourceTypeCamera)
- {
- if (cameraPicker.popoverController == nil)
- {
- cameraPicker.popoverController = [[NSClassFromString(@"UIPopoverController") alloc] initWithContentViewController:cameraPicker];
+
+ if ([self popoverSupported] && (sourceType != UIImagePickerControllerSourceTypeCamera)) {
+ if (cameraPicker.popoverController == nil) {
+ cameraPicker.popoverController = [[NSClassFromString (@"UIPopoverController")alloc] initWithContentViewController:cameraPicker];
}
int x = 0;
int y = 32;
@@ -142,45 +139,42 @@ static NSSet* org_apache_cordova_validArrowDirections;
y = [options integerValueForKey:@"y" defaultValue:32];
width = [options integerValueForKey:@"width" defaultValue:320];
height = [options integerValueForKey:@"height" defaultValue:480];
- arrowDirection = [options integerValueForKey: @"arrowDir" defaultValue:UIPopoverArrowDirectionAny];
- if(![org_apache_cordova_validArrowDirections containsObject:[NSNumber numberWithInt:arrowDirection]]){
+ arrowDirection = [options integerValueForKey:@"arrowDir" defaultValue:UIPopoverArrowDirectionAny];
+ if (![org_apache_cordova_validArrowDirections containsObject:[NSNumber numberWithInt:arrowDirection]]) {
arrowDirection = UIPopoverArrowDirectionAny;
}
}
-
+
cameraPicker.popoverController.delegate = self;
- [cameraPicker.popoverController presentPopoverFromRect:CGRectMake(x,y,width,height)
- inView:[self.webView superview]
- permittedArrowDirections:arrowDirection
- animated:YES];
- }
- else
- {
-
+ [cameraPicker.popoverController presentPopoverFromRect:CGRectMake(x, y, width, height)
+ inView:[self.webView superview]
+ permittedArrowDirections:arrowDirection
+ animated:YES];
+ } else {
if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:cameraPicker animated:YES completion:nil];
+ [self.viewController presentViewController:cameraPicker animated:YES completion:nil];
} else {
- [self.viewController presentModalViewController:cameraPicker animated:YES ];
- }
+ [self.viewController presentModalViewController:cameraPicker animated:YES];
+ }
}
self.hasPendingOperation = YES;
}
-- (void) cleanup:(CDVInvokedUrlCommand*)command
+- (void)cleanup:(CDVInvokedUrlCommand*)command
{
NSString* callbackId = command.callbackId;
-
+
// empty the tmp directory
NSFileManager* fileMgr = [[NSFileManager alloc] init];
NSError* err = nil;
BOOL hasErrors = NO;
-
- // clear contents of NSTemporaryDirectory
+
+ // clear contents of NSTemporaryDirectory
NSString* tempDirectoryPath = NSTemporaryDirectory();
- NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath];
+ NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath];
NSString* fileName = nil;
BOOL result;
-
+
while ((fileName = [directoryEnumerator nextObject])) {
// only delete the files we created
if (![fileName hasPrefix:CDV_PHOTO_PREFIX]) {
@@ -193,7 +187,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
hasErrors = YES;
}
}
-
+
if (hasErrors) {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:@"One or more files failed to be deleted."];
[super writeJavascript:[pluginResult toErrorCallbackString:callbackId]];
@@ -203,20 +197,21 @@ static NSSet* org_apache_cordova_validArrowDirections;
}
}
-- (void) popoverControllerDidDismissPopover:(id)popoverController
+- (void)popoverControllerDidDismissPopover:(id)popoverController
{
- //[ self imagePickerControllerDidCancel:self.pickerController ]; '
+ // [ self imagePickerControllerDidCancel:self.pickerController ]; '
UIPopoverController* pc = (UIPopoverController*)popoverController;
- [pc dismissPopoverAnimated:YES];
+
+ [pc dismissPopoverAnimated:YES];
pc.delegate = nil;
if (self.pickerController && self.pickerController.callbackId && self.pickerController.popoverController) {
self.pickerController.popoverController = nil;
NSString* callbackId = self.pickerController.callbackId;
- CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: @"no image selected"]; // error callback expects string ATM
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"no image selected"]; // error callback expects string ATM
// this "delay hack" is in case the callback contains a JavaScript alert. Without this delay or a
// setTimeout("alert('fail');", 0) on the JS side, the app will hang when the alert is displayed.
- [self.webView performSelector:@selector(stringByEvaluatingJavaScriptFromString:) withObject:[result toErrorCallbackString: callbackId] afterDelay:0.5];
- }
+ [self.webView performSelector:@selector(stringByEvaluatingJavaScriptFromString:) withObject:[result toErrorCallbackString:callbackId] afterDelay:0.5];
+ }
self.hasPendingOperation = NO;
}
@@ -224,159 +219,148 @@ static NSSet* org_apache_cordova_validArrowDirections;
{
CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;
- NSString* callbackId = cameraPicker.callbackId;
-
- if(cameraPicker.popoverSupported && cameraPicker.popoverController != nil)
- {
- [cameraPicker.popoverController dismissPopoverAnimated:YES];
- cameraPicker.popoverController.delegate = nil;
- cameraPicker.popoverController = nil;
- }
- else
- {
- if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
+ NSString* callbackId = cameraPicker.callbackId;
+
+ if (cameraPicker.popoverSupported && (cameraPicker.popoverController != nil)) {
+ [cameraPicker.popoverController dismissPopoverAnimated:YES];
+ cameraPicker.popoverController.delegate = nil;
+ cameraPicker.popoverController = nil;
+ } else {
+ if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
[[cameraPicker presentingViewController] dismissModalViewControllerAnimated:YES];
} else {
[[cameraPicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
- }
-
- NSString* jsString = nil;
+ }
+ }
+
+ NSString* jsString = nil;
CDVPluginResult* result = nil;
-
- NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
+
+ NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
// IMAGE TYPE
- if ([mediaType isEqualToString:(NSString*)kUTTypeImage])
- {
- // get the image
- UIImage* image = nil;
- if (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage]){
- image = [info objectForKey:UIImagePickerControllerEditedImage];
- } else {
- image = [info objectForKey:UIImagePickerControllerOriginalImage];
- }
-
+ if ([mediaType isEqualToString:(NSString*)kUTTypeImage]) {
+ // get the image
+ UIImage* image = nil;
+ if (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage]) {
+ image = [info objectForKey:UIImagePickerControllerEditedImage];
+ } else {
+ image = [info objectForKey:UIImagePickerControllerOriginalImage];
+ }
+
if (cameraPicker.saveToPhotoAlbum) {
- UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
+ UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}
-
+
if (cameraPicker.correctOrientation) {
- image = [self imageCorrectedForCaptureOrientation:image];
+ image = [self imageCorrectedForCaptureOrientation:image];
}
-
- UIImage *scaledImage = nil;
-
- if (cameraPicker.targetSize.width > 0 && cameraPicker.targetSize.height > 0) {
+
+ UIImage* scaledImage = nil;
+
+ if ((cameraPicker.targetSize.width > 0) && (cameraPicker.targetSize.height > 0)) {
// if cropToSize, resize image and crop to target size, otherwise resize to fit target without cropping
- if(cameraPicker.cropToSize) {
+ if (cameraPicker.cropToSize) {
scaledImage = [self imageByScalingAndCroppingForSize:image toSize:cameraPicker.targetSize];
} else {
scaledImage = [self imageByScalingNotCroppingForSize:image toSize:cameraPicker.targetSize];
}
}
-
+
NSData* data = nil;
if (cameraPicker.encodingType == EncodingTypePNG) {
data = UIImagePNGRepresentation(scaledImage == nil ? image : scaledImage);
- }
- else {
+ } else {
data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage, cameraPicker.quality / 100.0f);
}
-
+
if (cameraPicker.returnType == DestinationTypeFileUri) {
-
// write to temp directory and reutrn URI
// get the temp directory path
- NSString* docsPath = [NSTemporaryDirectory() stringByStandardizingPath];
+ NSString* docsPath = [NSTemporaryDirectory ()stringByStandardizingPath];
NSError* err = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init]; //recommended by apple (vs [NSFileManager defaultManager]) to be theadsafe
-
+ NSFileManager* fileMgr = [[NSFileManager alloc] init]; // recommended by apple (vs [NSFileManager defaultManager]) to be theadsafe
+
// generate unique file name
NSString* filePath;
-
+
int i = 1;
- do
- {
- filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, cameraPicker.encodingType == EncodingTypePNG ? @"png" : @"jpg"];
- }
- while ([fileMgr fileExistsAtPath: filePath]);
-
+ do {
+ filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, cameraPicker.encodingType == EncodingTypePNG ? @"png":@"jpg"];
+ } while ([fileMgr fileExistsAtPath:filePath]);
+
// save file
- if (![data writeToFile: filePath options: NSAtomicWrite error: &err]) {
- result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: [err localizedDescription]];
+ if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[err localizedDescription]];
jsString = [result toErrorCallbackString:callbackId];
} else {
- result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: [[NSURL fileURLWithPath: filePath] absoluteString]];
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[NSURL fileURLWithPath:filePath] absoluteString]];
jsString = [result toSuccessCallbackString:callbackId];
}
-
} else {
- result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: [data base64EncodedString]];
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[data base64EncodedString]];
jsString = [result toSuccessCallbackString:callbackId];
}
- }
+ }
// NOT IMAGE TYPE (MOVIE)
- else
- {
- NSString *moviePath = [[info objectForKey: UIImagePickerControllerMediaURL] absoluteString];
- result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: moviePath];
+ else {
+ NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] absoluteString];
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:moviePath];
jsString = [result toSuccessCallbackString:callbackId];
}
-
if (jsString) {
[self.webView stringByEvaluatingJavaScriptFromString:jsString];
}
- self.hasPendingOperation = NO;
+ self.hasPendingOperation = NO;
}
// older api calls newer didFinishPickingMediaWithInfo
-- (void) imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
+- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
{
- NSDictionary* imageInfo = [NSDictionary dictionaryWithObject:image forKey:UIImagePickerControllerOriginalImage];
- [self imagePickerController:picker didFinishPickingMediaWithInfo: imageInfo];
+ NSDictionary* imageInfo = [NSDictionary dictionaryWithObject:image forKey:UIImagePickerControllerOriginalImage];
+
+ [self imagePickerController:picker didFinishPickingMediaWithInfo:imageInfo];
}
-- (void) closePicker:(CDVCameraPicker*)cameraPicker
+- (void)closePicker:(CDVCameraPicker*)cameraPicker
{
NSLog(@"closePicker is DEPRECATED and will be removed in 2.0!");
- if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
+ if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
[[cameraPicker presentingViewController] dismissModalViewControllerAnimated:YES];
} else {
[[cameraPicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- if (cameraPicker.popoverSupported && cameraPicker.popoverController != nil)
- {
+ }
+
+ if (cameraPicker.popoverSupported && (cameraPicker.popoverController != nil)) {
cameraPicker.popoverController.delegate = nil;
cameraPicker.popoverController = nil;
}
}
-- (void) imagePickerControllerDidCancel:(UIImagePickerController*)picker
-{
+- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
+{
CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;
- NSString* callbackId = cameraPicker.callbackId;
-
- if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
+ NSString* callbackId = cameraPicker.callbackId;
+
+ if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
[[cameraPicker presentingViewController] dismissModalViewControllerAnimated:YES];
} else {
[[cameraPicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
- //popoverControllerDidDismissPopover:(id)popoverController is called if popover is cancelled
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsString: @"no image selected"]; // error callback expects string ATM
- [cameraPicker.webView stringByEvaluatingJavaScriptFromString:[result toErrorCallbackString: callbackId]];
-
+ }
+ // popoverControllerDidDismissPopover:(id)popoverController is called if popover is cancelled
+
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"no image selected"]; // error callback expects string ATM
+ [cameraPicker.webView stringByEvaluatingJavaScriptFromString:[result toErrorCallbackString:callbackId]];
+
self.hasPendingOperation = NO;
}
-- (UIImage*) imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize
+- (UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize
{
- UIImage *sourceImage = anImage;
- UIImage *newImage = nil;
+ UIImage* sourceImage = anImage;
+ UIImage* newImage = nil;
CGSize imageSize = sourceImage.size;
CGFloat width = imageSize.width;
CGFloat height = imageSize.height;
@@ -385,113 +369,113 @@ static NSSet* org_apache_cordova_validArrowDirections;
CGFloat scaleFactor = 0.0;
CGFloat scaledWidth = targetWidth;
CGFloat scaledHeight = targetHeight;
- CGPoint thumbnailPoint = CGPointMake(0.0,0.0);
-
- if (CGSizeEqualToSize(imageSize, targetSize) == NO)
- {
+ CGPoint thumbnailPoint = CGPointMake(0.0, 0.0);
+
+ if (CGSizeEqualToSize(imageSize, targetSize) == NO) {
CGFloat widthFactor = targetWidth / width;
CGFloat heightFactor = targetHeight / height;
-
- if (widthFactor > heightFactor)
+
+ if (widthFactor > heightFactor) {
scaleFactor = widthFactor; // scale to fit height
- else
+ } else {
scaleFactor = heightFactor; // scale to fit width
- scaledWidth = width * scaleFactor;
+ }
+ scaledWidth = width * scaleFactor;
scaledHeight = height * scaleFactor;
-
+
// center the image
- if (widthFactor > heightFactor)
- {
- thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
- }
- else if (widthFactor < heightFactor)
- {
+ if (widthFactor > heightFactor) {
+ thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
+ } else if (widthFactor < heightFactor) {
thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
}
- }
-
+ }
+
UIGraphicsBeginImageContext(targetSize); // this will crop
-
+
CGRect thumbnailRect = CGRectZero;
thumbnailRect.origin = thumbnailPoint;
- thumbnailRect.size.width = scaledWidth;
+ thumbnailRect.size.width = scaledWidth;
thumbnailRect.size.height = scaledHeight;
-
+
[sourceImage drawInRect:thumbnailRect];
-
+
newImage = UIGraphicsGetImageFromCurrentImageContext();
- if(newImage == nil) {
+ if (newImage == nil) {
NSLog(@"could not scale image");
}
-
- //pop the context to get back to the default
+
+ // pop the context to get back to the default
UIGraphicsEndImageContext();
return newImage;
}
-- (UIImage*) imageCorrectedForCaptureOrientation:(UIImage*)anImage
-{
- float rotation_radians = 0;
- bool perpendicular = false;
-
- switch ([anImage imageOrientation]) {
- case UIImageOrientationUp:
- rotation_radians = 0.0;
- break;
- case UIImageOrientationDown:
- rotation_radians = M_PI; //don't be scared of radians, if you're reading this, you're good at math
- break;
- case UIImageOrientationRight:
- rotation_radians = M_PI_2;
- perpendicular = true;
- break;
- case UIImageOrientationLeft:
- rotation_radians = -M_PI_2;
- perpendicular = true;
- break;
- default:
- break;
- }
-
- UIGraphicsBeginImageContext(CGSizeMake(anImage.size.width, anImage.size.height));
- CGContextRef context = UIGraphicsGetCurrentContext();
-
- //Rotate around the center point
- CGContextTranslateCTM(context, anImage.size.width/2, anImage.size.height/2);
- CGContextRotateCTM(context, rotation_radians);
-
- CGContextScaleCTM(context, 1.0, -1.0);
- float width = perpendicular ? anImage.size.height : anImage.size.width;
- float height = perpendicular ? anImage.size.width : anImage.size.height;
- CGContextDrawImage(context, CGRectMake(-width / 2, -height / 2, width, height), [anImage CGImage]);
-
- // Move the origin back since the rotation might've change it (if its 90 degrees)
- if (perpendicular) {
- CGContextTranslateCTM(context, -anImage.size.height/2, -anImage.size.width/2);
- }
-
- UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return newImage;
+- (UIImage*)imageCorrectedForCaptureOrientation:(UIImage*)anImage
+{
+ float rotation_radians = 0;
+ bool perpendicular = false;
+
+ switch ([anImage imageOrientation]) {
+ case UIImageOrientationUp :
+ rotation_radians = 0.0;
+ break;
+
+ case UIImageOrientationDown :
+ rotation_radians = M_PI; // don't be scared of radians, if you're reading this, you're good at math
+ break;
+
+ case UIImageOrientationRight:
+ rotation_radians = M_PI_2;
+ perpendicular = true;
+ break;
+
+ case UIImageOrientationLeft:
+ rotation_radians = -M_PI_2;
+ perpendicular = true;
+ break;
+
+ default:
+ break;
+ }
+
+ UIGraphicsBeginImageContext(CGSizeMake(anImage.size.width, anImage.size.height));
+ CGContextRef context = UIGraphicsGetCurrentContext();
+
+ // Rotate around the center point
+ CGContextTranslateCTM(context, anImage.size.width / 2, anImage.size.height / 2);
+ CGContextRotateCTM(context, rotation_radians);
+
+ CGContextScaleCTM(context, 1.0, -1.0);
+ float width = perpendicular ? anImage.size.height : anImage.size.width;
+ float height = perpendicular ? anImage.size.width : anImage.size.height;
+ CGContextDrawImage(context, CGRectMake(-width / 2, -height / 2, width, height), [anImage CGImage]);
+
+ // Move the origin back since the rotation might've change it (if its 90 degrees)
+ if (perpendicular) {
+ CGContextTranslateCTM(context, -anImage.size.height / 2, -anImage.size.width / 2);
+ }
+
+ UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
+ UIGraphicsEndImageContext();
+ return newImage;
}
-- (UIImage*) imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize
+- (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize
{
- UIImage *sourceImage = anImage;
- UIImage *newImage = nil;
- CGSize imageSize = sourceImage.size;
+ UIImage* sourceImage = anImage;
+ UIImage* newImage = nil;
+ CGSize imageSize = sourceImage.size;
CGFloat width = imageSize.width;
CGFloat height = imageSize.height;
CGFloat targetWidth = frameSize.width;
CGFloat targetHeight = frameSize.height;
CGFloat scaleFactor = 0.0;
- CGSize scaledSize = frameSize;
-
- if (CGSizeEqualToSize(imageSize, frameSize) == NO)
- {
+ CGSize scaledSize = frameSize;
+
+ if (CGSizeEqualToSize(imageSize, frameSize) == NO) {
CGFloat widthFactor = targetWidth / width;
CGFloat heightFactor = targetHeight / height;
-
+
// opposite comparison to imageByScalingAndCroppingForSize in order to contain the image within the given bounds
if (widthFactor > heightFactor) {
scaleFactor = heightFactor; // scale to fit height
@@ -500,66 +484,63 @@ static NSSet* org_apache_cordova_validArrowDirections;
}
scaledSize = CGSizeMake(MIN(width * scaleFactor, targetWidth), MIN(height * scaleFactor, targetHeight));
}
-
+
UIGraphicsBeginImageContext(scaledSize); // this will resize
-
+
[sourceImage drawInRect:CGRectMake(0, 0, scaledSize.width, scaledSize.height)];
-
+
newImage = UIGraphicsGetImageFromCurrentImageContext();
- if(newImage == nil) {
+ if (newImage == nil) {
NSLog(@"could not scale image");
}
-
- //pop the context to get back to the default
+
+ // pop the context to get back to the default
UIGraphicsEndImageContext();
return newImage;
}
-- (void) postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url
+- (void)postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url
{
self.hasPendingOperation = YES;
-
- NSString *boundary = @"----BOUNDARY_IS_I";
-
- NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
- [req setHTTPMethod:@"POST"];
-
- NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
- [req setValue:contentType forHTTPHeaderField:@"Content-type"];
-
- NSData *imageData = UIImagePNGRepresentation(anImage);
-
- // adding the body
- NSMutableData *postBody = [NSMutableData data];
-
- // first parameter an image
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
- [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upload\"; filename=\"%@\"\r\n", filename] dataUsingEncoding:NSUTF8StringEncoding]];
- [postBody appendData:[@"Content-Type: image/png\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
- [postBody appendData:imageData];
-
-// // second parameter information
-// [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
-// [postBody appendData:[@"Content-Disposition: form-data; name=\"some_other_name\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
-// [postBody appendData:[@"some_other_value" dataUsingEncoding:NSUTF8StringEncoding]];
-// [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r \n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
-
- [req setHTTPBody:postBody];
-
- NSURLResponse* response;
- NSError* error;
- [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
-
-// NSData* result = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
-// NSString * resultStr = [[[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding] autorelease];
-
- self.hasPendingOperation = NO;
-}
+ NSString* boundary = @"----BOUNDARY_IS_I";
+ NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
+ [req setHTTPMethod:@"POST"];
-@end
+ NSString* contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
+ [req setValue:contentType forHTTPHeaderField:@"Content-type"];
+
+ NSData* imageData = UIImagePNGRepresentation(anImage);
+
+ // adding the body
+ NSMutableData* postBody = [NSMutableData data];
+
+ // first parameter an image
+ [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
+ [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upload\"; filename=\"%@\"\r\n", filename] dataUsingEncoding:NSUTF8StringEncoding]];
+ [postBody appendData:[@"Content-Type: image/png\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
+ [postBody appendData:imageData];
+
+ // // second parameter information
+ // [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
+ // [postBody appendData:[@"Content-Disposition: form-data; name=\"some_other_name\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
+ // [postBody appendData:[@"some_other_value" dataUsingEncoding:NSUTF8StringEncoding]];
+ // [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r \n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
+
+ [req setHTTPBody:postBody];
+ NSURLResponse* response;
+ NSError* error;
+ [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
+
+ // NSData* result = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
+ // NSString * resultStr = [[[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding] autorelease];
+
+ self.hasPendingOperation = NO;
+}
+
+@end
@implementation CDVCameraPicker
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVCapture.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.h b/CordovaLib/Classes/CDVCapture.h
index 896d7dd..b4b4a2a 100644
--- a/CordovaLib/Classes/CDVCapture.h
+++ b/CordovaLib/Classes/CDVCapture.h
@@ -6,9 +6,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -24,7 +24,7 @@
#import "CDVFile.h"
enum CDVCaptureError {
- CAPTURE_INTERNAL_ERR = 0,
+ CAPTURE_INTERNAL_ERR = 0,
CAPTURE_APPLICATION_BUSY = 1,
CAPTURE_INVALID_ARGUMENT = 2,
CAPTURE_NO_MEDIA_FILES = 3,
@@ -32,11 +32,10 @@ enum CDVCaptureError {
};
typedef NSUInteger CDVCaptureError;
-
@interface CDVImagePicker : UIImagePickerController
{
- NSString* callbackid;
- NSInteger quality;
+ NSString* callbackid;
+ NSInteger quality;
NSString* mimeType;
}
@property (assign) NSInteger quality;
@@ -45,31 +44,32 @@ typedef NSUInteger CDVCaptureError;
@end
-@interface CDVCapture : CDVPlugin<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
+@interface CDVCapture : CDVPlugin <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
CDVImagePicker* pickerController;
BOOL inUse;
}
@property BOOL inUse;
-- (void) captureAudio:(CDVInvokedUrlCommand*)command;
-- (void) captureImage:(CDVInvokedUrlCommand*)command;
--(NSString*) processImage: (UIImage*) image type: (NSString*) mimeType forCallbackId: (NSString*)callbackId;
-- (void) captureVideo:(CDVInvokedUrlCommand*)command;
--(NSString*) processVideo: (NSString*) moviePath forCallbackId: (NSString*) callbackId;
-- (void) getMediaModes:(CDVInvokedUrlCommand*)command;
-- (void) getFormatData:(CDVInvokedUrlCommand*)command;
--(NSDictionary*) getMediaDictionaryFromPath: (NSString*) fullPath ofType: (NSString*) type;
+- (void)captureAudio:(CDVInvokedUrlCommand*)command;
+- (void)captureImage:(CDVInvokedUrlCommand*)command;
+- (NSString*)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId;
+- (void)captureVideo:(CDVInvokedUrlCommand*)command;
+- (NSString*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId;
+- (void)getMediaModes:(CDVInvokedUrlCommand*)command;
+- (void)getFormatData:(CDVInvokedUrlCommand*)command;
+- (NSDictionary*)getMediaDictionaryFromPath:(NSString*)fullPath ofType:(NSString*)type;
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
@end
+
/* AudioRecorderViewController is used to create a simple view for audio recording.
* It is created from [Capture captureAudio]. It creates a very simple interface for
- * recording by presenting just a record/stop button and a Done button to close the view.
+ * recording by presenting just a record/stop button and a Done button to close the view.
* The recording time is displayed and recording for a specified duration is supported. When duration
- * is specified there is no UI to the user - recording just stops when the specified
- * duration is reached. The UI has been minimized to avoid localization.
+ * is specified there is no UI to the user - recording just stops when the specified
+ * duration is reached. The UI has been minimized to avoid localization.
*/
@interface CDVAudioRecorderViewController : UIViewController <AVAudioRecorderDelegate>
{
@@ -84,11 +84,10 @@ typedef NSUInteger CDVCaptureError;
UIImage* stopRecordImage;
UILabel* timerLabel;
AVAudioRecorder* avRecorder;
- AVAudioSession *avSession;
+ AVAudioSession* avSession;
NSString* resultString;
NSTimer* timer;
BOOL isTimed;
-
}
@property (nonatomic) CDVCaptureError errorCode;
@property (nonatomic, copy) NSString* callbackId;
@@ -106,10 +105,10 @@ typedef NSUInteger CDVCaptureError;
@property (nonatomic, strong) NSTimer* timer;
@property (nonatomic) BOOL isTimed;
-- (id) initWithCommand: (CDVPlugin*) theCommand duration: (NSNumber*) theDuration callbackId: (NSString*) theCallbackId;
-- (void) processButton: (id) sender;
-- (void) stopRecordingCleanup;
-- (void) dismissAudioView: (id) sender;
-- (NSString *) formatTime: (int) interval;
-- (void) updateTime;
+- (id)initWithCommand:(CDVPlugin*)theCommand duration:(NSNumber*)theDuration callbackId:(NSString*)theCallbackId;
+- (void)processButton:(id)sender;
+- (void)stopRecordingCleanup;
+- (void)dismissAudioView:(id)sender;
+- (NSString*)formatTime:(int)interval;
+- (void)updateTime;
@end