diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fb012e..226be4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### 2.6.0 +- AND: Updated to FreKotlin 1.9.5 +- AND: Updated to Android Play Services to 17.0.0 +- AND: Updated to Jetpack +- iOS: Updated to Google Maps SDK 3.7.0 +- iOS: Updated to FreSwift 4.3.0 + ### 2.5.0 - AND: Updated to FreKotlin 1.8.0 - Updated to AIR 33 ARM 64bit diff --git a/README.md b/README.md index 6b371b5..69e1289 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ The dependencies can be downloaded directly from this repo: com.google.android.gms.play-services-base com.google.android.gms.play-services-location com.google.android.gms.play-services-maps - com.android.support.support-v4 + androidx.legacy.legacy-support-v4 com.google.code.gson.gson ... @@ -76,9 +76,6 @@ You will also need to include the following in your app manifest. Update accordi ``` -#### AIR 32 & 33 -This ANE is built against AIR 33 SDK. If you wish to use with AIR 32 you will need to replace dx.jar in lib/android/bin/ with [this one](https://github.com/tuarua/Android-ANE-Dependencies/blob/master/AIR32_patch/lib/android/bin/dx.jar?raw=true) - ------------- ## iOS @@ -116,18 +113,15 @@ You will also need to include the following in your app manifest. Update accordi You will need a Google API key [https://developers.google.com/maps/documentation/ios-sdk/get-api-key] -#### AIR 32 & 33 -You should use AIR 32 for iOS builds - ### Prerequisites You will need: -- IntelliJ IDEA / Flash Builder -- AIR 33 or greater -- Xcode 10.1 +- IntelliJ IDEA +- AIR 33.0.2.338+ +- Xcode 11.3 +- wget on macOS via `brew install wget` - Android Studio 3 if you wish to edit the Android source -- wget on macOS - Powershell on Windows ### References diff --git a/example/.actionScriptProperties b/example/.actionScriptProperties deleted file mode 100644 index 9face18..0000000 --- a/example/.actionScriptProperties +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/.gitignore b/example/.gitignore index a22e9c4..1710480 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -8,6 +8,8 @@ bin-release/ bin-release-temp/ cache/ +.key + *.app # Other files and folders diff --git a/example/.idea/libraries/androidx_legacy_legacy_support_v4_1_0_0.xml b/example/.idea/libraries/androidx_legacy_legacy_support_v4_1_0_0.xml new file mode 100644 index 0000000..a767cb5 --- /dev/null +++ b/example/.idea/libraries/androidx_legacy_legacy_support_v4_1_0_0.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/example/.idea/libraries/com_android_support_support_v4_27_1_0.xml b/example/.idea/libraries/com_android_support_support_v4_27_1_0.xml deleted file mode 100644 index ceac3db..0000000 --- a/example/.idea/libraries/com_android_support_support_v4_27_1_0.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/example/.idea/libraries/com_google_android_gms_play_services_maps_16_1_0.xml b/example/.idea/libraries/com_google_android_gms_play_services_base_17_0_0.xml similarity index 62% rename from example/.idea/libraries/com_google_android_gms_play_services_maps_16_1_0.xml rename to example/.idea/libraries/com_google_android_gms_play_services_base_17_0_0.xml index 9dc4b69..93f4b47 100644 --- a/example/.idea/libraries/com_google_android_gms_play_services_maps_16_1_0.xml +++ b/example/.idea/libraries/com_google_android_gms_play_services_base_17_0_0.xml @@ -1,7 +1,7 @@ - + - + diff --git a/example/.idea/libraries/com_google_android_gms_play_services_location_16_0_0.xml b/example/.idea/libraries/com_google_android_gms_play_services_location_17_0_0.xml similarity index 76% rename from example/.idea/libraries/com_google_android_gms_play_services_location_16_0_0.xml rename to example/.idea/libraries/com_google_android_gms_play_services_location_17_0_0.xml index 911d26e..6654e8f 100644 --- a/example/.idea/libraries/com_google_android_gms_play_services_location_16_0_0.xml +++ b/example/.idea/libraries/com_google_android_gms_play_services_location_17_0_0.xml @@ -1,7 +1,7 @@ - + - + diff --git a/example/.idea/libraries/com_google_android_gms_play_services_base_16_0_1.xml b/example/.idea/libraries/com_google_android_gms_play_services_maps_17_0_0.xml similarity index 57% rename from example/.idea/libraries/com_google_android_gms_play_services_base_16_0_1.xml rename to example/.idea/libraries/com_google_android_gms_play_services_maps_17_0_0.xml index ad7dade..81bfb21 100644 --- a/example/.idea/libraries/com_google_android_gms_play_services_base_16_0_1.xml +++ b/example/.idea/libraries/com_google_android_gms_play_services_maps_17_0_0.xml @@ -1,7 +1,7 @@ - + - + diff --git a/example/.idea/libraries/com_google_code_gson_gson_2_8_4.xml b/example/.idea/libraries/com_google_code_gson_gson_2_8_6.xml similarity index 64% rename from example/.idea/libraries/com_google_code_gson_gson_2_8_4.xml rename to example/.idea/libraries/com_google_code_gson_gson_2_8_6.xml index 8694ba3..a64833f 100644 --- a/example/.idea/libraries/com_google_code_gson_gson_2_8_4.xml +++ b/example/.idea/libraries/com_google_code_gson_gson_2_8_6.xml @@ -1,7 +1,7 @@ - + - + diff --git a/example/.idea/libraries/com_tuarua_frekotlin_1_8_0.xml b/example/.idea/libraries/com_tuarua_frekotlin_1_9_5.xml similarity index 67% rename from example/.idea/libraries/com_tuarua_frekotlin_1_8_0.xml rename to example/.idea/libraries/com_tuarua_frekotlin_1_9_5.xml index 1120a3d..dc3fad8 100644 --- a/example/.idea/libraries/com_tuarua_frekotlin_1_8_0.xml +++ b/example/.idea/libraries/com_tuarua_frekotlin_1_9_5.xml @@ -1,7 +1,7 @@ - + - + diff --git a/example/.idea/runConfigurations/iOS_Simulator.xml b/example/.idea/runConfigurations/iOS_Simulator.xml index 544bbfb..bc3d2e8 100644 --- a/example/.idea/runConfigurations/iOS_Simulator.xml +++ b/example/.idea/runConfigurations/iOS_Simulator.xml @@ -1,7 +1,8 @@ @@ -55,22 +55,22 @@ - + - + - + - + - + - + @@ -111,7 +111,7 @@ - + @@ -133,7 +133,7 @@ - + @@ -146,7 +146,7 @@ - + @@ -177,5 +177,8 @@ + + + \ No newline at end of file diff --git a/example/get_android_dependencies.ps1 b/example/get_android_dependencies.ps1 index f7e9941..669b5dd 100644 --- a/example/get_android_dependencies.ps1 +++ b/example/get_android_dependencies.ps1 @@ -1,10 +1,10 @@ -$AneVersion = "2.5.0" -$FreKotlinVersion = "1.8.0" -$PlayerServicesVersion = "16.0.1" -$MapsVersion = "16.1.0" -$LocationVersion = "16.0.0" -$SupportV4Version = "27.1.0" -$GsonVersion = "2.8.4" +$AneVersion = "2.6.0" +$FreKotlinVersion = "1.9.5" +$PlayerServicesVersion = "17.0.0" +$MapsVersion = "17.0.0" +$LocationVersion = "17.0.0" +$SupportV4Version = "1.0.0" +$GsonVersion = "2.8.6" $EventBusVersion = "3.0.0" $currentDir = (Get-Item -Path ".\" -Verbose).FullName @@ -13,7 +13,7 @@ Invoke-WebRequest -Uri https://github.com/tuarua/Google-Maps-ANE/releases/downlo Invoke-WebRequest -OutFile "$currentDir\android_dependencies\com.tuarua.frekotlin-$FreKotlinVersion.ane" -Uri https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/kotlin/com.tuarua.frekotlin-$FreKotlinVersion.ane?raw=true Invoke-WebRequest -OutFile "$currentDir\android_dependencies\org.greenrobot.eventbus-$EventBusVersion.ane" -Uri https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/misc/org.greenrobot.eventbus-$EventBusVersion.ane?raw=true Invoke-WebRequest -OutFile "$currentDir\android_dependencies\com.google.code.gson.gson-$GsonVersion.ane" -Uri https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/misc/com.google.code.gson.gson-$GsonVersion.ane?raw=true -Invoke-WebRequest -OutFile "$currentDir\android_dependencies\com.android.support.support-v4-$SupportV4Version.ane" -Uri https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/support/com.android.support.support-v4-$SupportV4Version.ane?raw=true +Invoke-WebRequest -OutFile "$currentDir\android_dependencies\androidx.legacy.legacy-support-v4-$SupportV4Version.ane" -Uri https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/support/androidx.legacy.legacy-support-v4-$SupportV4Version.ane?raw=true Invoke-WebRequest -OutFile "$currentDir\android_dependencies\com.google.android.gms.play-services-base-$PlayerServicesVersion.ane" -Uri https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/play-services/com.google.android.gms.play-services-base-$PlayerServicesVersion.ane?raw=true Invoke-WebRequest -OutFile "$currentDir\android_dependencies\com.google.android.gms.play-services-location-$LocationVersion.ane" -Uri https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/play-services/com.google.android.gms.play-services-location-$LocationVersion.ane?raw=true Invoke-WebRequest -OutFile "$currentDir\android_dependencies\com.google.android.gms.play-services-maps-$MapsVersion.ane" -Uri https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/play-services/com.google.android.gms.play-services-maps-$MapsVersion.ane?raw=true diff --git a/example/get_android_dependencies.sh b/example/get_android_dependencies.sh index 3ff1157..8892037 100755 --- a/example/get_android_dependencies.sh +++ b/example/get_android_dependencies.sh @@ -1,18 +1,18 @@ #!/bin/sh -AneVersion="2.5.0" -FreKotlinVersion="1.8.0" -PlayerServicesVersion="16.0.1" -MapsVersion="16.1.0" -LocationVersion="16.0.0" -SupportV4Version="27.1.0" -GsonVersion="2.8.4" +AneVersion="2.6.0" +FreKotlinVersion="1.9.5" +PlayerServicesVersion="17.0.0" +MapsVersion="17.0.0" +LocationVersion="17.0.0" +SupportV4Version="1.0.0" +GsonVersion="2.8.6" EventBusVersion="3.0.0" wget -O android_dependencies/com.tuarua.frekotlin-$FreKotlinVersion.ane https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/kotlin/com.tuarua.frekotlin-$FreKotlinVersion.ane?raw=true wget -O android_dependencies/org.greenrobot.eventbus-$EventBusVersion.ane https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/misc/org.greenrobot.eventbus-$EventBusVersion.ane?raw=true wget -O android_dependencies/com.google.code.gson.gson-$GsonVersion.ane https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/misc/com.google.code.gson.gson-$GsonVersion.ane?raw=true -wget -O android_dependencies/com.android.support.support-v4-$SupportV4Version.ane https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/support/com.android.support.support-v4-$SupportV4Version.ane?raw=true +wget -O android_dependencies/androidx.legacy.legacy-support-v4-$SupportV4Version.ane https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/support/androidx.legacy.legacy-support-v4-$SupportV4Version.ane?raw=true wget -O android_dependencies/com.google.android.gms.play-services-base-$PlayerServicesVersion.ane https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/play-services/com.google.android.gms.play-services-base-$PlayerServicesVersion.ane?raw=true wget -O android_dependencies/com.google.android.gms.play-services-location-$LocationVersion.ane https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/play-services/com.google.android.gms.play-services-location-$LocationVersion.ane?raw=true wget -O android_dependencies/com.google.android.gms.play-services-maps-$MapsVersion.ane https://github.com/tuarua/Android-ANE-Dependencies/blob/master/anes/play-services/com.google.android.gms.play-services-maps-$MapsVersion.ane?raw=true diff --git a/example/get_ios_dependencies.sh b/example/get_ios_dependencies.sh index 78fba43..5ab1f18 100755 --- a/example/get_ios_dependencies.sh +++ b/example/get_ios_dependencies.sh @@ -1,7 +1,7 @@ #!/bin/sh -AneVersion="2.5.0" -FreSwiftVersion="3.1.0" +AneVersion="2.6.0" +FreSwiftVersion="4.3.0" rm -r ios_dependencies/device rm -r ios_dependencies/simulator diff --git a/example/src/Main-app-android.xml b/example/src/Main-app-android.xml index 48ab6e8..f1c0c98 100644 --- a/example/src/Main-app-android.xml +++ b/example/src/Main-app-android.xml @@ -4,7 +4,7 @@ com.tuarua.googlemapsaneexample GoogleMapsANE GoogleMapsANE - 2.5.0 + 2.6.0 @@ -53,7 +53,8 @@ - + + @@ -66,21 +67,6 @@ ]]> - - - - - - - - - - - - - - - @@ -89,7 +75,7 @@ com.google.android.gms.play-services-base com.google.android.gms.play-services-location com.google.android.gms.play-services-maps - com.android.support.support-v4 + androidx.legacy.legacy-support-v4 com.google.code.gson.gson com.tuarua.GoogleMapsANE diff --git a/example/src/Main-app-ios.xml b/example/src/Main-app-ios.xml index 787a633..841143e 100644 --- a/example/src/Main-app-ios.xml +++ b/example/src/Main-app-ios.xml @@ -4,7 +4,7 @@ com.tuarua.googlemapsaneexample GoogleMapsANE GoogleMapsANE - 2.5.0 + 2.6.0 diff --git a/example/src/StarlingRoot.as b/example/src/StarlingRoot.as index f0c5921..2430a5d 100644 --- a/example/src/StarlingRoot.as +++ b/example/src/StarlingRoot.as @@ -1,5 +1,5 @@ package { -import com.tuarua.GoogleMapsANE; +import com.tuarua.GoogleMaps; import com.tuarua.fre.ANEError; import com.tuarua.googlemaps.CameraPosition; import com.tuarua.googlemaps.Circle; @@ -39,7 +39,7 @@ import starling.utils.AssetManager; import views.SimpleButton; public class StarlingRoot extends Sprite { - private var mapView:GoogleMapsANE; + private var mapView:GoogleMaps; [Embed(source="pin_b.png")] public static const pinImage:Class; @@ -88,11 +88,12 @@ public class StarlingRoot extends Sprite { NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExiting); var _assets:AssetManager = assets; - GoogleMapsANE.key = "AIzaSyCkmGADGPLtu9WOiRzK_3r9XXw8-3DHvEc"; - GoogleMapsANE.mapProvider = MapProvider.GOOGLE; - mapView = GoogleMapsANE.mapView; - - if (!mapView.isInited) { + GoogleMaps.key = "xxxx"; + GoogleMaps.mapProvider = MapProvider.GOOGLE; + try { + mapView = GoogleMaps.mapView; + } catch(e:ANEError) { + trace(e.message); return; } @@ -520,7 +521,7 @@ public class StarlingRoot extends Sprite { * It's very important to call dispose(); on any ANEs when the app is exiting. */ private function onExiting(event:Event):void { - GoogleMapsANE.dispose(); + GoogleMaps.dispose(); } } -} \ No newline at end of file +} diff --git a/native_extension/.actionScriptProperties b/native_extension/.actionScriptProperties deleted file mode 100644 index 1db4fc5..0000000 --- a/native_extension/.actionScriptProperties +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/native_extension/.flexLibProperties b/native_extension/.flexLibProperties deleted file mode 100644 index 1fbacb4..0000000 --- a/native_extension/.flexLibProperties +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/native_extension/.project b/native_extension/.project deleted file mode 100644 index 97465eb..0000000 --- a/native_extension/.project +++ /dev/null @@ -1,18 +0,0 @@ - - - GoogleMapsANE - - - - - - com.adobe.flexbuilder.project.flexbuilder - - - - - - com.adobe.flexbuilder.project.aslibnature - com.adobe.flexbuilder.project.actionscriptnature - - diff --git a/native_extension/ane/build_mobile.sh b/native_extension/ane/build.sh similarity index 98% rename from native_extension/ane/build_mobile.sh rename to native_extension/ane/build.sh index 04a21c6..2b762cd 100755 --- a/native_extension/ane/build_mobile.sh +++ b/native_extension/ane/build.sh @@ -130,7 +130,7 @@ mv "$pathtome/platforms/android/res" "$pathtome/platforms/android/com.tuarua.$PR #Run the build command. echo "Building ANE." "$AIR_SDK"/bin/adt -package \ --target ane "$pathtome/$PROJECTNAME.ane" "$pathtome/extension_mobile.xml" \ +-target ane "$pathtome/$PROJECTNAME.ane" "$pathtome/extension.xml" \ -swc "$pathtome/$PROJECTNAME.swc" \ -platform Android-x86 \ -C "$pathtome/platforms/android" "library.swf" "classes.jar" \ diff --git a/native_extension/ane/docs/com.tuarua.fre.xml b/native_extension/ane/docs/com.tuarua.fre.xml index cf666e6..36ca46e 100644 --- a/native_extension/ane/docs/com.tuarua.fre.xml +++ b/native_extension/ane/docs/com.tuarua.fre.xml @@ -1 +1 @@ -com.tuarua.freANEErrorErrorANEErrormessageerrorIDtypesourcestackTracegetStackTraceerrorIDsourcetypeANEUtilsObjectANEUtilsgetClassPropsclzgetClassPropsclzgetClassTypeclzgetClassTypeclzgetClassobjgetClassobjmapfromto \ No newline at end of file +com.tuarua.freANEErrorErrorANEErrormessageerrorIDtypesourcestackTracegetStackTraceerrorIDsourcetype \ No newline at end of file diff --git a/native_extension/ane/docs/com.tuarua.xml b/native_extension/ane/docs/com.tuarua.xml index 6d8d8f6..105c4ad 100644 --- a/native_extension/ane/docs/com.tuarua.xml +++ b/native_extension/ane/docs/com.tuarua.xml @@ -1,30 +1,30 @@ -com.tuaruaGoogleMapsANEContextObjectGoogleMapsANEContextdisposeNAMEGoogleMapsANETRACETRACEcirclesunknowngroundOverlaysunknownmarkersunknownpolygonsunknownpolylinesunknowncontextisDisposedGoogleMapsANEflash.events:EventDispatcherGoogleMapsANEaddCircle +com.tuaruaGoogleMapsANEContextObjectGoogleMapsANEContextdisposeNAMEGoogleMapsANETRACETRACEcirclesunknowngroundOverlaysunknownmarkersunknownpolygonsunknownpolylinesunknowncontextGoogleMapsflash.events:EventDispatcherGoogleMapsaddCircle circlecom.tuarua.googlemaps:Circle - addEventListener + addEventListener type listener useCapturefalse priority0 useWeakReferencefalse - addGroundOverlaygroundOverlaycom.tuarua.googlemaps:GroundOverlayaddMarker + addGroundOverlaygroundOverlaycom.tuarua.googlemaps:GroundOverlayaddMarker markercom.tuarua.googlemaps:Marker - addPolygon + addPolygon polygoncom.tuarua.googlemaps:Polygon - addPolyline + addPolyline polylinecom.tuarua.googlemaps:Polyline - capture + capture x0 y0 width0leaving as default of 0 captures the full width height0leaving as default of 0 captures the full height @@ -34,158 +34,150 @@ - clear + clear - disposeforwardGeocodeLocation + disposeforwardGeocodeLocation addressString - getCapture + getCapture Returns the last bitmap capture of the mapView

Returns the last bitmap capture of the mapView

-
hideInfoWindow + hideInfoWindow id - initMap + initMap viewPort centerAtcom.tuarua.googlemaps:Coordinate zoomLevel settingscom.tuarua.googlemaps:Settings scaleFactor1.0 - moveCamera + moveCamera positioncom.tuarua.googlemaps:CameraPosition animatesfalse - removeEventListener + removeEventListener type listener useCapturefalse - requestPermissions + requestPermissions - reverseGeocodeLocation + reverseGeocodeLocation coordinatecom.tuarua.googlemaps:Coordinate - scrollBy + scrollBy x y animatesfalse

Android Only.

-
setBounds + setBounds boundscom.tuarua.googlemaps:CoordinateBounds animatesfalse - showInfoWindow + showInfoWindow id - showUserLocation + showUserLocation - zoomIn + zoomIn animatesfalse - zoomOut + zoomOut animatesfalse - zoomTo + zoomTo zoomLevel animatesfalse - circles +
circles - groundOverlays + groundOverlays - isInited - - - - isMapInited - - - - mapViewcom.tuarua:GoogleMapsANEmarkers + mapViewcom.tuarua:GoogleMapsmarkers - polylines + polylines - projection + projection Returns a Projection object that you can use to convert between screen coordinates and latitude/longitude coordinates.com.tuarua.googlemaps:Projection Returns a Projection object that you can use to convert between screen coordinates and latitude/longitude coordinates. returns null on Apple Maps - viewPort + viewPort - visible + visible - animationDuration + animationDuration - buildingsEnabled + buildingsEnabled Sets whether 3D buildings layer is enabled. Sets whether 3D buildings layer is enabled. (default true). Ignored on Apple Maps - indoorEnabled + indoorEnabled Sets whether 3D buildings layer is enabled. Sets whether 3D buildings layer is enabled. (default true). Ignored on Apple Maps - keymapProvidermapType + keymapProvidermapType - maxZoom + maxZoom Maximum zoom (the closest the camera may be to the Earth). Maximum zoom (the closest the camera may be to the Earth). Ignored on Apple Maps - minZoom + minZoom Minimum zoom (the farthest the camera may be zoomed out). Minimum zoom (the farthest the camera may be zoomed out). Ignored on Apple Maps - myLocationEnabled + myLocationEnabled Enables or disables the my-location layer. Enables or disables the my-location layer. - style + style - trafficEnabled + trafficEnabled Controls whether the map is drawing traffic data, if available. Controls whether the map is drawing traffic data, if available. diff --git a/native_extension/ane/extension_mobile.xml b/native_extension/ane/extension.xml similarity index 98% rename from native_extension/ane/extension_mobile.xml rename to native_extension/ane/extension.xml index 67b13e4..7d0c81a 100644 --- a/native_extension/ane/extension_mobile.xml +++ b/native_extension/ane/extension.xml @@ -3,7 +3,7 @@ com.tuarua.GoogleMapsANE Google Maps ANE This work is licensed under Apache License, Copyright (c) 2017 Tua Rua Ltd. - 2.5.0 + 2.6.0 diff --git a/native_extension/ane/platforms/default/library.swf b/native_extension/ane/platforms/default/library.swf index e89dd40..f8768ff 100644 Binary files a/native_extension/ane/platforms/default/library.swf and b/native_extension/ane/platforms/default/library.swf differ diff --git a/native_extension/ane/platforms/ios/platform.xml b/native_extension/ane/platforms/ios/platform.xml index bc2bfec..26a3774 100644 --- a/native_extension/ane/platforms/ios/platform.xml +++ b/native_extension/ane/platforms/ios/platform.xml @@ -1,6 +1,6 @@ - 12.1 + 13.0 diff --git a/native_extension/bin/GoogleMapsANE.swc b/native_extension/bin/GoogleMapsANE.swc index dde0b0c..cfb16e5 100644 Binary files a/native_extension/bin/GoogleMapsANE.swc and b/native_extension/bin/GoogleMapsANE.swc differ diff --git a/native_extension/src/avmplus/DescribeTypeJSON.as b/native_extension/src/avmplus/DescribeTypeJSON.as new file mode 100644 index 0000000..ac61e0a --- /dev/null +++ b/native_extension/src/avmplus/DescribeTypeJSON.as @@ -0,0 +1,71 @@ +// ================================================================================================= +// +// Modified by Rodrigo Lopez [roipekerâ„¢] on 20/01/2019. +// +// original class: +// https://github.com/tschneidereit/SwiftSuspenders/blob/master/src/avmplus/DescribeTypeJSON.as +// +// Check https://jacksondunstan.com/articles/2609 for reference. +// +// +// ================================================================================================= + +package avmplus { + +/** + * -- Basic Usage: + * + * var desc:Object = DescribeTypeJSON.run( AnyClassOrInstance ); + * trace( JSON.stringify( desc )) ; + * + */ + +/** + * Makes the hidden, unofficial function describeTypeJSON available outside of the avmplus + * package. + * + * As Adobe doen't officially support this method and it is only visible to client + * code by accident, it should only ever be used with runtime-detection and automatic fallback + * on describeType. + * + * @see http://www.tillschneidereit.de/2009/11/22/improved-reflection-support-in-flash-player-10-1/ + * @private + */ +public class DescribeTypeJSON { + //---------------------- Public Properties ----------------------// + public static var available:Boolean = describeTypeJSON != null; + + public static const INSTANCE_FLAGS:uint = INCLUDE_VARIABLES | USE_ITRAITS | HIDE_OBJECT; + public static const CLASS_FLAGS:uint = INCLUDE_VARIABLES | INCLUDE_TRAITS | HIDE_OBJECT; + + + private static var _instance:DescribeTypeJSON; + + public static function get():DescribeTypeJSON { + if (!_instance) _instance = new DescribeTypeJSON(); + return _instance; + } + + public static function run(obj:Object):Object { + // little hack to call Class from instance + if (!(obj is Class)) obj = Object(obj).constructor; + return get().describeType(obj, CLASS_FLAGS | INSTANCE_FLAGS); + } + + //---------------------- Public Methods ----------------------// + public function DescribeTypeJSON() { + } + + public function describeType(target:Object, flags:uint):Object { + return describeTypeJSON(target, flags); + } + + public function getInstanceDescription(type:Object):Object { + return describeTypeJSON(type, INSTANCE_FLAGS); + } + + public function getClassDescription(type:Class):Object { + return describeTypeJSON(type, CLASS_FLAGS); + } +} +} \ No newline at end of file diff --git a/native_extension/src/com/tuarua/GoogleMapsANE.as b/native_extension/src/com/tuarua/GoogleMaps.as similarity index 76% rename from native_extension/src/com/tuarua/GoogleMapsANE.as rename to native_extension/src/com/tuarua/GoogleMaps.as index 9554cba..5d6c659 100644 --- a/native_extension/src/com/tuarua/GoogleMapsANE.as +++ b/native_extension/src/com/tuarua/GoogleMaps.as @@ -32,33 +32,30 @@ import flash.events.EventDispatcher; import flash.geom.Rectangle; import flash.utils.Dictionary; -public class GoogleMapsANE extends EventDispatcher { +public class GoogleMaps extends EventDispatcher { private var _viewPort:Rectangle; private var _visible:Boolean; - private var _isInited:Boolean; - private var _isMapInited:Boolean; - private static var _mapView:GoogleMapsANE; + private static var _mapView:GoogleMaps; private static var _key:String; private static var _mapProvider:int = MapProvider.GOOGLE; private var _projection:Projection = new Projection(); - public function GoogleMapsANE() { + public function GoogleMaps() { if (_mapView) { - throw new Error(GoogleMapsANEContext.NAME + "GoogleMapsANE is a singleton, use .mapView"); + throw new Error(GoogleMapsANEContext.NAME + " is a singleton, use .mapView"); } if (GoogleMapsANEContext.context) { var ret:* = GoogleMapsANEContext.context.call("init", _key, _mapProvider); if (ret is ANEError) throw ret as ANEError; - _isInited = ret; } _mapView = this; } - public static function get mapView():GoogleMapsANE { + public static function get mapView():GoogleMaps { if (_mapView == null) { - new GoogleMapsANE(); + new GoogleMaps(); } return _mapView; } @@ -86,14 +83,9 @@ public class GoogleMapsANE extends EventDispatcher { * @param useWeakReference * */ - override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, - useWeakReference:Boolean = false):void { + override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void { super.addEventListener(type, listener, useCapture, priority, useWeakReference); - if (_isInited) { - GoogleMapsANEContext.context.call("addEventListener", type); - } else { - trace("You need to init before adding EventListeners"); - } + GoogleMapsANEContext.context.call("addEventListener", type); } /** @@ -105,11 +97,7 @@ public class GoogleMapsANE extends EventDispatcher { */ override public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void { super.removeEventListener(type, listener, useCapture); - if (_isInited) { - GoogleMapsANEContext.context.call("removeEventListener", type); - } else { - trace("You need to init before removing EventListeners"); - } + GoogleMapsANEContext.context.call("removeEventListener", type); } /** @@ -121,16 +109,10 @@ public class GoogleMapsANE extends EventDispatcher { * @param scaleFactor * */ - public function initMap(viewPort:Rectangle, centerAt:Coordinate, zoomLevel:Number, settings:Settings, - scaleFactor:Number = 1.0):void { - if (_isInited) { - _viewPort = viewPort; - var ret:* = GoogleMapsANEContext.context.call("initMap", _viewPort, centerAt, zoomLevel, settings, scaleFactor); - if (ret is ANEError) throw ret as ANEError; - _isMapInited = true; - } else { - trace("initMap wasn't successful"); - } + public function initMap(viewPort:Rectangle, centerAt:Coordinate, zoomLevel:Number, settings:Settings, scaleFactor:Number = 1.0):void { + _viewPort = viewPort; + var ret:* = GoogleMapsANEContext.context.call("initMap", _viewPort, centerAt, zoomLevel, settings, scaleFactor); + if (ret is ANEError) throw ret as ANEError; } /** @@ -139,7 +121,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function addCircle(circle:Circle):void { - if (!safetyCheck()) return; var ret:* = GoogleMapsANEContext.context.call("addCircle", circle); if (ret is ANEError) throw ret as ANEError; var id:String = ret as String; @@ -149,7 +130,6 @@ public class GoogleMapsANE extends EventDispatcher { } public function addGroundOverlay(groundOverlay:GroundOverlay):void { - if (!safetyCheck()) return; var ret:* = GoogleMapsANEContext.context.call("addGroundOverlay", groundOverlay); if (ret is ANEError) throw ret as ANEError; var id:String = ret as String; @@ -164,7 +144,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function addPolyline(polyline:Polyline):void { - if (!safetyCheck()) return; var ret:* = GoogleMapsANEContext.context.call("addPolyline", polyline); if (ret is ANEError) throw ret as ANEError; var id:String = ret as String; @@ -179,7 +158,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function addPolygon(polygon:Polygon):void { - if (!safetyCheck()) return; var ret:* = GoogleMapsANEContext.context.call("addPolygon", polygon); if (ret is ANEError) throw ret as ANEError; var id:String = ret as String; @@ -195,7 +173,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function addMarker(marker:Marker):void { - if (!safetyCheck()) return; var ret:* = GoogleMapsANEContext.context.call("addMarker", marker); if (ret is ANEError) throw ret as ANEError; var id:String = ret as String; @@ -208,9 +185,7 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function clear():void { - if (safetyCheck()) { - GoogleMapsANEContext.context.call("clear"); - } + GoogleMapsANEContext.context.call("clear"); } /** @@ -221,7 +196,6 @@ public class GoogleMapsANE extends EventDispatcher { public function set visible(value:Boolean):void { if (_visible == value) return; _visible = value; - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setVisible", value); } @@ -231,7 +205,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function setBounds(bounds:CoordinateBounds, animates:Boolean = false):void { - if (!safetyCheck()) return; var ret:* = GoogleMapsANEContext.context.call("setBounds", bounds, animates); if (ret is ANEError) throw ret as ANEError; } @@ -243,7 +216,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function moveCamera(position:CameraPosition, animates:Boolean = false):void { - if (!safetyCheck()) return; var centerAt:Coordinate = position.centerAt ? position.centerAt : null; var zoom:* = position.zoom != -9999 ? position.zoom : null; var tilt:* = position.tilt != -9999 ? position.tilt : null; @@ -258,7 +230,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function zoomIn(animates:Boolean = false):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("zoomIn", animates); } @@ -268,7 +239,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function zoomOut(animates:Boolean = false):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("zoomOut", animates); } @@ -279,7 +249,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function zoomTo(zoomLevel:Number, animates:Boolean = false):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("zoomTo", zoomLevel, animates); } @@ -292,7 +261,6 @@ public class GoogleMapsANE extends EventDispatcher { *

Android Only.

*/ public function scrollBy(x:Number, y:Number, animates:Boolean = false):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("scrollBy", x, y, animates); } @@ -302,7 +270,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function set mapType(value:uint):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setMapType", value); } @@ -311,7 +278,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function showUserLocation():void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("showUserLocation"); } @@ -327,7 +293,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function capture(x:int = 0, y:int = 0, width:int = 0, height:int = 0):void { - if (!safetyCheck()) return; var ret:* = GoogleMapsANEContext.context.call("capture", x, y, width, height) as BitmapData; if (ret is ANEError) throw ret as ANEError; } @@ -336,7 +301,6 @@ public class GoogleMapsANE extends EventDispatcher { *

Returns the last bitmap capture of the mapView

*/ public function getCapture():BitmapData { - if (!safetyCheck()) return null; var ret:* = GoogleMapsANEContext.context.call("getCapture") as BitmapData; if (ret is ANEError) throw ret as ANEError; return ret; @@ -347,7 +311,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function requestPermissions():void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("requestPermissions"); } @@ -378,7 +341,6 @@ public class GoogleMapsANE extends EventDispatcher { */ public function set viewPort(value:Rectangle):void { _viewPort = value; - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setViewPort", _viewPort); } @@ -388,7 +350,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function showInfoWindow(id:String):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("showInfoWindow", id); } @@ -398,7 +359,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function hideInfoWindow(id:String):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("hideInfoWindow", id); } @@ -409,7 +369,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function set style(json:String):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setStyle", json); } @@ -419,7 +378,6 @@ public class GoogleMapsANE extends EventDispatcher { * Ignored on Apple Maps */ public function set buildingsEnabled(value:Boolean):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setBuildingsEnabled", value); } @@ -428,8 +386,7 @@ public class GoogleMapsANE extends EventDispatcher { * * Ignored on Apple Maps */ - public function set trafficEnabled(value:Boolean):void { - if (!safetyCheck()) return; + public function set trafficEnabled(value:Boolean):void { GoogleMapsANEContext.context.call("setTrafficEnabled", value); } @@ -438,8 +395,7 @@ public class GoogleMapsANE extends EventDispatcher { * * Ignored on Apple Maps */ - public function set minZoom(value:Number):void { - if (!safetyCheck()) return; + public function set minZoom(value:Number):void { GoogleMapsANEContext.context.call("setMinZoom", value); } @@ -448,8 +404,7 @@ public class GoogleMapsANE extends EventDispatcher { * * Ignored on Apple Maps */ - public function set maxZoom(value:Number):void { - if (!safetyCheck()) return; + public function set maxZoom(value:Number):void { GoogleMapsANEContext.context.call("setMaxZoom", value); } @@ -458,16 +413,14 @@ public class GoogleMapsANE extends EventDispatcher { * * Ignored on Apple Maps */ - public function set indoorEnabled(value:Boolean):void { - if (!safetyCheck()) return; + public function set indoorEnabled(value:Boolean):void { GoogleMapsANEContext.context.call("setIndoorEnabled", value); } /** * Enables or disables the my-location layer. */ - public function set myLocationEnabled(value:Boolean):void { - if (!safetyCheck()) return; + public function set myLocationEnabled(value:Boolean):void { GoogleMapsANEContext.context.call("setMyLocationEnabled", value); } @@ -477,7 +430,6 @@ public class GoogleMapsANE extends EventDispatcher { * returns null on Apple Maps */ public function get projection():Projection { - if (!safetyCheck()) return null; return _projection; } @@ -487,7 +439,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function set animationDuration(value:int):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setAnimationDuration", value); } @@ -497,9 +448,7 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function reverseGeocodeLocation(coordinate:Coordinate):void { - if (_isInited && !GoogleMapsANEContext.isDisposed) { - GoogleMapsANEContext.context.call("reverseGeocodeLocation", coordinate); - } + GoogleMapsANEContext.context.call("reverseGeocodeLocation", coordinate); } /** @@ -508,38 +457,7 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function forwardGeocodeLocation(addressString:String):void { - if (_isInited && !GoogleMapsANEContext.isDisposed) { - GoogleMapsANEContext.context.call("forwardGeocodeLocation", addressString); - } - } - - /** - * - * @return whether we have inited the Google Maps API - * - */ - public function get isInited():Boolean { - return _isInited; - } - - /** - * - * @return whether we have inited the mapView - * - */ - public function get isMapInited():Boolean { - return _isMapInited; - } - - /** - * This method is omitted from the output. * * @private - */ - private function safetyCheck():Boolean { - if (!_isInited && _isMapInited || GoogleMapsANEContext.isDisposed) { - trace("You need to init first"); - return false; - } - return true; + GoogleMapsANEContext.context.call("forwardGeocodeLocation", addressString); } //noinspection JSMethodCanBeStatic diff --git a/native_extension/src/com/tuarua/GoogleMapsANEContext.as b/native_extension/src/com/tuarua/GoogleMapsANEContext.as index 40aad69..d1d11f6 100644 --- a/native_extension/src/com/tuarua/GoogleMapsANEContext.as +++ b/native_extension/src/com/tuarua/GoogleMapsANEContext.as @@ -30,7 +30,6 @@ public class GoogleMapsANEContext { internal static const NAME:String = "GoogleMapsANE"; internal static const TRACE:String = "TRACE"; private static var _context:ExtensionContext; - private static var _isDisposed:Boolean; private static var argsAsJSON:Object; public static var markers:Dictionary = new Dictionary(); public static var circles:Dictionary = new Dictionary(); @@ -45,13 +44,9 @@ public class GoogleMapsANEContext { if (_context == null) { try { _context = ExtensionContext.createExtensionContext("com.tuarua." + NAME, null); - if (_context == null) { - throw new Error("ANE " + NAME + " not created properly. Future calls will fail."); - } _context.addEventListener(StatusEvent.STATUS, gotEvent); - _isDisposed = false; } catch (e:Error) { - trace("[" + NAME + "] ANE not loaded properly. Future calls will fail."); + throw new Error("ANE " + NAME + " not created properly. Future calls will fail."); } } return _context; @@ -67,7 +62,7 @@ public class GoogleMapsANEContext { try { argsAsJSON = JSON.parse(event.code); var coordinate:Coordinate = new Coordinate(argsAsJSON.latitude, argsAsJSON.longitude); - GoogleMapsANE.mapView.dispatchEvent(new GoogleMapsEvent(event.level, coordinate)); + GoogleMaps.mapView.dispatchEvent(new GoogleMapsEvent(event.level, coordinate)); } catch (e:Error) { trace(e.message); } @@ -85,7 +80,7 @@ public class GoogleMapsANEContext { case GoogleMapsEvent.ON_LOADED: case GoogleMapsEvent.ON_CAMERA_IDLE: case GoogleMapsEvent.ON_BITMAP_READY: - GoogleMapsANE.mapView.dispatchEvent(new GoogleMapsEvent(event.level, event.code)); + GoogleMaps.mapView.dispatchEvent(new GoogleMapsEvent(event.level, event.code)); break; case GoogleMapsEvent.DID_END_DRAGGING: try { @@ -96,7 +91,7 @@ public class GoogleMapsANEContext { var marker:Marker = markers[id] as Marker; marker.coordinate.latitude = latitude; marker.coordinate.longitude = longitude; - GoogleMapsANE.mapView.dispatchEvent(new GoogleMapsEvent(event.level, argsAsJSON)); + GoogleMaps.mapView.dispatchEvent(new GoogleMapsEvent(event.level, argsAsJSON)); } catch (e:Error) { trace(e.message); } @@ -105,7 +100,7 @@ public class GoogleMapsANEContext { case GoogleMapsEvent.ON_CAMERA_MOVE_STARTED: try { argsAsJSON = JSON.parse(event.code); - GoogleMapsANE.mapView.dispatchEvent(new GoogleMapsEvent(event.level, argsAsJSON)); + GoogleMaps.mapView.dispatchEvent(new GoogleMapsEvent(event.level, argsAsJSON)); } catch (e:Error) { trace(e.message); } @@ -113,7 +108,7 @@ public class GoogleMapsANEContext { case LocationEvent.LOCATION_UPDATED: try { argsAsJSON = JSON.parse(event.code); - GoogleMapsANE.mapView.dispatchEvent(new LocationEvent(event.level, + GoogleMaps.mapView.dispatchEvent(new LocationEvent(event.level, new Coordinate(argsAsJSON.latitude, argsAsJSON.longitude))); } catch (e:Error) { trace(e.message); @@ -122,7 +117,7 @@ public class GoogleMapsANEContext { case LocationEvent.ON_ADDRESS_LOOKUP: try { argsAsJSON = JSON.parse(event.code); - GoogleMapsANE.mapView.dispatchEvent(new LocationEvent(event.level, + GoogleMaps.mapView.dispatchEvent(new LocationEvent(event.level, new Coordinate(argsAsJSON.latitude, argsAsJSON.longitude), new Address( argsAsJSON.formattedAddress, @@ -137,12 +132,12 @@ public class GoogleMapsANEContext { } break; case LocationEvent.ON_ADDRESS_LOOKUP_ERROR: - GoogleMapsANE.mapView.dispatchEvent(new LocationEvent(event.level, null, null, event.code)); + GoogleMaps.mapView.dispatchEvent(new LocationEvent(event.level, null, null, event.code)); break; case PermissionEvent.ON_PERMISSION_STATUS: try { argsAsJSON = JSON.parse(event.code); - GoogleMapsANE.mapView.dispatchEvent(new PermissionEvent(event.level, argsAsJSON)); + GoogleMaps.mapView.dispatchEvent(new PermissionEvent(event.level, argsAsJSON)); } catch (e:Error) { trace(e.message); } @@ -151,18 +146,11 @@ public class GoogleMapsANEContext { } public static function dispose():void { - if (!_context) { - return; - } - _isDisposed = true; + if (!_context) return; trace("[" + NAME + "] Unloading ANE..."); _context.removeEventListener(StatusEvent.STATUS, gotEvent); _context.dispose(); _context = null; } - - public static function get isDisposed():Boolean { - return _isDisposed; - } } } diff --git a/native_extension/src/com/tuarua/fre/ANEUtils.as b/native_extension/src/com/tuarua/fre/ANEUtils.as index 5ccf7f2..deb9d78 100644 --- a/native_extension/src/com/tuarua/fre/ANEUtils.as +++ b/native_extension/src/com/tuarua/fre/ANEUtils.as @@ -16,10 +16,13 @@ */ package com.tuarua.fre { +import avmplus.DescribeTypeJSON; + import flash.utils.describeType; import flash.utils.getDefinitionByName; import flash.utils.getQualifiedClassName; +/** @private */ public class ANEUtils { public function ANEUtils() { } @@ -32,72 +35,62 @@ public class ANEUtils { return Class(getDefinitionByName(getQualifiedClassName(obj))); } - public static function getClassProps(clz:*):Vector. { + private static function _getClassProps(clz:*):Vector. { var ret:Vector. = new []; - var xml:XML = describeType(clz); - if (xml.variable && xml.variable.length() > 0) { - for each (var prop:XML in xml.variable) { - var obj:Object = {}; - obj.name = prop.@name.toString(); - obj.type = prop.@type.toString(); - obj.cls = obj.type == "*" ? null : getClass(Class(getDefinitionByName(obj.type))); - ret.push(obj); + var isObject:Boolean = false; + for (var id:String in clz) { + var objc:Object = {}; + objc.name = id; + if (clz.hasOwnProperty(id)) { + objc.type = getClassType(clz[id]); + objc.cls = objc.type == "*" ? null : getClass(Class(getDefinitionByName(objc.type))); + ret.push(objc); + isObject = true; } - } else if (xml.factory && xml.factory.variable && xml.factory.variable.length() > 0) { - for each (var propb:XML in xml.factory.variable) { - var objb:Object = {}; - objb.name = propb.@name.toString(); - objb.type = propb.@type.toString(); - objb.cls = objb.type == "*" ? null : getClass(Class(getDefinitionByName(objb.type))); - ret.push(objb); + } + if (isObject) { + return ret; + } + if (DescribeTypeJSON.available) { + var json:Object = DescribeTypeJSON.run(clz); + if (json.traits.variables) { + for each (var propd:Object in json.traits.variables) { + var objd:Object = {}; + objd.name = propd.name; + objd.type = propd.type; + objd.cls = objd.type == "*" ? null : getClass(Class(getDefinitionByName(objd.type))); + ret.push(objd); + } } } else { - for (var id:String in clz) { - var objc:Object = {}; - objc.name = id; - if (clz.hasOwnProperty(id)) { - objc.type = getClassType(clz[id]); - objc.cls = objc.type == "*" ? null : getClass(Class(getDefinitionByName(objc.type))); - ret.push(objc); + var xml:XML = describeType(clz); + if (xml.variable && xml.variable.length() > 0) { + for each (var prop:XML in xml.variable) { + var obj:Object = {}; + obj.name = prop.@name.toString(); + obj.type = prop.@type.toString(); + obj.cls = obj.type == "*" ? null : getClass(Class(getDefinitionByName(obj.type))); + ret.push(obj); + } + } else if (xml.factory && xml.factory.variable && xml.factory.variable.length() > 0) { + for each (var propb:XML in xml.factory.variable) { + var objb:Object = {}; + objb.name = propb.@name.toString(); + objb.type = propb.@type.toString(); + objb.cls = objb.type == "*" ? null : getClass(Class(getDefinitionByName(objb.type))); + ret.push(objb); } - } } return ret; } - public function getClassProps(clz:*):Vector. { - var ret:Vector. = new []; - var xml:XML = describeType(clz); - if (xml.variable && xml.variable.length() > 0) { - for each (var prop:XML in xml.variable) { - var obj:Object = {}; - obj.name = prop.@name.toString(); - obj.type = prop.@type.toString(); - obj.cls = obj.type == "*" ? null : getClass(Class(getDefinitionByName(obj.type))); - ret.push(obj); - } - } else if (xml.factory && xml.factory.variable && xml.factory.variable.length() > 0) { - for each (var propb:XML in xml.factory.variable) { - var objb:Object = {}; - objb.name = propb.@name.toString(); - objb.type = propb.@type.toString(); - objb.cls = objb.type == "*" ? null : getClass(Class(getDefinitionByName(objb.type))); - ret.push(objb); - } - } else { - for (var id:String in clz) { - var objc:Object = {}; - objc.name = id; - if (clz.hasOwnProperty(id)) { - objc.type = getClassType(clz[id]); - objc.cls = objc.type == "*" ? null : getClass(Class(getDefinitionByName(objc.type))); - ret.push(objc); - } + public static function getClassProps(clz:*):Vector. { + return _getClassProps(clz); + } - } - } - return ret; + public function getClassProps(clz:*):Vector. { + return _getClassProps(clz); } private static function getPropClass(name:String, cls:Class):Class { @@ -110,13 +103,23 @@ public class ANEUtils { return null; } - //noinspection ReservedWordAsName public static function map(from:Object, to:Class):Object { var classInstance:Object; classInstance = new to(); for (var id:String in from) { var name:String = id; - var propCls:Class = getPropClass(name, to); + var propCls:Class; + if (from[name] is String) { + propCls = String; + } else if (from[name] is Boolean) { + propCls = Boolean; + } else if (from[name] is int) { + propCls = int; + } else if (from[name] is Number) { + propCls = Number; + } else { + propCls = getPropClass(name, to); + } switch (propCls) { case String: @@ -128,13 +131,24 @@ public class ANEUtils { case Vector.: case Vector.: case Vector.: - classInstance[name] = from[name]; + if (classInstance.hasOwnProperty(name)) classInstance[name] = from[name]; break; case Date: - classInstance[name] = new Date(Date.parse(from[name])); + if (classInstance.hasOwnProperty(name)) classInstance[name] = new Date(Date.parse(from[name])); break; - default: //Object or Class - classInstance[name] = (propCls == null) ? from[name] : map(from[name], getPropClass(name, to)); + default: //Object or Class or Vector. + // handle Vector. + if (propCls && propCls.toString().indexOf("Vector.") > -1) { + var vec:* = new propCls(); + var vecClsName:String = propCls.toString().replace("[class Vector.<","").replace(">]",""); + var vecCls:Class = getClass(Class(getDefinitionByName(vecClsName))); + for each(var o:* in from[name]) { + vec.push(map(o, vecCls)); + } + if (classInstance.hasOwnProperty(name)) classInstance[name] = vec; + } else { + if (classInstance.hasOwnProperty(name)) classInstance[name] = (propCls == null) ? from[name] : map(from[name], getPropClass(name, to)); + } break; } @@ -151,4 +165,4 @@ public class ANEUtils { } } -} +} \ No newline at end of file diff --git a/native_library/android/GoogleMapsANE/.idea/codeStyles/Project.xml b/native_library/android/GoogleMapsANE/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/native_library/android/GoogleMapsANE/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/native_library/android/GoogleMapsANE/app/app.iml b/native_library/android/GoogleMapsANE/app/app.iml index 1e7a13d..d104553 100644 --- a/native_library/android/GoogleMapsANE/app/app.iml +++ b/native_library/android/GoogleMapsANE/app/app.iml @@ -4,6 +4,8 @@ @@ -24,13 +26,13 @@ - + @@ -71,14 +74,14 @@ - - + + - - + + @@ -122,64 +125,51 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/native_library/android/GoogleMapsANE/app/build.gradle b/native_library/android/GoogleMapsANE/app/build.gradle index 11f7634..cff72dc 100644 --- a/native_library/android/GoogleMapsANE/app/build.gradle +++ b/native_library/android/GoogleMapsANE/app/build.gradle @@ -7,9 +7,9 @@ android { buildToolsVersion "28.0.3" defaultConfig { minSdkVersion 19 - targetSdkVersion compileSdkVersion + targetSdkVersion 28 versionCode 1 - versionName "2.3.0" + versionName "2.6.0" } buildTypes { release { @@ -32,7 +32,7 @@ dependencies { implementation "com.google.android.gms:play-services-location:$play_location_version" implementation "com.google.android.gms:play-services-maps:$play_maps_version" implementation "com.google.code.gson:gson:$gson_version" - implementation "com.android.support:support-v4:$support_4_version" + implementation "androidx.legacy:legacy-support-v4:$legacy_support_4_version" implementation "com.tuarua:FreKotlin:$frekotlin_version" } repositories { diff --git a/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/GoogleMapsANEContext.java b/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/GoogleMapsANEContext.java index 59c9751..4deab04 100644 --- a/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/GoogleMapsANEContext.java +++ b/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/GoogleMapsANEContext.java @@ -14,57 +14,33 @@ * limitations under the License. */ package com.tuarua; -import com.adobe.air.TRActivityResultCallback; import com.adobe.air.AndroidActivityWrapper; -import com.adobe.air.TRStateChangeCallback; import com.tuarua.frekotlin.FreKotlinContext; import com.tuarua.frekotlin.FreKotlinMainController; +import com.tuarua.googlemapsane.KotlinController; -public class GoogleMapsANEContext extends FreKotlinContext implements TRActivityResultCallback, TRStateChangeCallback { +public class GoogleMapsANEContext extends FreKotlinContext { private AndroidActivityWrapper aaw; - private FreKotlinMainController controller; + private KotlinController kc; + GoogleMapsANEContext(String name, FreKotlinMainController controller, String[] functions) { super(name, controller, functions); this.controller = controller; + kc = (KotlinController) this.controller; aaw = AndroidActivityWrapper.GetAndroidActivityWrapper(); - aaw.addActivityResultListener(this); - aaw.addActivityStateChangeListner(this); - } - - @Override - public void onActivityStateChanged(AndroidActivityWrapper.ActivityState activityState) { - super.onActivityStateChanged(activityState); - switch (activityState){ - case STARTED: - this.controller.onStarted(); - break; - case RESTARTED: - this.controller.onRestarted(); - break; - case RESUMED: - this.controller.onResumed(); - break; - case PAUSED: - this.controller.onPaused(); - break; - case STOPPED: - this.controller.onStopped(); - break; - case DESTROYED: - this.controller.onDestroyed(); - break; - } + aaw.addActivityResultListener(kc); + aaw.addActivityStateChangeListner(kc); } @Override public void dispose() { super.dispose(); if (aaw != null) { - aaw.removeActivityResultListener(this); - aaw.removeActivityStateChangeListner(this); + aaw.removeActivityResultListener(kc); + aaw.removeActivityStateChangeListner(kc); aaw = null; } - controller.dispose(); - controller = null; + kc.dispose(); + kc = null; } } diff --git a/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/KotlinController.kt b/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/KotlinController.kt index 15bba57..82d95de 100644 --- a/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/KotlinController.kt +++ b/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/KotlinController.kt @@ -24,11 +24,15 @@ import android.content.Intent import android.content.pm.PackageInfo import android.content.pm.PackageManager import android.content.pm.PackageManager.GET_PERMISSIONS +import android.content.res.Configuration import android.graphics.RectF import android.location.Address import android.location.Geocoder -import android.support.v4.content.ContextCompat import android.view.ViewGroup +import androidx.core.content.ContextCompat +import com.adobe.air.AndroidActivityWrapper +import com.adobe.air.FreKotlinActivityResultCallback +import com.adobe.air.FreKotlinStateChangeCallback import com.adobe.fre.FREContext import com.adobe.fre.FREObject import com.google.android.gms.maps.model.* @@ -49,7 +53,7 @@ import org.greenrobot.eventbus.ThreadMode import java.io.IOException @Suppress("unused", "UNUSED_PARAMETER", "UNCHECKED_CAST", "PrivatePropertyName") -class KotlinController : FreKotlinMainController { +class KotlinController : FreKotlinMainController, FreKotlinStateChangeCallback, FreKotlinActivityResultCallback { private var scaleFactor = 1.0f private lateinit var airView: ViewGroup private val TRACE = "TRACE" @@ -80,7 +84,7 @@ class KotlinController : FreKotlinMainController { } fun reverseGeocodeLocation(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("reverseGeocodeLocation") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val coordinate = LatLng(argv[0]) val appActivity = ctx.activity if (appActivity != null) { @@ -97,7 +101,7 @@ class KotlinController : FreKotlinMainController { } fun forwardGeocodeLocation(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("forwardGeocodeLocation") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val addressSearch = String(argv[0]) ?: return null val appActivity = ctx.activity if (appActivity != null) { @@ -168,7 +172,7 @@ class KotlinController : FreKotlinMainController { } fun capture(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 3 } ?: return FreArgException("initMap") + argv.takeIf { argv.size > 3 } ?: return FreArgException() val xFre = Int(argv[0]) ?: return null val yFre = Int(argv[1]) ?: return null val wFre = Int(argv[2]) ?: return null @@ -233,7 +237,7 @@ class KotlinController : FreKotlinMainController { } fun initMap(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 4 } ?: return FreArgException("initMap") + argv.takeIf { argv.size > 4 } ?: return FreArgException() val centerAt = LatLng(argv[1]) val viewPort = RectF(argv[0]) val zoomLevel = Float(argv[2]) ?: 12.0f @@ -244,7 +248,7 @@ class KotlinController : FreKotlinMainController { } fun addEventListener(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("addEventListener") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val type = String(argv[0]) ?: return null if (mapController == null) { asListeners.add(type) @@ -262,7 +266,7 @@ class KotlinController : FreKotlinMainController { } fun removeEventListener(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("removeEventListener") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val type = String(argv[0]) ?: return null if (mapController == null) { asListeners.remove(type) @@ -278,13 +282,13 @@ class KotlinController : FreKotlinMainController { } fun addCircle(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("addCircle") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val addedCircle: Circle? = mapController?.addCircle(CircleOptions(argv[0])) return addedCircle?.id?.toFREObject() } fun setCircleProp(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 2 } ?: return FreArgException("setCircleProp") + argv.takeIf { argv.size > 2 } ?: return FreArgException() val id = String(argv[0]) ?: return null val name = String(argv[1]) ?: return null mapController?.setCircleProp(id, name, argv[2]) @@ -292,20 +296,20 @@ class KotlinController : FreKotlinMainController { } fun removeCircle(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("removeCircle") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val id = String(argv[0]) ?: return null mapController?.removeCircle(id) return null } fun addMarker(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("addMarker") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val addedMarker: Marker? = mapController?.addMarker(MarkerOptions(argv[0])) return addedMarker?.id?.toFREObject() } fun setMarkerProp(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 2 } ?: return FreArgException("setMarkerProp") + argv.takeIf { argv.size > 2 } ?: return FreArgException() val id = String(argv[0]) ?: return null val name = String(argv[1]) ?: return null mapController?.setMarkerProp(id, name, argv[2]) @@ -313,20 +317,20 @@ class KotlinController : FreKotlinMainController { } fun removeMarker(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("removeMarker") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val id = String(argv[0]) ?: return null mapController?.removeMarker(id) return null } fun addGroundOverlay(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("addGroundOverlay") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val addedOverlay: GroundOverlay? = mapController?.addGroundOverlay(GroundOverlayOptions(argv[0])) return addedOverlay?.id?.toFREObject() } fun setGroundOverlayProp(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 1 } ?: return FreArgException("setGroundOverlayProp") + argv.takeIf { argv.size > 1 } ?: return FreArgException() val id = String(argv[0]) ?: return null val name = String(argv[1]) ?: return null mapController?.setGroundOverlayProp(id, name, argv[2]) @@ -334,20 +338,20 @@ class KotlinController : FreKotlinMainController { } fun removeGroundOverlay(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("removeGroundOverlay") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val id = String(argv[0]) ?: return null mapController?.removeGroundOverlay(id) return null } fun addPolyline(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("addPolyline") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val addedPolyline: Polyline? = mapController?.addPolyline(PolylineOptions(argv[0])) return addedPolyline?.id?.toFREObject() } fun setPolylineProp(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 1 } ?: return FreArgException("setPolylineProp") + argv.takeIf { argv.size > 1 } ?: return FreArgException() val id = String(argv[0]) ?: return null val name = String(argv[1]) ?: return null mapController?.setPolylineProp(id, name, argv[2]) @@ -355,20 +359,20 @@ class KotlinController : FreKotlinMainController { } fun removePolyline(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("removePolyline") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val id = String(argv[0]) ?: return null mapController?.removePolyline(id) ?: return null return null } fun addPolygon(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("addPolygon") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val addedPolygon: Polygon? = mapController?.addPolygon(PolygonOptions(argv[0])) return addedPolygon?.id?.toFREObject() } fun setPolygonProp(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 1 } ?: return FreArgException("setPolygonProp") + argv.takeIf { argv.size > 1 } ?: return FreArgException() val id = String(argv[0]) ?: return null val name = String(argv[1]) ?: return null mapController?.setPolygonProp(id, name, argv[2]) @@ -376,21 +380,21 @@ class KotlinController : FreKotlinMainController { } fun removePolygon(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("removePolygon") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val id = String(argv[0]) ?: return null mapController?.removePolygon(id) return null } fun showInfoWindow(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("showInfoWindow") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val id = String(argv[0]) ?: return null mapController?.showInfoWindow(id) return null } fun hideInfoWindow(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("hideInfoWindow") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val id = String(argv[0]) ?: return null mapController?.hideInfoWindow(id) return null @@ -410,14 +414,14 @@ class KotlinController : FreKotlinMainController { } fun setViewPort(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("initMap") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val viewPortFre = RectF(argv[0]) mapController?.viewPort = scaleViewPort(viewPortFre) return null } fun setVisible(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("setVisible") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val visible = Boolean(argv[0]) == true if (!isAdded) { mapController?.add() @@ -428,7 +432,7 @@ class KotlinController : FreKotlinMainController { } fun moveCamera(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 4 } ?: return FreArgException("moveCamera") + argv.takeIf { argv.size > 4 } ?: return FreArgException() var centerAt: LatLng? = null if (argv[0].type != FreObjectTypeKotlin.NULL) { centerAt = LatLng(argv[0]) @@ -442,7 +446,7 @@ class KotlinController : FreKotlinMainController { } fun setBounds(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 1 } ?: return FreArgException("setBounds") + argv.takeIf { argv.size > 1 } ?: return FreArgException() val bounds = LatLngBounds(argv[0]) val animates = Boolean(argv[1]) == true mapController?.setBounds(bounds, animates) @@ -450,21 +454,21 @@ class KotlinController : FreKotlinMainController { } fun zoomIn(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("zoomIn") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val animates = Boolean(argv[0]) == true mapController?.zoomIn(animates) return null } fun zoomOut(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("zoomOut") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val animates = Boolean(argv[0]) == true mapController?.zoomOut(animates) return null } fun zoomTo(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 1 } ?: return FreArgException("zoomTo") + argv.takeIf { argv.size > 1 } ?: return FreArgException() val zoomLevel = Float(argv[0]) ?: return null val animates = Boolean(argv[1]) == true mapController?.zoomTo(zoomLevel, animates) @@ -472,7 +476,7 @@ class KotlinController : FreKotlinMainController { } fun scrollBy(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 2 } ?: return FreArgException("scrollBy") + argv.takeIf { argv.size > 2 } ?: return FreArgException() val x = Float(argv[0]) ?: return null val y = Float(argv[1]) ?: return null val animates = Boolean(argv[2]) == true @@ -481,70 +485,70 @@ class KotlinController : FreKotlinMainController { } fun setAnimationDuration(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("setAnimationDuration") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val duration = Int(argv[0]) ?: return null mapController?.animationDuration = duration return null } fun setStyle(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("setStyle") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val json = String(argv[0]) ?: return null mapController?.style = json return null } fun setMapType(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("setMapType") + argv.takeIf { argv.size > 0 } ?: return FreArgException() val type = Int(argv[0]) ?: return null mapController?.mapView?.mapType = type return null } fun setBuildingsEnabled(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("setBuildingsEnabled") + argv.takeIf { argv.size > 0 } ?: return FreArgException() mapController?.mapView?.isBuildingsEnabled = Boolean(argv[0]) == true return null } fun setTrafficEnabled(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("setTrafficEnabled") + argv.takeIf { argv.size > 0 } ?: return FreArgException() mapController?.mapView?.isTrafficEnabled = Boolean(argv[0]) == true return null } fun setMinZoom(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("setMinZoom") + argv.takeIf { argv.size > 0 } ?: return FreArgException() Float(argv[0])?.let { mapController?.mapView?.setMinZoomPreference(it) } return null } fun setMaxZoom(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("setMinZoom") + argv.takeIf { argv.size > 0 } ?: return FreArgException() Float(argv[0])?.let { mapController?.mapView?.setMaxZoomPreference(it) } return null } fun setIndoorEnabled(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("setIndoorEnabled") + argv.takeIf { argv.size > 0 } ?: return FreArgException() mapController?.mapView?.isIndoorEnabled = Boolean(argv[0]) == true return null } @SuppressLint("MissingPermission") fun setMyLocationEnabled(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("setIndoorEnabled") + argv.takeIf { argv.size > 0 } ?: return FreArgException() mapController?.mapView?.isMyLocationEnabled = Boolean(argv[0]) == true return null } fun projection_pointForCoordinate(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("projection_pointForCoordinate") + argv.takeIf { argv.size > 0 } ?: return FreArgException() return mapController?.mapView?.projection?.toScreenLocation(LatLng(argv[0]))?.toFREObject() } fun projection_coordinateForPoint(ctx: FREContext, argv: FREArgv): FREObject? { - argv.takeIf { argv.size > 0 } ?: return FreArgException("projection_coordinateForPoint") + argv.takeIf { argv.size > 0 } ?: return FreArgException() return mapController?.mapView?.projection?.fromScreenLocation(Point(argv[0]))?.toFREObject() } @@ -562,6 +566,15 @@ class KotlinController : FreKotlinMainController { return null } + override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) { + } + + override fun onConfigurationChanged(configuration: Configuration?) { + } + + override fun onActivityStateChanged(activityState: AndroidActivityWrapper.ActivityState?) { + } + override fun dispose() { super.dispose() mapController?.dispose() diff --git a/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/MapController.kt b/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/MapController.kt index 62c2f2d..888f7a1 100644 --- a/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/MapController.kt +++ b/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/MapController.kt @@ -24,8 +24,8 @@ import android.location.Location import android.view.View import android.view.ViewGroup import android.widget.FrameLayout +import androidx.core.content.ContextCompat.checkSelfPermission import com.adobe.fre.FREContext -import android.support.v4.content.ContextCompat.checkSelfPermission import com.adobe.fre.FREObject import com.google.android.gms.maps.model.* import com.google.android.gms.location.FusedLocationProviderClient diff --git a/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/PermissionActivity.kt b/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/PermissionActivity.kt index 9fb660a..2c5c0b7 100644 --- a/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/PermissionActivity.kt +++ b/native_library/android/GoogleMapsANE/app/src/main/java/com/tuarua/googlemapsane/PermissionActivity.kt @@ -19,7 +19,7 @@ package com.tuarua.googlemapsane import android.app.Activity import android.content.pm.PackageManager import android.os.Bundle -import android.support.v4.app.ActivityCompat +import androidx.core.app.ActivityCompat import com.tuarua.googlemapsane.events.PermissionEvent import org.greenrobot.eventbus.EventBus diff --git a/native_library/android/GoogleMapsANE/build.gradle b/native_library/android/GoogleMapsANE/build.gradle index 9fbbec1..05ac524 100644 --- a/native_library/android/GoogleMapsANE/build.gradle +++ b/native_library/android/GoogleMapsANE/build.gradle @@ -1,12 +1,12 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.40' - ext.frekotlin_version = '1.8.0' - ext.gson_version = '2.8.4' - ext.play_maps_version = '16.1.0' - ext.play_location_version = '16.0.0' - ext.support_4_version = '27.1.0' + ext.kotlin_version = '1.3.61' + ext.frekotlin_version = '1.9.5' + ext.gson_version = '2.8.6' + ext.play_maps_version = '17.0.0' + ext.play_location_version = '17.0.0' + ext.legacy_support_4_version = '1.0.0' repositories { google() diff --git a/native_library/ios/GoogleMapsANE/Cartfile b/native_library/ios/GoogleMapsANE/Cartfile index ff5cd47..5ba3e0d 100644 --- a/native_library/ios/GoogleMapsANE/Cartfile +++ b/native_library/ios/GoogleMapsANE/Cartfile @@ -1 +1 @@ -binary "https://github.com/tuarua/Swift-IOS-ANE/releases/download/3.1.0/FreSwift.json" ~> 3.1.0 \ No newline at end of file +binary "https://github.com/tuarua/Swift-IOS-ANE/releases/download/4.3.0/FreSwift.json" ~> 4.3.0 \ No newline at end of file diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.pbxproj b/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.pbxproj index 0b1e77c..7a26123 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.pbxproj +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.pbxproj @@ -3,72 +3,71 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ - 285FE1341741FC686F0BEB75 /* FreCLLocationCoordinate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285FE4E5D8DD21768875CCFD /* FreCLLocationCoordinate.swift */; }; - 285FE3EB871F2DD420623AEE /* GoogleMapsANE_LIB.h in Headers */ = {isa = PBXBuildFile; fileRef = 285FEBB3CADF8D704FAB5E4D /* GoogleMapsANE_LIB.h */; }; - 285FE43BB13A003DF0009958 /* FreMKCircle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285FE3EB6401C4553D5DC713 /* FreMKCircle.swift */; }; - 285FE645B808125071F7A08A /* CustomMKCircle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285FE9BC1B43C00633CEE916 /* CustomMKCircle.swift */; }; - 285FE6FF36D515256EAE7B63 /* FreGMSCircle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285FE41C9FE2CEB9DCF6CB30 /* FreGMSCircle.swift */; }; - 285FECB67C2311471C2CD119 /* GoogleMapsANE_LIB.m in Sources */ = {isa = PBXBuildFile; fileRef = 285FE6D7F3D6356FA03A26C0 /* GoogleMapsANE_LIB.m */; }; - 9022967A2299736400495FDE /* CoreImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 902296792299736300495FDE /* CoreImage.framework */; }; - 9022967C2299737B00495FDE /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9022967B2299737B00495FDE /* CoreTelephony.framework */; }; - 9022967E229973B300495FDE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9022967D229973B300495FDE /* UIKit.framework */; }; - 902296802299903900495FDE /* FreGMSCoordinateBounds.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9022967F2299903900495FDE /* FreGMSCoordinateBounds.swift */; }; - 90942B0A229AB549006672D9 /* FreGMSVisibleRegion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90942B09229AB549006672D9 /* FreGMSVisibleRegion.swift */; }; - 90C3B5D721F4D83B002F59AB /* FreGMSPolygon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90C3B5D621F4D83B002F59AB /* FreGMSPolygon.swift */; }; - 90C3B5D921F4E135002F59AB /* FreGMSMutablePath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90C3B5D821F4E135002F59AB /* FreGMSMutablePath.swift */; }; - 90C940C2229A0AAB007AD291 /* FreGMSCameraPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90C940C1229A0AAB007AD291 /* FreGMSCameraPosition.swift */; }; - CE39808E1E58BAA90062485B /* GoogleMapsANE_FW.h in Headers */ = {isa = PBXBuildFile; fileRef = CE39808C1E58BAA90062485B /* GoogleMapsANE_FW.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CE3980981E58BB070062485B /* SwiftController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE3980971E58BB070062485B /* SwiftController.swift */; }; - CE3980AD1E58BF3F0062485B /* GoogleMapsANE_FW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE39808A1E58BAA90062485B /* GoogleMapsANE_FW.framework */; }; - CE5D4976202619540067B01C /* LocationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5D4975202619540067B01C /* LocationController.swift */; }; - CE5D4978202619CD0067B01C /* MapProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5D4977202619CD0067B01C /* MapProvider.swift */; }; - CE5E29881F6452CC00FDB81A /* MarkerOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5E29871F6452CC00FDB81A /* MarkerOptions.swift */; }; - CE60CCC41F63DA7F004B1BE7 /* FreSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE60CCC31F63DA7F004B1BE7 /* FreSwift.framework */; }; - CE60CCCB1F63E25C004B1BE7 /* FreSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE60CCC31F63DA7F004B1BE7 /* FreSwift.framework */; }; - CE60CCCC1F63E444004B1BE7 /* FreMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = CE60CCC11F63DA4D004B1BE7 /* FreMacros.h */; }; - CE6589F31F6EE39100656914 /* MKMapController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6589F21F6EE39100656914 /* MKMapController.swift */; }; - CE6589F51F6F1A9900656914 /* MapViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6589F41F6F1A9900656914 /* MapViewExtension.swift */; }; - CE6589F71F6F1B6200656914 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE6589F61F6F1B6200656914 /* MapKit.framework */; }; - CE9397501F70772400A1428C /* CustomMKAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE93974F1F70772400A1428C /* CustomMKAnnotation.swift */; }; - CEA0DE161F5DF7330012EB4E /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE151F5DF7330012EB4E /* Accelerate.framework */; }; - CEA0DE181F5DF7490012EB4E /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE171F5DF7490012EB4E /* CoreBluetooth.framework */; }; - CEA0DE1A1F5DF7650012EB4E /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE191F5DF7650012EB4E /* libz.tbd */; }; - CEA0DE1C1F5DF7710012EB4E /* libicucore.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE1B1F5DF7710012EB4E /* libicucore.tbd */; }; - CEA0DE1E1F5DF77D0012EB4E /* libc++.1.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE1D1F5DF77D0012EB4E /* libc++.1.tbd */; }; - CEA0DE201F5DF78A0012EB4E /* libc++abi.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE1F1F5DF78A0012EB4E /* libc++abi.tbd */; }; - CEA0DE221F5DF7940012EB4E /* libc.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE211F5DF7940012EB4E /* libc.tbd */; }; - CEA0DE241F5DF7A10012EB4E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE231F5DF7A10012EB4E /* CoreGraphics.framework */; }; - CEA0DE261F5DF7AC0012EB4E /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE251F5DF7AC0012EB4E /* SystemConfiguration.framework */; }; - CEA0DE281F5DF7B80012EB4E /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE271F5DF7B80012EB4E /* QuartzCore.framework */; }; - CEA0DE2A1F5DF7C40012EB4E /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE291F5DF7C40012EB4E /* OpenGLES.framework */; }; - CEA0DE2C1F5DF7CE0012EB4E /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE2B1F5DF7CE0012EB4E /* ImageIO.framework */; }; - CEA0DE2E1F5DF7D90012EB4E /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE2D1F5DF7D90012EB4E /* GLKit.framework */; }; - CEA0DE301F5DF7E80012EB4E /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE2F1F5DF7E80012EB4E /* CoreText.framework */; }; - CEA0DE321F5DF7F30012EB4E /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE311F5DF7F30012EB4E /* CoreLocation.framework */; }; - CEA0DE341F5DF7FA0012EB4E /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE331F5DF7FA0012EB4E /* CoreData.framework */; }; - CEA0DE361F5DF8040012EB4E /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE351F5DF8040012EB4E /* AVFoundation.framework */; }; - CEA0DE3C1F5DF8820012EB4E /* GoogleMaps.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE391F5DF8820012EB4E /* GoogleMaps.framework */; }; - CEA0DE3D1F5DF8820012EB4E /* GoogleMapsBase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE3A1F5DF8820012EB4E /* GoogleMapsBase.framework */; }; - CEA0DE3E1F5DF8820012EB4E /* GoogleMapsCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE3B1F5DF8820012EB4E /* GoogleMapsCore.framework */; }; - CEA0DE401F5DF9DD0012EB4E /* GMSMapController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA0DE3F1F5DF9DD0012EB4E /* GMSMapController.swift */; }; - CEA0DE421F5DFA7A0012EB4E /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA0DE411F5DFA7A0012EB4E /* Settings.swift */; }; - CEA653332027602C0034C691 /* GMSMapController+GMSMapViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA653322027602C0034C691 /* GMSMapController+GMSMapViewDelegate.swift */; }; - CEA65335202761590034C691 /* MKMapController+MKMapViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA65334202761590034C691 /* MKMapController+MKMapViewDelegate.swift */; }; - CEA65337202763570034C691 /* SwiftController+FreSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA65336202763570034C691 /* SwiftController+FreSwift.swift */; }; - CEB5ED121F5C4F7800AE8B16 /* SwiftyJSON.h in Headers */ = {isa = PBXBuildFile; fileRef = CEB5ED101F5C4F7800AE8B16 /* SwiftyJSON.h */; }; - CEB5ED131F5C4F7800AE8B16 /* SwiftyJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB5ED111F5C4F7800AE8B16 /* SwiftyJSON.swift */; }; - CEB5ED151F5C56F900AE8B16 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB5ED141F5C56F900AE8B16 /* Constants.swift */; }; - CEC1A0FD1FF7187600ED797A /* FreGMSMarker.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEC1A0FC1FF7187600ED797A /* FreGMSMarker.swift */; }; - CEFB3BC11FF7C4460095DE62 /* FreGMSGroundOverlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BC01FF7C4460095DE62 /* FreGMSGroundOverlay.swift */; }; - CEFB3BC31FF7CC3F0095DE62 /* FreGMSPolyline.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BC21FF7CC3F0095DE62 /* FreGMSPolyline.swift */; }; - CEFB3BC71FF802360095DE62 /* CustomMKPolygon.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BC61FF802360095DE62 /* CustomMKPolygon.swift */; }; - CEFB3BC91FF805D00095DE62 /* FreMKPolygon.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BC81FF805D00095DE62 /* FreMKPolygon.swift */; }; - CEFB3BCB1FF82D240095DE62 /* CustomMKPolyline.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BCA1FF82D240095DE62 /* CustomMKPolyline.swift */; }; - CEFB3BCD1FF82D8F0095DE62 /* FreMKPolyline.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BCC1FF82D8F0095DE62 /* FreMKPolyline.swift */; }; + 285FE1341741FC686F0BEB75 /* FreCLLocationCoordinate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285FE4E5D8DD21768875CCFD /* FreCLLocationCoordinate.swift */; platformFilter = ios; }; + 285FE3EB871F2DD420623AEE /* GoogleMapsANE_LIB.h in Headers */ = {isa = PBXBuildFile; fileRef = 285FEBB3CADF8D704FAB5E4D /* GoogleMapsANE_LIB.h */; platformFilter = ios; }; + 285FE43BB13A003DF0009958 /* FreMKCircle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285FE3EB6401C4553D5DC713 /* FreMKCircle.swift */; platformFilter = ios; }; + 285FE645B808125071F7A08A /* CustomMKCircle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285FE9BC1B43C00633CEE916 /* CustomMKCircle.swift */; platformFilter = ios; }; + 285FE6FF36D515256EAE7B63 /* FreGMSCircle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285FE41C9FE2CEB9DCF6CB30 /* FreGMSCircle.swift */; platformFilter = ios; }; + 285FECB67C2311471C2CD119 /* GoogleMapsANE_LIB.m in Sources */ = {isa = PBXBuildFile; fileRef = 285FE6D7F3D6356FA03A26C0 /* GoogleMapsANE_LIB.m */; platformFilter = ios; }; + 9022967A2299736400495FDE /* CoreImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 902296792299736300495FDE /* CoreImage.framework */; platformFilter = ios; }; + 9022967C2299737B00495FDE /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9022967B2299737B00495FDE /* CoreTelephony.framework */; platformFilter = ios; }; + 9022967E229973B300495FDE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9022967D229973B300495FDE /* UIKit.framework */; platformFilter = ios; }; + 902296802299903900495FDE /* FreGMSCoordinateBounds.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9022967F2299903900495FDE /* FreGMSCoordinateBounds.swift */; platformFilter = ios; }; + 907FA0382396DF8A00A02384 /* SwiftyJSON in Frameworks */ = {isa = PBXBuildFile; platformFilter = ios; productRef = 907FA0372396DF8A00A02384 /* SwiftyJSON */; }; + 90942B0A229AB549006672D9 /* FreGMSVisibleRegion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90942B09229AB549006672D9 /* FreGMSVisibleRegion.swift */; platformFilter = ios; }; + 90C3B5D721F4D83B002F59AB /* FreGMSPolygon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90C3B5D621F4D83B002F59AB /* FreGMSPolygon.swift */; platformFilter = ios; }; + 90C3B5D921F4E135002F59AB /* FreGMSMutablePath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90C3B5D821F4E135002F59AB /* FreGMSMutablePath.swift */; platformFilter = ios; }; + 90C940C2229A0AAB007AD291 /* FreGMSCameraPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90C940C1229A0AAB007AD291 /* FreGMSCameraPosition.swift */; platformFilter = ios; }; + CE39808E1E58BAA90062485B /* GoogleMapsANE_FW.h in Headers */ = {isa = PBXBuildFile; fileRef = CE39808C1E58BAA90062485B /* GoogleMapsANE_FW.h */; platformFilter = ios; settings = {ATTRIBUTES = (Public, ); }; }; + CE3980981E58BB070062485B /* SwiftController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE3980971E58BB070062485B /* SwiftController.swift */; platformFilter = ios; }; + CE3980AD1E58BF3F0062485B /* GoogleMapsANE_FW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE39808A1E58BAA90062485B /* GoogleMapsANE_FW.framework */; platformFilter = ios; }; + CE5D4976202619540067B01C /* LocationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5D4975202619540067B01C /* LocationController.swift */; platformFilter = ios; }; + CE5D4978202619CD0067B01C /* MapProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5D4977202619CD0067B01C /* MapProvider.swift */; platformFilter = ios; }; + CE5E29881F6452CC00FDB81A /* MarkerOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5E29871F6452CC00FDB81A /* MarkerOptions.swift */; platformFilter = ios; }; + CE60CCC41F63DA7F004B1BE7 /* FreSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE60CCC31F63DA7F004B1BE7 /* FreSwift.framework */; platformFilter = ios; }; + CE60CCCB1F63E25C004B1BE7 /* FreSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE60CCC31F63DA7F004B1BE7 /* FreSwift.framework */; platformFilter = ios; }; + CE60CCCC1F63E444004B1BE7 /* FreMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = CE60CCC11F63DA4D004B1BE7 /* FreMacros.h */; platformFilter = ios; }; + CE6589F31F6EE39100656914 /* MKMapController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6589F21F6EE39100656914 /* MKMapController.swift */; platformFilter = ios; }; + CE6589F51F6F1A9900656914 /* MapViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6589F41F6F1A9900656914 /* MapViewExtension.swift */; platformFilter = ios; }; + CE6589F71F6F1B6200656914 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE6589F61F6F1B6200656914 /* MapKit.framework */; platformFilter = ios; }; + CE9397501F70772400A1428C /* CustomMKAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE93974F1F70772400A1428C /* CustomMKAnnotation.swift */; platformFilter = ios; }; + CEA0DE161F5DF7330012EB4E /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE151F5DF7330012EB4E /* Accelerate.framework */; platformFilter = ios; }; + CEA0DE181F5DF7490012EB4E /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE171F5DF7490012EB4E /* CoreBluetooth.framework */; platformFilter = ios; }; + CEA0DE1A1F5DF7650012EB4E /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE191F5DF7650012EB4E /* libz.tbd */; platformFilter = ios; }; + CEA0DE1C1F5DF7710012EB4E /* libicucore.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE1B1F5DF7710012EB4E /* libicucore.tbd */; platformFilter = ios; }; + CEA0DE1E1F5DF77D0012EB4E /* libc++.1.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE1D1F5DF77D0012EB4E /* libc++.1.tbd */; platformFilter = ios; }; + CEA0DE201F5DF78A0012EB4E /* libc++abi.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE1F1F5DF78A0012EB4E /* libc++abi.tbd */; platformFilter = ios; }; + CEA0DE221F5DF7940012EB4E /* libc.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE211F5DF7940012EB4E /* libc.tbd */; platformFilter = ios; }; + CEA0DE241F5DF7A10012EB4E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE231F5DF7A10012EB4E /* CoreGraphics.framework */; platformFilter = ios; }; + CEA0DE261F5DF7AC0012EB4E /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE251F5DF7AC0012EB4E /* SystemConfiguration.framework */; platformFilter = ios; }; + CEA0DE281F5DF7B80012EB4E /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE271F5DF7B80012EB4E /* QuartzCore.framework */; platformFilter = ios; }; + CEA0DE2A1F5DF7C40012EB4E /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE291F5DF7C40012EB4E /* OpenGLES.framework */; platformFilter = ios; }; + CEA0DE2C1F5DF7CE0012EB4E /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE2B1F5DF7CE0012EB4E /* ImageIO.framework */; platformFilter = ios; }; + CEA0DE2E1F5DF7D90012EB4E /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE2D1F5DF7D90012EB4E /* GLKit.framework */; platformFilter = ios; }; + CEA0DE301F5DF7E80012EB4E /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE2F1F5DF7E80012EB4E /* CoreText.framework */; platformFilter = ios; }; + CEA0DE321F5DF7F30012EB4E /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE311F5DF7F30012EB4E /* CoreLocation.framework */; platformFilter = ios; }; + CEA0DE341F5DF7FA0012EB4E /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE331F5DF7FA0012EB4E /* CoreData.framework */; platformFilter = ios; }; + CEA0DE361F5DF8040012EB4E /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE351F5DF8040012EB4E /* AVFoundation.framework */; platformFilter = ios; }; + CEA0DE3C1F5DF8820012EB4E /* GoogleMaps.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE391F5DF8820012EB4E /* GoogleMaps.framework */; platformFilter = ios; }; + CEA0DE3D1F5DF8820012EB4E /* GoogleMapsBase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE3A1F5DF8820012EB4E /* GoogleMapsBase.framework */; platformFilter = ios; }; + CEA0DE3E1F5DF8820012EB4E /* GoogleMapsCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA0DE3B1F5DF8820012EB4E /* GoogleMapsCore.framework */; platformFilter = ios; }; + CEA0DE401F5DF9DD0012EB4E /* GMSMapController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA0DE3F1F5DF9DD0012EB4E /* GMSMapController.swift */; platformFilter = ios; }; + CEA0DE421F5DFA7A0012EB4E /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA0DE411F5DFA7A0012EB4E /* Settings.swift */; platformFilter = ios; }; + CEA653332027602C0034C691 /* GMSMapController+GMSMapViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA653322027602C0034C691 /* GMSMapController+GMSMapViewDelegate.swift */; platformFilter = ios; }; + CEA65335202761590034C691 /* MKMapController+MKMapViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA65334202761590034C691 /* MKMapController+MKMapViewDelegate.swift */; platformFilter = ios; }; + CEA65337202763570034C691 /* SwiftController+FreSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA65336202763570034C691 /* SwiftController+FreSwift.swift */; platformFilter = ios; }; + CEB5ED151F5C56F900AE8B16 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB5ED141F5C56F900AE8B16 /* Constants.swift */; platformFilter = ios; }; + CEC1A0FD1FF7187600ED797A /* FreGMSMarker.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEC1A0FC1FF7187600ED797A /* FreGMSMarker.swift */; platformFilter = ios; }; + CEFB3BC11FF7C4460095DE62 /* FreGMSGroundOverlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BC01FF7C4460095DE62 /* FreGMSGroundOverlay.swift */; platformFilter = ios; }; + CEFB3BC31FF7CC3F0095DE62 /* FreGMSPolyline.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BC21FF7CC3F0095DE62 /* FreGMSPolyline.swift */; platformFilter = ios; }; + CEFB3BC71FF802360095DE62 /* CustomMKPolygon.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BC61FF802360095DE62 /* CustomMKPolygon.swift */; platformFilter = ios; }; + CEFB3BC91FF805D00095DE62 /* FreMKPolygon.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BC81FF805D00095DE62 /* FreMKPolygon.swift */; platformFilter = ios; }; + CEFB3BCB1FF82D240095DE62 /* CustomMKPolyline.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BCA1FF82D240095DE62 /* CustomMKPolyline.swift */; platformFilter = ios; }; + CEFB3BCD1FF82D8F0095DE62 /* FreMKPolyline.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB3BCC1FF82D8F0095DE62 /* FreMKPolyline.swift */; platformFilter = ios; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -99,7 +98,7 @@ CE39808A1E58BAA90062485B /* GoogleMapsANE_FW.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GoogleMapsANE_FW.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CE39808C1E58BAA90062485B /* GoogleMapsANE_FW.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GoogleMapsANE_FW.h; sourceTree = ""; }; CE39808D1E58BAA90062485B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - CE3980971E58BB070062485B /* SwiftController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = SwiftController.swift; sourceTree = ""; tabWidth = 2; }; + CE3980971E58BB070062485B /* SwiftController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = SwiftController.swift; sourceTree = ""; tabWidth = 4; }; CE39809F1E58BEE10062485B /* libGoogleMapsANE_LIB.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libGoogleMapsANE_LIB.a; sourceTree = BUILT_PRODUCTS_DIR; }; CE5D4975202619540067B01C /* LocationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationController.swift; sourceTree = ""; }; CE5D4977202619CD0067B01C /* MapProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapProvider.swift; sourceTree = ""; }; @@ -136,8 +135,6 @@ CEA653322027602C0034C691 /* GMSMapController+GMSMapViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GMSMapController+GMSMapViewDelegate.swift"; sourceTree = ""; }; CEA65334202761590034C691 /* MKMapController+MKMapViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MKMapController+MKMapViewDelegate.swift"; sourceTree = ""; }; CEA65336202763570034C691 /* SwiftController+FreSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SwiftController+FreSwift.swift"; sourceTree = ""; }; - CEB5ED101F5C4F7800AE8B16 /* SwiftyJSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SwiftyJSON.h; path = SwiftyJSON/SwiftyJSON.h; sourceTree = ""; }; - CEB5ED111F5C4F7800AE8B16 /* SwiftyJSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftyJSON.swift; path = SwiftyJSON/SwiftyJSON.swift; sourceTree = ""; }; CEB5ED141F5C56F900AE8B16 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; CEC1A0FC1FF7187600ED797A /* FreGMSMarker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreGMSMarker.swift; sourceTree = ""; }; CEFB3BC01FF7C4460095DE62 /* FreGMSGroundOverlay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreGMSGroundOverlay.swift; sourceTree = ""; }; @@ -153,6 +150,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 907FA0382396DF8A00A02384 /* SwiftyJSON in Frameworks */, CEA0DE3D1F5DF8820012EB4E /* GoogleMapsBase.framework in Frameworks */, CEA0DE3C1F5DF8820012EB4E /* GoogleMaps.framework in Frameworks */, CEA0DE3E1F5DF8820012EB4E /* GoogleMapsCore.framework in Frameworks */, @@ -196,8 +194,6 @@ CE3551E01E7F1C2E009375A7 /* Misc */ = { isa = PBXGroup; children = ( - CEB5ED101F5C4F7800AE8B16 /* SwiftyJSON.h */, - CEB5ED111F5C4F7800AE8B16 /* SwiftyJSON.swift */, CE39808D1E58BAA90062485B /* Info.plist */, ); name = Misc; @@ -342,7 +338,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - CEB5ED121F5C4F7800AE8B16 /* SwiftyJSON.h in Headers */, CE39808E1E58BAA90062485B /* GoogleMapsANE_FW.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -373,6 +368,9 @@ dependencies = ( ); name = GoogleMapsANE_FW; + packageProductDependencies = ( + 907FA0372396DF8A00A02384 /* SwiftyJSON */, + ); productName = SwiftIOSANE_FW; productReference = CE39808A1E58BAA90062485B /* GoogleMapsANE_FW.framework */; productType = "com.apple.product-type.framework"; @@ -402,13 +400,13 @@ CE3980631E58BA7F0062485B /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1100; ORGANIZATIONNAME = "Tua Rua Ltd"; TargetAttributes = { CE3980891E58BAA90062485B = { CreatedOnToolsVersion = 8.2; DevelopmentTeam = FWEQJ32FGC; - LastSwiftMigration = 0910; + LastSwiftMigration = 1100; ProvisioningStyle = Manual; }; CE39809E1E58BEE10062485B = { @@ -419,13 +417,16 @@ }; buildConfigurationList = CE3980661E58BA7F0062485B /* Build configuration list for PBXProject "GoogleMapsANE" */; compatibilityVersion = "Xcode 10.0"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, Base, ); mainGroup = CE3980621E58BA7F0062485B; + packageReferences = ( + 907FA0362396DF8A00A02384 /* XCRemoteSwiftPackageReference "SwiftyJSON" */, + ); productRefGroup = CE39806C1E58BA7F0062485B /* Products */; projectDirPath = ""; projectRoot = ""; @@ -448,7 +449,7 @@ ); runOnlyForDeploymentPostprocessing = 1; shellPath = /bin/sh; - shellScript = "../../../native_extension/ane/build_mobile.sh\n"; + shellScript = "../../../native_extension/ane/build.sh\n"; }; CE7CFE0420229017007F9024 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -487,7 +488,6 @@ CE3980981E58BB070062485B /* SwiftController.swift in Sources */, 902296802299903900495FDE /* FreGMSCoordinateBounds.swift in Sources */, CE6589F51F6F1A9900656914 /* MapViewExtension.swift in Sources */, - CEB5ED131F5C4F7800AE8B16 /* SwiftyJSON.swift in Sources */, 90942B0A229AB549006672D9 /* FreGMSVisibleRegion.swift in Sources */, CE6589F31F6EE39100656914 /* MKMapController.swift in Sources */, CEA0DE421F5DFA7A0012EB4E /* Settings.swift in Sources */, @@ -516,6 +516,7 @@ /* Begin PBXTargetDependency section */ CE3980B11E58C08A0062485B /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilter = ios; target = CE3980891E58BAA90062485B /* GoogleMapsANE_FW */; targetProxy = CE3980B01E58C08A0062485B /* PBXContainerItemProxy */; }; @@ -526,6 +527,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; CLANG_CXX_LIBRARY = "compiler-default"; @@ -585,6 +587,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; CLANG_CXX_LIBRARY = "compiler-default"; @@ -663,17 +666,19 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MARKETING_VERSION = 2.6.0; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = com.tuarua.GoogleMapsANE; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OBJC_INTERFACE_HEADER_NAME = "GoogleMapsANE_FW-Swift.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -706,17 +711,19 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MARKETING_VERSION = 2.6.0; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = com.tuarua.GoogleMapsANE; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OBJC_INTERFACE_HEADER_NAME = "GoogleMapsANE_FW-Swift.h"; SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -805,6 +812,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 907FA0362396DF8A00A02384 /* XCRemoteSwiftPackageReference "SwiftyJSON" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SwiftyJSON/SwiftyJSON.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 907FA0372396DF8A00A02384 /* SwiftyJSON */ = { + isa = XCSwiftPackageProductDependency; + package = 907FA0362396DF8A00A02384 /* XCRemoteSwiftPackageReference "SwiftyJSON" */; + productName = SwiftyJSON; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = CE3980631E58BA7F0062485B /* Project object */; } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 6555830..919434a 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..8a63c30 --- /dev/null +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "SwiftyJSON", + "repositoryURL": "https://github.com/SwiftyJSON/SwiftyJSON.git", + "state": { + "branch": null, + "revision": "2b6054efa051565954e1d2b9da831680026cd768", + "version": "5.0.0" + } + } + ] + }, + "version": 1 +} diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreCLLocationCoordinate.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreCLLocationCoordinate.swift index ccc0896..cfe18b9 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreCLLocationCoordinate.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreCLLocationCoordinate.swift @@ -17,6 +17,7 @@ import Foundation import GoogleMaps import FreSwift +import SwiftyJSON public extension CLLocationCoordinate2D { init?(_ freObject: FREObject?) { @@ -40,15 +41,15 @@ public extension CLLocationCoordinate2D { } public extension FreObjectSwift { - public subscript(dynamicMember name: String) -> CLLocationCoordinate2D? { + subscript(dynamicMember name: String) -> CLLocationCoordinate2D? { get { return CLLocationCoordinate2D(rawValue?[name]) } set { rawValue?[name] = newValue?.toFREObject() } } - public subscript(dynamicMember name: String) -> CLLocationCoordinate2D { + subscript(dynamicMember name: String) -> CLLocationCoordinate2D { get { return CLLocationCoordinate2D(rawValue?[name]) ?? CLLocationCoordinate2D() } set { rawValue?[name] = newValue.toFREObject() } } - public subscript(dynamicMember name: String) -> [CLLocationCoordinate2D] { + subscript(dynamicMember name: String) -> [CLLocationCoordinate2D] { return [CLLocationCoordinate2D](rawValue?[name]) ?? [] } } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCameraPosition.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCameraPosition.swift index ee6a4f0..919a60f 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCameraPosition.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCameraPosition.swift @@ -16,6 +16,7 @@ import Foundation import GoogleMaps +import SwiftyJSON public extension GMSCameraPosition { func toJSON() -> String { diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCircle.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCircle.swift index c54a23d..4e463fa 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCircle.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCircle.swift @@ -26,32 +26,32 @@ public extension GMSCircle { let fre = FreObjectSwift(rv) self.init(position: fre.center, radius: fre.radius) - self.strokeWidth = fre.strokeWidth - self.strokeColor = fre.strokeColor - self.fillColor = fre.fillColor - self.zIndex = Int32(fre.zIndex as Int) - self.isTappable = fre.isTappable - self.userData = UUID().uuidString + strokeWidth = fre.strokeWidth + strokeColor = fre.strokeColor + fillColor = fre.fillColor + zIndex = Int32(fre.zIndex as Int) + isTappable = fre.isTappable + userData = UUID().uuidString } func setProp(name: String, value: FREObject) { switch name { case "center": - self.position = CLLocationCoordinate2D(value) ?? self.position + position = CLLocationCoordinate2D(value) ?? position case "strokeWidth": - self.strokeWidth = CGFloat(value) ?? self.strokeWidth + strokeWidth = CGFloat(value) ?? strokeWidth case "radius": - self.radius = Double(value) ?? self.radius + radius = Double(value) ?? radius case "isTappable": - self.isTappable = Bool(value) ?? self.isTappable + isTappable = Bool(value) ?? isTappable case "zIndex": if let z = Int(value) { - self.zIndex = Int32(z) + zIndex = Int32(z) } case "strokeColor": - self.strokeColor = UIColor(value) ?? self.strokeColor + strokeColor = UIColor(value) ?? strokeColor case "fillColor": - self.fillColor = UIColor(value) ?? self.fillColor + fillColor = UIColor(value) ?? fillColor default: break } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCoordinateBounds.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCoordinateBounds.swift index eacda02..beb9d04 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCoordinateBounds.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSCoordinateBounds.swift @@ -35,11 +35,11 @@ public extension GMSCoordinateBounds { } public extension FreObjectSwift { - public subscript(dynamicMember name: String) -> GMSCoordinateBounds? { + subscript(dynamicMember name: String) -> GMSCoordinateBounds? { get { return GMSCoordinateBounds(rawValue?[name]) } set { rawValue?[name] = newValue?.toFREObject() } } - public subscript(dynamicMember name: String) -> GMSCoordinateBounds { + subscript(dynamicMember name: String) -> GMSCoordinateBounds { get { return GMSCoordinateBounds(rawValue?[name]) ?? GMSCoordinateBounds() } set { rawValue?[name] = newValue.toFREObject() } } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSGroundOverlay.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSGroundOverlay.swift index c0de136..802e3a0 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSGroundOverlay.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSGroundOverlay.swift @@ -26,32 +26,32 @@ public extension GMSGroundOverlay { let fre = FreObjectSwift(rv) self.init(bounds: fre.bounds, icon: UIImage(freObject: fre.image, scale: UIScreen.main.scale, orientation: .up)) - self.bearing = fre.bearing - self.opacity = 1.0 - fre.transparency - self.isTappable = fre.isTappable - self.zIndex = Int32(fre.zIndex as Int) - self.userData = UUID().uuidString + bearing = fre.bearing + opacity = 1.0 - fre.transparency + isTappable = fre.isTappable + zIndex = Int32(fre.zIndex as Int) + userData = UUID().uuidString } func setProp(name: String, value: FREObject) { switch name { case "bounds": - self.bounds = GMSCoordinateBounds(value) ?? self.bounds + bounds = GMSCoordinateBounds(value) ?? bounds case "bearing": - self.bearing = CLLocationDirection(value) ?? self.bearing + bearing = CLLocationDirection(value) ?? bearing case "transparency": if let v = Float(value) { - self.opacity = 1.0 - v + opacity = 1.0 - v } case "isTappable": - self.isTappable = Bool(value) ?? self.isTappable + isTappable = Bool(value) ?? isTappable case "zIndex": if let z = Int(value) { - self.zIndex = Int32(z) + zIndex = Int32(z) } case "image": if let img = UIImage(freObject: value, scale: UIScreen.main.scale, orientation: .up) { - self.icon = img + icon = img } default: break diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSMarker.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSMarker.swift index 244057f..e7f9dd4 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSMarker.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSMarker.swift @@ -25,49 +25,49 @@ public extension GMSMarker { } let fre = FreObjectSwift(rv) self.init(position: fre.coordinate) - self.tracksInfoWindowChanges = true - self.title = fre.title - self.snippet = fre.snippet - self.isDraggable = fre.isDraggable - self.isFlat = fre.isFlat - self.isTappable = fre.isTappable - self.rotation = fre.rotation - self.opacity = fre.alpha - self.userData = UUID().uuidString + tracksInfoWindowChanges = true + title = fre.title + snippet = fre.snippet + isDraggable = fre.isDraggable + isFlat = fre.isFlat + isTappable = fre.isTappable + rotation = fre.rotation + opacity = fre.alpha + userData = UUID().uuidString if let img = UIImage(freObject: fre.icon, scale: UIScreen.main.scale, orientation: .up) { - self.icon = img + icon = img } else { - self.icon = GMSMarker.markerImage(with: fre.color) + icon = GMSMarker.markerImage(with: fre.color) } } func setProp(name: String, value: FREObject) { switch name { case "coordinate": - self.position = CLLocationCoordinate2D(value) ?? self.position + position = CLLocationCoordinate2D(value) ?? position case "title": - self.title = String(value) ?? self.title + title = String(value) ?? title case "snippet": - self.snippet = String(value) ?? self.snippet + snippet = String(value) ?? snippet case "isDraggable": - self.isDraggable = Bool(value) ?? self.isDraggable + isDraggable = Bool(value) ?? isDraggable case "isFlat": - self.isFlat = Bool(value) ?? self.isFlat + isFlat = Bool(value) ?? isFlat case "isTappable": - self.isTappable = Bool(value) ?? self.isTappable + isTappable = Bool(value) ?? isTappable case "rotation": - self.rotation = CLLocationDegrees(value) ?? self.rotation + rotation = CLLocationDegrees(value) ?? rotation case "color": if let color = UIColor(value) { - self.icon = GMSMarker.markerImage(with: color) + icon = GMSMarker.markerImage(with: color) } case "icon": if let img = UIImage(freObject: value, scale: UIScreen.main.scale, orientation: .up) { - self.icon = img + icon = img } case "alpha": - self.opacity = Float(value) ?? self.opacity + opacity = Float(value) ?? opacity default: break } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSMutablePath.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSMutablePath.swift index dbae785..ffe9af5 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSMutablePath.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSMutablePath.swift @@ -18,10 +18,10 @@ import GoogleMaps import FreSwift public extension FreObjectSwift { - public subscript(dynamicMember name: String) -> GMSMutablePath { + subscript(dynamicMember name: String) -> GMSMutablePath { return GMSMutablePath(rawValue?[name]) ?? GMSMutablePath() } - public subscript(dynamicMember name: String) -> [GMSMutablePath] { + subscript(dynamicMember name: String) -> [GMSMutablePath] { return [GMSMutablePath](rawValue?[name]) ?? [] } } @@ -32,7 +32,7 @@ public extension GMSMutablePath { self.init() for frePoint in FREArray(rv) { if let point = CLLocationCoordinate2D(frePoint) { - self.add(point) + add(point) } } } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSPolygon.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSPolygon.swift index e147312..477a141 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSPolygon.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSPolygon.swift @@ -25,37 +25,36 @@ public extension GMSPolygon { } let fre = FreObjectSwift(rv) self.init() - self.geodesic = fre.geodesic - self.strokeWidth = fre.strokeWidth - self.strokeColor = fre.strokeColor - self.fillColor = fre.fillColor - self.zIndex = Int32(fre.zIndex as Int) - self.userData = UUID().uuidString - self.isTappable = fre.isTappable - self.path = GMSMutablePath(rv["points"]) ?? GMSMutablePath() - self.holes = fre.holes - + geodesic = fre.geodesic + strokeWidth = fre.strokeWidth + strokeColor = fre.strokeColor + fillColor = fre.fillColor + zIndex = Int32(fre.zIndex as Int) + userData = UUID().uuidString + isTappable = fre.isTappable + path = GMSMutablePath(rv["points"]) ?? GMSMutablePath() + holes = fre.holes } func setProp(name: String, value: FREObject) { switch name { case "geodesic": - self.geodesic = Bool(value) ?? self.geodesic + geodesic = Bool(value) ?? geodesic case "strokeWidth": - self.strokeWidth = CGFloat(value) ?? self.strokeWidth + strokeWidth = CGFloat(value) ?? strokeWidth case "isTappable": - self.isTappable = Bool(value) ?? self.isTappable + isTappable = Bool(value) ?? isTappable case "zIndex": if let z = Int(value) { self.zIndex = Int32(z) } case "strokeColor": - self.strokeColor = UIColor(value) ?? self.strokeColor + strokeColor = UIColor(value) ?? strokeColor case "fillColor": - self.fillColor = UIColor(value) ?? self.fillColor + fillColor = UIColor(value) ?? fillColor case "points": if let points = GMSMutablePath(value) { - self.path = points + path = points } case "holes": if let holes = [GMSMutablePath](value) { diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSPolyline.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSPolyline.swift index 439827a..439a5ca 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSPolyline.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreGMSPolyline.swift @@ -25,34 +25,34 @@ public extension GMSPolyline { } let fre = FreObjectSwift(rv) self.init() - self.geodesic = fre.geodesic - self.strokeWidth = fre.width - self.strokeColor = fre.color - self.zIndex = Int32(fre.zIndex as Int) - self.isTappable = fre.isTappable - self.userData = UUID().uuidString + geodesic = fre.geodesic + strokeWidth = fre.width + strokeColor = fre.color + zIndex = Int32(fre.zIndex as Int) + isTappable = fre.isTappable + userData = UUID().uuidString if let points = GMSMutablePath(rv["points"]) { - self.path = points + path = points } } func setProp(name: String, value: FREObject) { switch name { case "geodesic": - self.geodesic = Bool(value) ?? self.geodesic + geodesic = Bool(value) ?? geodesic case "width": - self.strokeWidth = CGFloat(value) ?? self.strokeWidth + strokeWidth = CGFloat(value) ?? strokeWidth case "isTappable": - self.isTappable = Bool(value) ?? self.isTappable + isTappable = Bool(value) ?? isTappable case "zIndex": if let z = Int(value) { - self.zIndex = Int32(z) + zIndex = Int32(z) } case "color": - self.strokeColor = UIColor(value) ?? self.strokeColor + strokeColor = UIColor(value) ?? strokeColor case "points": if let points = GMSMutablePath(value) { - self.path = points + path = points } default: break diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKCircle.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKCircle.swift index c572e13..db4d3ef 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKCircle.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKCircle.swift @@ -27,19 +27,19 @@ extension CustomMKCircle { self.init(center: fre.center, radius: fre.radius, identifier: UUID().uuidString) - self.fillColor = fre.fillColor - self.strokeColor = fre.strokeColor - self.strokeWidth = fre.strokeWidth + fillColor = fre.fillColor + strokeColor = fre.strokeColor + strokeWidth = fre.strokeWidth } func setProp(name: String, value: FREObject) { switch name { case "strokeWidth": - self.strokeWidth = CGFloat(value) ?? self.strokeWidth + strokeWidth = CGFloat(value) ?? strokeWidth case "strokeColor": - self.strokeColor = UIColor(value) ?? self.strokeColor + strokeColor = UIColor(value) ?? strokeColor case "fillColor": - self.fillColor = UIColor(value) ?? self.fillColor + fillColor = UIColor(value) ?? fillColor default: break } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKPolygon.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKPolygon.swift index 4054e95..556a037 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKPolygon.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKPolygon.swift @@ -36,9 +36,9 @@ extension CustomMKPolygon { } self.init(points: fre.points, holes: holes, identifier: UUID().uuidString) - self.fillColor = fre.fillColor - self.strokeColor = fre.strokeColor - self.strokeWidth = fre.strokeWidth + fillColor = fre.fillColor + strokeColor = fre.strokeColor + strokeWidth = fre.strokeWidth } convenience init?(_ freObject: FREObject?, polygon: CustomMKPolygon) { @@ -47,19 +47,19 @@ extension CustomMKPolygon { } let fre = FreObjectSwift(rv) self.init(points: fre.points, holePolygons: polygon.interiorPolygons, identifier: polygon.identifier) - self.fillColor = polygon.fillColor - self.strokeColor = polygon.strokeColor - self.strokeWidth = polygon.strokeWidth + fillColor = polygon.fillColor + strokeColor = polygon.strokeColor + strokeWidth = polygon.strokeWidth } func setProp(name: String, value: FREObject) { switch name { case "strokeWidth": - self.strokeWidth = CGFloat(value) ?? self.strokeWidth + strokeWidth = CGFloat(value) ?? strokeWidth case "strokeColor": - self.strokeColor = UIColor(value) ?? self.strokeColor + strokeColor = UIColor(value) ?? strokeColor case "fillColor": - self.fillColor = UIColor(value) ?? self.fillColor + fillColor = UIColor(value) ?? fillColor default: break } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKPolyline.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKPolyline.swift index 692dc76..9bb8099 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKPolyline.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Extensions/FreMKPolyline.swift @@ -24,8 +24,8 @@ extension CustomMKPolyline { } let fre = FreObjectSwift(rv) self.init(points: fre.points, identifier: UUID().uuidString) - self.color = fre.color - self.width = fre.width + color = fre.color + width = fre.width } convenience init?(_ freObject: FREObject?, polyline: CustomMKPolyline) { @@ -34,16 +34,16 @@ extension CustomMKPolyline { } let fre = FreObjectSwift(rv) self.init(points: fre.points, identifier: polyline.identifier) - self.color = polyline.color - self.width = polyline.width + color = polyline.color + width = polyline.width } func setProp(name: String, value: FREObject) { switch name { case "width": - self.width = CGFloat(value) ?? self.width + width = CGFloat(value) ?? width case "color": - self.color = UIColor(value) ?? self.color + color = UIColor(value) ?? color default: break } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/GMSMapController+GMSMapViewDelegate.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/GMSMapController+GMSMapViewDelegate.swift index d33f86a..f351cfe 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/GMSMapController+GMSMapViewDelegate.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/GMSMapController+GMSMapViewDelegate.swift @@ -16,6 +16,7 @@ import Foundation import GoogleMaps +import SwiftyJSON extension GMSMapController: GMSMapViewDelegate { func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) { diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Info.plist b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Info.plist index f69838d..ec0cc7b 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Info.plist +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.1.0 + $(MARKETING_VERSION) CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/LocationController.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/LocationController.swift index c394e86..ce732bc 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/LocationController.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/LocationController.swift @@ -16,6 +16,7 @@ import GoogleMaps import FreSwift +import SwiftyJSON internal class LocationController: NSObject, FreSwiftController, CLLocationManagerDelegate { var context: FreContextSwift! @@ -128,6 +129,8 @@ internal class LocationController: NSObject, FreSwiftController, CLLocationManag case .authorizedWhenInUse: props["status"] = Constants.PERMISSION_WHEN_IN_USE permissionsGranted = true + @unknown default: + props["status"] = Constants.PERMISSION_DENIED } if permissionsGranted { diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/MKMapController+MKMapViewDelegate.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/MKMapController+MKMapViewDelegate.swift index a9176e9..2a66b33 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/MKMapController+MKMapViewDelegate.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/MKMapController+MKMapViewDelegate.swift @@ -16,6 +16,7 @@ import Foundation import MapKit +import SwiftyJSON extension MKMapController: MKMapViewDelegate { internal func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) { @@ -72,6 +73,8 @@ extension MKMapController: MKMapViewDelegate { view.setDragState(.none, animated: false) case .canceling: break + @unknown default: + break } } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/MapKit/MapViewExtension.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/MapKit/MapViewExtension.swift index 2a8a1c2..7d7384a 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/MapKit/MapViewExtension.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/MapKit/MapViewExtension.swift @@ -20,7 +20,7 @@ public extension MKMapView { /// By setting this property, you can change map zoom level based on **current map center**. /// /// - Note: The level is between 0 and 18, level 0 means the highest camera height. - public var zoomLevel: UInt { + var zoomLevel: UInt { get { let centerPixelX = region.center.longitude.pixelSpaceXForLongitude let topLeftPixelX = (region.center.longitude - region.span.longitudeDelta / 2).pixelSpaceXForLongitude @@ -44,7 +44,7 @@ public extension MKMapView { /// - coordinate: the aim coordinate that you want set it to center /// - zoomLevel: a unsigned int which is between 0 and 18, level 0 means the highest camera height /// - animated: determine whether moving map animately - public func setCenter(coordinate: CLLocationCoordinate2D, zoomLevel: UInt, animated: Bool ) { + func setCenter(coordinate: CLLocationCoordinate2D, zoomLevel: UInt, animated: Bool ) { // clamp large numbers to 28 let zoomLevel = min(zoomLevel, 28) @@ -63,7 +63,7 @@ public extension MKMapView { /// - zoomLevel: a unsigned int which is between 0 and 18, level 0 means the highest camera height /// /// - Returns: corresponding region - public func getCoordinateRegion(_ centerCoordinate: CLLocationCoordinate2D, zoomLevel: UInt) -> MKCoordinateRegion { + func getCoordinateRegion(_ centerCoordinate: CLLocationCoordinate2D, zoomLevel: UInt) -> MKCoordinateRegion { // clamp lat/long values to appropriate ranges var centerCoordinate = centerCoordinate centerCoordinate.latitude = min(max(-90, centerCoordinate.latitude), 90) @@ -118,14 +118,14 @@ public extension MKMapView { /// Increase zoom level by 1 /// /// - Note: the max zoom level is 18. - public func zoomIn() { + func zoomIn() { zoomLevel += 1 } /// Decrease zoom level by 1 /// /// - Note: the min zoom level is 1. - public func zoomOut() { + func zoomOut() { zoomLevel -= 1 } @@ -136,7 +136,7 @@ public extension MKMapView { /// - Requires: iOS 9.0 and above /// - Note: if you want to use it below the iOS 9, please use `showsCompass` instead. @available(iOS, deprecated: 9.0, message: "showsCompassView is deprecated in iOS 9.0, please use \"showsCompass\" instead") - public var showsCompassView: Bool { + var showsCompassView: Bool { set(show) { if let compassView = MapComponent.sharedInstance.compassView { self.decideView(compassView, shouldShow: show) @@ -153,7 +153,7 @@ public extension MKMapView { } /// A Boolean indicating whether the map displays the lower left attributed label. - public var showsLegalLabel: Bool { + var showsLegalLabel: Bool { set(show) { if let legalLabel = MapComponent.sharedInstance.legalLabel { decideView(legalLabel, shouldShow: show) @@ -176,7 +176,7 @@ public extension MKMapView { /// there's no any UIImageViews added to MKMapView. If you really needs to add image view /// onto the mapView, you should set the mapView's tag to any value expect 0. /// Or this property may remove the wrong image. - public var showsMapInfoImageView: Bool { + var showsMapInfoImageView: Bool { set(show) { if let mapInfoImageView = MapComponent.sharedInstance.mapInfoImageView { decideView(mapInfoImageView, shouldShow: show) @@ -197,47 +197,47 @@ public extension MKMapView { public extension MKMapRect { /// The rect that contains every map point in the world. - public static var zero: MKMapRect { return MKMapRect(x: 0, y: 0, width: 0, height: 0) } - public static var infinite: MKMapRect { + static var zero: MKMapRect { return MKMapRect(x: 0, y: 0, width: 0, height: 0) } + static var infinite: MKMapRect { //let max = DBL_MAX let max = Double.greatestFiniteMagnitude let origin = -max / 2 return MKMapRect(x: origin, y: origin, width: max, height: max) } - public init(x: Double, y: Double, width: Double, height: Double) { + init(x: Double, y: Double, width: Double, height: Double) { self.init(origin: MKMapPoint(x: x, y: y), size: MKMapSize(width: width, height: height)) } - public init(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat) { + init(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat) { self.init(origin: MKMapPoint(x: Double(x), y: Double(y)), size: MKMapSize(width: Double(width), height: Double(height))) } - public init(x: Int, y: Int, width: Int, height: Int) { + init(x: Int, y: Int, width: Int, height: Int) { self.init(origin: MKMapPoint(x: Double(x), y: Double(y)), size: MKMapSize(width: Double(width), height: Double(height))) } - public var isInfinite: Bool { return self == MKMapRect.infinite } - public var standardized: MKMapRect { + var isInfinite: Bool { return self == MKMapRect.infinite } + var standardized: MKMapRect { let realWidth = abs(self.size.width) let realHeight = abs(self.size.height) let realX = self.size.width < 0 ? self.origin.x + self.size.width : self.origin.x let realY = self.size.height < 0 ? self.origin.y + self.size.height : self.origin.y return MKMapRect(x: realX, y: realY, width: realWidth, height: realHeight) } - public var integral: MKMapRect { return MKMapRect(x: floor(self.minX), y: floor(self.minY), width: ceil(self.width), height: ceil(self.height)) } + var integral: MKMapRect { return MKMapRect(x: floor(self.minX), y: floor(self.minY), width: ceil(self.width), height: ceil(self.height)) } - public mutating func standardizeInPlace() { self = standardized } - public mutating func makeIntegralInPlace() { self = integral } + mutating func standardizeInPlace() { self = standardized } + mutating func makeIntegralInPlace() { self = integral } - public mutating func insetInPlace(_ dx: Double, _ dy: Double) { self = insetBy(dx: dx, dy: dy) } + mutating func insetInPlace(_ dx: Double, _ dy: Double) { self = insetBy(dx: dx, dy: dy) } - public mutating func offsetInPlace(_ dx: Double, _ dy: Double) { self = offsetBy(dx: dx, dy: dy) } + mutating func offsetInPlace(_ dx: Double, _ dy: Double) { self = offsetBy(dx: dx, dy: dy) } - public mutating func unionInPlace(_ rect: MKMapRect) { self = union(rect.standardized) } + mutating func unionInPlace(_ rect: MKMapRect) { self = union(rect.standardized) } - public func intersect(_ rect: MKMapRect) -> MKMapRect { return self.standardized.intersection(rect.standardized) } + func intersect(_ rect: MKMapRect) -> MKMapRect { return self.standardized.intersection(rect.standardized) } - public mutating func intersectInPlace(_ rect: MKMapRect) { self = intersect(rect.standardized) } + mutating func intersectInPlace(_ rect: MKMapRect) { self = intersect(rect.standardized) } - public func divide(_ atDistance: Double, fromEdge: MKMapRectEdge) -> (slice: MKMapRect, remainder: MKMapRect) { + func divide(_ atDistance: Double, fromEdge: MKMapRectEdge) -> (slice: MKMapRect, remainder: MKMapRect) { var slice = MKMapRect.zero var remainder = MKMapRect.zero MKMapRectDivide(self.standardized, &slice, &remainder, atDistance, fromEdge) @@ -247,11 +247,11 @@ public extension MKMapRect { } public extension MKMapRect { - public var coordinateRegion: MKCoordinateRegion { + var coordinateRegion: MKCoordinateRegion { return MKCoordinateRegion(self) } - public var mapRectSpans180thMeridian: Bool { + var mapRectSpans180thMeridian: Bool { return self.spans180thMeridian } @@ -259,7 +259,7 @@ public extension MKMapRect { /// that lies outside of the world rect wrapped around to the other side of the /// world. The portion of the rect that lies inside the world rect can be /// determined with rect.intersect(MKMapRect.world). - public var mapRectRemainder: MKMapRect { + var mapRectRemainder: MKMapRect { return self.remainder } } @@ -279,12 +279,12 @@ extension MKMapRect: CustomStringConvertible { // MARK: Points public extension MKMapPoint { - public static var zero: MKMapPoint { return MKMapPoint(x: 0, y: 0) } + static var zero: MKMapPoint { return MKMapPoint(x: 0, y: 0) } - public init(x: Int, y: Int) { + init(x: Int, y: Int) { self.init(x: Double(x), y: Double(y)) } - public init(x: CGFloat, y: CGFloat) { + init(x: CGFloat, y: CGFloat) { self.init(x: Double(x), y: Double(y)) } } @@ -293,7 +293,7 @@ public extension MKMapPoint { /// Conversion between unprojected and projected coordinates // public var coordinate: CLLocationCoordinate2D { return self.coordinate } - public func getMeters(to mapPoint: MKMapPoint) -> CLLocationDistance { + func getMeters(to mapPoint: MKMapPoint) -> CLLocationDistance { return self.distance(to:mapPoint) } } @@ -313,14 +313,14 @@ extension MKMapPoint: CustomStringConvertible { // MARK: Sizes public extension MKMapSize { - public static var zero: MKMapSize { return MKMapSize(width: 0, height: 0) } + static var zero: MKMapSize { return MKMapSize(width: 0, height: 0) } /// The size that contains every map point in the world. // public static var world: MKMapSize { return MKMapSize.world } - public init(width: Int, height: Int) { + init(width: Int, height: Int) { self.init(width: Double(width), height: Double(height)) } - public init(width: CGFloat, height: CGFloat) { + init(width: CGFloat, height: CGFloat) { self.init(width: Double(width), height: Double(height)) } } @@ -341,16 +341,16 @@ extension MKMapSize: CustomStringConvertible { public extension CLLocationCoordinate2D { /// Conversion between unprojected and projected coordinates - public var mapPoint: MKMapPoint { return MKMapPoint(self) } + var mapPoint: MKMapPoint { return MKMapPoint(self) } } // MARK: Degrees public extension CLLocationDegrees { /// Conversion between distances and projected coordinates - public var metersPerMapPoint: CLLocationDistance { return MKMetersPerMapPointAtLatitude(self) } + var metersPerMapPoint: CLLocationDistance { return MKMetersPerMapPointAtLatitude(self) } /// Conversion between distances and projected coordinates - public var mapPointsPerMeter: Double { return MKMapPointsPerMeterAtLatitude(self) } + var mapPointsPerMeter: Double { return MKMapPointsPerMeterAtLatitude(self) } } public typealias MKMapRectEdge = CGRectEdge @@ -370,7 +370,7 @@ private struct MapComponent { fileprivate extension MKMapView { // MARK: Helper Methods - fileprivate func findView(_ name: String? = nil, className: AnyClass? = nil) -> UIView? { + func findView(_ name: String? = nil, className: AnyClass? = nil) -> UIView? { var cla: AnyClass? = className if let name = name, let className = NSClassFromString(name) { cla = className @@ -383,7 +383,7 @@ fileprivate extension MKMapView { return nil } - fileprivate func decideView(_ view: UIView, shouldShow show: Bool) { + func decideView(_ view: UIView, shouldShow show: Bool) { if show { self.addSubview(view) view.alpha = 0 @@ -399,7 +399,7 @@ fileprivate extension MKMapView { } } - fileprivate func coordinateSpanWithCenterCoordinate(_ center: CLLocationCoordinate2D, + func coordinateSpanWithCenterCoordinate(_ center: CLLocationCoordinate2D, zoomLevel: UInt) -> MKCoordinateSpan { // convert center coordinate to pixel space let centerPixelX = center.longitude.pixelSpaceXForLongitude @@ -437,23 +437,23 @@ fileprivate extension MKMapView { fileprivate extension Double { - fileprivate var pixelSpaceXForLongitude: Double { + var pixelSpaceXForLongitude: Double { let result: Double = mercatorOffset + mercatorRadius * self * Double.pi / 180 return result.rounded() } - fileprivate var pixelSpaceYForLatitude: Double { + var pixelSpaceYForLatitude: Double { if self == 90 { return 0 } else if self == -90 { return mercatorOffset * 2 } else { return (mercatorOffset - mercatorRadius * log((1 + sin(self * Double.pi / 180)) / (1 - sin(self * Double.pi / 180))) / 2).rounded() } } - fileprivate var longitudeForPixelSpaceX: Double { + var longitudeForPixelSpaceX: Double { return ((self.rounded() - mercatorOffset) / mercatorRadius) * 180 / Double.pi } - fileprivate var latitudeForPixelSpaceY: Double { + var latitudeForPixelSpaceY: Double { return (Double.pi / 2 - 2 * atan(exp((self.rounded() - mercatorOffset) / mercatorRadius))) * 180 / Double.pi } } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Model/Constants.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Model/Constants.swift index 9b3dc42..04d7788 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Model/Constants.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Model/Constants.swift @@ -16,30 +16,30 @@ import Foundation -public struct Constants { - public static let ON_LOADED = "GoogleMaps.OnLoaded" - public static let ON_READY = "GoogleMaps.OnReady" - public static let DID_TAP_AT = "GoogleMaps.DidTapAt" - public static let DID_LONG_PRESS_AT = "GoogleMaps.DidLongPressAt" - public static let DID_TAP_MARKER = "GoogleMaps.DidTapMarker" - public static let DID_BEGIN_DRAGGING = "GoogleMaps.DidBeginDragging" - public static let DID_END_DRAGGING = "GoogleMaps.DidEndDragging" - public static let DID_DRAG = "GoogleMaps.DidDrag" - public static let DID_TAP_INFO_WINDOW = "GoogleMaps.DidTapInfoWindow" - public static let DID_CLOSE_INFO_WINDOW = "GoogleMaps.DidCloseInfoWindow" - public static let DID_LONG_PRESS_INFO_WINDOW = "GoogleMaps.DidLongPressInfoWindow" - public static let DID_TAP_GROUND_OVERLAY = "GoogleMaps.DidTapGroundOverlay" - public static let ON_CAMERA_MOVE = "GoogleMaps.OnCameraMove" - public static let ON_CAMERA_MOVE_STARTED = "GoogleMaps.OnCameraMoveStarted" - public static let ON_CAMERA_IDLE = "GoogleMaps.OnCameraIdle" - public static let LOCATION_UPDATED = "Location.LocationUpdated" - public static let ON_ADDRESS_LOOKUP = "Location.OnAddressLookup" - public static let ON_ADDRESS_LOOKUP_ERROR = "Location.OnAddressLookupError" - public static let ON_PERMISSION_STATUS = "Permission.OnStatus" - public static let ON_BITMAP_READY = "GoogleMaps.OnBitmapReady" - public static let PERMISSION_NOT_DETERMINED = 0 - public static let PERMISSION_RESTRICTED = 1 - public static let PERMISSION_DENIED = 2 - public static let PERMISSION_ALWAYS = 3 - public static let PERMISSION_WHEN_IN_USE = 4 +struct Constants { + static let ON_LOADED = "GoogleMaps.OnLoaded" + static let ON_READY = "GoogleMaps.OnReady" + static let DID_TAP_AT = "GoogleMaps.DidTapAt" + static let DID_LONG_PRESS_AT = "GoogleMaps.DidLongPressAt" + static let DID_TAP_MARKER = "GoogleMaps.DidTapMarker" + static let DID_BEGIN_DRAGGING = "GoogleMaps.DidBeginDragging" + static let DID_END_DRAGGING = "GoogleMaps.DidEndDragging" + static let DID_DRAG = "GoogleMaps.DidDrag" + static let DID_TAP_INFO_WINDOW = "GoogleMaps.DidTapInfoWindow" + static let DID_CLOSE_INFO_WINDOW = "GoogleMaps.DidCloseInfoWindow" + static let DID_LONG_PRESS_INFO_WINDOW = "GoogleMaps.DidLongPressInfoWindow" + static let DID_TAP_GROUND_OVERLAY = "GoogleMaps.DidTapGroundOverlay" + static let ON_CAMERA_MOVE = "GoogleMaps.OnCameraMove" + static let ON_CAMERA_MOVE_STARTED = "GoogleMaps.OnCameraMoveStarted" + static let ON_CAMERA_IDLE = "GoogleMaps.OnCameraIdle" + static let LOCATION_UPDATED = "Location.LocationUpdated" + static let ON_ADDRESS_LOOKUP = "Location.OnAddressLookup" + static let ON_ADDRESS_LOOKUP_ERROR = "Location.OnAddressLookupError" + static let ON_PERMISSION_STATUS = "Permission.OnStatus" + static let ON_BITMAP_READY = "GoogleMaps.OnBitmapReady" + static let PERMISSION_NOT_DETERMINED = 0 + static let PERMISSION_RESTRICTED = 1 + static let PERMISSION_DENIED = 2 + static let PERMISSION_ALWAYS = 3 + static let PERMISSION_WHEN_IN_USE = 4 } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Model/Settings.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Model/Settings.swift index 5adef15..6b8c597 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Model/Settings.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/Model/Settings.swift @@ -18,15 +18,15 @@ import Foundation import FreSwift public struct Settings { - public var scrollGestures = true - public var zoomGestures = true - public var tiltGestures = true - public var rotateGestures = true - public var consumesGesturesInView = true - public var compassButton = false - public var myLocationButtonEnabled = false - public var indoorPicker = true - public var allowScrollGesturesDuringRotateOrZoom = true + var scrollGestures = true + var zoomGestures = true + var tiltGestures = true + var rotateGestures = true + var consumesGesturesInView = true + var compassButton = false + var myLocationButtonEnabled = false + var indoorPicker = true + var allowScrollGesturesDuringRotateOrZoom = true init?(freObject: FREObject?) { guard let rv = freObject else { return nil } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/SwiftController.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/SwiftController.swift index d9c8083..5525ae3 100644 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/SwiftController.swift +++ b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/SwiftController.swift @@ -34,8 +34,8 @@ public class SwiftController: NSObject { func addEventListener(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, - let type = String(argv[0]) else { - return FreArgError(message: "addEventListener").getError(#file, #line, #column) + let type = String(argv[0]) + else { return FreArgError().getError() } if mapControllerMK == nil && mapControllerGMS == nil { @@ -56,8 +56,8 @@ public class SwiftController: NSObject { func removeEventListener(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, - let type = String(argv[0]) else { - return FreArgError(message: "removeEventListener").getError(#file, #line, #column) + let type = String(argv[0]) + else { return FreArgError().getError() } if mapControllerMK == nil && mapControllerGMS == nil { asListeners = asListeners.filter({ $0 != type }) @@ -78,8 +78,8 @@ public class SwiftController: NSObject { let xFre = Int(argv[0]), let yFre = Int(argv[1]), let wFre = Int(argv[2]), - let hFre = Int(argv[3]) else { - return FreArgError(message: "capture").getError(#file, #line, #column) + let hFre = Int(argv[3]) + else { return FreArgError().getError() } let x = xFre * Int(UIScreen.main.scale) @@ -135,8 +135,7 @@ public class SwiftController: NSObject { func addCircle(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0 - else { - return FreArgError(message: "addCircle").getError(#file, #line, #column) + else { return FreArgError().getError() } if mapProvider == .apple, let mvc = mapControllerMK, @@ -157,8 +156,7 @@ public class SwiftController: NSObject { let id = String(argv[0]), let name = String(argv[1]), let freValue = argv[2] - else { - return FreArgError(message: "setCircleProp").getError(#file, #line, #column) + else { return FreArgError().getError() } mapControllerMK?.setCircleProp(id: id, name: name, value: freValue) mapControllerGMS?.setCircleProp(id: id, name: name, value: freValue) @@ -168,8 +166,7 @@ public class SwiftController: NSObject { func removeCircle(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let id = String(argv[0]) - else { - return FreArgError(message: "removeCircle").getError(#file, #line, #column) + else { return FreArgError().getError() } mapControllerMK?.removeCircle(id: id) mapControllerGMS?.removeCircle(id: id) @@ -178,8 +175,7 @@ public class SwiftController: NSObject { func addGroundOverlay(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0 - else { - return FreArgError(message: "addCircle").getError(#file, #line, #column) + else { return FreArgError().getError() } if mapProvider == .apple { warning("Ground overlays are available on GoogleMaps only") @@ -196,8 +192,7 @@ public class SwiftController: NSObject { let id = String(argv[0]), let name = String(argv[1]), let freValue = argv[2] - else { - return FreArgError(message: "setGroundOverlayProp").getError(#file, #line, #column) + else { return FreArgError().getError() } mapControllerGMS?.setGroundOverlay(id: id, name: name, value: freValue) return nil @@ -205,8 +200,7 @@ public class SwiftController: NSObject { func removeGroundOverlay(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let id = String(argv[0]) - else { - return FreArgError(message: "removeGroundOverlay").getError(#file, #line, #column) + else { return FreArgError().getError() } mapControllerGMS?.removeGroundOverlay(id: id) return nil @@ -214,8 +208,7 @@ public class SwiftController: NSObject { func addPolyline(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0 - else { - return FreArgError(message: "addPolyline").getError(#file, #line, #column) + else { return FreArgError().getError() } if mapProvider == .apple, let mvc = mapControllerMK, @@ -235,8 +228,7 @@ public class SwiftController: NSObject { let id = String(argv[0]), let name = String(argv[1]), let freValue = argv[2] - else { - return FreArgError(message: "setPolylineProp").getError(#file, #line, #column) + else { return FreArgError().getError() } mapControllerMK?.setPolylineProp(id: id, name: name, value: freValue) mapControllerGMS?.setPolylineProp(id: id, name: name, value: freValue) @@ -245,8 +237,7 @@ public class SwiftController: NSObject { func removePolyline(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let id = String(argv[0]) - else { - return FreArgError(message: "removePolyline").getError(#file, #line, #column) + else { return FreArgError().getError() } mapControllerMK?.removePolyline(id: id) mapControllerGMS?.removePolyline(id: id) @@ -255,8 +246,7 @@ public class SwiftController: NSObject { func addPolygon(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0 - else { - return FreArgError(message: "addPolygon").getError(#file, #line, #column) + else { return FreArgError().getError() } if mapProvider == .apple, let mvc = mapControllerMK, @@ -276,8 +266,7 @@ public class SwiftController: NSObject { let id = String(argv[0]), let name = String(argv[1]), let freValue = argv[2] - else { - return FreArgError(message: "setPolygonProp").getError(#file, #line, #column) + else { return FreArgError().getError() } mapControllerMK?.setPolygonProp(id: id, name: name, value: freValue) mapControllerGMS?.setPolygonProp(id: id, name: name, value: freValue) @@ -286,8 +275,7 @@ public class SwiftController: NSObject { func removePolygon(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let id = String(argv[0]) - else { - return FreArgError(message: "removePolygon").getError(#file, #line, #column) + else { return FreArgError().getError() } mapControllerMK?.removePolygon(id: id) mapControllerGMS?.removePolygon(id: id) @@ -297,8 +285,8 @@ public class SwiftController: NSObject { func setBounds(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 1, let bounds = GMSCoordinateBounds(argv[0]), - let animates = Bool(argv[1]) else { - return FreArgError(message: "setBounds").getError(#file, #line, #column) + let animates = Bool(argv[1]) + else { return FreArgError().getError() } mapControllerMK?.setBounds(bounds: bounds, animates: animates) mapControllerGMS?.setBounds(bounds: bounds, animates: animates) @@ -307,8 +295,8 @@ public class SwiftController: NSObject { func zoomIn(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, - let animates = Bool(argv[0]) else { - return FreArgError(message: "zoomIn").getError(#file, #line, #column) + let animates = Bool(argv[0]) + else { return FreArgError().getError() } mapControllerMK?.zoomIn(animates: animates) mapControllerGMS?.zoomIn(animates: animates) @@ -317,8 +305,8 @@ public class SwiftController: NSObject { func zoomOut(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, - let animates = Bool(argv[0]) else { - return FreArgError(message: "zoomOut").getError(#file, #line, #column) + let animates = Bool(argv[0]) + else { return FreArgError().getError() } mapControllerMK?.zoomOut(animates: animates) mapControllerGMS?.zoomOut(animates: animates) @@ -327,9 +315,9 @@ public class SwiftController: NSObject { func zoomTo(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 1, - let zoomLevel = CGFloat(argv[1]), - let animates = Bool(argv[0]) else { - return FreArgError(message: "zoomTo").getError(#file, #line, #column) + let zoomLevel = CGFloat(argv[1]), + let animates = Bool(argv[0]) + else { return FreArgError().getError() } mapControllerMK?.zoomTo(zoomLevel: zoomLevel, animates: animates) @@ -353,9 +341,9 @@ public class SwiftController: NSObject { func initController(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 1, - let key = String(argv[0]), - let mapProvider = Int(argv[1]) else { - return FreArgError(message: "initController").getError(#file, #line, #column) + let key = String(argv[0]), + let mapProvider = Int(argv[1]) + else { return FreArgError().getError() } self.mapProvider = mapProvider == 0 ? .google : .apple @@ -368,12 +356,11 @@ public class SwiftController: NSObject { func initMap(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 3, - let inFRE3 = argv[3], // settings:Settings - let viewPort = CGRect(argv[0]), - let zoomLevel = CGFloat(argv[2]), - let coordinate = CLLocationCoordinate2D(argv[1]) - else { - return FreArgError(message: "initMap").getError(#file, #line, #column) + let inFRE3 = argv[3], // settings:Settings + let viewPort = CGRect(argv[0]), + let zoomLevel = CGFloat(argv[2]), + let coordinate = CLLocationCoordinate2D(argv[1]) + else { return FreArgError().getError() } settings = Settings(freObject: inFRE3) @@ -391,9 +378,8 @@ public class SwiftController: NSObject { func addMarker(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, - let inFRE0 = argv[0] //marker:Marker - else { - return FreArgError(message: "addMarker").getError(#file, #line, #column) + let inFRE0 = argv[0] //marker:Marker + else { return FreArgError().getError() } if self.mapProvider == .google { if let marker = GMSMarker(inFRE0) { @@ -418,8 +404,7 @@ public class SwiftController: NSObject { let id = String(argv[0]), let name = String(argv[1]), let freValue = argv[2] - else { - return FreArgError(message: "updateMarker").getError(#file, #line, #column) + else { return FreArgError().getError() } mapControllerMK?.setMarkerProp(id: id, name: name, value: freValue) mapControllerGMS?.setMarkerProp(id: id, name: name, value: freValue) @@ -428,9 +413,8 @@ public class SwiftController: NSObject { func removeMarker(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, - let id = String(argv[0]) - else { - return FreArgError(message: "removeMarker").getError(#file, #line, #column) + let id = String(argv[0]) + else { return FreArgError().getError() } mapControllerMK?.removeMarker(id: id) mapControllerGMS?.removeMarker(id: id) @@ -445,9 +429,8 @@ public class SwiftController: NSObject { func setViewPort(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, - let viewPort = CGRect(argv[0]) - else { - return FreArgError(message: "setViewPort").getError(#file, #line, #column) + let viewPort = CGRect(argv[0]) + else { return FreArgError().getError() } mapControllerMK?.setViewPort(viewPort) mapControllerGMS?.setViewPort(viewPort) @@ -456,9 +439,8 @@ public class SwiftController: NSObject { func moveCamera(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 4, - let animates = Bool(argv[4]) - else { - return FreArgError(message: "moveCamera").getError(#file, #line, #column) + let animates = Bool(argv[4]) + else { return FreArgError().getError() } let centerAt: CLLocationCoordinate2D? = CLLocationCoordinate2D(argv[0]) @@ -472,9 +454,8 @@ public class SwiftController: NSObject { func setStyle(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, - let json = String(argv[0]) - else { - return FreArgError(message: "setStyle").getError(#file, #line, #column) + let json = String(argv[0]) + else { return FreArgError().getError() } mapControllerGMS?.setStyle(json) return nil @@ -482,9 +463,8 @@ public class SwiftController: NSObject { func setMapType(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, - let type = UInt(argv[0]) - else { - return FreArgError(message: "setMapType").getError(#file, #line, #column) + let type = UInt(argv[0]) + else { return FreArgError().getError() } mapControllerMK?.setMapType(type) mapControllerGMS?.setMapType(type) @@ -493,9 +473,9 @@ public class SwiftController: NSObject { func setVisible(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, - let visible = Bool(argv[0]) - else { - return FreArgError(message: "setVisible").getError(#file, #line, #column) } + let visible = Bool(argv[0]) + else { return FreArgError().getError() + } if mapControllerMK == nil && mapControllerGMS == nil { return nil } @@ -531,8 +511,7 @@ public class SwiftController: NSObject { func reverseGeocodeLocation(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let coordinate = CLLocationCoordinate2D(argv[0]) - else { - return FreArgError(message: "reverseGeocodeLocation").getError(#file, #line, #column) + else { return FreArgError().getError() } locationController.reverseGeocodeLocation(coordinate) return nil @@ -541,8 +520,7 @@ public class SwiftController: NSObject { func forwardGeocodeLocation(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let address = String(argv[0]) - else { - return FreArgError(message: "forwardGeocodeLocation").getError(#file, #line, #column) + else { return FreArgError().getError() } locationController.forwardGeocodeLocation(address) return nil @@ -551,8 +529,7 @@ public class SwiftController: NSObject { func setBuildingsEnabled(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let value = Bool(argv[0]) - else { - return FreArgError(message: "setBuildingsEnabled").getError() + else { return FreArgError().getError() } mapControllerGMS?.mapView.isBuildingsEnabled = value return nil @@ -561,8 +538,7 @@ public class SwiftController: NSObject { func setTrafficEnabled(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let value = Bool(argv[0]) - else { - return FreArgError(message: "setTrafficEnabled").getError() + else { return FreArgError().getError() } mapControllerGMS?.mapView.isTrafficEnabled = value return nil @@ -572,8 +548,7 @@ public class SwiftController: NSObject { guard argc > 0, let value = Float(argv[0]), let maxZoom = mapControllerGMS?.mapView.maxZoom - else { - return FreArgError(message: "setMinZoom").getError() + else { return FreArgError().getError() } mapControllerGMS?.mapView.setMinZoom(value, maxZoom: maxZoom) return nil @@ -583,8 +558,7 @@ public class SwiftController: NSObject { guard argc > 0, let value = Float(argv[0]), let minZoom = mapControllerGMS?.mapView.minZoom - else { - return FreArgError(message: "setMaxZoom").getError() + else { return FreArgError().getError() } mapControllerGMS?.mapView.setMinZoom(minZoom, maxZoom: value) return nil @@ -593,8 +567,7 @@ public class SwiftController: NSObject { func setIndoorEnabled(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let value = Bool(argv[0]) - else { - return FreArgError(message: "setIndoorEnabled").getError() + else { return FreArgError().getError() } mapControllerGMS?.mapView.isIndoorEnabled = value return nil @@ -603,8 +576,7 @@ public class SwiftController: NSObject { func setMyLocationEnabled(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let value = Bool(argv[0]) - else { - return FreArgError(message: "setMyLocationEnabled").getError() + else { return FreArgError().getError() } mapControllerMK?.showsUserLocation = value mapControllerGMS?.mapView.isMyLocationEnabled = value @@ -614,8 +586,7 @@ public class SwiftController: NSObject { func projection_pointForCoordinate(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let value = CLLocationCoordinate2D(argv[0]) - else { - return FreArgError(message: "projection_pointForCoordinate").getError() + else { return FreArgError().getError() } return mapControllerGMS?.mapView.projection.point(for: value).toFREObject() } @@ -623,8 +594,7 @@ public class SwiftController: NSObject { func projection_coordinateForPoint(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let value = CGPoint(argv[0]) - else { - return FreArgError(message: "projection_coordinateForPoint").getError() + else { return FreArgError().getError() } return mapControllerGMS?.mapView.projection.coordinate(for: value).toFREObject() } @@ -632,8 +602,7 @@ public class SwiftController: NSObject { func projection_containsCoordinate(ctx: FREContext, argc: FREArgc, argv: FREArgv) -> FREObject? { guard argc > 0, let value = CLLocationCoordinate2D(argv[0]) - else { - return FreArgError(message: "projection_containsCoordinate").getError() + else { return FreArgError().getError() } return mapControllerGMS?.mapView.projection.contains(value).toFREObject() } @@ -646,8 +615,7 @@ public class SwiftController: NSObject { guard argc > 1, let forMeters = CLLocationDistance(argv[0]), let at = CLLocationCoordinate2D(argv[1]) - else { - return FreArgError(message: "projection_pointsForMeters").getError() + else { return FreArgError().getError() } return mapControllerGMS?.mapView.projection.points(forMeters: forMeters, at: at).toFREObject() } diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/SwiftyJSON/SwiftyJSON.h b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/SwiftyJSON/SwiftyJSON.h deleted file mode 100644 index d69a764..0000000 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/SwiftyJSON/SwiftyJSON.h +++ /dev/null @@ -1,31 +0,0 @@ -// SwiftyJSON.h -// -// Copyright (c) 2014 - 2017 Ruoyu Fu, Pinglin Tang -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -@import Foundation; - -//! Project version number for SwiftyJSON. -FOUNDATION_EXPORT double SwiftyJSONVersionNumber; - -//! Project version string for SwiftyJSON. -FOUNDATION_EXPORT const unsigned char SwiftyJSONVersionString[]; - - diff --git a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/SwiftyJSON/SwiftyJSON.swift b/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/SwiftyJSON/SwiftyJSON.swift deleted file mode 100644 index 3412c8d..0000000 --- a/native_library/ios/GoogleMapsANE/GoogleMapsANE_FW/SwiftyJSON/SwiftyJSON.swift +++ /dev/null @@ -1,1485 +0,0 @@ -// SwiftyJSON.swift -// -// Copyright (c) 2014 - 2017 Ruoyu Fu, Pinglin Tang -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -import Foundation - -// MARK: - Error - -///Error domain -public let ErrorDomain: String = "SwiftyJSONErrorDomain" - -///Error code -public let ErrorUnsupportedType: Int = 999 -public let ErrorIndexOutOfBounds: Int = 900 -public let ErrorWrongType: Int = 901 -public let ErrorNotExist: Int = 500 -public let ErrorInvalidJSON: Int = 490 - -// MARK: - JSON Type - -/** - JSON's type definitions. - - See http://www.json.org - */ -public enum Type :Int{ - - case number - case string - case bool - case array - case dictionary - case null - case unknown -} - -// MARK: - JSON Base -public struct JSON { - - /** - Creates a JSON using the data. - - - parameter data: The NSData used to convert to json.Top level object in data is an NSArray or NSDictionary - - parameter opt: The JSON serialization reading options. `.AllowFragments` by default. - - parameter error: The NSErrorPointer used to return the error. `nil` by default. - - - returns: The created JSON - */ - public init(data: Data, options opt: JSONSerialization.ReadingOptions = .allowFragments, error: NSErrorPointer = nil) { - do { - let object: Any = try JSONSerialization.jsonObject(with: data, options: opt) - self.init(jsonObject: object) - } catch let aError as NSError { - if error != nil { - error?.pointee = aError - } - self.init(jsonObject: NSNull()) - } - } - - /** - Creates a JSON object - - parameter object: the object - - note: this does not parse a `String` into JSON, instead use `init(parseJSON: String)` - - returns: the created JSON object - */ - public init(_ object: Any) { - switch object { - case let object as [JSON] where object.count > 0: - self.init(array: object) - case let object as [String: JSON] where object.count > 0: - self.init(dictionary: object) - case let object as Data: - self.init(data: object) - default: - self.init(jsonObject: object) - } - } - - /** - Parses the JSON string into a JSON object - - parameter json: the JSON string - - returns: the created JSON object - */ - public init(parseJSON jsonString: String) { - if let data = jsonString.data(using: .utf8) { - self.init(data) - } else { - self.init(NSNull()) - } - } - - /** - Creates a JSON from JSON string - - parameter string: Normal json string like '{"a":"b"}' - - - returns: The created JSON - */ - @available(*, deprecated: 3.2, message: "Use instead `init(parseJSON: )`") - public static func parse(_ json: String) -> JSON { - return json.data(using: String.Encoding.utf8) - .flatMap{ JSON(data: $0) } ?? JSON(NSNull()) - } - - /** - Creates a JSON using the object. - - - parameter object: The object must have the following properties: All objects are NSString/String, NSNumber/Int/Float/Double/Bool, NSArray/Array, NSDictionary/Dictionary, or NSNull; All dictionary keys are NSStrings/String; NSNumbers are not NaN or infinity. - - - returns: The created JSON - */ - fileprivate init(jsonObject: Any) { - self.object = jsonObject - } - - /** - Creates a JSON from a [JSON] - - - parameter jsonArray: A Swift array of JSON objects - - - returns: The created JSON - */ - fileprivate init(array: [JSON]) { - self.init(array.map { $0.object }) - } - - /** - Creates a JSON from a [String: JSON] - - - parameter jsonDictionary: A Swift dictionary of JSON objects - - - returns: The created JSON - */ - fileprivate init(dictionary: [String: JSON]) { - var newDictionary = [String: Any](minimumCapacity: dictionary.count) - for (key, json) in dictionary { - newDictionary[key] = json.object - } - - self.init(newDictionary) - } - - /** - Merges another JSON into this JSON, whereas primitive values which are not present in this JSON are getting added, - present values getting overwritten, array values getting appended and nested JSONs getting merged the same way. - - - parameter other: The JSON which gets merged into this JSON - - throws `ErrorWrongType` if the other JSONs differs in type on the top level. - */ - public mutating func merge(with other: JSON) throws { - try self.merge(with: other, typecheck: true) - } - - /** - Merges another JSON into this JSON and returns a new JSON, whereas primitive values which are not present in this JSON are getting added, - present values getting overwritten, array values getting appended and nested JSONS getting merged the same way. - - - parameter other: The JSON which gets merged into this JSON - - returns: New merged JSON - - throws `ErrorWrongType` if the other JSONs differs in type on the top level. - */ - public func merged(with other: JSON) throws -> JSON { - var merged = self - try merged.merge(with: other, typecheck: true) - return merged - } - - // Private woker function which does the actual merging - // Typecheck is set to true for the first recursion level to prevent total override of the source JSON - fileprivate mutating func merge(with other: JSON, typecheck: Bool) throws { - if self.type == other.type { - switch self.type { - case .dictionary: - for (key, _) in other { - try self[key].merge(with: other[key], typecheck: false) - } - case .array: - self = JSON(self.arrayValue + other.arrayValue) - default: - self = other - } - } else { - if typecheck { - throw NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Couldn't merge, because the JSONs differ in type on top level."]) - } else { - self = other - } - } - } - - /// Private object - fileprivate var rawArray: [Any] = [] - fileprivate var rawDictionary: [String : Any] = [:] - fileprivate var rawString: String = "" - fileprivate var rawNumber: NSNumber = 0 - fileprivate var rawNull: NSNull = NSNull() - fileprivate var rawBool: Bool = false - /// Private type - fileprivate var _type: Type = .null - /// prviate error - fileprivate var _error: NSError? = nil - - /// Object in JSON - public var object: Any { - get { - switch self.type { - case .array: - return self.rawArray - case .dictionary: - return self.rawDictionary - case .string: - return self.rawString - case .number: - return self.rawNumber - case .bool: - return self.rawBool - default: - return self.rawNull - } - } - set { - _error = nil - switch newValue { - case let number as NSNumber: - if number.isBool { - _type = .bool - self.rawBool = number.boolValue - } else { - _type = .number - self.rawNumber = number - } - case let string as String: - _type = .string - self.rawString = string - case _ as NSNull: - _type = .null - case _ as [JSON]: - _type = .array - case nil: - _type = .null - case let array as [Any]: - _type = .array - self.rawArray = array - case let dictionary as [String : Any]: - _type = .dictionary - self.rawDictionary = dictionary - default: - _type = .unknown - _error = NSError(domain: ErrorDomain, code: ErrorUnsupportedType, userInfo: [NSLocalizedDescriptionKey: "It is a unsupported type"]) - } - } - } - - /// JSON type - public var type: Type { get { return _type } } - - /// Error in JSON - public var error: NSError? { get { return self._error } } - - /// The static null JSON - @available(*, unavailable, renamed:"null") - public static var nullJSON: JSON { get { return null } } - public static var null: JSON { get { return JSON(NSNull()) } } -} - -public enum Index: Comparable -{ - case array(Int) - case dictionary(DictionaryIndex) - case null - - static public func ==(lhs: Index, rhs: Index) -> Bool { - switch (lhs, rhs) { - case (.array(let left), .array(let right)): - return left == right - case (.dictionary(let left), .dictionary(let right)): - return left == right - case (.null, .null): return true - default: - return false - } - } - - static public func <(lhs: Index, rhs: Index) -> Bool { - switch (lhs, rhs) { - case (.array(let left), .array(let right)): - return left < right - case (.dictionary(let left), .dictionary(let right)): - return left < right - default: - return false - } - } -} - -public typealias JSONIndex = Index -public typealias JSONRawIndex = Index - - -extension JSON: Collection -{ - - public typealias Index = JSONRawIndex - - public var startIndex: Index - { - switch type - { - case .array: - return .array(rawArray.startIndex) - case .dictionary: - return .dictionary(rawDictionary.startIndex) - default: - return .null - } - } - - public var endIndex: Index - { - switch type - { - case .array: - return .array(rawArray.endIndex) - case .dictionary: - return .dictionary(rawDictionary.endIndex) - default: - return .null - } - } - - public func index(after i: Index) -> Index - { - switch i - { - case .array(let idx): - return .array(rawArray.index(after: idx)) - case .dictionary(let idx): - return .dictionary(rawDictionary.index(after: idx)) - default: - return .null - } - - } - - public subscript (position: Index) -> (String, JSON) - { - switch position - { - case .array(let idx): - return (String(idx), JSON(self.rawArray[idx])) - case .dictionary(let idx): - let (key, value) = self.rawDictionary[idx] - return (key, JSON(value)) - default: - return ("", JSON.null) - } - } - - -} - -// MARK: - Subscript - -/** - * To mark both String and Int can be used in subscript. - */ -public enum JSONKey -{ - case index(Int) - case key(String) -} - -public protocol JSONSubscriptType { - var jsonKey:JSONKey { get } -} - -extension Int: JSONSubscriptType { - public var jsonKey:JSONKey { - return JSONKey.index(self) - } -} - -extension String: JSONSubscriptType { - public var jsonKey:JSONKey { - return JSONKey.key(self) - } -} - -extension JSON { - - /// If `type` is `.Array`, return json whose object is `array[index]`, otherwise return null json with error. - fileprivate subscript(index index: Int) -> JSON { - get { - if self.type != .array { - var r = JSON.null - r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] failure, It is not an array"]) - return r - } else if index >= 0 && index < self.rawArray.count { - return JSON(self.rawArray[index]) - } else { - var r = JSON.null - r._error = NSError(domain: ErrorDomain, code:ErrorIndexOutOfBounds , userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] is out of bounds"]) - return r - } - } - set { - if self.type == .array { - if self.rawArray.count > index && newValue.error == nil { - self.rawArray[index] = newValue.object - } - } - } - } - - /// If `type` is `.Dictionary`, return json whose object is `dictionary[key]` , otherwise return null json with error. - fileprivate subscript(key key: String) -> JSON { - get { - var r = JSON.null - if self.type == .dictionary { - if let o = self.rawDictionary[key] { - r = JSON(o) - } else { - r._error = NSError(domain: ErrorDomain, code: ErrorNotExist, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] does not exist"]) - } - } else { - r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] failure, It is not an dictionary"]) - } - return r - } - set { - if self.type == .dictionary && newValue.error == nil { - self.rawDictionary[key] = newValue.object - } - } - } - - /// If `sub` is `Int`, return `subscript(index:)`; If `sub` is `String`, return `subscript(key:)`. - fileprivate subscript(sub sub: JSONSubscriptType) -> JSON { - get { - switch sub.jsonKey { - case .index(let index): return self[index: index] - case .key(let key): return self[key: key] - } - } - set { - switch sub.jsonKey { - case .index(let index): self[index: index] = newValue - case .key(let key): self[key: key] = newValue - } - } - } - - /** - Find a json in the complex data structures by using array of Int and/or String as path. - - - parameter path: The target json's path. Example: - - let json = JSON[data] - let path = [9,"list","person","name"] - let name = json[path] - - The same as: let name = json[9]["list"]["person"]["name"] - - - returns: Return a json found by the path or a null json with error - */ - public subscript(path: [JSONSubscriptType]) -> JSON { - get { - return path.reduce(self) { $0[sub: $1] } - } - set { - switch path.count { - case 0: - return - case 1: - self[sub:path[0]].object = newValue.object - default: - var aPath = path; aPath.remove(at: 0) - var nextJSON = self[sub: path[0]] - nextJSON[aPath] = newValue - self[sub: path[0]] = nextJSON - } - } - } - - /** - Find a json in the complex data structures by using array of Int and/or String as path. - - - parameter path: The target json's path. Example: - - let name = json[9,"list","person","name"] - - The same as: let name = json[9]["list"]["person"]["name"] - - - returns: Return a json found by the path or a null json with error - */ - public subscript(path: JSONSubscriptType...) -> JSON { - get { - return self[path] - } - set { - self[path] = newValue - } - } -} - -// MARK: - LiteralConvertible - -extension JSON: Swift.ExpressibleByStringLiteral { - - public init(stringLiteral value: StringLiteralType) { - self.init(value as Any) - } - - public init(extendedGraphemeClusterLiteral value: StringLiteralType) { - self.init(value as Any) - } - - public init(unicodeScalarLiteral value: StringLiteralType) { - self.init(value as Any) - } -} - -extension JSON: Swift.ExpressibleByIntegerLiteral { - - public init(integerLiteral value: IntegerLiteralType) { - self.init(value as Any) - } -} - -extension JSON: Swift.ExpressibleByBooleanLiteral { - - public init(booleanLiteral value: BooleanLiteralType) { - self.init(value as Any) - } -} - -extension JSON: Swift.ExpressibleByFloatLiteral { - - public init(floatLiteral value: FloatLiteralType) { - self.init(value as Any) - } -} - -extension JSON: Swift.ExpressibleByDictionaryLiteral { - public init(dictionaryLiteral elements: (String, Any)...) { - let array = elements - self.init(dictionaryLiteral: array) - } - - public init(dictionaryLiteral elements: [(String, Any)]) { - let jsonFromDictionaryLiteral: ([String : Any]) -> JSON = { dictionary in - let initializeElement = Array(dictionary.keys).compactMap { key -> (String, Any)? in - if let value = dictionary[key] { - return (key, value) - } - return nil - } - return JSON(dictionaryLiteral: initializeElement) - } - - var dict = [String : Any](minimumCapacity: elements.count) - - for element in elements { - let elementToSet: Any - if let json = element.1 as? JSON { - elementToSet = json.object - } else if let jsonArray = element.1 as? [JSON] { - elementToSet = JSON(jsonArray).object - } else if let dictionary = element.1 as? [String : Any] { - elementToSet = jsonFromDictionaryLiteral(dictionary).object - } else if let dictArray = element.1 as? [[String : Any]] { - let jsonArray = dictArray.map { jsonFromDictionaryLiteral($0) } - elementToSet = JSON(jsonArray).object - } else { - elementToSet = element.1 - } - dict[element.0] = elementToSet - } - - self.init(dict) - } -} - -extension JSON: Swift.ExpressibleByArrayLiteral { - - public init(arrayLiteral elements: Any...) { - self.init(elements as Any) - } -} - -extension JSON: Swift.ExpressibleByNilLiteral { - - @available(*, deprecated, message: "use JSON.null instead. Will be removed in future versions") - public init(nilLiteral: ()) { - self.init(NSNull() as Any) - } -} - -// MARK: - Raw - -extension JSON: Swift.RawRepresentable { - - public init?(rawValue: Any) { - if JSON(rawValue).type == .unknown { - return nil - } else { - self.init(rawValue) - } - } - - public var rawValue: Any { - return self.object - } - - public func rawData(options opt: JSONSerialization.WritingOptions = JSONSerialization.WritingOptions(rawValue: 0)) throws -> Data { - guard JSONSerialization.isValidJSONObject(self.object) else { - throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "JSON is invalid"]) - } - - return try JSONSerialization.data(withJSONObject: self.object, options: opt) - } - - public func rawString(_ encoding: String.Encoding = .utf8, options opt: JSONSerialization.WritingOptions = .prettyPrinted) -> String? { - do { - return try _rawString(encoding, options: [.jsonSerialization: opt]) - } catch { - print("Could not serialize object to JSON because:", error.localizedDescription) - return nil - } - } - - public func rawString(_ options: [writingOptionsKeys: Any]) -> String? { - let encoding = options[.encoding] as? String.Encoding ?? String.Encoding.utf8 - let maxObjectDepth = options[.maxObjextDepth] as? Int ?? 10 - do { - return try _rawString(encoding, options: options, maxObjectDepth: maxObjectDepth) - } catch { - print("Could not serialize object to JSON because:", error.localizedDescription) - return nil - } - } - - fileprivate func _rawString( - _ encoding: String.Encoding = .utf8, - options: [writingOptionsKeys: Any], - maxObjectDepth: Int = 10 - ) throws -> String? { - if (maxObjectDepth < 0) { - throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "Element too deep. Increase maxObjectDepth and make sure there is no reference loop"]) - } - switch self.type { - case .dictionary: - do { - if !(options[.castNilToNSNull] as? Bool ?? false) { - let jsonOption = options[.jsonSerialization] as? JSONSerialization.WritingOptions ?? JSONSerialization.WritingOptions.prettyPrinted - let data = try self.rawData(options: jsonOption) - return String(data: data, encoding: encoding) - } - - guard let dict = self.object as? [String: Any?] else { - return nil - } - let body = try dict.keys.map { key throws -> String in - guard let value = dict[key] else { - return "\"\(key)\": null" - } - guard let unwrappedValue = value else { - return "\"\(key)\": null" - } - - let nestedValue = JSON(unwrappedValue) - guard let nestedString = try nestedValue._rawString(encoding, options: options, maxObjectDepth: maxObjectDepth - 1) else { - throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "Could not serialize nested JSON"]) - } - if nestedValue.type == .string { - return "\"\(key)\": \"\(nestedString.replacingOccurrences(of: "\\", with: "\\\\").replacingOccurrences(of: "\"", with: "\\\""))\"" - } else { - return "\"\(key)\": \(nestedString)" - } - } - - return "{\(body.joined(separator: ","))}" - } catch _ { - return nil - } - case .array: - do { - if !(options[.castNilToNSNull] as? Bool ?? false) { - let jsonOption = options[.jsonSerialization] as? JSONSerialization.WritingOptions ?? JSONSerialization.WritingOptions.prettyPrinted - let data = try self.rawData(options: jsonOption) - return String(data: data, encoding: encoding) - } - - guard let array = self.object as? [Any?] else { - return nil - } - let body = try array.map { value throws -> String in - guard let unwrappedValue = value else { - return "null" - } - - let nestedValue = JSON(unwrappedValue) - guard let nestedString = try nestedValue._rawString(encoding, options: options, maxObjectDepth: maxObjectDepth - 1) else { - throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "Could not serialize nested JSON"]) - } - if nestedValue.type == .string { - return "\"\(nestedString.replacingOccurrences(of: "\\", with: "\\\\").replacingOccurrences(of: "\"", with: "\\\""))\"" - } else { - return nestedString - } - } - - return "[\(body.joined(separator: ","))]" - } catch _ { - return nil - } - case .string: - return self.rawString - case .number: - return self.rawNumber.stringValue - case .bool: - return self.rawBool.description - case .null: - return "null" - default: - return nil - } - } -} - -// MARK: - Printable, DebugPrintable - -extension JSON: Swift.CustomStringConvertible, Swift.CustomDebugStringConvertible { - - public var description: String { - if let string = self.rawString(options:.prettyPrinted) { - return string - } else { - return "unknown" - } - } - - public var debugDescription: String { - return description - } -} - -// MARK: - Array - -extension JSON { - - //Optional [JSON] - public var array: [JSON]? { - get { - if self.type == .array { - return self.rawArray.map{ JSON($0) } - } else { - return nil - } - } - } - - //Non-optional [JSON] - public var arrayValue: [JSON] { - get { - return self.array ?? [] - } - } - - //Optional [Any] - public var arrayObject: [Any]? { - get { - switch self.type { - case .array: - return self.rawArray - default: - return nil - } - } - set { - if let array = newValue { - self.object = array as Any - } else { - self.object = NSNull() - } - } - } -} - -// MARK: - Dictionary - -extension JSON { - - //Optional [String : JSON] - public var dictionary: [String : JSON]? { - if self.type == .dictionary { - var d = [String : JSON](minimumCapacity: rawDictionary.count) - for (key, value) in rawDictionary { - d[key] = JSON(value) - } - return d - } else { - return nil - } - } - - //Non-optional [String : JSON] - public var dictionaryValue: [String : JSON] { - return self.dictionary ?? [:] - } - - //Optional [String : Any] - - public var dictionaryObject: [String : Any]? { - get { - switch self.type { - case .dictionary: - return self.rawDictionary - default: - return nil - } - } - set { - if let v = newValue { - self.object = v as Any - } else { - self.object = NSNull() - } - } - } -} - -// MARK: - Bool - -extension JSON { // : Swift.Bool - - //Optional bool - public var bool: Bool? { - get { - switch self.type { - case .bool: - return self.rawBool - default: - return nil - } - } - set { - if let newValue = newValue { - self.object = newValue as Bool - } else { - self.object = NSNull() - } - } - } - - //Non-optional bool - public var boolValue: Bool { - get { - switch self.type { - case .bool: - return self.rawBool - case .number: - return self.rawNumber.boolValue - case .string: - return ["true", "y", "t"].contains() { (truthyString) in - return self.rawString.caseInsensitiveCompare(truthyString) == .orderedSame - } - default: - return false - } - } - set { - self.object = newValue - } - } -} - -// MARK: - String - -extension JSON { - - //Optional string - public var string: String? { - get { - switch self.type { - case .string: - return self.object as? String - default: - return nil - } - } - set { - if let newValue = newValue { - self.object = NSString(string:newValue) - } else { - self.object = NSNull() - } - } - } - - //Non-optional string - public var stringValue: String { - get { - switch self.type { - case .string: - return self.object as? String ?? "" - case .number: - return self.rawNumber.stringValue - case .bool: - return (self.object as? Bool).map { String($0) } ?? "" - default: - return "" - } - } - set { - self.object = NSString(string:newValue) - } - } -} - -// MARK: - Number -extension JSON { - - //Optional number - public var number: NSNumber? { - get { - switch self.type { - case .number: - return self.rawNumber - case .bool: - return NSNumber(value: self.rawBool ? 1 : 0) - default: - return nil - } - } - set { - self.object = newValue ?? NSNull() - } - } - - //Non-optional number - public var numberValue: NSNumber { - get { - switch self.type { - case .string: - let decimal = NSDecimalNumber(string: self.object as? String) - if decimal == NSDecimalNumber.notANumber { // indicates parse error - return NSDecimalNumber.zero - } - return decimal - case .number: - return self.object as? NSNumber ?? NSNumber(value: 0) - case .bool: - return NSNumber(value: self.rawBool ? 1 : 0) - default: - return NSNumber(value: 0.0) - } - } - set { - self.object = newValue - } - } -} - -//MARK: - Null -extension JSON { - - public var null: NSNull? { - get { - switch self.type { - case .null: - return self.rawNull - default: - return nil - } - } - set { - self.object = NSNull() - } - } - public func exists() -> Bool{ - if let errorValue = error, errorValue.code == ErrorNotExist || - errorValue.code == ErrorIndexOutOfBounds || - errorValue.code == ErrorWrongType { - return false - } - return true - } -} - -//MARK: - URL -extension JSON { - - //Optional URL - public var url: URL? { - get { - switch self.type { - case .string: - // Check for existing percent escapes first to prevent double-escaping of % character - if let _ = self.rawString.range(of: "%[0-9A-Fa-f]{2}", options: .regularExpression, range: nil, locale: nil) { - return Foundation.URL(string: self.rawString) - } else if let encodedString_ = self.rawString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) { - // We have to use `Foundation.URL` otherwise it conflicts with the variable name. - return Foundation.URL(string: encodedString_) - } else { - return nil - } - default: - return nil - } - } - set { - self.object = newValue?.absoluteString ?? NSNull() - } - } -} - -// MARK: - Int, Double, Float, Int8, Int16, Int32, Int64 - -extension JSON { - - public var double: Double? { - get { - return self.number?.doubleValue - } - set { - if let newValue = newValue { - self.object = NSNumber(value: newValue) - } else { - self.object = NSNull() - } - } - } - - public var doubleValue: Double { - get { - return self.numberValue.doubleValue - } - set { - self.object = NSNumber(value: newValue) - } - } - - public var float: Float? { - get { - return self.number?.floatValue - } - set { - if let newValue = newValue { - self.object = NSNumber(value: newValue) - } else { - self.object = NSNull() - } - } - } - - public var floatValue: Float { - get { - return self.numberValue.floatValue - } - set { - self.object = NSNumber(value: newValue) - } - } - - public var int: Int? - { - get - { - return self.number?.intValue - } - set - { - if let newValue = newValue - { - self.object = NSNumber(value: newValue) - } else - { - self.object = NSNull() - } - } - } - - public var intValue: Int { - get { - return self.numberValue.intValue - } - set { - self.object = NSNumber(value: newValue) - } - } - - public var uInt: UInt? { - get { - return self.number?.uintValue - } - set { - if let newValue = newValue { - self.object = NSNumber(value: newValue) - } else { - self.object = NSNull() - } - } - } - - public var uIntValue: UInt { - get { - return self.numberValue.uintValue - } - set { - self.object = NSNumber(value: newValue) - } - } - - public var int8: Int8? { - get { - return self.number?.int8Value - } - set { - if let newValue = newValue { - self.object = NSNumber(value: Int(newValue)) - } else { - self.object = NSNull() - } - } - } - - public var int8Value: Int8 { - get { - return self.numberValue.int8Value - } - set { - self.object = NSNumber(value: Int(newValue)) - } - } - - public var uInt8: UInt8? { - get { - return self.number?.uint8Value - } - set { - if let newValue = newValue { - self.object = NSNumber(value: newValue) - } else { - self.object = NSNull() - } - } - } - - public var uInt8Value: UInt8 { - get { - return self.numberValue.uint8Value - } - set { - self.object = NSNumber(value: newValue) - } - } - - public var int16: Int16? { - get { - return self.number?.int16Value - } - set { - if let newValue = newValue { - self.object = NSNumber(value: newValue) - } else { - self.object = NSNull() - } - } - } - - public var int16Value: Int16 { - get { - return self.numberValue.int16Value - } - set { - self.object = NSNumber(value: newValue) - } - } - - public var uInt16: UInt16? { - get { - return self.number?.uint16Value - } - set { - if let newValue = newValue { - self.object = NSNumber(value: newValue) - } else { - self.object = NSNull() - } - } - } - - public var uInt16Value: UInt16 { - get { - return self.numberValue.uint16Value - } - set { - self.object = NSNumber(value: newValue) - } - } - - public var int32: Int32? { - get { - return self.number?.int32Value - } - set { - if let newValue = newValue { - self.object = NSNumber(value: newValue) - } else { - self.object = NSNull() - } - } - } - - public var int32Value: Int32 { - get { - return self.numberValue.int32Value - } - set { - self.object = NSNumber(value: newValue) - } - } - - public var uInt32: UInt32? { - get { - return self.number?.uint32Value - } - set { - if let newValue = newValue { - self.object = NSNumber(value: newValue) - } else { - self.object = NSNull() - } - } - } - - public var uInt32Value: UInt32 { - get { - return self.numberValue.uint32Value - } - set { - self.object = NSNumber(value: newValue) - } - } - - public var int64: Int64? { - get { - return self.number?.int64Value - } - set { - if let newValue = newValue { - self.object = NSNumber(value: newValue) - } else { - self.object = NSNull() - } - } - } - - public var int64Value: Int64 { - get { - return self.numberValue.int64Value - } - set { - self.object = NSNumber(value: newValue) - } - } - - public var uInt64: UInt64? { - get { - return self.number?.uint64Value - } - set { - if let newValue = newValue { - self.object = NSNumber(value: newValue) - } else { - self.object = NSNull() - } - } - } - - public var uInt64Value: UInt64 { - get { - return self.numberValue.uint64Value - } - set { - self.object = NSNumber(value: newValue) - } - } -} - -//MARK: - Comparable -extension JSON : Swift.Comparable {} - -public func ==(lhs: JSON, rhs: JSON) -> Bool { - - switch (lhs.type, rhs.type) { - case (.number, .number): - return lhs.rawNumber == rhs.rawNumber - case (.string, .string): - return lhs.rawString == rhs.rawString - case (.bool, .bool): - return lhs.rawBool == rhs.rawBool - case (.array, .array): - return lhs.rawArray as NSArray == rhs.rawArray as NSArray - case (.dictionary, .dictionary): - return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary - case (.null, .null): - return true - default: - return false - } -} - -public func <=(lhs: JSON, rhs: JSON) -> Bool { - - switch (lhs.type, rhs.type) { - case (.number, .number): - return lhs.rawNumber <= rhs.rawNumber - case (.string, .string): - return lhs.rawString <= rhs.rawString - case (.bool, .bool): - return lhs.rawBool == rhs.rawBool - case (.array, .array): - return lhs.rawArray as NSArray == rhs.rawArray as NSArray - case (.dictionary, .dictionary): - return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary - case (.null, .null): - return true - default: - return false - } -} - -public func >=(lhs: JSON, rhs: JSON) -> Bool { - - switch (lhs.type, rhs.type) { - case (.number, .number): - return lhs.rawNumber >= rhs.rawNumber - case (.string, .string): - return lhs.rawString >= rhs.rawString - case (.bool, .bool): - return lhs.rawBool == rhs.rawBool - case (.array, .array): - return lhs.rawArray as NSArray == rhs.rawArray as NSArray - case (.dictionary, .dictionary): - return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary - case (.null, .null): - return true - default: - return false - } -} - -public func >(lhs: JSON, rhs: JSON) -> Bool { - - switch (lhs.type, rhs.type) { - case (.number, .number): - return lhs.rawNumber > rhs.rawNumber - case (.string, .string): - return lhs.rawString > rhs.rawString - default: - return false - } -} - -public func <(lhs: JSON, rhs: JSON) -> Bool { - - switch (lhs.type, rhs.type) { - case (.number, .number): - return lhs.rawNumber < rhs.rawNumber - case (.string, .string): - return lhs.rawString < rhs.rawString - default: - return false - } -} - -private let trueNumber = NSNumber(value: true) -private let falseNumber = NSNumber(value: false) -private let trueObjCType = String(cString: trueNumber.objCType) -private let falseObjCType = String(cString: falseNumber.objCType) - -// MARK: - NSNumber: Comparable - -extension NSNumber { - var isBool:Bool { - get { - let objCType = String(cString: self.objCType) - if (self.compare(trueNumber) == .orderedSame && objCType == trueObjCType) || (self.compare(falseNumber) == .orderedSame && objCType == falseObjCType){ - return true - } else { - return false - } - } - } -} - -func ==(lhs: NSNumber, rhs: NSNumber) -> Bool { - switch (lhs.isBool, rhs.isBool) { - case (false, true): - return false - case (true, false): - return false - default: - return lhs.compare(rhs) == .orderedSame - } -} - -func !=(lhs: NSNumber, rhs: NSNumber) -> Bool { - return !(lhs == rhs) -} - -func <(lhs: NSNumber, rhs: NSNumber) -> Bool { - - switch (lhs.isBool, rhs.isBool) { - case (false, true): - return false - case (true, false): - return false - default: - return lhs.compare(rhs) == .orderedAscending - } -} - -func >(lhs: NSNumber, rhs: NSNumber) -> Bool { - - switch (lhs.isBool, rhs.isBool) { - case (false, true): - return false - case (true, false): - return false - default: - return lhs.compare(rhs) == ComparisonResult.orderedDescending - } -} - -func <=(lhs: NSNumber, rhs: NSNumber) -> Bool { - - switch (lhs.isBool, rhs.isBool) { - case (false, true): - return false - case (true, false): - return false - default: - return lhs.compare(rhs) != .orderedDescending - } -} - -func >=(lhs: NSNumber, rhs: NSNumber) -> Bool { - - switch (lhs.isBool, rhs.isBool) { - case (false, true): - return false - case (true, false): - return false - default: - return lhs.compare(rhs) != .orderedAscending - } -} - -public enum writingOptionsKeys { - case jsonSerialization - case castNilToNSNull - case maxObjextDepth - case encoding -}