Skip to content

Commit

Permalink
Merge pull request #72 from ngageoint/develop
Browse files Browse the repository at this point in the history
v2.1.10 release
  • Loading branch information
jclark118 authored Oct 23, 2023
2 parents 9d5e1bb + 4a5eaa6 commit 8a9940f
Show file tree
Hide file tree
Showing 18 changed files with 380 additions and 290 deletions.
27 changes: 20 additions & 7 deletions mapcache/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ android {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

// Verbose logging for debug
// allprojects {
// tasks.withType(JavaCompile) {
// options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
// }
// }
defaultConfig {
applicationId "mil.nga.mapcache"
resValue "string", "applicationId", applicationId
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
minSdkVersion 28
targetSdkVersion 33
versionCode 56
versionName '2.1.9'
versionCode 59
versionName '2.1.10'
multiDexEnabled true
}
buildTypes {
Expand All @@ -41,7 +49,7 @@ android {
sourceSets {
main {
java {
srcDirs 'src/main/java', 'src/test'
srcDirs 'src/main/java', 'src/test', 'src/androidTest'
}
}
}
Expand All @@ -60,7 +68,7 @@ dependencies {
api 'com.google.android.material:material:1.6.0'
api 'androidx.preference:preference:1.2.1'
api 'androidx.lifecycle:lifecycle-extensions:2.2.0'
api 'mil.nga.geopackage.map:geopackage-android-map:6.7.1' // comment out to build locally
api 'mil.nga.geopackage.map:geopackage-android-map:6.7.2' // comment out to build locally
//api project(':geopackage-map') // uncomment me to build locally
api 'mil.nga.mgrs:mgrs-android:2.2.2'
api 'mil.nga.gars:gars-android:1.2.2'
Expand All @@ -71,11 +79,16 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
implementation 'org.locationtech.jts:jts-core:1.18.2'
implementation 'com.github.matomo-org:matomo-sdk-android:v2.0.0'
implementation 'junit:junit:4.12'
testImplementation 'androidx.multidex:multidex:2.0.1'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
implementation 'com.github.matomo-org:matomo-sdk-android:v2.0.0'
testImplementation 'junit:junit:4.12'
testImplementation "org.robolectric:robolectric:4.7.3"
testImplementation 'androidx.test.espresso:espresso-core:3.5.1'
testImplementation 'androidx.test:core:1.5.0'
testImplementation 'androidx.test.ext:junit:1.1.5'
testImplementation 'androidx.test:runner:1.5.2'
testImplementation 'androidx.test:rules:1.5.0'
}

configure extensions.android, {
Expand Down
4 changes: 4 additions & 0 deletions mapcache/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
package="mil.nga.mapcache"
android:installLocation="auto">

<uses-feature
android:name="android.hardware.camera"
android:required="false" />

<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,8 @@ private void processFeatureRow(MapFeaturesUpdateTask task, String database, Feat
}
}
} catch (Exception e) {
new Handler(Looper.getMainLooper()).post(() -> {
Toast toast = Toast.makeText(context, "Error loading geometry", Toast.LENGTH_SHORT);
toast.show();
});
// set task error
task.setErrorCount(task.getErrorCount() + 1);
}
}
}
Expand Down
72 changes: 44 additions & 28 deletions mapcache/src/main/java/mil/nga/mapcache/GeoPackageMapFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.hardware.SensorEvent;
import android.location.Location;
import android.net.Uri;
Expand Down Expand Up @@ -105,19 +103,15 @@
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;

import mil.nga.geopackage.BoundingBox;
import mil.nga.geopackage.GeoPackage;
import mil.nga.geopackage.GeoPackageException;
import mil.nga.geopackage.contents.Contents;
import mil.nga.geopackage.contents.ContentsDao;
import mil.nga.geopackage.db.GeoPackageDataType;
Expand Down Expand Up @@ -160,16 +154,14 @@
import mil.nga.mapcache.listeners.LayerActiveSwitchListener;
import mil.nga.mapcache.listeners.OnDialogButtonClickListener;
import mil.nga.mapcache.listeners.SensorCallback;
import mil.nga.mapcache.load.DownloadTask;
import mil.nga.mapcache.load.Downloader;
import mil.nga.mapcache.load.ILoadTilesTask;
import mil.nga.mapcache.load.ImportTask;
import mil.nga.mapcache.load.ShareTask;
import mil.nga.mapcache.preferences.GridType;
import mil.nga.mapcache.preferences.PreferencesActivity;
import mil.nga.mapcache.repository.GeoPackageModifier;
import mil.nga.mapcache.sensors.SensorHandler;
import mil.nga.mapcache.utils.ProjUtils;
import mil.nga.mapcache.repository.sensors.SensorHandler;
import mil.nga.mapcache.utils.SampleDownloader;
import mil.nga.mapcache.utils.SwipeController;
import mil.nga.mapcache.utils.ViewAnimation;
Expand Down Expand Up @@ -584,6 +576,16 @@ private enum EditType {
*/
private Zoomer zoomer;

/**
* Disclaimer message when first launching the app
*/
AlertDialog disclaimerDialog;

/**
* Max features warning popup dialog
*/
AlertDialog maxFeaturesDialog;

/**
* Model that contains various states involving the map.
*/
Expand Down Expand Up @@ -1630,29 +1632,42 @@ private void showDisclaimer() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
boolean disclaimerPref = sharedPreferences.getBoolean(getString(R.string.disclaimerPref), false);
if (!disclaimerPref) {
LayoutInflater inflater = LayoutInflater.from(getActivity());
View disclaimerView = inflater.inflate(R.layout.disclaimer_window, null);
Button acceptButton = disclaimerView.findViewById(R.id.accept_button);
Button exitButton = disclaimerView.findViewById(R.id.exit_button);

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle)
.setView(disclaimerView);
final AlertDialog alertDialog = dialogBuilder.create();
acceptButton.setOnClickListener((View view) -> {
sharedPreferences.edit().putBoolean(getString(R.string.disclaimerPref), true).apply();
alertDialog.dismiss();
});
exitButton.setOnClickListener((View view) -> getActivity().finish());
LayoutInflater inflater = LayoutInflater.from(getActivity());
View disclaimerView = inflater.inflate(R.layout.disclaimer_window, null);
Button acceptButton = disclaimerView.findViewById(R.id.accept_button);
Button exitButton = disclaimerView.findViewById(R.id.exit_button);

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle)
.setView(disclaimerView);
disclaimerDialog = dialogBuilder.create();
acceptButton.setOnClickListener((View view) -> {
sharedPreferences.edit().putBoolean(getString(R.string.disclaimerPref), true).apply();
disclaimerDialog.dismiss();
});
exitButton.setOnClickListener((View view) -> getActivity().finish());

// Prevent the dialog from closing when clicking outside the dialog or the back button
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.setOnKeyListener((DialogInterface arg0, int keyCode,
KeyEvent event) -> true);
alertDialog.show();
// Prevent the dialog from closing when clicking outside the dialog or the back button
disclaimerDialog.setCanceledOnTouchOutside(false);
disclaimerDialog.setOnKeyListener((DialogInterface arg0, int keyCode,
KeyEvent event) -> true);
disclaimerDialog.show();
}
}
}

/**
* Manually dismiss the disclaimer dialog on stop, otherwise we have a leak
*/
@Override
public void onStop() {
if(disclaimerDialog != null) {
disclaimerDialog.dismiss();
}
if(maxFeaturesDialog != null){
maxFeaturesDialog.dismiss();
}
super.onStop();
}

/**
* Show a warning that the user has selected more features than the current max features setting
Expand Down Expand Up @@ -1696,7 +1711,8 @@ private void showMaxFeaturesExceeded() {
}
d.cancel();
});
dialog.show();
maxFeaturesDialog = dialog.create();
maxFeaturesDialog.show();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package mil.nga.mapcache;

import android.app.Activity;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.Marker;
Expand Down Expand Up @@ -86,6 +89,11 @@ public class MapFeaturesUpdateTask implements Runnable {
*/
private boolean filter;

/**
* Keep track of any errors when displaying features on the map
*/
private int errorCount = 0;

/**
* Constructor.
*
Expand Down Expand Up @@ -265,6 +273,8 @@ private void displayFeatures(GeoPackage geoPackage, StyleCache styleCache, Strin

// Get the GeoPackage and feature DAO
String database = geoPackage.getName();
setErrorCount(0);

Map<String, FeatureDao> dataAccessObjects = model.getFeatureDaos().get(database);
if (dataAccessObjects != null) {
FeatureDao featureDao = dataAccessObjects.get(features);
Expand Down Expand Up @@ -336,8 +346,16 @@ private void displayFeatures(GeoPackage geoPackage, StyleCache styleCache, Strin
+ ", row: " + cursor.getPosition(), e);
}
}

int totalErrors = getErrorCount();
if(totalErrors > 0){
new Handler(Looper.getMainLooper()).post(() -> {
Toast toast = Toast.makeText(activity, "Error loading geometry", Toast.LENGTH_SHORT);
toast.show();
});
setErrorCount(0);
}
}

}
indexer.close();

Expand All @@ -361,6 +379,8 @@ private void displayFeatures(GeoPackage geoPackage, StyleCache styleCache, Strin
private void processFeatureIndexResults(FeatureIndexResults indexResults, String database, FeatureDao featureDao,
GoogleMapShapeConverter converter, StyleCache styleCache, AtomicInteger count, final int maxFeatures, final boolean editable) {
try {
setErrorCount(0);

for (FeatureRow row : indexResults) {

if (cancelled || count.get() >= maxFeatures) {
Expand All @@ -384,6 +404,15 @@ private void processFeatureIndexResults(FeatureIndexResults indexResults, String
}
} finally {
indexResults.close();
int totalErrors = getErrorCount();
if(totalErrors > 0){
new Handler(Looper.getMainLooper()).post(() -> {
Toast toast = Toast.makeText(activity, totalErrors + " Geometries failed to load", Toast.LENGTH_SHORT);
toast.show();
});
setErrorCount(0);

}
}
}

Expand All @@ -402,6 +431,15 @@ private void addMarkerShape(long featureId, String database, String tableName, G
model.getMarkerIds().put(marker.getId(), markerFeature);
}
}
/**
* Update the number of errors encountered while processing features
*/
public int getErrorCount() {
return errorCount;
}
public void setErrorCount(int errorCount) {
this.errorCount = errorCount;
}

@Override
public void run() {
Expand Down
Loading

0 comments on commit 8a9940f

Please sign in to comment.