mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
feat(utils): work openFile in simulator (#8495)
* feat: open file in iOS simulator * feat: added isRealDevice util * feat: have in mind isRealDevice in utils.openFile refactor to avoid some circular dependencies Co-authored-by: Vasil Trifonov <v.trifonov@gmail.com>
This commit is contained in:
@ -1947,7 +1947,7 @@ export class Span extends ViewBase {
|
|||||||
|
|
||||||
public textDecoration: TextDecoration;
|
public textDecoration: TextDecoration;
|
||||||
//@endprivate
|
//@endprivate
|
||||||
}
|
}
|
||||||
|
|
||||||
// @public
|
// @public
|
||||||
export class StackLayout extends LayoutBase {
|
export class StackLayout extends LayoutBase {
|
||||||
@ -2428,8 +2428,7 @@ export interface TapGestureEventData extends GestureEventData {
|
|||||||
getPointerCount(): number;
|
getPointerCount(): number;
|
||||||
getX(): number;
|
getX(): number;
|
||||||
getY(): number;
|
getY(): number;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// @public
|
// @public
|
||||||
export interface Template {
|
export interface Template {
|
||||||
@ -2623,6 +2622,7 @@ export const Utils: {
|
|||||||
getModuleName: typeof getModuleName;
|
getModuleName: typeof getModuleName;
|
||||||
openFile: typeof openFile;
|
openFile: typeof openFile;
|
||||||
openUrl: typeof openUrl;
|
openUrl: typeof openUrl;
|
||||||
|
isRealDevice: typeof isRealDevice;
|
||||||
layout: typeof layout;
|
layout: typeof layout;
|
||||||
android: typeof ad;
|
android: typeof ad;
|
||||||
ios: typeof ios;
|
ios: typeof ios;
|
||||||
@ -3116,9 +3116,10 @@ export class XmlParser {
|
|||||||
// nativescript-core/index.d.ts:114:5 - (ae-forgotten-export) The symbol "getModuleName" needs to be exported by the entry point index.d.ts
|
// nativescript-core/index.d.ts:114:5 - (ae-forgotten-export) The symbol "getModuleName" needs to be exported by the entry point index.d.ts
|
||||||
// nativescript-core/index.d.ts:115:5 - (ae-forgotten-export) The symbol "openFile" needs to be exported by the entry point index.d.ts
|
// nativescript-core/index.d.ts:115:5 - (ae-forgotten-export) The symbol "openFile" needs to be exported by the entry point index.d.ts
|
||||||
// nativescript-core/index.d.ts:116:5 - (ae-forgotten-export) The symbol "openUrl" needs to be exported by the entry point index.d.ts
|
// nativescript-core/index.d.ts:116:5 - (ae-forgotten-export) The symbol "openUrl" needs to be exported by the entry point index.d.ts
|
||||||
// nativescript-core/index.d.ts:117:5 - (ae-forgotten-export) The symbol "layout" needs to be exported by the entry point index.d.ts
|
// nativescript-core/index.d.ts:117:5 - (ae-forgotten-export) The symbol "isRealDevice" needs to be exported by the entry point index.d.ts
|
||||||
// nativescript-core/index.d.ts:118:5 - (ae-forgotten-export) The symbol "ad" needs to be exported by the entry point index.d.ts
|
// nativescript-core/index.d.ts:118:5 - (ae-forgotten-export) The symbol "layout" needs to be exported by the entry point index.d.ts
|
||||||
// nativescript-core/index.d.ts:119:5 - (ae-forgotten-export) The symbol "ios" needs to be exported by the entry point index.d.ts
|
// nativescript-core/index.d.ts:119:5 - (ae-forgotten-export) The symbol "ad" needs to be exported by the entry point index.d.ts
|
||||||
|
// nativescript-core/index.d.ts:120:5 - (ae-forgotten-export) The symbol "ios" needs to be exported by the entry point index.d.ts
|
||||||
// nativescript-core/ui/core/view-base/view-base.d.ts:179:26 - (ae-forgotten-export) The symbol "Property" needs to be exported by the entry point index.d.ts
|
// nativescript-core/ui/core/view-base/view-base.d.ts:179:26 - (ae-forgotten-export) The symbol "Property" needs to be exported by the entry point index.d.ts
|
||||||
// nativescript-core/ui/core/view-base/view-base.d.ts:179:26 - (ae-forgotten-export) The symbol "CssProperty" needs to be exported by the entry point index.d.ts
|
// nativescript-core/ui/core/view-base/view-base.d.ts:179:26 - (ae-forgotten-export) The symbol "CssProperty" needs to be exported by the entry point index.d.ts
|
||||||
// nativescript-core/ui/core/view-base/view-base.d.ts:179:26 - (ae-forgotten-export) The symbol "CssAnimationProperty" needs to be exported by the entry point index.d.ts
|
// nativescript-core/ui/core/view-base/view-base.d.ts:179:26 - (ae-forgotten-export) The symbol "CssAnimationProperty" needs to be exported by the entry point index.d.ts
|
||||||
|
3
nativescript-core/index.d.ts
vendored
3
nativescript-core/index.d.ts
vendored
@ -100,7 +100,7 @@ export declare const Trace: {
|
|||||||
isEnabled: typeof isEnabled;
|
isEnabled: typeof isEnabled;
|
||||||
};
|
};
|
||||||
export * from "./ui";
|
export * from "./ui";
|
||||||
import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, layout, ad as androidUtils, ios as iosUtils } from "./utils/utils";
|
import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, ios as iosUtils } from "./utils/utils";
|
||||||
export declare const Utils: {
|
export declare const Utils: {
|
||||||
GC: typeof GC;
|
GC: typeof GC;
|
||||||
isFontIconURI: typeof isFontIconURI;
|
isFontIconURI: typeof isFontIconURI;
|
||||||
@ -114,6 +114,7 @@ export declare const Utils: {
|
|||||||
getModuleName: typeof getModuleName;
|
getModuleName: typeof getModuleName;
|
||||||
openFile: typeof openFile;
|
openFile: typeof openFile;
|
||||||
openUrl: typeof openUrl;
|
openUrl: typeof openUrl;
|
||||||
|
isRealDevice: typeof isRealDevice;
|
||||||
layout: typeof layout;
|
layout: typeof layout;
|
||||||
android: typeof androidUtils;
|
android: typeof androidUtils;
|
||||||
ios: typeof iosUtils;
|
ios: typeof iosUtils;
|
||||||
|
@ -98,7 +98,7 @@ import {
|
|||||||
GC, isFontIconURI, isDataURI, isFileOrResourcePath,
|
GC, isFontIconURI, isDataURI, isFileOrResourcePath,
|
||||||
executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject,
|
executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject,
|
||||||
getModuleName,
|
getModuleName,
|
||||||
openFile, openUrl,
|
openFile, openUrl, isRealDevice,
|
||||||
layout, ad as androidUtils, ios as iosUtils
|
layout, ad as androidUtils, ios as iosUtils
|
||||||
} from "./utils/utils";
|
} from "./utils/utils";
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ export const Utils = {
|
|||||||
executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject,
|
executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject,
|
||||||
|
|
||||||
getModuleName,
|
getModuleName,
|
||||||
openFile, openUrl,
|
openFile, openUrl, isRealDevice,
|
||||||
|
|
||||||
layout, android: androidUtils, ios: iosUtils
|
layout, android: androidUtils, ios: iosUtils
|
||||||
};
|
};
|
||||||
|
61
nativescript-core/ui/gestures/gestures.d.ts
vendored
61
nativescript-core/ui/gestures/gestures.d.ts
vendored
@ -42,7 +42,7 @@
|
|||||||
*/
|
*/
|
||||||
touch
|
touch
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines an enum with supported gesture states.
|
* Defines an enum with supported gesture states.
|
||||||
*/
|
*/
|
||||||
@ -64,7 +64,7 @@
|
|||||||
*/
|
*/
|
||||||
ended
|
ended
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines an enum for swipe gesture direction.
|
* Defines an enum for swipe gesture direction.
|
||||||
*/
|
*/
|
||||||
@ -86,7 +86,7 @@
|
|||||||
*/
|
*/
|
||||||
down
|
down
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a touch action
|
* Defines a touch action
|
||||||
*/
|
*/
|
||||||
@ -95,23 +95,23 @@
|
|||||||
* Down action.
|
* Down action.
|
||||||
*/
|
*/
|
||||||
export const down: string;
|
export const down: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Up action.
|
* Up action.
|
||||||
*/
|
*/
|
||||||
export const up: string;
|
export const up: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move action.
|
* Move action.
|
||||||
*/
|
*/
|
||||||
export const move: string;
|
export const move: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel action.
|
* Cancel action.
|
||||||
*/
|
*/
|
||||||
export const cancel: string;
|
export const cancel: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides gesture event data.
|
* Provides gesture event data.
|
||||||
*/
|
*/
|
||||||
@ -137,7 +137,7 @@
|
|||||||
/**
|
/**
|
||||||
* Provides gesture event data.
|
* Provides gesture event data.
|
||||||
*/
|
*/
|
||||||
export interface TapGestureEventData extends GestureEventData {
|
export interface TapGestureEventData extends GestureEventData {
|
||||||
/**
|
/**
|
||||||
* Gets the number of pointers in the event.
|
* Gets the number of pointers in the event.
|
||||||
*/
|
*/
|
||||||
@ -152,7 +152,7 @@
|
|||||||
getY(): number;
|
getY(): number;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides gesture event data.
|
* Provides gesture event data.
|
||||||
*/
|
*/
|
||||||
@ -160,19 +160,19 @@
|
|||||||
/**
|
/**
|
||||||
* Gets action of the touch. Possible values: 'up', 'move', 'down', 'cancel'
|
* Gets action of the touch. Possible values: 'up', 'move', 'down', 'cancel'
|
||||||
*/
|
*/
|
||||||
action: "up" | "move" | "down" | "cancel";
|
action: "up" | "move" | "down" | "cancel";
|
||||||
/**
|
/**
|
||||||
* Gets the pointers that triggered the event.
|
* Gets the pointers that triggered the event.
|
||||||
* Note: In Android there is aways only one active pointer.
|
* Note: In Android there is aways only one active pointer.
|
||||||
*/
|
*/
|
||||||
getActivePointers(): Array<Pointer>;
|
getActivePointers(): Array<Pointer>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all pointers.
|
* Gets all pointers.
|
||||||
*/
|
*/
|
||||||
getAllPointers(): Array<Pointer>;
|
getAllPointers(): Array<Pointer>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pointer is an object representing a finger (or other object) that is touching the screen.
|
* Pointer is an object representing a finger (or other object) that is touching the screen.
|
||||||
*/
|
*/
|
||||||
@ -181,12 +181,12 @@
|
|||||||
* The id of the pointer.
|
* The id of the pointer.
|
||||||
*/
|
*/
|
||||||
android: any;
|
android: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The UITouch object associated to the touch
|
* The UITouch object associated to the touch
|
||||||
*/
|
*/
|
||||||
ios: any;
|
ios: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the X coordinate of the pointer inside the view that triggered the event.
|
* Gets the X coordinate of the pointer inside the view that triggered the event.
|
||||||
*/
|
*/
|
||||||
@ -221,31 +221,31 @@
|
|||||||
*/
|
*/
|
||||||
getYDIP(): number
|
getYDIP(): number
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides gesture event data.
|
* Provides gesture event data.
|
||||||
*/
|
*/
|
||||||
export interface GestureEventDataWithState extends GestureEventData {
|
export interface GestureEventDataWithState extends GestureEventData {
|
||||||
state: number;
|
state: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides gesture event data for pinch gesture.
|
* Provides gesture event data for pinch gesture.
|
||||||
*/
|
*/
|
||||||
export interface PinchGestureEventData extends GestureEventDataWithState {
|
export interface PinchGestureEventData extends GestureEventDataWithState {
|
||||||
scale: number;
|
scale: number;
|
||||||
|
|
||||||
getFocusX(): number;
|
getFocusX(): number;
|
||||||
getFocusY(): number;
|
getFocusY(): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides gesture event data for swipe gesture.
|
* Provides gesture event data for swipe gesture.
|
||||||
*/
|
*/
|
||||||
export interface SwipeGestureEventData extends GestureEventData {
|
export interface SwipeGestureEventData extends GestureEventData {
|
||||||
direction: SwipeDirection;
|
direction: SwipeDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides gesture event data for pan gesture.
|
* Provides gesture event data for pan gesture.
|
||||||
*/
|
*/
|
||||||
@ -253,14 +253,14 @@
|
|||||||
deltaX: number;
|
deltaX: number;
|
||||||
deltaY: number;
|
deltaY: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides gesture event data for rotation gesture.
|
* Provides gesture event data for rotation gesture.
|
||||||
*/
|
*/
|
||||||
export interface RotationGestureEventData extends GestureEventDataWithState {
|
export interface RotationGestureEventData extends GestureEventDataWithState {
|
||||||
rotation: number;
|
rotation: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides options for the GesturesObserver.
|
* Provides options for the GesturesObserver.
|
||||||
*/
|
*/
|
||||||
@ -272,39 +272,39 @@
|
|||||||
* @param context - default this argument for the callbacks.
|
* @param context - default this argument for the callbacks.
|
||||||
*/
|
*/
|
||||||
constructor(target: View, callback: (args: GestureEventData) => void, context: any);
|
constructor(target: View, callback: (args: GestureEventData) => void, context: any);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a gesture observer to a view and gesture.
|
* Registers a gesture observer to a view and gesture.
|
||||||
* @param type - Type of the gesture.
|
* @param type - Type of the gesture.
|
||||||
*/
|
*/
|
||||||
observe(type: GestureTypes);
|
observe(type: GestureTypes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects the gesture observer.
|
* Disconnects the gesture observer.
|
||||||
*/
|
*/
|
||||||
disconnect();
|
disconnect();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gesture type attached to the observer.
|
* Gesture type attached to the observer.
|
||||||
*/
|
*/
|
||||||
type: GestureTypes;
|
type: GestureTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that will be executed when a gesture is received.
|
* A function that will be executed when a gesture is received.
|
||||||
*/
|
*/
|
||||||
callback: (args: GestureEventData) => void;
|
callback: (args: GestureEventData) => void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A context which will be used as `this` in callback execution.
|
* A context which will be used as `this` in callback execution.
|
||||||
*/
|
*/
|
||||||
context: any;
|
context: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An internal Android specific method used to pass the motion event to the correct gesture observer.
|
* An internal Android specific method used to pass the motion event to the correct gesture observer.
|
||||||
*/
|
*/
|
||||||
androidOnTouchEvent: (motionEvent: any /* android.view.MotionEvent */) => void;
|
androidOnTouchEvent: (motionEvent: any /* android.view.MotionEvent */) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A short-hand function that is used to create a gesture observer for a view and gesture.
|
* A short-hand function that is used to create a gesture observer for a view and gesture.
|
||||||
* @param target - View which will be watched for originating a specific gesture.
|
* @param target - View which will be watched for originating a specific gesture.
|
||||||
@ -313,17 +313,16 @@
|
|||||||
* @param context - this argument for the callback.
|
* @param context - this argument for the callback.
|
||||||
*/
|
*/
|
||||||
export function observe(target: View, type: GestureTypes, callback: (args: GestureEventData) => void, context?: any): GesturesObserver;
|
export function observe(target: View, type: GestureTypes, callback: (args: GestureEventData) => void, context?: any): GesturesObserver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation of a gesture type.
|
* Returns a string representation of a gesture type.
|
||||||
* @param type - Type of the gesture.
|
* @param type - Type of the gesture.
|
||||||
* @param separator(optional) - Text separator between gesture type strings.
|
* @param separator(optional) - Text separator between gesture type strings.
|
||||||
*/
|
*/
|
||||||
export function toString(type: GestureTypes, separator?: string): string;
|
export function toString(type: GestureTypes, separator?: string): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a gesture type enum value from a string (case insensitive).
|
* Returns a gesture type enum value from a string (case insensitive).
|
||||||
* @param type - A string representation of a gesture type (e.g. Tap).
|
* @param type - A string representation of a gesture type (e.g. Tap).
|
||||||
*/
|
*/
|
||||||
export function fromString(type: string): GestureTypes;
|
export function fromString(type: string): GestureTypes;
|
||||||
|
|
@ -153,4 +153,10 @@ export module ad {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isRealDevice(): boolean {
|
||||||
|
const fingerprint = android.os.Build.FINGERPRINT;
|
||||||
|
|
||||||
|
return fingerprint != null && (fingerprint.indexOf("vbox") > -1 || fingerprint.indexOf("generic") > -1);
|
||||||
|
}
|
||||||
}
|
}
|
12
nativescript-core/utils/native-helper.d.ts
vendored
12
nativescript-core/utils/native-helper.d.ts
vendored
@ -83,6 +83,11 @@ export module ad {
|
|||||||
*/
|
*/
|
||||||
export function getPaletteColor(name: string, context: any /* android.content.Context */): number;
|
export function getPaletteColor(name: string, context: any /* android.content.Context */): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the application is running on real device and not on emulator.
|
||||||
|
*/
|
||||||
|
export function isRealDevice(): boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Module with ios specific utilities.
|
* Module with ios specific utilities.
|
||||||
@ -156,7 +161,7 @@ export module ios {
|
|||||||
export function getVisibleViewController(rootViewController: any/* UIViewController*/): any/* UIViewController*/;
|
export function getVisibleViewController(rootViewController: any/* UIViewController*/): any/* UIViewController*/;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param transform Applies a rotation transform over X,Y and Z axis
|
* @param transform Applies a rotation transform over X,Y and Z axis
|
||||||
* @param x Rotation over X axis in degrees
|
* @param x Rotation over X axis in degrees
|
||||||
* @param y Rotation over Y axis in degrees
|
* @param y Rotation over Y axis in degrees
|
||||||
@ -165,4 +170,9 @@ export module ios {
|
|||||||
export function applyRotateTransform(transform: any /* CATransform3D*/, x: number, y: number, z: number): any /* CATransform3D*/;
|
export function applyRotateTransform(transform: any /* CATransform3D*/, x: number, y: number, z: number): any /* CATransform3D*/;
|
||||||
|
|
||||||
export class UIDocumentInteractionControllerDelegateImpl { }
|
export class UIDocumentInteractionControllerDelegateImpl { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the application is running on real device and not on simulator.
|
||||||
|
*/
|
||||||
|
export function isRealDevice(): boolean;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import {
|
|||||||
write as traceWrite
|
write as traceWrite
|
||||||
} from "../trace";
|
} from "../trace";
|
||||||
|
|
||||||
|
declare var UIImagePickerControllerSourceType: any;
|
||||||
|
|
||||||
const radToDeg = Math.PI / 180;
|
const radToDeg = Math.PI / 180;
|
||||||
|
|
||||||
function isOrientationLandscape(orientation: number) {
|
function isOrientationLandscape(orientation: number) {
|
||||||
@ -14,7 +16,7 @@ function isOrientationLandscape(orientation: number) {
|
|||||||
function openFileAtRootModule(filePath: string): boolean {
|
function openFileAtRootModule(filePath: string): boolean {
|
||||||
try {
|
try {
|
||||||
const appPath = ios.getCurrentAppPath();
|
const appPath = ios.getCurrentAppPath();
|
||||||
const path = filePath.replace("~", appPath);
|
let path = ios.isRealDevice() ? filePath.replace("~", appPath) : filePath;
|
||||||
|
|
||||||
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
|
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
|
||||||
controller.delegate = new ios.UIDocumentInteractionControllerDelegateImpl();
|
controller.delegate = new ios.UIDocumentInteractionControllerDelegateImpl();
|
||||||
@ -153,4 +155,16 @@ export module ios {
|
|||||||
return this.getViewController().view.frame;
|
return this.getViewController().view.frame;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isRealDevice() {
|
||||||
|
try {
|
||||||
|
// https://stackoverflow.com/a/5093092/4936697
|
||||||
|
const sourceType = UIImagePickerControllerSourceType.UIImagePickerControllerSourceTypeCamera;
|
||||||
|
const mediaTypes = UIImagePickerController.availableMediaTypesForSourceType(sourceType);
|
||||||
|
|
||||||
|
return mediaTypes;
|
||||||
|
} catch (e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,3 +182,7 @@ Please ensure you have your manifest correctly configured with the FileProvider.
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isRealDevice(): boolean {
|
||||||
|
return ad.isRealDevice();
|
||||||
|
}
|
||||||
|
5
nativescript-core/utils/utils.d.ts
vendored
5
nativescript-core/utils/utils.d.ts
vendored
@ -347,3 +347,8 @@ export function hasDuplicates(arr: Array<any>): boolean;
|
|||||||
* @param arr - The array.
|
* @param arr - The array.
|
||||||
*/
|
*/
|
||||||
export function eliminateDuplicates(arr: Array<any>): Array<any>;
|
export function eliminateDuplicates(arr: Array<any>): Array<any>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the application is running on real device and not on simulator/emulator.
|
||||||
|
*/
|
||||||
|
export function isRealDevice(): boolean;
|
@ -9,7 +9,7 @@ export * from "./utils-common";
|
|||||||
export function openFile(filePath: string): boolean {
|
export function openFile(filePath: string): boolean {
|
||||||
try {
|
try {
|
||||||
const appPath = ios.getCurrentAppPath();
|
const appPath = ios.getCurrentAppPath();
|
||||||
const path = filePath.replace("~", appPath);
|
let path = ios.isRealDevice() ? filePath.replace("~", appPath) : filePath;
|
||||||
|
|
||||||
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
|
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
|
||||||
controller.delegate = <UIDocumentInteractionControllerDelegate>new ios.UIDocumentInteractionControllerDelegateImpl();
|
controller.delegate = <UIDocumentInteractionControllerDelegate>new ios.UIDocumentInteractionControllerDelegateImpl();
|
||||||
@ -45,3 +45,7 @@ export function openUrl(location: string): boolean {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isRealDevice(): boolean {
|
||||||
|
return ios.isRealDevice();
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user