Skip to content

Commit

Permalink
Merge pull request #15 from ngageoint/develop
Browse files Browse the repository at this point in the history
Develop to Master, open GeoPackage file changes
  • Loading branch information
bosborn committed Nov 23, 2015
2 parents 5dfca76 + 76a7206 commit c3515f1
Show file tree
Hide file tree
Showing 13 changed files with 688 additions and 79 deletions.
2 changes: 1 addition & 1 deletion mage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dependencies {

//compile project(':sdk') // uncomment me to build locally
compile "mil.nga.giat.mage:sdk:5.0.0" // comment me to build locally
compile "mil.nga.geopackage:geopackage-android:1.1.0"
compile "mil.nga.geopackage:geopackage-android:1.1.1"
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
Expand Down
23 changes: 23 additions & 0 deletions mage/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,29 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Open files with matching extensions from a file browser -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.gpkg" /> <!-- GeoPackage -->
<data android:pathPattern=".*\\.gpkx" /> <!-- GeoPackage Extension -->
<data android:host="*" />
</intent-filter>
<!-- Email attachments -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:mimeType="application/octet-stream" />
</intent-filter>
<!-- Google Drive -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/octet-stream" />
</intent-filter>
</activity>
<activity
android:name="mil.nga.giat.mage.login.OAuthActivity"
Expand Down
37 changes: 36 additions & 1 deletion mage/src/main/java/mil/nga/giat/mage/LandingActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
import java.util.ArrayList;
import java.util.List;

import mil.nga.geopackage.validate.GeoPackageValidate;
import mil.nga.giat.mage.event.EventFragment;
import mil.nga.giat.mage.help.HelpFragment;
import mil.nga.giat.mage.cache.GeoPackageCacheUtils;
import mil.nga.giat.mage.login.AlertBannerFragment;
import mil.nga.giat.mage.login.LoginActivity;
import mil.nga.giat.mage.map.MapFragment;
Expand All @@ -53,6 +55,11 @@
*/
public class LandingActivity extends Activity implements ListView.OnItemClickListener {

/**
* Extra key for storing the local file path used to launch MAGE
*/
public static final String EXTRA_OPEN_FILE_PATH = "extra_open_file_path";

private static final String LOG_NAME = LandingActivity.class.getName();

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

// Check if MAGE was launched with a local file
String openFilePath = getIntent().getStringExtra(EXTRA_OPEN_FILE_PATH);
if(openFilePath != null){
handleOpenFilePath(openFilePath);
}

goToMap();
}

Expand Down Expand Up @@ -306,7 +319,28 @@ public void onItemClick(AdapterView<?> adapterView, View view, int position, lon
drawerList.setItemChecked(position, true);
drawerLayout.closeDrawer(drawerList);
}


/**
* Handle opening the file path that MAGE was launched with
* @param path
*/
private void handleOpenFilePath(String path){

File cacheFile = new File(path);

// Handle GeoPackage files by linking them to their current location
if(GeoPackageValidate.hasGeoPackageExtension(cacheFile)){

// Import the GeoPackage if needed
String cacheName = GeoPackageCacheUtils.importGeoPackage(this, cacheFile);
if(cacheName != null){
MAGE mage = ((MAGE) getApplication());
mage.enableAndRefreshTileOverlays(cacheName);
}
}

}

public static void deleteAllData(Context context) {
DaoStore.getInstance(context).resetDatabase();
PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commit();
Expand Down Expand Up @@ -344,4 +378,5 @@ public static boolean deleteDir(File dir) {
}
return dir.delete();
}

}
Loading

0 comments on commit c3515f1

Please sign in to comment.