You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/06/11 02:51:43 UTC
[29/36] ios commit: removed battery code
removed battery code
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/69a53dc7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/69a53dc7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/69a53dc7
Branch: refs/heads/3.0.0
Commit: 69a53dc7f0a302514113baaad32726f57dd95c23
Parents: 0387748
Author: Steven Gill <st...@gmail.com>
Authored: Mon May 20 17:39:30 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:48:46 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVBattery.h | 40 -----
CordovaLib/Classes/CDVBattery.m | 152 -------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 8 -
CordovaLib/cordova.js | 11 ++
bin/templates/project/__TESTING__/config.xml | 3 -
6 files changed, 11 insertions(+), 204 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 267ad8a..50fe28d 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,7 +25,6 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVBattery.h"
#import "CDVCamera.h"
#import "CDVCapture.h"
#import "CDVConnection.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/CordovaLib/Classes/CDVBattery.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVBattery.h b/CordovaLib/Classes/CDVBattery.h
deleted file mode 100644
index ba26c3a..0000000
--- a/CordovaLib/Classes/CDVBattery.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- 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
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-
-@interface CDVBattery : CDVPlugin {
- UIDeviceBatteryState state;
- float level;
- bool isPlugged;
- NSString* callbackId;
-}
-
-@property (nonatomic) UIDeviceBatteryState state;
-@property (nonatomic) float level;
-@property (nonatomic) bool isPlugged;
-@property (strong) NSString* callbackId;
-
-- (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/cordova-ios/blob/69a53dc7/CordovaLib/Classes/CDVBattery.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVBattery.m b/CordovaLib/Classes/CDVBattery.m
deleted file mode 100644
index 681511c..0000000
--- a/CordovaLib/Classes/CDVBattery.m
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- 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
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import "CDVBattery.h"
-
-@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
-{
- // send batterylow event for less than 25% battery
- // send batterycritical event for less than 10% battery
- // W3c says to send batteryStatus event when batterylevel changes by more than 1% (iOS seems to notify each 5%)
- // always update the navigator.device.battery info
- float currentLevel = [[UIDevice currentDevice] batteryLevel];
- NSString* type = @"";
- // no check for level == -1 since this api is only called when monitoring is enabled so level should be valid
- if (currentLevel < 0.10){
- type = @"batterycritical";
- } else if (currentLevel < 0.25) {
- type = @"batterylow";
- } else {
- float onePercent = 0.1;
- if (self.level >= 0 ){
- onePercent = self.level * 0.01;
- }
- if (fabsf(currentLevel - self.level) > onePercent){
- // issue batteryStatus event
- type = @"batterystatus";
- }
- }
- // update the battery info and fire event
- NSString* jsString = [NSString stringWithFormat:@"navigator.device.battery._status(\"%@\", %@)", type,[[self getBatteryStatus] JSONRepresentation]];
- [super writeJavascript:jsString];
-}
- */
-
-- (void)updateBatteryStatus:(NSNotification*)notification
-{
- NSDictionary* batteryData = [self getBatteryStatus];
-
- if (self.callbackId) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:batteryData];
- [result setKeepCallbackAsBool:YES];
- [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
- }
-}
-
-/* Get the current battery status and level. Status will be unknown and level will be -1.0 if
- * monitoring is turned off.
- */
-- (NSDictionary*)getBatteryStatus
-{
- UIDevice* currentDevice = [UIDevice currentDevice];
- UIDeviceBatteryState currentState = [currentDevice batteryState];
-
- isPlugged = FALSE; // UIDeviceBatteryStateUnknown or UIDeviceBatteryStateUnplugged
- if ((currentState == UIDeviceBatteryStateCharging) || (currentState == UIDeviceBatteryStateFull)) {
- isPlugged = TRUE;
- }
- float currentLevel = [currentDevice batteryLevel];
-
- 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)) {
- w3cLevel = [NSNull null];
- } else {
- w3cLevel = [NSNumber numberWithFloat:(currentLevel * 100)];
- }
- NSMutableDictionary* batteryData = [NSMutableDictionary dictionaryWithCapacity:2];
- [batteryData setObject:[NSNumber numberWithBool:isPlugged] forKey:@"isPlugged"];
- [batteryData setObject:w3cLevel forKey:@"level"];
- return batteryData;
-}
-
-/* turn on battery monitoring*/
-- (void)start:(CDVInvokedUrlCommand*)command
-{
- self.callbackId = command.callbackId;
-
- 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];
- }
-}
-
-/* turn off battery monitoring */
-- (void)stop:(CDVInvokedUrlCommand*)command
-{
- // callback one last time to clear the callback function on JS side
- if (self.callbackId) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getBatteryStatus]];
- [result setKeepCallbackAsBool:NO];
- [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
- }
- self.callbackId = nil;
- [[UIDevice currentDevice] setBatteryMonitoringEnabled:NO];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryStateDidChangeNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryLevelDidChangeNotification object:nil];
-}
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVBattery*)[super initWithWebView:theWebView];
- if (self) {
- self.state = UIDeviceBatteryStateUnknown;
- self.level = -1.0;
- }
- return self;
-}
-
-- (void)dealloc
-{
- [self stop:nil];
-}
-
-- (void)onReset
-{
- [self stop:nil];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 224d8fa..da4e2f0 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -7,8 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
- 1F2BECC013F9785B00A93BF6 /* CDVBattery.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F2BECBE13F9785B00A93BF6 /* CDVBattery.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 1F2BECC113F9785B00A93BF6 /* CDVBattery.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F2BECBF13F9785B00A93BF6 /* CDVBattery.m */; };
1F3C04CE12BC247D004F9E10 /* CDVContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F3C04CC12BC247D004F9E10 /* CDVContact.h */; settings = {ATTRIBUTES = (Public, ); }; };
1F3C04CF12BC247D004F9E10 /* CDVContact.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3C04CD12BC247D004F9E10 /* CDVContact.m */; };
1F584B9B1385A28A00ED25E8 /* CDVCapture.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F584B991385A28900ED25E8 /* CDVCapture.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -86,8 +84,6 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
- 1F2BECBE13F9785B00A93BF6 /* CDVBattery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVBattery.h; path = Classes/CDVBattery.h; sourceTree = "<group>"; };
- 1F2BECBF13F9785B00A93BF6 /* CDVBattery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVBattery.m; path = Classes/CDVBattery.m; sourceTree = "<group>"; };
1F3C04CC12BC247D004F9E10 /* CDVContact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVContact.h; path = Classes/CDVContact.h; sourceTree = "<group>"; };
1F3C04CD12BC247D004F9E10 /* CDVContact.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVContact.m; path = Classes/CDVContact.m; sourceTree = "<group>"; };
1F584B991385A28900ED25E8 /* CDVCapture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCapture.h; path = Classes/CDVCapture.h; sourceTree = "<group>"; };
@@ -268,8 +264,6 @@
30C684931407044A004C1A8E /* CDVURLProtocol.m */,
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */,
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */,
- 1F2BECBE13F9785B00A93BF6 /* CDVBattery.h */,
- 1F2BECBF13F9785B00A93BF6 /* CDVBattery.m */,
30B39EBC13D0268B0009682A /* CDVSplashScreen.h */,
30B39EBD13D0268B0009682A /* CDVSplashScreen.m */,
30E33AF013A7E24B00594D64 /* CDVPlugin.h */,
@@ -370,7 +364,6 @@
302965BC13A94E9D007046C5 /* CDVDebug.h in Headers */,
30B39EBE13D0268B0009682A /* CDVSplashScreen.h in Headers */,
30E563CF13E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */,
- 1F2BECC013F9785B00A93BF6 /* CDVBattery.h in Headers */,
30C684801406CB38004C1A8E /* CDVWhitelist.h in Headers */,
30C684941407044B004C1A8E /* CDVURLProtocol.h in Headers */,
8852C43A14B65FD800F0E735 /* CDVViewController.h in Headers */,
@@ -465,7 +458,6 @@
30E33AF313A7E24B00594D64 /* CDVPlugin.m in Sources */,
30B39EBF13D0268B0009682A /* CDVSplashScreen.m in Sources */,
30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */,
- 1F2BECC113F9785B00A93BF6 /* CDVBattery.m in Sources */,
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */,
30C684961407044B004C1A8E /* CDVURLProtocol.m in Sources */,
8852C43C14B65FD800F0E735 /* CDVViewController.m in Sources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 6c42712..eb17a61 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,9 +1,13 @@
// Platform: ios
<<<<<<< HEAD
+<<<<<<< HEAD
// 2.8.0-0-g6208c95
=======
// 2.7.0rc1-80-geda98d1
>>>>>>> removed InAppBrowser
+=======
+// 2.7.0rc1-81-gc09114e
+>>>>>>> removed battery code
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -24,10 +28,14 @@
*/
;(function() {
<<<<<<< HEAD
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-80-geda98d1';
>>>>>>> removed InAppBrowser
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-81-gc09114e';
+>>>>>>> removed battery code
// file: lib/scripts/require.js
var require,
@@ -3695,6 +3703,7 @@ module.exports = ProgressEvent;
});
+<<<<<<< HEAD
// file: lib/common/plugin/accelerometer.js
define("cordova/plugin/accelerometer", function(require, exports, module) {
@@ -3955,6 +3964,8 @@ modulemapper.defaults('cordova/plugin/battery', 'navigator.battery');
});
+=======
+>>>>>>> removed battery code
// file: lib/common/plugin/camera/symbols.js
define("cordova/plugin/camera/symbols", function(require, exports, module) {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 7bb5448..dbe25bb 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -77,9 +77,6 @@
<feature name="Capture">
<param name="ios-package" value="CDVCapture"/>
</feature>
- <feature name="Battery">
- <param name="ios-package" value="CDVBattery"/>
- </feature>
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen"/>
</feature>