3030import java .util .ArrayList ;
3131import java .util .List ;
3232
33+ import mil .nga .geopackage .validate .GeoPackageValidate ;
3334import mil .nga .giat .mage .event .EventFragment ;
3435import mil .nga .giat .mage .help .HelpFragment ;
36+ import mil .nga .giat .mage .cache .GeoPackageCacheUtils ;
3537import mil .nga .giat .mage .login .AlertBannerFragment ;
3638import mil .nga .giat .mage .login .LoginActivity ;
3739import mil .nga .giat .mage .map .MapFragment ;
5355 */
5456public 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