You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2020/08/28 10:46:22 UTC

[cordova-plugin-device-motion] branch fix/platforms created (now aed5e25)

This is an automated email from the ASF dual-hosted git repository.

timbru31 pushed a change to branch fix/platforms
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-device-motion.git.


      at aed5e25  fix!: remove deprecated platforms

This branch includes the following new commits:

     new aed5e25  fix!: remove deprecated platforms

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[cordova-plugin-device-motion] 01/01: fix!: remove deprecated platforms

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

timbru31 pushed a commit to branch fix/platforms
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-device-motion.git

commit aed5e25635921ce77fbc08a4083eb01035e98d57
Author: Tim Brust <ti...@sinnerschrader.com>
AuthorDate: Fri Aug 28 12:46:08 2020 +0200

    fix!: remove deprecated platforms
---
 README.md                       |   5 --
 package.json                    |  16 ----
 plugin.xml                      |  86 -------------------
 src/blackberry10/index.js       |  47 -----------
 src/firefoxos/accelerometer.js  |  41 ---------
 src/tizen/AccelerometerProxy.js |  49 -----------
 src/ubuntu/accelerometer.cpp    |  58 -------------
 src/ubuntu/accelerometer.h      |  55 ------------
 src/wp/Accelerometer.cs         | 179 ----------------------------------------
 tests/tests.js                  |   2 +-
 10 files changed, 1 insertion(+), 537 deletions(-)

diff --git a/README.md b/README.md
index 44aef4b..700c95f 100644
--- a/README.md
+++ b/README.md
@@ -60,14 +60,9 @@ Report issues with this plugin on the [Apache Cordova issue tracker](https://iss
 
 ## Supported Platforms
 
-- Amazon Fire OS
 - Android
-- BlackBerry 10
 - Browser
-- Firefox OS
 - iOS
-- Tizen
-- Windows Phone 8
 - Windows
 
 ## Methods
diff --git a/package.json b/package.json
index e3cb71a..ec7f162 100644
--- a/package.json
+++ b/package.json
@@ -6,17 +6,9 @@
   "cordova": {
     "id": "cordova-plugin-device-motion",
     "platforms": [
-      "firefoxos",
       "android",
-      "amazon-fireos",
-      "ubuntu",
       "ios",
-      "blackberry10",
-      "wp7",
-      "wp8",
-      "windows8",
       "windows",
-      "tizen",
       "browser"
     ]
   },
@@ -32,17 +24,9 @@
     "device",
     "motion",
     "ecosystem:cordova",
-    "cordova-firefoxos",
     "cordova-android",
-    "cordova-amazon-fireos",
-    "cordova-ubuntu",
     "cordova-ios",
-    "cordova-blackberry10",
-    "cordova-wp7",
-    "cordova-wp8",
-    "cordova-windows8",
     "cordova-windows",
-    "cordova-tizen",
     "cordova-browser"
   ],
   "scripts": {
diff --git a/plugin.xml b/plugin.xml
index 1b88b57..a9d8d59 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -42,22 +42,8 @@
         With the W3C Device Motion and Orientation API now being supported on iOS, Android and Windows devices, this plugin is not needed any more. Read more about the API at https://www.w3.org/TR/2016/CR-orientation-event-20160818/ 
     </info>
 
-    <!-- firefoxos -->
-    <platform name="firefoxos">
-        <config-file target="config.xml" parent="/*">
-            <feature name="Accelerometer">
-                <param name="firefoxos-package" value="Accelerometer" />
-            </feature>
-        </config-file>
-
-        <js-module src="src/firefoxos/accelerometer.js" name="accelerometer-impl">
-          <runs />
-        </js-module>
-    </platform>
-
     <!-- android -->
     <platform name="android">
-
         <config-file target="res/xml/config.xml" parent="/*">
             <feature name="Accelerometer">
                 <param name="android-package" value="org.apache.cordova.devicemotion.AccelListener"/>
@@ -68,28 +54,8 @@
 
     </platform>
 
-    <!-- amazon-fireos -->
-    <platform name="amazon-fireos">
-
-        <config-file target="res/xml/config.xml" parent="/*">
-            <feature name="Accelerometer">
-                <param name="android-package" value="org.apache.cordova.devicemotion.AccelListener"/>
-            </feature>
-        </config-file>
-
-        <source-file src="src/android/AccelListener.java" target-dir="src/org/apache/cordova/devicemotion" />
-
-    </platform>
-
-    <!-- ubuntu -->
-    <platform name="ubuntu">
-        <header-file src="src/ubuntu/accelerometer.h" />
-        <source-file src="src/ubuntu/accelerometer.cpp" />
-    </platform>
-
     <!-- ios -->
     <platform name="ios">
-
         <config-file target="config.xml" parent="/*">
             <feature name="Accelerometer">
                 <param name="ios-package" value="CDVAccelerometer"/>
@@ -102,51 +68,6 @@
         <framework src="CoreMotion.framework" />
     </platform>
 
-    <!-- blackberry10 -->
-    <platform name="blackberry10">
-        <config-file target="www/config.xml" parent="/widget">
-            <feature name="Accelerometer" value="Accelerometer"/>
-        </config-file>
-        <source-file src="src/blackberry10/index.js" target-dir="Accelerometer" />
-    </platform>
-
-    <!-- wp7 -->
-    <platform name="wp7">
-        <config-file target="config.xml" parent="/*">
-            <feature name="Accelerometer">
-                <param name="wp-package" value="Accelerometer"/>
-            </feature>
-        </config-file>
-
-        <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
-            <Capability Name="ID_CAP_SENSORS" />
-        </config-file>
-
-        <source-file src="src/wp/Accelerometer.cs" />
-    </platform>
-
-    <!-- wp8 -->
-    <platform name="wp8">
-        <config-file target="config.xml" parent="/*">
-            <feature name="Accelerometer">
-                <param name="wp-package" value="Accelerometer"/>
-            </feature>
-        </config-file>
-
-        <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
-            <Capability Name="ID_CAP_SENSORS" />
-        </config-file>
-
-        <source-file src="src/wp/Accelerometer.cs" />
-    </platform>
-
-    <!-- windows8 -->
-    <platform name="windows8">
-        <js-module src="src/windows/AccelerometerProxy.js" name="AccelerometerProxy">
-            <runs />
-        </js-module>
-    </platform>
-
     <!-- windows -->
     <platform name="windows">
         <js-module src="src/windows/AccelerometerProxy.js" name="AccelerometerProxy">
@@ -154,13 +75,6 @@
         </js-module>
     </platform>
 
-    <!-- tizen -->
-    <platform name="tizen">
-        <js-module src="src/tizen/AccelerometerProxy.js" name="AccelerometerProxy">
-            <runs/>
-        </js-module>
-    </platform>
-
     <!-- browser -->
     <platform name="browser">
         <js-module src="src/browser/AccelerometerProxy.js" name="AccelerometerProxy">
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
deleted file mode 100644
index 98bd8ce..0000000
--- a/src/blackberry10/index.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 PluginResult */
-
-var callback;
-
-module.exports = {
-    start: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-        window.removeEventListener("devicemotion", callback);
-        callback = function (motion) {
-            var info = {
-                x: motion.accelerationIncludingGravity.x,
-                y: motion.accelerationIncludingGravity.y,
-                z: motion.accelerationIncludingGravity.z,
-                timestamp: motion.timestamp
-            };
-            result.callbackOk(info, true);
-        };
-        window.addEventListener("devicemotion", callback);
-        result.noResult(true);
-    },
-    stop: function (success, fail, args, env) {
-        var result = new PluginResult(args, env);
-        window.removeEventListener("devicemotion", callback);
-        result.ok("removed");
-    }
-};
diff --git a/src/firefoxos/accelerometer.js b/src/firefoxos/accelerometer.js
deleted file mode 100644
index 5a2f986..0000000
--- a/src/firefoxos/accelerometer.js
+++ /dev/null
@@ -1,41 +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.
- *
-*/
-
-function listener(success, ev) {
-    var acc = ev.accelerationIncludingGravity;
-    acc.timestamp = new Date().getTime();
-    success(acc);
-}
-
-var Accelerometer = {
-    start: function start(success, error) {
-        return window.addEventListener('devicemotion', function(ev) {
-            listener(success, ev);
-        }, false);
-    },
-
-    stop: function stop() {
-        window.removeEventListener('devicemotion', listener, false);
-    }
-};
-
-module.exports = Accelerometer;
-require('cordova/exec/proxy').add('Accelerometer', Accelerometer);
diff --git a/src/tizen/AccelerometerProxy.js b/src/tizen/AccelerometerProxy.js
deleted file mode 100644
index 8352ba9..0000000
--- a/src/tizen/AccelerometerProxy.js
+++ /dev/null
@@ -1,49 +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.
- *
-*/
-
-(function(win) {
-    var accelerometerCallback = null;
-
-    module.exports = {
-        start: function (successCallback, errorCallback) {
-            if (accelerometerCallback) {
-                win.removeEventListener("devicemotion", accelerometerCallback, true);
-            }
-
-            accelerometerCallback = function (motion) {
-                successCallback({
-                    x: motion.accelerationIncludingGravity.x,
-                    y: motion.accelerationIncludingGravity.y,
-                    z: motion.accelerationIncludingGravity.z,
-                    timestamp: new Date().getTime()
-                });
-            };
-            win.addEventListener("devicemotion", accelerometerCallback, true);
-        },
-
-        stop: function (successCallback, errorCallback) {
-            win.removeEventListener("devicemotion", accelerometerCallback, true);
-            accelerometerCallback = null;
-        }
-    };
-
-    require("cordova/tizen/commandProxy").add("Accelerometer", module.exports);
-}(window));
diff --git a/src/ubuntu/accelerometer.cpp b/src/ubuntu/accelerometer.cpp
deleted file mode 100644
index 74e3ead..0000000
--- a/src/ubuntu/accelerometer.cpp
+++ /dev/null
@@ -1,58 +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.
- *
-*/
-
-#include <cassert>
-#include "accelerometer.h"
-
-DeviceMotion::DeviceMotion(Cordova *cordova): CPlugin(cordova), _scId(0), _ecId(0) {
-    _accelerometerSource = QSharedPointer<QAccelerometer>(new QAccelerometer());
-    _sensorAvaliable = _accelerometerSource->start();
-    connect(_accelerometerSource.data(), SIGNAL(readingChanged()), SLOT(updateSensor()));
-}
-
-void DeviceMotion::start(int scId, int ecId) {
-    assert(_ecId == 0);
-    assert(_scId == 0);
-
-    _ecId = ecId;
-    _scId = scId;
-
-    if (!_sensorAvaliable) {
-        this->cb(ecId);
-        return;
-    }
-}
-
-void DeviceMotion::stop(int, int) {
-    _scId = 0;
-    _ecId = 0;
-}
-
-void DeviceMotion::updateSensor() {
-    QAccelerometerReading *accelerometer = _accelerometerSource->reading();
-
-    QVariantMap obj;
-    obj.insert("x", accelerometer->x());
-    obj.insert("y", accelerometer->y());
-    obj.insert("z", accelerometer->z());
-    // accelerometer->timestamp() is not sutiable.
-    // Timestamps values are microseconds since _a_ fixed point(depend on backend).
-    obj.insert("timestamp", QDateTime::currentDateTime().toMSecsSinceEpoch());
-
-    if (_scId)
-        this->callbackWithoutRemove(_scId, CordovaInternal::format(obj));
-}
diff --git a/src/ubuntu/accelerometer.h b/src/ubuntu/accelerometer.h
deleted file mode 100644
index 3f36a16..0000000
--- a/src/ubuntu/accelerometer.h
+++ /dev/null
@@ -1,55 +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.
- *
-*/
-
-#ifndef ACCELEROMETER_H
-#define ACCELEROMETER_H
-
-#include <cplugin.h>
-#include <QAccelerometer>
-#include <QtCore>
-
-class DeviceMotion: public CPlugin {
-    Q_OBJECT
-public:
-    explicit DeviceMotion(Cordova *cordova);
-
-    virtual const QString fullName() override {
-        return DeviceMotion::fullID();
-    }
-
-    virtual const QString shortName() override {
-        return "Accelerometer";
-    }
-
-    static const QString fullID() {
-        return "Accelerometer";
-    }
-
-public slots:
-    void start(int scId, int ecId);
-    void stop(int scId, int ecId);
-
-protected slots:
-    void updateSensor();
-
-private:
-    int _scId, _ecId;
-    bool _sensorAvaliable;
-    QSharedPointer<QAccelerometer> _accelerometerSource;
-};
-
-#endif
diff --git a/src/wp/Accelerometer.cs b/src/wp/Accelerometer.cs
deleted file mode 100644
index 33c5434..0000000
--- a/src/wp/Accelerometer.cs
+++ /dev/null
@@ -1,179 +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.Collections.Generic;
-using System.Runtime.Serialization;
-using System.Threading;
-using Microsoft.Devices.Sensors;
-using System.Globalization;
-using System.Diagnostics;
-using System.Windows.Threading;
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
-    /// <summary>
-    /// Captures device motion in the x, y, and z direction.
-    /// </summary>
-    public class Accelerometer : BaseCommand
-    {
-        #region Status codes and Constants
-
-        public const int Stopped = 0;
-        public const int Starting = 1;
-        public const int Running = 2;
-        public const int ErrorFailedToStart = 3;
-
-        public const double gConstant = -9.81;
-
-        #endregion
-
-        #region Static members
-
-        /// <summary>
-        /// Status of listener
-        /// </summary>
-        private static int currentStatus;
-
-        /// <summary>
-        /// Accelerometer
-        /// </summary>
-        private static readonly Windows.Devices.Sensors.Accelerometer accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault();
-
-        /// <summary>
-        /// Timer which is used to update
-        /// </summary>
-        private static Timer updateTimer;
-
-        /// <summary>
-        /// Callback Id to report acceleration result in watch mode
-        /// </summary>
-        private static string watchCallbackId;
- 
-        #endregion
-
-        /// <summary>
-        /// Starts listening for acceleration sensor
-        /// </summary>
-        /// <returns>status of listener</returns>
-        public void start(string options)
-        {
-            watchCallbackId = GetCallbackIdFromOptions(options);
-
-            if (currentStatus == Running)
-            {
-                return;
-            }
-
-            try
-            {
-                // we use 20ms as a minimum allowed update interval
-                int minReportInterval = Math.Max((int)accelerometer.MinimumReportInterval, 20);
-
-                updateTimer = new Timer(ReportAccelerationValue, null, 0, minReportInterval);
-                this.SetStatus(Running);
-
-                PluginResult result = new PluginResult(PluginResult.Status.OK, GetCurrentAccelerationFormatted());
-                result.KeepCallback = true;
-                DispatchCommandResult(result, watchCallbackId);
-            }
-            catch (Exception ex)
-            {
-                this.SetStatus(ErrorFailedToStart);
-                DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ErrorFailedToStart), watchCallbackId);
-            }
-        }
-
-        public void stop(string options)
-        {
-            string callbackId = GetCallbackIdFromOptions(options);
-
-            if (currentStatus == Running)
-            {
-                watchCallbackId = null;
-                updateTimer.Dispose();
-                this.SetStatus(Stopped);
-            }
-
-            DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId);
-        }
-
-        public void getCurrentAcceleration(string options)
-        {
-            string callbackId = GetCallbackIdFromOptions(options);
-
-            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, GetCurrentAccelerationFormatted()), callbackId);
-        }
-
-        private void ReportAccelerationValue(object stateInfo)
-        {
-            if (String.IsNullOrEmpty(watchCallbackId)) {
-                // soemthing goes wrong, callback has been called after stop..
-                return;
-            }
-            string currentAccelerationFormatted = GetCurrentAccelerationFormatted();
-            var result = currentAccelerationFormatted == null ? new PluginResult(PluginResult.Status.NO_RESULT)
-                                                              : new PluginResult(PluginResult.Status.OK, currentAccelerationFormatted);
-            result.KeepCallback = true;
-            DispatchCommandResult(result, watchCallbackId);
-        }
-
-        /// <summary>
-        /// Formats current coordinates into JSON format
-        /// </summary>
-        /// <returns>Coordinates in JSON format</returns>
-        private string GetCurrentAccelerationFormatted()
-        {
-            try
-            {
-                var currentReading = accelerometer.GetCurrentReading();
-                var currentCoordinates = String.Format("\"x\":{0},\"y\":{1},\"z\":{2}",
-                                (currentReading.AccelerationX * gConstant).ToString("0.00000", CultureInfo.InvariantCulture),
-                                (currentReading.AccelerationY * gConstant).ToString("0.00000", CultureInfo.InvariantCulture),
-                                (currentReading.AccelerationZ * gConstant).ToString("0.00000", CultureInfo.InvariantCulture));
-
-                return "{" + currentCoordinates + "}";
-            }
-            catch
-            {
-                return null;
-            }
-        }
-
-        /// <summary>
-        /// Sets current status
-        /// </summary>
-        /// <param name="status">current status</param>
-        private void SetStatus(int status)
-        {
-            currentStatus = status;
-        }
-
-        private string GetCallbackIdFromOptions(string options)
-        {
-            try
-            {
-                string[] optionsString = JSON.JsonHelper.Deserialize<string[]>(options);
-
-                return optionsString[0];
-            }
-            catch (Exception)
-            {
-                DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION), this.CurrentCommandCallbackId);
-                return null;
-            }
-        }
-    }
-}
diff --git a/tests/tests.js b/tests/tests.js
index e5bc63f..aa2baa2 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -23,7 +23,7 @@
 /* global Windows */
 
 exports.defineAutoTests = function () {
-    var isWindows = (cordova.platformId === "windows") || (cordova.platformId === "windows8"),
+    var isWindows = (cordova.platformId === "windows"),
      // Checking existence of accelerometer for windows platform
      // Assumed that accelerometer always exists on other platforms. Extend
      // condition to support accelerometer check on other platforms


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org