11import { DocumentSnapshot , firebase , QuerySnapshot } from "./firebase-common" ;
22import * as appModule from "tns-core-modules/application" ;
33import { AndroidActivityResultEventData } from "tns-core-modules/application" ;
4- import * as utils from "tns-core-modules/utils/utils" ;
4+ import { ad as AndroidUtils , layout } from "tns-core-modules/utils/utils" ;
55import lazy from "tns-core-modules/utils/lazy" ;
6- import * as frame from "tns-core-modules/ui/frame" ;
7- import * as fs from "tns-core-modules/file-system" ;
8- import { firestore } from "./firebase" ;
6+ import { topmost } from "tns-core-modules/ui/frame" ;
7+ import { File } from "tns-core-modules/file-system" ;
8+ import { firestore , FIRESTORE_SERVER_TS } from "./firebase" ;
99
10- declare const com , org : any ;
10+ declare const android , com , org : any ;
1111
1212firebase . _launchNotification = null ;
1313firebase . _cachedDynamicLink = null ;
@@ -126,12 +126,16 @@ firebase.toHashMap = obj => {
126126 if ( obj [ property ] === null ) {
127127 node . put ( property , null ) ;
128128 } else {
129- if ( obj [ property ] instanceof Date ) {
129+ // note that the Android Firestore SDK only supports this for 'update' (not for 'set')
130+ if ( obj [ property ] === FIRESTORE_SERVER_TS ) {
131+ node . put ( property , com . google . firebase . firestore . FieldValue . serverTimestamp ( ) ) ;
132+ } else if ( obj [ property ] instanceof Date ) {
130133 node . put ( property , new java . util . Date ( obj [ property ] . getTime ( ) ) ) ;
131134 } else if ( Array . isArray ( obj [ property ] ) ) {
132135 node . put ( property , firebase . toJavaArray ( obj [ property ] ) ) ;
133136 } else {
134137 switch ( typeof obj [ property ] ) {
138+ case 'object' :
135139 case 'object' :
136140 node . put ( property , firebase . toHashMap ( obj [ property ] , node ) ) ;
137141 break ;
@@ -616,7 +620,7 @@ firebase.admob.showBanner = arg => {
616620 const ad = firebase . admob . _buildAdRequest ( settings ) ;
617621 firebase . admob . adView . loadAd ( ad ) ;
618622
619- const density = utils . layout . getDisplayDensity ( ) ,
623+ const density = layout . getDisplayDensity ( ) ,
620624 top = settings . margins . top * density ,
621625 bottom = settings . margins . bottom * density ;
622626
@@ -644,8 +648,8 @@ firebase.admob.showBanner = arg => {
644648 // Wrapping it in a timeout makes sure that when this function is loaded from a Page.loaded event 'frame.topmost()' doesn't resolve to 'undefined'.
645649 // Also, in NativeScript 4+ it may be undefined anyway.. so using the appModule in that case.
646650 setTimeout ( ( ) => {
647- if ( frame . topmost ( ) !== undefined ) {
648- frame . topmost ( ) . currentPage . android . getParent ( ) . addView ( adViewLayout , relativeLayoutParamsOuter ) ;
651+ if ( topmost ( ) !== undefined ) {
652+ topmost ( ) . currentPage . android . getParent ( ) . addView ( adViewLayout , relativeLayoutParamsOuter ) ;
649653 } else {
650654 appModule . android . foregroundActivity . getWindow ( ) . getDecorView ( ) . addView ( adViewLayout , relativeLayoutParamsOuter ) ;
651655 }
@@ -1154,7 +1158,7 @@ firebase.login = arg => {
11541158 arg . phoneOptions . phoneNumber ,
11551159 60 , // timeout (in seconds, because of the next argument)
11561160 java . util . concurrent . TimeUnit . SECONDS ,
1157- appModule . android . foregroundActivity , // or utils.ad.getApplicationContext()
1161+ appModule . android . foregroundActivity ,
11581162 new OnVerificationStateChangedCallbacks ( ) ) ;
11591163
11601164 } else if ( arg . type === firebase . LoginType . CUSTOM ) {
@@ -1215,7 +1219,7 @@ firebase.login = arg => {
12151219 if ( arg . facebookOptions && arg . facebookOptions . scope ) {
12161220 scope = arg . facebookOptions . scope ;
12171221 }
1218- const permissions = utils . ad . collections . stringArrayToStringSet ( scope ) ;
1222+ const permissions = AndroidUtils . collections . stringArrayToStringSet ( scope ) ;
12191223
12201224 const activity = appModule . android . foregroundActivity ;
12211225 fbLoginManager . logInWithReadPermissions ( activity , permissions ) ;
@@ -1226,8 +1230,8 @@ firebase.login = arg => {
12261230 return ;
12271231 }
12281232
1229- const clientStringId = utils . ad . resources . getStringId ( "default_web_client_id" ) ;
1230- const clientId = utils . ad . getApplicationContext ( ) . getResources ( ) . getString ( clientStringId ) ;
1233+ const clientStringId = AndroidUtils . resources . getStringId ( "default_web_client_id" ) ;
1234+ const clientId = AndroidUtils . getApplicationContext ( ) . getResources ( ) . getString ( clientStringId ) ;
12311235
12321236 // Configure Google Sign In
12331237 const googleSignInOptionsBuilder = new com . google . android . gms . auth . api . signin . GoogleSignInOptions . Builder ( com . google . android . gms . auth . api . signin . GoogleSignInOptions . DEFAULT_SIGN_IN )
@@ -1967,7 +1971,7 @@ firebase.uploadFile = arg => {
19671971
19681972 } else if ( arg . localFullPath ) {
19691973
1970- if ( ! fs . File . exists ( arg . localFullPath ) ) {
1974+ if ( ! File . exists ( arg . localFullPath ) ) {
19711975 reject ( "File does not exist: " + arg . localFullPath ) ;
19721976 return ;
19731977 }
0 commit comments