Loading res/values/strings.xml +4 −2 Original line number Original line Diff line number Diff line Loading @@ -151,6 +151,10 @@ <!-- The parent directory of the current directory in navigation view --> <!-- The parent directory of the current directory in navigation view --> <string name="parent_dir">Parent Directory</string> <string name="parent_dir">Parent Directory</string> <!-- External Storage descripton --> <string name="external_storage">External storage</string> <!-- Usb Storage descripton --> <string name="usb_storage">Usb storage</string> <!-- ActionBar Buttons > FileSystem --> <!-- ActionBar Buttons > FileSystem --> <string name="actionbar_button_filesystem_cd">Filesystem info</string> <string name="actionbar_button_filesystem_cd">Filesystem info</string> Loading Loading @@ -351,8 +355,6 @@ <string name="bookmarks_root_folder">Root folder</string> <string name="bookmarks_root_folder">Root folder</string> <!-- Bookmark name * System folder --> <!-- Bookmark name * System folder --> <string name="bookmarks_system_folder">System folder</string> <string name="bookmarks_system_folder">System folder</string> <!-- Bookmark name * External Storage --> <string name="bookmarks_external_storage">External storage</string> <!-- Bookmark name * Button * Initial directory content description --> <!-- Bookmark name * Button * Initial directory content description --> <string name="bookmarks_button_config_cd">Set the initial directory</string> <string name="bookmarks_button_config_cd">Set the initial directory</string> <!-- Bookmark name * Button * Remove bookmark content description --> <!-- Bookmark name * Button * Remove bookmark content description --> Loading src/com/cyanogenmod/explorer/activities/BookmarksActivity.java +6 −69 Original line number Original line Diff line number Diff line Loading @@ -18,14 +18,11 @@ package com.cyanogenmod.explorer.activities; import android.app.ActionBar; import android.app.ActionBar; import android.app.Activity; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo; import android.content.res.XmlResourceParser; import android.content.res.XmlResourceParser; import android.database.Cursor; import android.database.Cursor; import android.os.Bundle; import android.os.Bundle; import android.os.Environment; import android.os.storage.StorageManager; import android.os.storage.StorageVolume; import android.os.storage.StorageVolume; import android.util.Log; import android.util.Log; import android.view.KeyEvent; import android.view.KeyEvent; Loading @@ -52,10 +49,9 @@ import com.cyanogenmod.explorer.ui.dialogs.InitialDirectoryDialog; import com.cyanogenmod.explorer.util.CommandHelper; import com.cyanogenmod.explorer.util.CommandHelper; import com.cyanogenmod.explorer.util.DialogHelper; import com.cyanogenmod.explorer.util.DialogHelper; import com.cyanogenmod.explorer.util.ExceptionUtil; import com.cyanogenmod.explorer.util.ExceptionUtil; import com.cyanogenmod.explorer.util.StorageHelper; import java.io.File; import java.io.FileNotFoundException; import java.io.FileNotFoundException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; Loading Loading @@ -360,59 +356,28 @@ public class BookmarksActivity extends Activity implements OnItemClickListener, try { try { //Recovery sdcards from storage manager //Recovery sdcards from storage manager //IMP!! Android SDK doesn't have a "getVolumeList" but is supported by CM10. StorageVolume[] volumes = StorageHelper.getStorageVolumes(getApplication()); //Use reflect to get this value (if possible) StorageManager sm = (StorageManager) getSystemService(Context.STORAGE_SERVICE); Method method = sm.getClass().getMethod("getVolumeList"); //$NON-NLS-1$ StorageVolume[] volumes = (StorageVolume[])method.invoke(sm); int cc = volumes.length; int cc = volumes.length; for (int i = 0; i < cc ; i++) { for (int i = 0; i < cc ; i++) { if (volumes[i].getPath().toLowerCase().indexOf("usb") != -1) { //$NON-NLS-1$ if (volumes[i].getPath().toLowerCase().indexOf("usb") != -1) { //$NON-NLS-1$ bookmarks.add( bookmarks.add( new Bookmark( new Bookmark( BOOKMARK_TYPE.USB, BOOKMARK_TYPE.USB, getStorageVolumeDescription(volumes[i]), StorageHelper.getStorageVolumeDescription( getApplication(), volumes[i]), volumes[i].getPath())); volumes[i].getPath())); } else { } else { bookmarks.add( bookmarks.add( new Bookmark( new Bookmark( BOOKMARK_TYPE.SDCARD, BOOKMARK_TYPE.SDCARD, getStorageVolumeDescription(volumes[i]), StorageHelper.getStorageVolumeDescription( getApplication(), volumes[i]), volumes[i].getPath())); volumes[i].getPath())); } } } } //Return the bookmarks //Return the bookmarks return bookmarks; return bookmarks; } catch (NoSuchMethodException nsmex) { //Ignore. Android SDK StorageManager class doesn't have this method //Use default android information from environment try { File externalStorage = Environment.getExternalStorageDirectory(); if (externalStorage != null) { String path = externalStorage.getCanonicalPath(); if (path.toLowerCase().indexOf("usb") != -1) { //$NON-NLS-1$ bookmarks.add( new Bookmark( BOOKMARK_TYPE.USB, getString(R.string.bookmarks_external_storage), path)); } else { bookmarks.add( new Bookmark( BOOKMARK_TYPE.SDCARD, getString(R.string.bookmarks_external_storage), path)); } } //Return the bookmarks return bookmarks; } catch (Throwable ex) { /**NON BLOCK**/ } } catch (Throwable ex) { } catch (Throwable ex) { Log.e(TAG, "Load filesystem bookmarks failed", ex); //$NON-NLS-1$ Log.e(TAG, "Load filesystem bookmarks failed", ex); //$NON-NLS-1$ } } Loading @@ -421,34 +386,6 @@ public class BookmarksActivity extends Activity implements OnItemClickListener, return new ArrayList<Bookmark>(); return new ArrayList<Bookmark>(); } } /** * Method that returns the storage volume description. This method uses * reflection to retrieve the description because CM10 has a {@link Context} * as first parameter, that AOSP hasn't. * * @param volume The storage volume * @return String The description of the storage volume */ private String getStorageVolumeDescription(StorageVolume volume) { try { Method method = volume.getClass().getMethod( "getDescription", //$NON-NLS-1$ new Class[]{Context.class}); if (method == null) { // AOSP method = volume.getClass().getMethod("getDescription"); //$NON-NLS-1$ return (String)method.invoke(volume); } // CM10 return (String)method.invoke(volume, (Context)getApplication()); } catch (Throwable _throw) { // Returns the volume storage path return volume.getPath(); } } /** /** * Method that loads the user bookmarks (added by the user). * Method that loads the user bookmarks (added by the user). * * Loading Loading
res/values/strings.xml +4 −2 Original line number Original line Diff line number Diff line Loading @@ -151,6 +151,10 @@ <!-- The parent directory of the current directory in navigation view --> <!-- The parent directory of the current directory in navigation view --> <string name="parent_dir">Parent Directory</string> <string name="parent_dir">Parent Directory</string> <!-- External Storage descripton --> <string name="external_storage">External storage</string> <!-- Usb Storage descripton --> <string name="usb_storage">Usb storage</string> <!-- ActionBar Buttons > FileSystem --> <!-- ActionBar Buttons > FileSystem --> <string name="actionbar_button_filesystem_cd">Filesystem info</string> <string name="actionbar_button_filesystem_cd">Filesystem info</string> Loading Loading @@ -351,8 +355,6 @@ <string name="bookmarks_root_folder">Root folder</string> <string name="bookmarks_root_folder">Root folder</string> <!-- Bookmark name * System folder --> <!-- Bookmark name * System folder --> <string name="bookmarks_system_folder">System folder</string> <string name="bookmarks_system_folder">System folder</string> <!-- Bookmark name * External Storage --> <string name="bookmarks_external_storage">External storage</string> <!-- Bookmark name * Button * Initial directory content description --> <!-- Bookmark name * Button * Initial directory content description --> <string name="bookmarks_button_config_cd">Set the initial directory</string> <string name="bookmarks_button_config_cd">Set the initial directory</string> <!-- Bookmark name * Button * Remove bookmark content description --> <!-- Bookmark name * Button * Remove bookmark content description --> Loading
src/com/cyanogenmod/explorer/activities/BookmarksActivity.java +6 −69 Original line number Original line Diff line number Diff line Loading @@ -18,14 +18,11 @@ package com.cyanogenmod.explorer.activities; import android.app.ActionBar; import android.app.ActionBar; import android.app.Activity; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo; import android.content.res.XmlResourceParser; import android.content.res.XmlResourceParser; import android.database.Cursor; import android.database.Cursor; import android.os.Bundle; import android.os.Bundle; import android.os.Environment; import android.os.storage.StorageManager; import android.os.storage.StorageVolume; import android.os.storage.StorageVolume; import android.util.Log; import android.util.Log; import android.view.KeyEvent; import android.view.KeyEvent; Loading @@ -52,10 +49,9 @@ import com.cyanogenmod.explorer.ui.dialogs.InitialDirectoryDialog; import com.cyanogenmod.explorer.util.CommandHelper; import com.cyanogenmod.explorer.util.CommandHelper; import com.cyanogenmod.explorer.util.DialogHelper; import com.cyanogenmod.explorer.util.DialogHelper; import com.cyanogenmod.explorer.util.ExceptionUtil; import com.cyanogenmod.explorer.util.ExceptionUtil; import com.cyanogenmod.explorer.util.StorageHelper; import java.io.File; import java.io.FileNotFoundException; import java.io.FileNotFoundException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; Loading Loading @@ -360,59 +356,28 @@ public class BookmarksActivity extends Activity implements OnItemClickListener, try { try { //Recovery sdcards from storage manager //Recovery sdcards from storage manager //IMP!! Android SDK doesn't have a "getVolumeList" but is supported by CM10. StorageVolume[] volumes = StorageHelper.getStorageVolumes(getApplication()); //Use reflect to get this value (if possible) StorageManager sm = (StorageManager) getSystemService(Context.STORAGE_SERVICE); Method method = sm.getClass().getMethod("getVolumeList"); //$NON-NLS-1$ StorageVolume[] volumes = (StorageVolume[])method.invoke(sm); int cc = volumes.length; int cc = volumes.length; for (int i = 0; i < cc ; i++) { for (int i = 0; i < cc ; i++) { if (volumes[i].getPath().toLowerCase().indexOf("usb") != -1) { //$NON-NLS-1$ if (volumes[i].getPath().toLowerCase().indexOf("usb") != -1) { //$NON-NLS-1$ bookmarks.add( bookmarks.add( new Bookmark( new Bookmark( BOOKMARK_TYPE.USB, BOOKMARK_TYPE.USB, getStorageVolumeDescription(volumes[i]), StorageHelper.getStorageVolumeDescription( getApplication(), volumes[i]), volumes[i].getPath())); volumes[i].getPath())); } else { } else { bookmarks.add( bookmarks.add( new Bookmark( new Bookmark( BOOKMARK_TYPE.SDCARD, BOOKMARK_TYPE.SDCARD, getStorageVolumeDescription(volumes[i]), StorageHelper.getStorageVolumeDescription( getApplication(), volumes[i]), volumes[i].getPath())); volumes[i].getPath())); } } } } //Return the bookmarks //Return the bookmarks return bookmarks; return bookmarks; } catch (NoSuchMethodException nsmex) { //Ignore. Android SDK StorageManager class doesn't have this method //Use default android information from environment try { File externalStorage = Environment.getExternalStorageDirectory(); if (externalStorage != null) { String path = externalStorage.getCanonicalPath(); if (path.toLowerCase().indexOf("usb") != -1) { //$NON-NLS-1$ bookmarks.add( new Bookmark( BOOKMARK_TYPE.USB, getString(R.string.bookmarks_external_storage), path)); } else { bookmarks.add( new Bookmark( BOOKMARK_TYPE.SDCARD, getString(R.string.bookmarks_external_storage), path)); } } //Return the bookmarks return bookmarks; } catch (Throwable ex) { /**NON BLOCK**/ } } catch (Throwable ex) { } catch (Throwable ex) { Log.e(TAG, "Load filesystem bookmarks failed", ex); //$NON-NLS-1$ Log.e(TAG, "Load filesystem bookmarks failed", ex); //$NON-NLS-1$ } } Loading @@ -421,34 +386,6 @@ public class BookmarksActivity extends Activity implements OnItemClickListener, return new ArrayList<Bookmark>(); return new ArrayList<Bookmark>(); } } /** * Method that returns the storage volume description. This method uses * reflection to retrieve the description because CM10 has a {@link Context} * as first parameter, that AOSP hasn't. * * @param volume The storage volume * @return String The description of the storage volume */ private String getStorageVolumeDescription(StorageVolume volume) { try { Method method = volume.getClass().getMethod( "getDescription", //$NON-NLS-1$ new Class[]{Context.class}); if (method == null) { // AOSP method = volume.getClass().getMethod("getDescription"); //$NON-NLS-1$ return (String)method.invoke(volume); } // CM10 return (String)method.invoke(volume, (Context)getApplication()); } catch (Throwable _throw) { // Returns the volume storage path return volume.getPath(); } } /** /** * Method that loads the user bookmarks (added by the user). * Method that loads the user bookmarks (added by the user). * * Loading