Skip to content

Commit

Permalink
Merge pull request #2 from Navionics/features/library_alignment
Browse files Browse the repository at this point in the history
NavionicsMobileSDKv2.2.0: new library version alignment
  • Loading branch information
pasqualedona authored Dec 5, 2022
2 parents b12dd00 + 34fb217 commit fbc1e95
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 130 deletions.
3 changes: 2 additions & 1 deletion Example.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
210 changes: 89 additions & 121 deletions app/src/main/java/com/navionics/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@

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
}
}

allprojects {
repositories {
jcenter()
mavenCentral()
}
repositories {
jcenter()
mavenCentral()
flatDir {
dirs 'libs'
}
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fbc1e95

Please sign in to comment.