From 34fb2172703b1796fcec90b93333d84a6349e04f Mon Sep 17 00:00:00 2001 From: pasqualedona Date: Mon, 5 Dec 2022 09:39:03 +0100 Subject: [PATCH] New library version alignment - Update gradle and Android Gradle Plugin - Replace NSError with NMSError - Replace jcenter() dependencies - Update Example.md --- Example.md | 3 +- .../java/com/navionics/demo/MainActivity.java | 210 ++++++++---------- build.gradle | 9 +- gradle/wrapper/gradle-wrapper.properties | 6 +- 4 files changed, 98 insertions(+), 130 deletions(-) diff --git a/Example.md b/Example.md index 363b800..c84aa79 100644 --- a/Example.md +++ b/Example.md @@ -42,7 +42,8 @@ NMSSettings settings = NMSSettings.settings(); settings.setMode(NMSEnum.NMSFrameworkMode.NMSFrameworkModeSandbox); setProjectToken = ("YOUR-PROJECT-TOKEN"); setPrivateKey("-----BEGIN RSA PRIVATE KEY-----\nYOUR\nPRIVATE\nKEY\n-----END RSA PRIVATE KEY-----\n"); -NSError error = new NSError(); +setConfigurationToken("YOUR-CONFIGURATION-TOKEN"); +NMSError error = new NMSError(); NavionicsMobileServices.initializeWithSettings(settings, error); ``` Note that your private key will have the following format: diff --git a/app/src/main/java/com/navionics/demo/MainActivity.java b/app/src/main/java/com/navionics/demo/MainActivity.java index fb69285..5783b76 100755 --- a/app/src/main/java/com/navionics/demo/MainActivity.java +++ b/app/src/main/java/com/navionics/demo/MainActivity.java @@ -21,7 +21,7 @@ import com.navionics.android.nms.NMSPolyline; import com.navionics.android.nms.NMSSettings; import com.navionics.android.nms.NavionicsMobileServices; -import com.navionics.android.nms.core.NSError; +import com.navionics.android.nms.core.NMSError; import com.navionics.android.nms.model.CGPoint; import com.navionics.android.nms.model.NMSColor; import com.navionics.android.nms.model.NMSLocationCoordinate2D; @@ -67,16 +67,14 @@ public void onSuccess() { } @Override - public void onError(NSError nsError) { + public void onError(NMSError nsError) { AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle("Mobile SDK Initialization error"); alertDialog.setMessage("The mobile sdk cannot be initialized, please check the configuration"); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - System.exit(0); - } + (dialog, which) -> { + dialog.dismiss(); + System.exit(0); }); alertDialog.show(); } @@ -90,145 +88,116 @@ private void init(Bundle savedInstanceState) { setContentView(R.layout.activity_main); zoomIn = findViewById(R.id.zoomIn); - zoomIn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - NMSMapView mapView = getMapView(); - mapView.zoomInAnimated(true); - } + zoomIn.setOnClickListener(view -> { + NMSMapView mapView = getMapView(); + mapView.zoomInAnimated(true); }); zoomOut = findViewById(R.id.zoomOut); - zoomOut.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - NMSMapView mapView = getMapView(); - mapView.zoomOutAnimated(true); - } + zoomOut.setOnClickListener(view -> { + NMSMapView mapView = getMapView(); + mapView.zoomOutAnimated(true); }); circle = findViewById(R.id.circle); - circle.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - NMSMapView mapView = getMapView(); - if (mCircles.size()==0) { - circle.setBackgroundColor(Color.RED); - addCircle(mapView); - } else { - circle.setBackgroundColor(getResources().getColor(R.color.darker_gray)); - removeCircle(); - } + circle.setOnClickListener(view -> { + NMSMapView mapView = getMapView(); + if (mCircles.size()==0) { + circle.setBackgroundColor(Color.RED); + addCircle(mapView); + } else { + circle.setBackgroundColor(getResources().getColor(R.color.darker_gray)); + removeCircle(); } }); polygon= findViewById(R.id.polygon); - polygon.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - NMSMapView mapView = getMapView(); - if (mPolygons.size()==0) { - polygon.setBackgroundColor(Color.RED); - addPolygon(mapView); - } else { - polygon.setBackgroundColor(getResources().getColor(R.color.darker_gray)); - removePolygon(); - } + polygon.setOnClickListener(view -> { + NMSMapView mapView = getMapView(); + if (mPolygons.size()==0) { + polygon.setBackgroundColor(Color.RED); + addPolygon(mapView); + } else { + polygon.setBackgroundColor(getResources().getColor(R.color.darker_gray)); + removePolygon(); } }); polyline = findViewById(R.id.polyline); - polyline.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - NMSMapView mapView = getMapView(); - if (mPolylines.size()==0) { - - polyline.setBackgroundColor(Color.RED); - addPolyline(mapView); - } else { - polyline.setBackgroundColor(getResources().getColor(R.color.darker_gray)); - removePolyline(); - } + polyline.setOnClickListener(view -> { + NMSMapView mapView = getMapView(); + if (mPolylines.size()==0) { + + polyline.setBackgroundColor(Color.RED); + addPolyline(mapView); + } else { + polyline.setBackgroundColor(getResources().getColor(R.color.darker_gray)); + removePolyline(); } }); marker = findViewById(R.id.marker); - marker.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - NMSMapView mapView = getMapView(); - if (mMarkers.size()==0) { - marker.setBackgroundColor(Color.RED); - addMarker(mapView); - } else { - marker.setBackgroundColor(getResources().getColor(R.color.darker_gray)); - removeMarker(); - } + marker.setOnClickListener(view -> { + NMSMapView mapView = getMapView(); + if (mMarkers.size()==0) { + marker.setBackgroundColor(Color.RED); + addMarker(mapView); + } else { + marker.setBackgroundColor(getResources().getColor(R.color.darker_gray)); + removeMarker(); } }); login= findViewById(R.id.login); - login.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - NavionicsMobileServices.navionicsUser(); - } - }); + login.setOnClickListener(view -> NavionicsMobileServices.navionicsUser()); download= findViewById(R.id.download); - download.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (!downloadEnabled) { - NavionicsMobileServices.enableDownloadAreaSelector(); - downloadEnabled=true; - download.setBackgroundColor(Color.RED); - } else { - download.setBackgroundColor(getResources().getColor(R.color.darker_gray)); - downloadEnabled=false; - NavionicsMobileServices.disableDownloadAreaSelectorAndConfirm(true); - } - + download.setOnClickListener(view -> { + if (!downloadEnabled) { + NavionicsMobileServices.enableDownloadAreaSelector(); + downloadEnabled=true; + download.setBackgroundColor(Color.RED); + } else { + download.setBackgroundColor(getResources().getColor(R.color.darker_gray)); + downloadEnabled=false; + NavionicsMobileServices.disableDownloadAreaSelectorAndConfirm(true); } + }); gps= findViewById(R.id.gps); - gps.setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View view) { - NMSMapView mapView=getMapView(); - if (!gpsEnabled) { - if (NavionicsMobileServices.enableGPSServices()) { - gps.setBackgroundColor(Color.RED); - gpsEnabled=true; + gps.setOnClickListener(view -> { + NMSMapView mapView=getMapView(); + if (!gpsEnabled) { + if (NavionicsMobileServices.enableGPSServices()) { + gps.setBackgroundColor(Color.RED); + gpsEnabled=true; + } + switch (mapView.getGpsMode()) { + case NMSGPSModeUnlinked: + case NMSGPSModeCourseUpUnlinked: { + mapView.setGpsMode(NMSEnum.NMSGPSMode.NMSGPSModeNorthUp); + break; + } + case NMSGPSModeNorthUp: + { + mapView.setGpsMode(NMSEnum.NMSGPSMode.NMSGPSModeCompass); + + break; + } + case NMSGPSModeCompass: + { + mapView.setGpsMode(NMSEnum.NMSGPSMode.NMSGPSModeCourseUp); + break; } - switch (mapView.getGpsMode()) { - case NMSGPSModeUnlinked: - case NMSGPSModeCourseUpUnlinked: { - mapView.setGpsMode(NMSEnum.NMSGPSMode.NMSGPSModeNorthUp); - break; - } - case NMSGPSModeNorthUp: - { - mapView.setGpsMode(NMSEnum.NMSGPSMode.NMSGPSModeCompass); - - break; - } - case NMSGPSModeCompass: - { - mapView.setGpsMode(NMSEnum.NMSGPSMode.NMSGPSModeCourseUp); - break; - } - case NMSGPSModeCourseUp: - { - mapView.setGpsMode(NMSEnum.NMSGPSMode.NMSGPSModeCourseUpUnlinked); - break; - } - default: - break; + case NMSGPSModeCourseUp: + { + mapView.setGpsMode(NMSEnum.NMSGPSMode.NMSGPSModeCourseUpUnlinked); + break; } - } else { - NavionicsMobileServices.disableGPSServices(); - gps.setBackgroundColor(Color.LTGRAY); - gpsEnabled=false; + default: + break; } + } else { + NavionicsMobileServices.disableGPSServices(); + gps.setBackgroundColor(Color.LTGRAY); + gpsEnabled=false; } }); reset(savedInstanceState); @@ -264,10 +233,9 @@ private void reset(Bundle savedInstanceState){ } } private NMSMapView getMapView(){ - //(NMSMapView) findViewById(R.id.mapView); NMSMapFragment fg=(NMSMapFragment)getSupportFragmentManager().findFragmentById(R.id.mapFragment); assert fg != null; - return fg.getMapView();//R.id.mapView); + return fg.getMapView(); } private void addCircle(NMSMapView view){ NMSCircle circle=NMSCircle.circleWithPosition(new NMSLocationCoordinate2D(41.814092,-70.5326246),250); diff --git a/build.gradle b/build.gradle index ffd94a5..0477be9 100644 --- a/build.gradle +++ b/build.gradle @@ -2,12 +2,11 @@ buildscript { repositories { - jcenter() + mavenCentral() google() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.2' - + classpath 'com.android.tools.build:gradle:7.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -15,10 +14,10 @@ buildscript { allprojects { repositories { - jcenter() + mavenCentral() } repositories { - jcenter() + mavenCentral() flatDir { dirs 'libs' } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 44386a8..c43deff 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jan 21 11:24:52 CET 2020 +#Wed Nov 30 09:59:34 CET 2022 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +zipStoreBase=GRADLE_USER_HOME