diff options
4 files changed, 25 insertions, 16 deletions
diff --git a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java b/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java index 2bb34996..1f4946a3 100644 --- a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java +++ b/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java @@ -21,6 +21,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.app.SearchManager; import android.content.BroadcastReceiver; +import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -319,11 +320,9 @@ public class NavigationActivity extends Activity NavigationActivity.this.getCurrentNavigationView().refresh(); } } else if (intent.getAction().compareTo( - FileManagerSettings.INTENT_MOUNT_STATUS_CHANGED) == 0) { - onRequestBookmarksRefresh(); - removeUnmountedHistory(); - removeUnmountedSelection(); - } else if(intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)) { + FileManagerSettings.INTENT_MOUNT_STATUS_CHANGED) == 0 || + intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED) || + intent.getAction().equals(Intent.ACTION_MEDIA_UNMOUNTED)) { onRequestBookmarksRefresh(); removeUnmountedHistory(); removeUnmountedSelection(); @@ -502,9 +501,15 @@ public class NavigationActivity extends Activity filter.addAction(Intent.ACTION_TIME_CHANGED); filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); filter.addAction(FileManagerSettings.INTENT_MOUNT_STATUS_CHANGED); - filter.addAction(Intent.ACTION_MEDIA_MOUNTED); registerReceiver(this.mNotificationReceiver, filter); + // This filter needs the file data scheme, so it must be defined separately. + IntentFilter newFilter = new IntentFilter(); + newFilter.addAction(Intent.ACTION_MEDIA_MOUNTED); + newFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); + newFilter.addDataScheme(ContentResolver.SCHEME_FILE); + registerReceiver(mNotificationReceiver, newFilter); + // Set the theme before setContentView Theme theme = ThemeManager.getCurrentTheme(this); theme.setBaseThemeNoActionBar(this); @@ -1301,7 +1306,7 @@ public class NavigationActivity extends Activity try { // Recovery sdcards from storage manager StorageVolume[] volumes = StorageHelper - .getStorageVolumes(getApplication()); + .getStorageVolumes(getApplication(), true); for (StorageVolume volume: volumes) { if (volume != null) { String mountedState = volume.getState(); @@ -1569,7 +1574,7 @@ public class NavigationActivity extends Activity // Initial directory is the first external sdcard (sdcard, emmc, usb, ...) if (!StorageHelper.isPathInStorageVolume(initialDir)) { StorageVolume[] volumes = - StorageHelper.getStorageVolumes(this); + StorageHelper.getStorageVolumes(this, false); if (volumes != null && volumes.length > 0) { initialDir = volumes[0].getPath(); //Ensure that initial directory is an absolute directory diff --git a/src/com/cyanogenmod/filemanager/activities/PickerActivity.java b/src/com/cyanogenmod/filemanager/activities/PickerActivity.java index 120fd1d4..bff98b52 100644 --- a/src/com/cyanogenmod/filemanager/activities/PickerActivity.java +++ b/src/com/cyanogenmod/filemanager/activities/PickerActivity.java @@ -596,7 +596,7 @@ public class PickerActivity extends Activity */ private void showStorageVolumesPopUp(View anchor) { // Create a list (but not checkable) - final StorageVolume[] volumes = StorageHelper.getStorageVolumes(PickerActivity.this); + final StorageVolume[] volumes = StorageHelper.getStorageVolumes(PickerActivity.this, false); List<CheckableItem> descriptions = new ArrayList<CheckableItem>(); if (volumes != null) { int cc = volumes.length; diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java b/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java index 9573f682..099f0edb 100644 --- a/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java +++ b/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java @@ -1372,7 +1372,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe //Change to first storage volume StorageVolume[] volumes = - StorageHelper.getStorageVolumes(getContext()); + StorageHelper.getStorageVolumes(getContext(), false); if (volumes != null && volumes.length > 0) { changeCurrentDir(volumes[0].getPath(), false, true, false, null, null); } @@ -1403,7 +1403,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe // Check if the path is owned by one of the storage volumes if (!StorageHelper.isPathInStorageVolume(newDir)) { - StorageVolume[] volumes = StorageHelper.getStorageVolumes(getContext()); + StorageVolume[] volumes = StorageHelper.getStorageVolumes(getContext(), false); if (volumes != null && volumes.length > 0) { return volumes[0].getPath(); } diff --git a/src/com/cyanogenmod/filemanager/util/StorageHelper.java b/src/com/cyanogenmod/filemanager/util/StorageHelper.java index 9b04a6b3..ed07fd5e 100644 --- a/src/com/cyanogenmod/filemanager/util/StorageHelper.java +++ b/src/com/cyanogenmod/filemanager/util/StorageHelper.java @@ -41,11 +41,12 @@ public final class StorageHelper { * as first parameter, that AOSP hasn't. * * @param ctx The current context + * @param reload If true, re-query the volumes and do not return the already cached list. * @return StorageVolume[] The storage volumes defined in the system */ @SuppressWarnings("boxing") - public static synchronized StorageVolume[] getStorageVolumes(Context ctx) { - if (sStorageVolumes == null) { + public static synchronized StorageVolume[] getStorageVolumes(Context ctx, boolean reload) { + if (sStorageVolumes == null || reload) { //IMP!! Android SDK doesn't have a "getVolumeList" but is supported by CM10. //Use reflect to get this value (if possible) try { @@ -129,7 +130,8 @@ public final class StorageHelper { public static boolean isPathInStorageVolume(String path) { String fso = FileHelper.getAbsPath(path); StorageVolume[] volumes = - getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext()); + getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext(), + false); int cc = volumes.length; for (int i = 0; i < cc; i++) { StorageVolume vol = volumes[i]; @@ -148,7 +150,8 @@ public final class StorageHelper { */ public static boolean isStorageVolume(String path) { StorageVolume[] volumes = - getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext()); + getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext(), + false); int cc = volumes.length; for (int i = 0; i < cc; i++) { StorageVolume vol = volumes[i]; @@ -169,7 +172,8 @@ public final class StorageHelper { */ public static String getChrootedPath(String path) { StorageVolume[] volumes = - getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext()); + getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext(), + false); int cc = volumes.length; for (int i = 0; i < cc; i++) { StorageVolume vol = volumes[i]; |