Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(windows)!: remove platform support #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ description: Access accelerometer data.

# Usage Notice

With the [W3C Device Orientation API](https://www.w3.org/TR/orientation-event/), Android, iOS, and Windows devices may not need this plugin anymore.
With the [W3C Device Orientation API](https://www.w3.org/TR/orientation-event/), Android and iOS devices may not need this plugin anymore.

However, on iOS 13+, potential issues with permissions and secure contexts can arise. Therefore it is recommended to use this plugin as it uses a native implementation.

Expand Down Expand Up @@ -61,7 +61,6 @@ Report issues with this plugin on the [Apache Cordova issue tracker](https://iss
- Android
- Browser
- iOS
- Windows

## Methods

Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"platforms": [
"android",
"ios",
"windows",
"browser"
]
},
Expand All @@ -21,7 +20,6 @@
"ecosystem:cordova",
"cordova-android",
"cordova-ios",
"cordova-windows",
"cordova-browser"
],
"scripts": {
Expand Down
7 changes: 0 additions & 7 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@
<framework src="CoreMotion.framework" />
</platform>

<!-- windows -->
<platform name="windows">
<js-module src="src/windows/AccelerometerProxy.js" name="AccelerometerProxy">
<runs />
</js-module>
</platform>

<!-- browser -->
<platform name="browser">
<js-module src="src/browser/AccelerometerProxy.js" name="AccelerometerProxy">
Expand Down
74 changes: 0 additions & 74 deletions src/windows/AccelerometerProxy.js

This file was deleted.

42 changes: 0 additions & 42 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@
*
*/

/* global cordova, Windows */

exports.defineAutoTests = function () {
const 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
let isAccelExist = isWindows ? Windows.Devices.Sensors.Accelerometer.getDefault() !== null : true;

describe('Accelerometer (navigator.accelerometer)', function () {
const fail = function (done) {
expect(true).toBe(false);
Expand All @@ -53,10 +45,6 @@ exports.defineAutoTests = function () {
});

it('accelerometer.spec.3 success callback should be called with an Acceleration object', function (done) {
// skip the test if Accelerometer doesn't exist on this device
if (!isAccelExist) {
pending();
}
const win = function (a) {
expect(a).toBeDefined();
expect(a.x).toBeDefined();
Expand All @@ -73,7 +61,6 @@ exports.defineAutoTests = function () {
const onError = function (err) {
console.log(err);
console.log('Skipping gyroscope tests, marking all as pending.');
isAccelExist = false;
expect(true).toBe(true);
done();
};
Expand All @@ -82,10 +69,6 @@ exports.defineAutoTests = function () {
});

it('accelerometer.spec.4 success callback Acceleration object should have (reasonable) values for x, y and z expressed in m/s^2', function (done) {
// skip the test if Accelerometer doesn't exist on this device
if (!isAccelExist) {
pending();
}
const reasonableThreshold = 15;
const win = function (a) {
expect(a.x).toBeLessThan(reasonableThreshold);
Expand All @@ -101,10 +84,6 @@ exports.defineAutoTests = function () {
});

it('accelerometer.spec.5 success callback Acceleration object should return a recent timestamp', function (done) {
// skip the test if Accelerometer doesn't exist on this device
if (!isAccelExist) {
pending();
}
const veryRecently = new Date().getTime();
// Need to check that dates returned are not vastly greater than a recent time stamp.
// In case the timestamps returned are ridiculously high
Expand Down Expand Up @@ -137,10 +116,6 @@ exports.defineAutoTests = function () {
});

it('accelerometer.spec.7 success callback should be called with an Acceleration object', function (done) {
// skip the test if Accelerometer doesn't exist on this device
if (!isAccelExist) {
pending();
}
const win = function (a) {
expect(a).toBeDefined();
expect(a.x).toBeDefined();
Expand All @@ -158,10 +133,6 @@ exports.defineAutoTests = function () {
});

it('accelerometer.spec.8 success callback Acceleration object should have (reasonable) values for x, y and z expressed in m/s^2', function (done) {
// skip the test if Accelerometer doesn't exist on this device
if (!isAccelExist) {
pending();
}
const reasonableThreshold = 15;
const win = function (a) {
expect(a.x).toBeLessThan(reasonableThreshold);
Expand All @@ -177,10 +148,6 @@ exports.defineAutoTests = function () {
});

it('accelerometer.spec.9 success callback Acceleration object should return a recent timestamp', function (done) {
// skip the test if Accelerometer doesn't exist on this device
if (!isAccelExist) {
pending();
}
const veryRecently = new Date().getTime();
// Need to check that dates returned are not vastly greater than a recent time stamp.
// In case the timestamps returned are ridiculously high
Expand All @@ -195,10 +162,6 @@ exports.defineAutoTests = function () {
});

it('accelerometer.spec.12 success callback should be preserved and called several times', function (done) {
// skip the test if Accelerometer doesn't exist on this device
if (!isAccelExist) {
pending();
}
let callbacksCallCount = 0;
const callbacksCallTestCount = 3;

Expand All @@ -221,11 +184,6 @@ exports.defineAutoTests = function () {
});

it('accelerometer.spec.11 should clear an existing watch', function (done) {
// skip the test if Accelerometer doesn't exist on this device
if (!isAccelExist) {
pending();
}

// expect win to get called exactly once
let win = function (a) {
// clear watch on first call
Expand Down
17 changes: 0 additions & 17 deletions www/accelerometer.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,6 @@ var accelerometer = {
getCurrentAcceleration: function (successCallback, errorCallback, options) {
argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);

if (cordova.platformId === 'windowsphone') {
exec(
function (a) {
accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
successCallback(accel);
},
function (e) {
errorCallback(e);
},
'Accelerometer',
'getCurrentAcceleration',
[]
);

return;
}

if (cordova.platformId === 'browser' && !eventTimerId) {
// fire devicemotion event once
var devicemotionEvent = new Event('devicemotion');
Expand Down
Loading