From 855031b8ceeddab2c35e63bbaf131db0661b3b8e Mon Sep 17 00:00:00 2001 From: Ahmed Mozaly Date: Thu, 7 Nov 2019 10:08:53 +0200 Subject: [PATCH 1/4] add mocked property --- .../io/alfanhui/new_geolocation/data/LocationData.kt | 6 ++++-- example/ios/Flutter/flutter_export_environment.sh | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/android/src/main/kotlin/io/alfanhui/new_geolocation/data/LocationData.kt b/android/src/main/kotlin/io/alfanhui/new_geolocation/data/LocationData.kt index 7ad1761..ceb1401 100644 --- a/android/src/main/kotlin/io/alfanhui/new_geolocation/data/LocationData.kt +++ b/android/src/main/kotlin/io/alfanhui/new_geolocation/data/LocationData.kt @@ -7,13 +7,15 @@ import android.location.Location class LocationData(val latitude: Double, val longitude: Double, - val altitude: Double + val altitude: Double, + val isMocked: Boolean ) { companion object { fun from(location: Location) = LocationData( latitude = location.latitude, longitude = location.longitude, - altitude = location.altitude + altitude = location.altitude, + isMocked = location.isFromMockProvider ) } } \ No newline at end of file diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 0bc4930..9fed040 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -1,10 +1,10 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/Alfanhui/Library/Android/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/Alfanhui/Nextcloud/Code/dart/new_geolocation/example" -export "FLUTTER_TARGET=/Users/Alfanhui/Nextcloud/Code/dart/new_geolocation/example/lib/main.dart" +export "FLUTTER_ROOT=C:\Program Files\flutter" +export "FLUTTER_APPLICATION_PATH=C:\Mozaly\MoveIT\new_geolocation\example" +export "FLUTTER_TARGET=lib\main.dart" export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build/ios" -export "FLUTTER_FRAMEWORK_DIR=/Users/Alfanhui/Library/Android/flutter/bin/cache/artifacts/engine/ios" +export "SYMROOT=${SOURCE_ROOT}/../build\ios" +export "FLUTTER_FRAMEWORK_DIR=C:\Program Files\flutter\bin\cache\artifacts\engine\ios" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" From 64501a7f2048321258dfc08a335d816275e3e606 Mon Sep 17 00:00:00 2001 From: Ahmed Mozaly Date: Thu, 7 Nov 2019 11:01:51 +0200 Subject: [PATCH 2/4] parse isMocked from android result --- lib/channel/codec.dart | 5 +++++ lib/data/location.dart | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/channel/codec.dart b/lib/channel/codec.dart index ea91073..8bc7fb4 100644 --- a/lib/channel/codec.dart +++ b/lib/channel/codec.dart @@ -23,6 +23,10 @@ class _Codec { static double parseJsonNumber(dynamic value) { return value.runtimeType == int ? (value as int).toDouble() : value; } + + static bool parseJsonBoolean(dynamic value) { + return value.toLowerCase() == 'true'; + } static String encodeEnum(dynamic value) { return value.toString().split('.').last; @@ -105,6 +109,7 @@ class _JsonCodec { _Codec.parseJsonNumber(json['latitude']), _Codec.parseJsonNumber(json['longitude']), _Codec.parseJsonNumber(json['altitude']), + _Codec.parseJsonBoolean(json['isMocked']), ); static Map locationUpdatesRequestToJson( diff --git a/lib/data/location.dart b/lib/data/location.dart index b52d20f..39f3e2f 100644 --- a/lib/data/location.dart +++ b/lib/data/location.dart @@ -4,7 +4,7 @@ part of new_geolocation; class Location { - Location._(this.latitude, this.longitude, this.altitude); + Location._(this.latitude, this.longitude, this.altitude, this.isMocked); /// Latitude in degrees final double latitude; @@ -15,6 +15,8 @@ class Location { /// Altitude measured in meters. final double altitude; + final bool isMocked; + @override String toString() { return '{lat: $latitude, lng: $longitude}'; From 036dcabb36e2e831bb0749437bf68658407e8a5d Mon Sep 17 00:00:00 2001 From: Ahmed Mozaly Date: Thu, 7 Nov 2019 11:42:20 +0200 Subject: [PATCH 3/4] fix isMocked value setting and parsing --- .../kotlin/io/alfanhui/new_geolocation/data/LocationData.kt | 2 +- lib/channel/codec.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/kotlin/io/alfanhui/new_geolocation/data/LocationData.kt b/android/src/main/kotlin/io/alfanhui/new_geolocation/data/LocationData.kt index ceb1401..3415d62 100644 --- a/android/src/main/kotlin/io/alfanhui/new_geolocation/data/LocationData.kt +++ b/android/src/main/kotlin/io/alfanhui/new_geolocation/data/LocationData.kt @@ -15,7 +15,7 @@ class LocationData(val latitude: Double, latitude = location.latitude, longitude = location.longitude, altitude = location.altitude, - isMocked = location.isFromMockProvider + isMocked = location.isFromMockProvider() ) } } \ No newline at end of file diff --git a/lib/channel/codec.dart b/lib/channel/codec.dart index 8bc7fb4..747c833 100644 --- a/lib/channel/codec.dart +++ b/lib/channel/codec.dart @@ -25,7 +25,7 @@ class _Codec { } static bool parseJsonBoolean(dynamic value) { - return value.toLowerCase() == 'true'; + return value.toString() == 'true'; } static String encodeEnum(dynamic value) { From 4c5738fdabc39e5ba3e6c79669b198de621fe60e Mon Sep 17 00:00:00 2001 From: Ahmed Mozaly Date: Thu, 7 Nov 2019 11:52:33 +0200 Subject: [PATCH 4/4] clean up shell file --- example/ios/Flutter/flutter_export_environment.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 9fed040..0bc4930 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -1,10 +1,10 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=C:\Program Files\flutter" -export "FLUTTER_APPLICATION_PATH=C:\Mozaly\MoveIT\new_geolocation\example" -export "FLUTTER_TARGET=lib\main.dart" +export "FLUTTER_ROOT=/Users/Alfanhui/Library/Android/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/Alfanhui/Nextcloud/Code/dart/new_geolocation/example" +export "FLUTTER_TARGET=/Users/Alfanhui/Nextcloud/Code/dart/new_geolocation/example/lib/main.dart" export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build\ios" -export "FLUTTER_FRAMEWORK_DIR=C:\Program Files\flutter\bin\cache\artifacts\engine\ios" +export "SYMROOT=${SOURCE_ROOT}/../build/ios" +export "FLUTTER_FRAMEWORK_DIR=/Users/Alfanhui/Library/Android/flutter/bin/cache/artifacts/engine/ios" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1"