nativescript-plugin-firebase
Advanced tools
Comparing version 8.0.1 to 8.1.0
import { firestore } from "./firebase"; | ||
export declare type JDocumentReference = com.google.firebase.firestore.DocumentReference; | ||
export declare type JCollectionReference = com.google.firebase.firestore.CollectionReference; | ||
export declare class QuerySnapshot implements firestore.QuerySnapshot { | ||
@@ -4,0 +5,0 @@ private snapshot; |
@@ -791,14 +791,27 @@ /** | ||
export interface DocumentReference { | ||
discriminator: "docRef"; | ||
id: string; | ||
path: string; | ||
readonly discriminator: "docRef"; | ||
readonly id: string; | ||
/** | ||
* A reference to the Collection to which this DocumentReference belongs. | ||
*/ | ||
readonly parent: CollectionReference; | ||
readonly path: string; | ||
collection: (collectionPath: string) => CollectionReference; | ||
set: (document: any, options?: SetOptions) => Promise<void>; | ||
get: () => Promise<DocumentSnapshot>; | ||
update: (document: any) => Promise<void>; | ||
delete: () => Promise<void>; | ||
onSnapshot(optionsOrCallback: SnapshotListenOptions | ((snapshot: DocumentSnapshot) => void), callback?: (snapshot: DocumentSnapshot) => void): () => void; | ||
onSnapshot(optionsOrCallback: SnapshotListenOptions | ((snapshot: DocumentSnapshot) => void), callbackOrOnError?: (snapshot: DocumentSnapshot | Error) => void, onError?: (error: Error) => void): () => void; | ||
android?: any; | ||
ios?: any; | ||
@@ -816,3 +829,3 @@ } | ||
onSnapshot(optionsOrCallback: SnapshotListenOptions | ((snapshot: QuerySnapshot) => void), callback?: (snapshot: QuerySnapshot) => void): () => void; | ||
onSnapshot(optionsOrCallback: SnapshotListenOptions | ((snapshot: QuerySnapshot) => void), callbackOrOnError?: (snapshotOrError: QuerySnapshot | Error) => void, onError?: (error: Error) => void): () => void; | ||
@@ -829,4 +842,9 @@ startAt(snapshot: DocumentSnapshot): Query; | ||
export interface CollectionReference extends Query { | ||
id: string; | ||
readonly id: string; | ||
/** | ||
* A reference to the containing Document if this is a subcollection, else null. | ||
*/ | ||
readonly parent: DocumentReference | null; | ||
doc(documentPath?: string): DocumentReference; | ||
@@ -833,0 +851,0 @@ |
@@ -5,2 +5,4 @@ import { MLKitScanBarcodesOnDeviceOptions, MLKitScanBarcodesOnDeviceResult } from "./"; | ||
export declare class MLKitBarcodeScanner extends MLKitBarcodeScannerBase { | ||
private player; | ||
disposeNativeView(): void; | ||
protected createDetector(): any; | ||
@@ -7,0 +9,0 @@ protected createSuccessListener(): any; |
@@ -6,2 +6,3 @@ "use strict"; | ||
exports.BarcodeFormat = barcodescanning_common_1.BarcodeFormat; | ||
var application = require("tns-core-modules/application"); | ||
var gmsTasks = com.google.android.gms.tasks; | ||
@@ -13,2 +14,9 @@ var MLKitBarcodeScanner = (function (_super) { | ||
} | ||
MLKitBarcodeScanner.prototype.disposeNativeView = function () { | ||
_super.prototype.disposeNativeView.call(this); | ||
if (this.player) { | ||
this.player.release(); | ||
this.player = undefined; | ||
} | ||
}; | ||
MLKitBarcodeScanner.prototype.createDetector = function () { | ||
@@ -21,2 +29,31 @@ var formats; | ||
} | ||
if (this.beepOnScan) { | ||
var activity = (application.android.foregroundActivity || application.android.startActivity); | ||
activity.setVolumeControlStream(android.media.AudioManager.STREAM_MUSIC); | ||
try { | ||
var file = application.android.context.getResources().getIdentifier("beep", "raw", application.android.context.getPackageName()); | ||
if (file === 0) { | ||
console.log("No 'beep.*' soundfile found in the resources /raw folder. There will be no audible feedback upon scanning a barcode."); | ||
} | ||
else { | ||
this.player = new android.media.MediaPlayer(); | ||
var fileDescriptor = application.android.context.getResources().openRawResourceFd(file); | ||
try { | ||
this.player.setDataSource(fileDescriptor.getFileDescriptor(), fileDescriptor.getStartOffset(), fileDescriptor.getLength()); | ||
} | ||
finally { | ||
fileDescriptor.close(); | ||
} | ||
this.player.setAudioStreamType(android.media.AudioManager.STREAM_MUSIC); | ||
this.player.setLooping(false); | ||
this.player.setVolume(0.10, 0.10); | ||
this.player.prepare(); | ||
} | ||
} | ||
catch (e) { | ||
console.log(e); | ||
this.player.release(); | ||
this.player = undefined; | ||
} | ||
} | ||
return getBarcodeDetector(formats); | ||
@@ -31,3 +68,3 @@ }; | ||
}; | ||
if (barcodes) { | ||
if (barcodes && barcodes.size() > 0) { | ||
for (var i = 0; i < barcodes.size(); i++) { | ||
@@ -42,2 +79,5 @@ var barcode = barcodes.get(i); | ||
} | ||
if (_this.player) { | ||
_this.player.start(); | ||
} | ||
} | ||
@@ -44,0 +84,0 @@ _this.notify({ |
@@ -36,2 +36,14 @@ import { MLKitCameraView, MLKitVisionOptions, MLKitVisionResult } from "../"; | ||
formats?: Array<BarcodeFormat>; | ||
/** | ||
* Play a sound when a code was scanned. | ||
* Default: true | ||
*/ | ||
beepOnScan?: boolean; | ||
/** | ||
* Wheter or not to report duplicate scan results during continuous scanning. | ||
* Default false. | ||
*/ | ||
reportDuplicates?: boolean; | ||
} | ||
@@ -38,0 +50,0 @@ |
@@ -5,2 +5,3 @@ import { MLKitScanBarcodesOnDeviceOptions, MLKitScanBarcodesOnDeviceResult } from "./index"; | ||
export declare class MLKitBarcodeScanner extends MLKitBarcodeScannerBase { | ||
private player; | ||
protected createDetector(): any; | ||
@@ -7,0 +8,0 @@ protected createSuccessListener(): any; |
@@ -18,2 +18,10 @@ "use strict"; | ||
} | ||
if (this.beepOnScan) { | ||
AVAudioSession.sharedInstance().setCategoryModeOptionsError(AVAudioSessionCategoryPlayback, AVAudioSessionModeDefault, 1); | ||
var barcodeBundlePath = NSBundle.bundleWithIdentifier("org.nativescript.plugin.firebase.MLKit").bundlePath; | ||
this.player = new AVAudioPlayer({ contentsOfURL: NSURL.fileURLWithPath(barcodeBundlePath + "/beep.caf") }); | ||
this.player.numberOfLoops = 1; | ||
this.player.volume = 0.7; | ||
this.player.prepareToPlay(); | ||
} | ||
return getBarcodeDetector(formats); | ||
@@ -45,2 +53,5 @@ }; | ||
}); | ||
if (barcodes.count > 0 && _this.player) { | ||
_this.player.play(); | ||
} | ||
} | ||
@@ -47,0 +58,0 @@ }; |
{ | ||
"name": "nativescript-plugin-firebase", | ||
"version": "8.0.1", | ||
"version": "8.1.0", | ||
"description": "Fire. Base. Firebase!", | ||
@@ -5,0 +5,0 @@ "main": "firebase", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
3994086
154
17113