[
https://issues.apache.org/jira/browse/CB-13667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16290456#comment-16290456
]
ASF GitHub Bot commented on CB-13667:
-------------------------------------
maverickmishra closed pull request #61: CB-13667 : Remove deprecated platforms
URL: https://github.com/apache/cordova-plugin-battery-status/pull/61
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/README.md b/README.md
index 6c76309..f8f9eda 100644
--- a/README.md
+++ b/README.md
@@ -60,26 +60,14 @@ Fires when the battery charge percentage changes by at
least 1 percent, or when
### Supported Platforms
-- Amazon Fire OS
- iOS
- Android
-- BlackBerry 10
-- Windows Phone 7 and 8
-- Windows (Windows Phone 8.1 and Windows 10)
-- Firefox OS
+- Windows
- Browser (Chrome, Firefox, Opera)
-### Quirks: Android & Amazon Fire OS
+### Quirks: Android
-**Warning**: the Android and Fire OS implementations are greedy and prolonged
use will drain the device's battery.
-
-### Quirks: Windows Phone 7 & Windows Phone 8
-
-The `level` property is _not_ supported on Windows Phone 7 because the OS does
not provide native APIs to determine battery level. The `isPlugged` parameter
_is_ supported.
-
-### Quirks: Windows Phone 8.1
-
-The `isPlugged` parameter is _not_ supported on Windows Phone 8.1. The `level`
parameter _is_ supported.
+**Warning**: the Android implementation is greedy and prolonged use will drain
the device's battery.
## batterylow event
@@ -95,18 +83,11 @@ Fires when the battery charge percentage reaches the low
charge threshold. This
### Supported Platforms
-- Amazon Fire OS
- iOS
- Android
-- BlackBerry 10
-- Firefox OS
-- Windows (Windows Phone 8.1 and Windows 10)
+- Windows
- Browser (Chrome, Firefox, Opera)
-### Quirks: Windows Phone 8.1
-
-The `batterylow` event fires on Windows Phone 8.1 irrespective of whether the
device is plugged in or not. This happens because the OS does not provide an
API to detect whether the device is plugged in.
-
## batterycritical event
Fires when the battery charge percentage reaches the critical charge
threshold. This threshold value is device-specific. Returns an
[object][status_object] containing battery status.
@@ -121,17 +102,11 @@ Fires when the battery charge percentage reaches the
critical charge threshold.
### Supported Platforms
-- Amazon Fire OS
- iOS
- Android
-- BlackBerry 10
-- Firefox OS
-- Windows (Windows Phone 8.1 and Windows 10)
+- Windows
- Browser (Chrome, Firefox, Opera)
-### Quirks: Windows Phone 8.1
-
-The `batterycritical` event fires on Windows Phone 8.1 irrespective of whether
the device is plugged in or not. This happens because the OS does not provide
an API to detect whether the device is plugged in.
[w3c_spec]: http://www.w3.org/TR/2011/WD-battery-status-20110915/
[status_object]: #status-object
diff --git a/package.json b/package.json
index 24d80e0..73447f3 100644
--- a/package.json
+++ b/package.json
@@ -1,20 +1,15 @@
{
"name": "cordova-plugin-battery-status",
- "version": "1.2.6-dev",
+ "version": "2.0.0-dev",
"description": "Cordova Battery Plugin",
"types": "./types/index.d.ts",
"cordova": {
"id": "cordova-plugin-battery-status",
"platforms": [
"android",
- "amazon-fireos",
- "ubuntu",
"ios",
- "blackberry10",
- "wp7",
- "wp8",
- "tizen",
- "firefoxos"
+ "browser",
+ "windows"
]
},
"repository": {
@@ -29,14 +24,7 @@
"battery",
"ecosystem:cordova",
"cordova-android",
- "cordova-amazon-fireos",
- "cordova-ubuntu",
- "cordova-ios",
- "cordova-blackberry10",
- "cordova-wp7",
- "cordova-wp8",
- "cordova-tizen",
- "cordova-firefoxos"
+ "cordova-ios"
],
"scripts": {
"test": "npm run eslint",
diff --git a/plugin.xml b/plugin.xml
index 39d1596..3c15e77 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -20,7 +20,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-battery-status"
- version="1.2.6-dev">
+ version="2.0.0-dev">
<name>Battery</name>
<description>Cordova Battery Plugin</description>
<license>Apache 2.0</license>
@@ -43,23 +43,6 @@
<source-file src="src/android/BatteryListener.java"
target-dir="src/org/apache/cordova/batterystatus" />
</platform>
- <!-- amazon-fireos -->
- <platform name="amazon-fireos">
- <config-file target="res/xml/config.xml" parent="/*">
- <feature name="Battery" >
- <param name="android-package"
value="org.apache.cordova.batterystatus.BatteryListener"/>
- </feature>
- </config-file>
-
- <source-file src="src/android/BatteryListener.java"
target-dir="src/org/apache/cordova/batterystatus" />
- </platform>
-
- <!-- ubuntu -->
- <platform name="ubuntu">
- <header-file src="src/ubuntu/battery.h" />
- <source-file src="src/ubuntu/battery.cpp" />
- </platform>
-
<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
@@ -71,36 +54,6 @@
<source-file src="src/ios/CDVBattery.m" />
</platform>
- <!-- blackberry10 -->
- <platform name="blackberry10">
- <source-file src="src/blackberry10/index.js" target-dir="Battery" />
- <config-file target="www/config.xml" parent="/widget">
- <feature name="Battery" value="Battery"/>
- </config-file>
- </platform>
-
- <!-- wp7 -->
- <platform name="wp7">
- <config-file target="config.xml" parent="/*">
- <feature name="Battery">
- <param name="wp-package" value="Battery"/>
- </feature>
- </config-file>
-
- <source-file src="src/wp/Battery.cs" />
- </platform>
-
- <!-- wp8 -->
- <platform name="wp8">
- <config-file target="config.xml" parent="/*">
- <feature name="Battery">
- <param name="wp-package" value="Battery"/>
- </feature>
- </config-file>
-
- <source-file src="src/wp/Battery.cs" />
- </platform>
-
<!-- windows -->
<platform name="windows">
<js-module src="src/windows/BatteryProxy.js" name="Battery">
@@ -110,20 +63,6 @@
<framework src="src/windows/BatteryStatus.winmd" custom="true"
target="phone"/>
</platform>
- <!-- tizen -->
- <platform name="tizen">
- <js-module src="src/tizen/BatteryStatusProxy.js"
name="BatteryStatusProxy">
- <runs/>
- </js-module>
- </platform>
-
- <!-- firefoxos -->
- <platform name="firefoxos">
- <js-module src="src/firefoxos/BatteryProxy.js" name="Battery">
- <runs />
- </js-module>
- </platform>
-
<!-- browser -->
<platform name="browser">
<js-module src="src/browser/BatteryProxy.js" name="Battery">
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
deleted file mode 100644
index 995908d..0000000
--- a/src/blackberry10/index.js
+++ /dev/null
@@ -1,79 +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.
- *
-*/
-
-/* global PluginResult */
-
-var _clientListeners = {};
-var _webkitBattery = navigator.webkitBattery || navigator.battery;
-
-module.exports = {
- start: function (success, fail, args, env) {
- var result = new PluginResult(args, env);
- var listener = function (info) {
- var resultInfo = {};
- if (info) {
- if (info.srcElement) {
- // webkitBattery listeners store webkitBattery in
srcElement object
- info = info.srcElement;
- }
-
- // put data from webkitBattery into a format cordova expects
- // webkitBattery seems to return level as a decimal pre 10.2
- resultInfo.level = info.level <= 1 ? info.level * 100 :
info.level;
- resultInfo.isPlugged = info.charging;
- }
-
- result.callbackOk(resultInfo, true);
- };
-
- if (_clientListeners[env.webview.id]) {
- // TODO: Change back to erroring out after reset is implemented
- // result.error("Battery listener already running");
- _webkitBattery.onchargingchange = null;
- _webkitBattery.onlevelchange = null;
- }
-
- _clientListeners[env.webview.id] = listener;
-
- _webkitBattery.onchargingchange = listener;
- _webkitBattery.onlevelchange = listener;
-
- setTimeout(function () {
- // Call callback with webkitBattery data right away
- listener(_webkitBattery);
- });
-
- result.noResult(true);
- },
- stop: function (success, fail, args, env) {
- var result = new PluginResult(args, env);
- var listener = _clientListeners[env.webview.id];
-
- if (!listener) {
- result.error('Battery listener has not started');
- } else {
- _webkitBattery.onchargingchange = null;
- _webkitBattery.onlevelchange = null;
- delete _clientListeners[env.webview.id];
- result.noResult(false);
- }
- }
-};
diff --git a/src/firefoxos/BatteryProxy.js b/src/firefoxos/BatteryProxy.js
deleted file mode 100644
index 98a76a1..0000000
--- a/src/firefoxos/BatteryProxy.js
+++ /dev/null
@@ -1,61 +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.
- *
- */
-
-var mozBattery =
cordova.require('cordova/modulemapper').getOriginalSymbol(window,
'navigator.battery') || navigator.mozBattery; // eslint-disable-line no-undef
-
-var Battery = {
- start: function (successCB, failCB, args, env) {
- if (mozBattery) {
- Battery.attachListeners(successCB);
- } else {
- failCB('Could not get window.navigator.battery');
- }
- },
-
- stop: function () {
- Battery.detachListeners();
- },
-
- attachListeners: function (_callBack) {
-
- Battery.updateBatteryStatus(_callBack); // send a battery status event
-
- mozBattery.addEventListener('chargingchange', function () {
- _callBack({level: (mozBattery.level * 100), isPlugged:
mozBattery.charging});
- });
-
- mozBattery.addEventListener('levelchange', function () {
- _callBack({level: (mozBattery.level * 100), isPlugged:
mozBattery.charging});
- });
- },
-
- detachListeners: function () {
-
- mozBattery.removeEventListener('chargingchange', null);
- mozBattery.removeEventListener('levelchange', null);
- },
-
- updateBatteryStatus: function (_callBack) {
- _callBack({level: (mozBattery.level * 100), isPlugged:
mozBattery.charging});
- }
-};
-
-require('cordova/exec/proxy').add('Battery', Battery);
diff --git a/src/tizen/BatteryStatusProxy.js b/src/tizen/BatteryStatusProxy.js
deleted file mode 100644
index 56feabc..0000000
--- a/src/tizen/BatteryStatusProxy.js
+++ /dev/null
@@ -1,47 +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.
- *
-*/
-
-/* global tizen */
-
-var batteryListenerId = null;
-
-module.exports = {
- start: function (successCallback, errorCallback) {
- var batterySuccessCallback = function (power) {
- if (successCallback) {
- successCallback({level: Math.round(power.level * 100),
isPlugged: power.isCharging});
- }
- };
-
- if (batteryListenerId === null) {
- batteryListenerId =
tizen.systeminfo.addPropertyValueChangeListener('BATTERY',
batterySuccessCallback);
- }
-
- tizen.systeminfo.getPropertyValue('BATTERY', batterySuccessCallback,
errorCallback);
- },
-
- stop: function (successCallback, errorCallback) {
- tizen.systeminfo.removePropertyValueChangeListener(batteryListenerId);
- batteryListenerId = null;
- }
-};
-
-require('cordova/tizen/commandProxy').add('Battery', module.exports);
diff --git a/src/ubuntu/battery.cpp b/src/ubuntu/battery.cpp
deleted file mode 100644
index f3b8f80..0000000
--- a/src/ubuntu/battery.cpp
+++ /dev/null
@@ -1,78 +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.
- *
-*/
-
-#include <QtCore>
-
-#include "battery.h"
-
-BatteryStatus::BatteryStatus(Cordova *cordova) : CPlugin(cordova) {
- _scId = 0;
-
- connect(&_batteryInfo, SIGNAL(remainingCapacityChanged(int,int)), this,
SLOT(remainingCapacityChanged(int,int)));
- connect(&_batteryInfo,
SIGNAL(chargerTypeChanged(QBatteryInfo::ChargerType)), this,
SLOT(chargerTypeChanged(QBatteryInfo::ChargerType)));
-}
-
-void BatteryStatus::remainingCapacityChanged(int battery, int capacity) {
- Q_UNUSED(battery);
- Q_UNUSED(capacity);
-
- fireEvents();
-}
-
-void BatteryStatus::chargerTypeChanged(QBatteryInfo::ChargerType type) {
- Q_UNUSED(type);
-
- fireEvents();
-}
-
-void BatteryStatus::fireEvents() {
- int fullCount = 0;
- bool isPlugged = false;
-
- int remaining = 0, total = 0;
- for (int i = 0; i < _batteryInfo.batteryCount(); i++) {
- isPlugged = (_batteryInfo.chargingState(i) == QBatteryInfo::Charging)
|| isPlugged;
- fullCount += _batteryInfo.chargingState(i) == QBatteryInfo::Full;
-
- remaining += _batteryInfo.remainingCapacity(i);
- total += _batteryInfo.maximumCapacity(i);
- }
-
- isPlugged = isPlugged || (_batteryInfo.batteryCount() == fullCount);
-
- if (_scId) {
- QVariantMap obj;
- obj.insert("isPlugged", (int)isPlugged);
- if (total != 0)
- obj.insert("level", remaining * 100 / total);
- else
- obj.insert("level", 100);
-
- this->callbackWithoutRemove(_scId, CordovaInternal::format(obj));
- }
-}
-
-void BatteryStatus::start(int scId, int) {
- _scId = scId;
-}
-
-void BatteryStatus::stop(int, int) {
- _scId = 0;
-}
diff --git a/src/ubuntu/battery.h b/src/ubuntu/battery.h
deleted file mode 100644
index cec7856..0000000
--- a/src/ubuntu/battery.h
+++ /dev/null
@@ -1,62 +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.
- *
-*/
-
-#ifndef BATTERY_H_AAAAAAAA
-#define BATTERY_H_AAAAAAAA
-
-#include <QBatteryInfo>
-
-#include <cplugin.h>
-
-class BatteryStatus: public CPlugin {
- Q_OBJECT
-public:
- explicit BatteryStatus(Cordova *cordova);
-
- virtual const QString fullName() override {
- return BatteryStatus::fullID();
- }
-
- virtual const QString shortName() override {
- return "Battery";
- }
-
- static const QString fullID() {
- return "Battery";
- }
-
-public slots:
- void start(int scId, int ecId);
- void stop(int scId, int ecId);
-
-private slots:
- void remainingCapacityChanged(int battery, int capacity);
- void chargerTypeChanged(QBatteryInfo::ChargerType type);
- void onlineStatusChanged(bool isOnline);
-
-private:
- void fireEvents();
-
- QBatteryInfo _batteryInfo;
-
- int _scId;
-};
-
-#endif
diff --git a/src/wp/Battery.cs b/src/wp/Battery.cs
deleted file mode 100644
index 219d8ff..0000000
--- a/src/wp/Battery.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- Licensed 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.
-*/
-
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-
-using Microsoft.Phone.Info;
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
- /// <summary>
- /// Listens for changes to the state of the battery on the device.
- /// </summary>
- public class Battery : BaseCommand
- {
- private bool isPlugged = false;
- private EventHandler powerChanged;
-#if WP8
- private Windows.Phone.Devices.Power.Battery battery;
-#endif
- public Battery()
- {
- powerChanged = new EventHandler(DeviceStatus_PowerSourceChanged);
- isPlugged =
DeviceStatus.PowerSource.ToString().CompareTo("External") == 0;
-
-#if WP8
- battery = Windows.Phone.Devices.Power.Battery.GetDefault();
-#endif
- }
-
- public void start(string options)
- {
- // Register power changed event handler
- DeviceStatus.PowerSourceChanged += powerChanged;
-
-#if WP8
- battery.RemainingChargePercentChanged +=
Battery_RemainingChargePercentChanged;
-#endif
-
- PluginResult result = new
PluginResult(PluginResult.Status.NO_RESULT);
- result.KeepCallback = true;
- DispatchCommandResult(result);
- }
- public void stop(string options)
- {
- // Unregister power changed event handler
- DeviceStatus.PowerSourceChanged -= powerChanged;
-#if WP8
- battery.RemainingChargePercentChanged -=
Battery_RemainingChargePercentChanged;
-#endif
- }
-
- private void DeviceStatus_PowerSourceChanged(object sender, EventArgs
e)
- {
- isPlugged =
DeviceStatus.PowerSource.ToString().CompareTo("External") == 0;
- PluginResult result = new PluginResult(PluginResult.Status.OK,
GetCurrentBatteryStateFormatted());
- result.KeepCallback = true;
- DispatchCommandResult(result);
- }
-
- private void Battery_RemainingChargePercentChanged(object sender,
object e)
- {
- PluginResult result = new PluginResult(PluginResult.Status.OK,
GetCurrentBatteryStateFormatted());
- result.KeepCallback = true;
- DispatchCommandResult(result);
- }
-
- private string GetCurrentBatteryStateFormatted()
- {
- int remainingChargePercent = -1;
-#if WP8
- remainingChargePercent = battery.RemainingChargePercent;
-#endif
-
-
- string batteryState =
String.Format("\"level\":{0},\"isPlugged\":{1}",
- remainingChargePercent,
- isPlugged ? "true" :
"false"
- );
- batteryState = "{" + batteryState + "}";
- return batteryState;
- }
-
- }
-}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Remove deprecated platforms for the Battery status plugin
> ---------------------------------------------------------
>
> Key: CB-13667
> URL: https://issues.apache.org/jira/browse/CB-13667
> Project: Apache Cordova
> Issue Type: Task
> Reporter: Vishal Mishra
> Assignee: Vishal Mishra
>
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]