Skip to content

Commit c3515f1

Browse files
committed
Merge pull request #15 from ngageoint/develop
Develop to Master, open GeoPackage file changes
2 parents 5dfca76 + 76a7206 commit c3515f1

File tree

13 files changed

+688
-79
lines changed

13 files changed

+688
-79
lines changed

mage/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ dependencies {
9090

9191
//compile project(':sdk') // uncomment me to build locally
9292
compile "mil.nga.giat.mage:sdk:5.0.0" // comment me to build locally
93-
compile "mil.nga.geopackage:geopackage-android:1.1.0"
93+
compile "mil.nga.geopackage:geopackage-android:1.1.1"
9494
compile 'com.android.support:multidex:1.0.1'
9595
compile 'com.android.support:support-v4:23.1.1'
9696
compile 'com.google.android.gms:play-services:8.3.0'

mage/src/main/AndroidManifest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,29 @@
5252
<action android:name="android.intent.action.MAIN" />
5353
<category android:name="android.intent.category.LAUNCHER" />
5454
</intent-filter>
55+
<!-- Open files with matching extensions from a file browser -->
56+
<intent-filter>
57+
<action android:name="android.intent.action.VIEW" />
58+
<category android:name="android.intent.category.DEFAULT" />
59+
<data android:scheme="file" />
60+
<data android:mimeType="*/*" />
61+
<data android:pathPattern=".*\\.gpkg" /> <!-- GeoPackage -->
62+
<data android:pathPattern=".*\\.gpkx" /> <!-- GeoPackage Extension -->
63+
<data android:host="*" />
64+
</intent-filter>
65+
<!-- Email attachments -->
66+
<intent-filter>
67+
<action android:name="android.intent.action.VIEW" />
68+
<category android:name="android.intent.category.DEFAULT" />
69+
<data android:scheme="content" />
70+
<data android:mimeType="application/octet-stream" />
71+
</intent-filter>
72+
<!-- Google Drive -->
73+
<intent-filter>
74+
<action android:name="android.intent.action.VIEW" />
75+
<category android:name="android.intent.category.DEFAULT" />
76+
<data android:mimeType="application/octet-stream" />
77+
</intent-filter>
5578
</activity>
5679
<activity
5780
android:name="mil.nga.giat.mage.login.OAuthActivity"

mage/src/main/java/mil/nga/giat/mage/LandingActivity.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
import java.util.ArrayList;
3131
import java.util.List;
3232

33+
import mil.nga.geopackage.validate.GeoPackageValidate;
3334
import mil.nga.giat.mage.event.EventFragment;
3435
import mil.nga.giat.mage.help.HelpFragment;
36+
import mil.nga.giat.mage.cache.GeoPackageCacheUtils;
3537
import mil.nga.giat.mage.login.AlertBannerFragment;
3638
import mil.nga.giat.mage.login.LoginActivity;
3739
import mil.nga.giat.mage.map.MapFragment;
@@ -53,6 +55,11 @@
5355
*/
5456
public class LandingActivity extends Activity implements ListView.OnItemClickListener {
5557

58+
/**
59+
* Extra key for storing the local file path used to launch MAGE
60+
*/
61+
public static final String EXTRA_OPEN_FILE_PATH = "extra_open_file_path";
62+
5663
private static final String LOG_NAME = LandingActivity.class.getName();
5764

5865
private DrawerLayout drawerLayout;
@@ -145,6 +152,12 @@ public View getView(int position, View view, ViewGroup parent) {
145152
getFragmentManager().beginTransaction().add(android.R.id.content, alertBannerFragment).commit();
146153
}
147154

155+
// Check if MAGE was launched with a local file
156+
String openFilePath = getIntent().getStringExtra(EXTRA_OPEN_FILE_PATH);
157+
if(openFilePath != null){
158+
handleOpenFilePath(openFilePath);
159+
}
160+
148161
goToMap();
149162
}
150163

@@ -306,7 +319,28 @@ public void onItemClick(AdapterView<?> adapterView, View view, int position, lon
306319
drawerList.setItemChecked(position, true);
307320
drawerLayout.closeDrawer(drawerList);
308321
}
309-
322+
323+
/**
324+
* Handle opening the file path that MAGE was launched with
325+
* @param path
326+
*/
327+
private void handleOpenFilePath(String path){
328+
329+
File cacheFile = new File(path);
330+
331+
// Handle GeoPackage files by linking them to their current location
332+
if(GeoPackageValidate.hasGeoPackageExtension(cacheFile)){
333+
334+
// Import the GeoPackage if needed
335+
String cacheName = GeoPackageCacheUtils.importGeoPackage(this, cacheFile);
336+
if(cacheName != null){
337+
MAGE mage = ((MAGE) getApplication());
338+
mage.enableAndRefreshTileOverlays(cacheName);
339+
}
340+
}
341+
342+
}
343+
310344
public static void deleteAllData(Context context) {
311345
DaoStore.getInstance(context).resetDatabase();
312346
PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commit();
@@ -344,4 +378,5 @@ public static boolean deleteDir(File dir) {
344378
}
345379
return dir.delete();
346380
}
381+
347382
}

0 commit comments

Comments
 (0)