mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
Removed location tests and deprecated camera module.
This commit is contained in:
@ -1,176 +0,0 @@
|
|||||||
// >> location-require
|
|
||||||
import locationModule = require("location");
|
|
||||||
// << location-require
|
|
||||||
|
|
||||||
import TKUnit = require("./TKUnit");
|
|
||||||
|
|
||||||
var LocationManager = locationModule.LocationManager;
|
|
||||||
var Location = locationModule.Location;
|
|
||||||
|
|
||||||
var locationIsEnabled: boolean;
|
|
||||||
|
|
||||||
export function setUp() {
|
|
||||||
locationIsEnabled = LocationManager.isEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function tearDown() {
|
|
||||||
locationIsEnabled = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export var testIsEnabled = function () {
|
|
||||||
if (!locationIsEnabled) {
|
|
||||||
console.log("Location service is not enabled!!!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// >> location-funcs
|
|
||||||
//var LocationManager = require("location").LocationManager;
|
|
||||||
var isEnabled = LocationManager.isEnabled();
|
|
||||||
// << location-funcs
|
|
||||||
TKUnit.assert(isEnabled);
|
|
||||||
};
|
|
||||||
|
|
||||||
export var testDistance = function () {
|
|
||||||
// >> location-distance
|
|
||||||
//var Location = require("location").Location;
|
|
||||||
var locSofia = new Location();
|
|
||||||
locSofia.longitude = 42.696552;
|
|
||||||
locSofia.latitude = 23.32601;
|
|
||||||
var locNewYork = new Location();
|
|
||||||
locNewYork.longitude = 40.71448;
|
|
||||||
locNewYork.latitude = -74.00598;
|
|
||||||
var distance = LocationManager.distance(locSofia, locNewYork);
|
|
||||||
// << location-distance
|
|
||||||
TKUnit.assert((distance > 10780000) && (distance < 10860000), "invalid distance " + distance);
|
|
||||||
};
|
|
||||||
|
|
||||||
export var testLocation = function (done) {
|
|
||||||
if (!locationIsEnabled) {
|
|
||||||
done(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
var locationReceived;
|
|
||||||
|
|
||||||
// >> location-updates
|
|
||||||
//var LocationManager = require("location").LocationManager;
|
|
||||||
var locationManager = new LocationManager();
|
|
||||||
|
|
||||||
locationManager.startLocationMonitoring(function (location) {
|
|
||||||
//console.log('Location received: ' + JSON.stringify(location));
|
|
||||||
// >> (hide)
|
|
||||||
locationReceived = true;
|
|
||||||
locationManager.stopLocationMonitoring();
|
|
||||||
try {
|
|
||||||
TKUnit.assert(true === locationReceived, locationReceived);
|
|
||||||
done(null);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
done(e);
|
|
||||||
}
|
|
||||||
// << (hide)
|
|
||||||
}, function (error) {
|
|
||||||
//console.log('Location error received: ' + error);
|
|
||||||
// >> (hide)
|
|
||||||
locationReceived = error;
|
|
||||||
locationManager.stopLocationMonitoring();
|
|
||||||
done(error);
|
|
||||||
// << (hide)
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// << location-updates
|
|
||||||
//var isReady = function () {
|
|
||||||
// return locationReceived;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//TKUnit.waitUntilReady(isReady, 10);
|
|
||||||
|
|
||||||
//TKUnit.assert(true === locationReceived, locationReceived);
|
|
||||||
};
|
|
||||||
|
|
||||||
export var testLastKnownLocation = function () {
|
|
||||||
if (!locationIsEnabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TKUnit.waitUntilReady(function () { return false; }, 1); // give it some time after the last test
|
|
||||||
// >> location-last-known
|
|
||||||
// var LocationManager = require("location").LocationManager;
|
|
||||||
var locationManager = new LocationManager();
|
|
||||||
var lastKnownLocation = locationManager.lastKnownLocation;
|
|
||||||
// << location-last-known
|
|
||||||
TKUnit.assert((lastKnownLocation != null), "There is no last known location");
|
|
||||||
};
|
|
||||||
|
|
||||||
function doOnce(options: locationModule.Options, done) {
|
|
||||||
if (!locationIsEnabled) {
|
|
||||||
return done(null);
|
|
||||||
}
|
|
||||||
var locationReceived;
|
|
||||||
locationModule.getLocation(options).then(function (location) {
|
|
||||||
locationReceived = true;
|
|
||||||
try {
|
|
||||||
TKUnit.assert(true === locationReceived, locationReceived);
|
|
||||||
done(null);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
done(e);
|
|
||||||
}
|
|
||||||
}, function (error) {
|
|
||||||
locationReceived = error;
|
|
||||||
done(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export var testLocationOnce = function (done) {
|
|
||||||
doOnce(undefined, done);
|
|
||||||
};
|
|
||||||
|
|
||||||
export var testLocationOnceTimeout0 = function (done) {
|
|
||||||
doOnce({ timeout: 0 }, done);
|
|
||||||
};
|
|
||||||
|
|
||||||
export var testLocationOnceMaximumAge = function (done) {
|
|
||||||
if (!locationIsEnabled) {
|
|
||||||
return done(null);
|
|
||||||
}
|
|
||||||
TKUnit.waitUntilReady(function () { return false; }, 2);
|
|
||||||
doOnce({ maximumAge: 86400000, timeout: 0 }, done); // this should pass max age denotes that Real location is taken today.
|
|
||||||
doOnce({ maximumAge: 1000, timeout: 0 }, (err) => {
|
|
||||||
if (err && err.message === "timeout is 0 and last known location is older than maximumAge") {
|
|
||||||
// since last known location is taken before 1 sec (what is the meaning of the maximumAge: 1000 value)
|
|
||||||
// we consider this as a successful test since we test that maxAge check is working
|
|
||||||
done(null);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
done(new Error("maximumAge check failed"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export var testLocationOnceTimeout10000 = function (done) {
|
|
||||||
doOnce({ timeout: 10000 }, done);
|
|
||||||
};
|
|
||||||
|
|
||||||
export var testSnippet = function (done) {
|
|
||||||
if (!locationIsEnabled) {
|
|
||||||
return done(null);
|
|
||||||
}
|
|
||||||
var locationReceived;
|
|
||||||
// >> location-timeour
|
|
||||||
// var locationModule = require("location");
|
|
||||||
//// options can also look like { maximumAge: 2000, timeout: 20 * 1000 }
|
|
||||||
locationModule.getLocation({ maximumAge: 30000, timeout: 5000 }).then(function (location) {
|
|
||||||
//console.log('Location received: ' + location);
|
|
||||||
// >> (hide)
|
|
||||||
locationReceived = true;
|
|
||||||
done(null);
|
|
||||||
// << (hide)
|
|
||||||
}, function (error) {
|
|
||||||
//console.log('Location error received: ' + error);
|
|
||||||
// >> (hide)
|
|
||||||
locationReceived = error;
|
|
||||||
done(error);
|
|
||||||
// << (hide)
|
|
||||||
});
|
|
||||||
// << location-timeour
|
|
||||||
};
|
|
@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
nav-title: "location How-To"
|
|
||||||
title: "location"
|
|
||||||
environment: nativescript
|
|
||||||
description: "Examples for using location"
|
|
||||||
previous_url: /ApiReference/location/HOW-TO
|
|
||||||
---
|
|
||||||
# Location
|
|
||||||
Using the location requires the Location module.
|
|
||||||
{%snippet location-require%}
|
|
||||||
|
|
||||||
## Other functions
|
|
||||||
### Test are location services available for this device
|
|
||||||
{%snippet location-funcs%}
|
|
||||||
|
|
||||||
### Get distance between two locations
|
|
||||||
{%snippet location-distance%}
|
|
||||||
|
|
||||||
## Getting location
|
|
||||||
### Receive continuous location updates
|
|
||||||
{%snippet location-updates%}
|
|
||||||
|
|
||||||
### Get last known location
|
|
||||||
{%snippet location-last-known%}
|
|
||||||
|
|
||||||
### Get location once
|
|
||||||
if there is `options.timeout` you will receive error on timeout. If `options.timeout` is 0 then the result is the same as the result from `LocationManager.lastKnownLocation`
|
|
||||||
and there will be no wait. You can use `options.maximumAge` to specify you don't want to receive locations older than specified time in ms.
|
|
||||||
{%snippet location-timeour%}
|
|
@ -28,9 +28,6 @@ export function isRunningOnEmulator(): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export var allTests = {};
|
export var allTests = {};
|
||||||
if (!isRunningOnEmulator()) {
|
|
||||||
allTests["LOCATION"] = require("./location-tests");
|
|
||||||
}
|
|
||||||
|
|
||||||
allTests["PLATFORM"] = require("./platform-tests");
|
allTests["PLATFORM"] = require("./platform-tests");
|
||||||
allTests["FILE SYSTEM"] = require("./file-system-tests");
|
allTests["FILE SYSTEM"] = require("./file-system-tests");
|
||||||
|
@ -1 +1 @@
|
|||||||
Allows you to take pictures with the device's camera.
|
Deprecated. Please use same functionality from `nativescript-camera` npm module.
|
||||||
|
@ -7,6 +7,9 @@ import * as platform from "platform";
|
|||||||
|
|
||||||
var REQUEST_IMAGE_CAPTURE = 3453;
|
var REQUEST_IMAGE_CAPTURE = 3453;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-camera` npm module]
|
||||||
|
*/
|
||||||
export var takePicture = function (options?): Promise<any> {
|
export var takePicture = function (options?): Promise<any> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
@ -96,6 +99,9 @@ export var takePicture = function (options?): Promise<any> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-camera` npm module]
|
||||||
|
*/
|
||||||
export var isAvailable = function () {
|
export var isAvailable = function () {
|
||||||
var utils: typeof utilsModule = require("utils/utils");
|
var utils: typeof utilsModule = require("utils/utils");
|
||||||
|
|
||||||
|
8
tns-core-modules/camera/camera.d.ts
vendored
8
tns-core-modules/camera/camera.d.ts
vendored
@ -6,16 +6,18 @@ declare module "camera" {
|
|||||||
import imageSource = require("image-source");
|
import imageSource = require("image-source");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take a photo using the camera.
|
* [Deprecated. Please use same functionality from `nativescript-camera` npm module]
|
||||||
* @param options - Optional parameter for setting different camera options.
|
|
||||||
*/
|
*/
|
||||||
export function takePicture(options?: CameraOptions): Promise<imageSource.ImageSource>;
|
export function takePicture(options?: CameraOptions): Promise<imageSource.ImageSource>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the camera available to use
|
* [Deprecated. Please use same functionality from `nativescript-camera` npm module]
|
||||||
*/
|
*/
|
||||||
export function isAvailable(): Boolean;
|
export function isAvailable(): Boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-camera` npm module]
|
||||||
|
*/
|
||||||
export interface CameraOptions {
|
export interface CameraOptions {
|
||||||
/**
|
/**
|
||||||
* Defines the desired width (in device independent pixels) of the taken image. It should be used with height property.
|
* Defines the desired width (in device independent pixels) of the taken image. It should be used with height property.
|
||||||
|
@ -3,6 +3,7 @@ import * as cameraCommonModule from "./camera-common";
|
|||||||
import * as imageSourceModule from "image-source";
|
import * as imageSourceModule from "image-source";
|
||||||
import * as frameModule from "ui/frame";
|
import * as frameModule from "ui/frame";
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePickerControllerDelegate {
|
class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePickerControllerDelegate {
|
||||||
public static ObjCProtocols = [UIImagePickerControllerDelegate];
|
public static ObjCProtocols = [UIImagePickerControllerDelegate];
|
||||||
|
|
||||||
@ -79,6 +80,9 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic
|
|||||||
|
|
||||||
var listener;
|
var listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-camera` npm module]
|
||||||
|
*/
|
||||||
export var takePicture = function (options): Promise<any> {
|
export var takePicture = function (options): Promise<any> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
listener = null;
|
listener = null;
|
||||||
@ -125,6 +129,9 @@ export var takePicture = function (options): Promise<any> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-camera` npm module]
|
||||||
|
*/
|
||||||
export var isAvailable = function () {
|
export var isAvailable = function () {
|
||||||
return UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera);
|
return UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera);
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Allows you to use the geolocation of the device.
|
Deprecated. Please use same functionality from `nativescript-geolocation` npm module.
|
6
tns-core-modules/location/location.d.ts
vendored
6
tns-core-modules/location/location.d.ts
vendored
@ -12,6 +12,7 @@ declare module "location" {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A data class that encapsulates common properties for a geolocation.
|
* A data class that encapsulates common properties for a geolocation.
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-geolocation` npm module]
|
||||||
*/
|
*/
|
||||||
export class Location {
|
export class Location {
|
||||||
/**
|
/**
|
||||||
@ -67,6 +68,7 @@ declare module "location" {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides options for location monitoring.
|
* Provides options for location monitoring.
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-geolocation` npm module]
|
||||||
*/
|
*/
|
||||||
export interface Options {
|
export interface Options {
|
||||||
/**
|
/**
|
||||||
@ -97,6 +99,7 @@ declare module "location" {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides methods for querying geolocation (in case available) on the target platform.
|
* Provides methods for querying geolocation (in case available) on the target platform.
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-geolocation` npm module]
|
||||||
*/
|
*/
|
||||||
export class LocationManager {
|
export class LocationManager {
|
||||||
/**
|
/**
|
||||||
@ -157,6 +160,7 @@ declare module "location" {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Android specific data related to location.
|
* Provides Android specific data related to location.
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-geolocation` npm module]
|
||||||
*/
|
*/
|
||||||
export interface AndroidLocationManager {
|
export interface AndroidLocationManager {
|
||||||
/**
|
/**
|
||||||
@ -175,12 +179,14 @@ declare module "location" {
|
|||||||
* If you specify timeout = 0 it just requests the last known location.
|
* If you specify timeout = 0 it just requests the last known location.
|
||||||
* However if you specify maximumAge and the location received is older it won't be received.
|
* However if you specify maximumAge and the location received is older it won't be received.
|
||||||
* @param options - An optional object specifying location update settings.
|
* @param options - An optional object specifying location update settings.
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-geolocation` npm module]
|
||||||
*/
|
*/
|
||||||
export function getLocation(options?: Options): Promise<Location>;
|
export function getLocation(options?: Options): Promise<Location>;
|
||||||
|
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/**
|
/**
|
||||||
* Provides iOS specific data related to location.
|
* Provides iOS specific data related to location.
|
||||||
|
* [Deprecated. Please use same functionality from `nativescript-geolocation` npm module]
|
||||||
*/
|
*/
|
||||||
export interface iOSLocationManager {
|
export interface iOSLocationManager {
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user