From 5119fb5c6c4e2414be989ed16f072aa6154cceb6 Mon Sep 17 00:00:00 2001 From: ichchha Date: Thu, 27 Feb 2020 13:58:08 +0545 Subject: [PATCH] added network security policy --- app/build.gradle | 2 +- .../osmnavigationapp/MainActivity.java | 66 +++++++++---------- .../values/xml/network_security_config.xml | 6 ++ 3 files changed, 37 insertions(+), 37 deletions(-) create mode 100644 toasterlibrary/src/main/res/values/xml/network_security_config.xml diff --git a/app/build.gradle b/app/build.gradle index 92ea62f..279adb1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ dependencies { androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' //toaster library - implementation 'com.github.Ichchhie:Toaster-Library:0.4.0' + implementation 'com.github.Ichchhie:Toaster-Library:0.5.0' implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:8.6.2'){ exclude group: 'group_name', module: 'module_name' diff --git a/app/src/main/java/com/kathmandulivinglabs/osmnavigationapp/MainActivity.java b/app/src/main/java/com/kathmandulivinglabs/osmnavigationapp/MainActivity.java index 88b962a..04eac75 100644 --- a/app/src/main/java/com/kathmandulivinglabs/osmnavigationapp/MainActivity.java +++ b/app/src/main/java/com/kathmandulivinglabs/osmnavigationapp/MainActivity.java @@ -6,8 +6,11 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; +import com.kathmandulivinglabs.navigationlibrary.models.Geocode; import com.kathmandulivinglabs.navigationlibrary.models.Geometry; +import com.kathmandulivinglabs.navigationlibrary.models.Place; import com.kathmandulivinglabs.navigationlibrary.services.Baato; +import com.kathmandulivinglabs.navigationlibrary.services.BaatoReverseGeoCodeService; import com.kathmandulivinglabs.navigationlibrary.services.ToasterMessage; import com.kathmandulivinglabs.navigationlibrary.utilities.BaatoUtil; import com.mapbox.api.directions.v5.models.DirectionsResponse; @@ -31,7 +34,7 @@ import retrofit2.Response; public class MainActivity extends AppCompatActivity implements OnMapReadyCallback, - MapboxMap.OnMapLongClickListener, Callback { + MapboxMap.OnMapLongClickListener{ private static final String TAG = "apple"; private MapboxMap mapboxMap; @@ -49,15 +52,31 @@ protected void onCreate(Bundle savedInstanceState) { mapView.getMapAsync(this); ToasterMessage.s(this, "Hello Good Morning"); Geometry geometry = BaatoUtil.getGeoJsonFromEncodedPolyLine(encoded); - Log.d(TAG, "onCreate: " + Baato.search(Constants.TOKEN, "chardhunga").toString()); - NavigationRoute.builder(this) - .accessToken(Mapbox.getAccessToken()) - .origin(Point.fromLngLat(85.4278774, 27.6721352)) - .destination(Point.fromLngLat(85.3346386, 27.7340328)) - .alternatives(true) - .build() - .getRoute(this); - Log.d("hello", "onCreate: " + geometry.coordinates); + new BaatoReverseGeoCodeService(this) + .setGeoCode(new Geocode(27.73405, 85.33685)) + .setAccessToken(Constants.TOKEN) + .setRadius(2) + .withListener(new BaatoReverseGeoCodeService.BaatoReverseGeoCodeRequestListener() { + @Override + public void onSuccess(List places) { + Log.d(TAG, "onSuccess:reverse " + places.toString()); + } + + @Override + public void onFailed(Throwable error) { + Log.d(TAG, "onFailed:reverse " + error.getMessage()); + } + }) + .doReverseGeoCode(); +// Log.d(TAG, "onCreate: " + Baato.search(Constants.TOKEN, "chardhunga").toString()); +// NavigationRoute.builder(this) +// .accessToken(Mapbox.getAccessToken()) +// .origin(Point.fromLngLat(85.4278774, 27.6721352)) +// .destination(Point.fromLngLat(85.3346386, 27.7340328)) +// .alternatives(true) +// .build() +// .getRoute(this); +// Log.d("hello", "onCreate: " + geometry.coordinates); } @Override @@ -69,38 +88,13 @@ public boolean onMapLongClick(@NonNull LatLng point) { public void onMapReady(@NonNull MapboxMap mapboxMap) { this.mapboxMap = mapboxMap; mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> { - initializeLocationComponent(mapboxMap); +// initializeLocationComponent(mapboxMap); // navigationMapRoute = new NavigationMapRoute(null, mapView, mapboxMap); mapboxMap.addOnMapLongClickListener(this); // Snackbar.make(mapView, "Long press to select route", Snackbar.LENGTH_SHORT).show(); }); } - @SuppressWarnings("MissingPermission") - private void initializeLocationComponent(MapboxMap mapboxMap) { - LocationComponent locationComponent = mapboxMap.getLocationComponent(); - locationComponent.activateLocationComponent(this, mapboxMap.getStyle()); - locationComponent.setLocationComponentEnabled(true); - locationComponent.setRenderMode(RenderMode.COMPASS); - locationComponent.setCameraMode(CameraMode.TRACKING); - locationComponent.zoomWhileTracking(10d); - } - - @Override - public void onResponse(Call call, Response response) { - if (response.isSuccessful() - && response.body() != null - && !response.body().routes().isEmpty()) { - List routes = response.body().routes(); -// navigationMapRoute.addRoutes(routes); - } - } - - @Override - public void onFailure(Call call, Throwable t) { - Log.d(TAG, "onFailure: " + t.getMessage()); - } - @Override public void onResume() { super.onResume(); diff --git a/toasterlibrary/src/main/res/values/xml/network_security_config.xml b/toasterlibrary/src/main/res/values/xml/network_security_config.xml new file mode 100644 index 0000000..5dc38b2 --- /dev/null +++ b/toasterlibrary/src/main/res/values/xml/network_security_config.xml @@ -0,0 +1,6 @@ + + + + 178.128.59.143 + + \ No newline at end of file