try {
//Recovery sdcards from storage manager
- //IMP!! Android SDK doesn't have a "getVolumeList" but is supported by CM9.
+ //IMP!! Android SDK doesn't have a "getVolumeList" but is supported by CM10.
//Use reflect to get this value (if possible)
StorageManager sm = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
Method method = sm.getClass().getMethod("getVolumeList"); //$NON-NLS-1$
bookmarks.add(
new Bookmark(
BOOKMARK_TYPE.USB,
- volumes[i].getDescription(),
+ getStorageVolumeDescription(volumes[i]),
volumes[i].getPath()));
} else {
bookmarks.add(
new Bookmark(
BOOKMARK_TYPE.SDCARD,
- volumes[i].getDescription(),
+ getStorageVolumeDescription(volumes[i]),
volumes[i].getPath()));
}
}
}
/**
+ * 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).
*
* @return List<Bookmark> The bookmarks loaded
tvText2.setOnLongClickListener(this);
tvText2.setTag(String.format("%d|%d", position, menuItem2.getItemId())); //$NON-NLS-1$
} else {
- tvText2.setBackgroundDrawable(null);
+ tvText2.setBackground(null);
tvText2.setClickable(false);
tvText2.setOnClickListener(null);
tvText2.setOnLongClickListener(null);