OSDN Git Service

Update to CM10/JellyBean
authorjruesga <jorge@ruesga.com>
Wed, 12 Sep 2012 22:07:34 +0000 (00:07 +0200)
committerjruesga <jorge@ruesga.com>
Wed, 12 Sep 2012 22:07:34 +0000 (00:07 +0200)
.gitignore [new file with mode: 0644]
AndroidManifest.xml
src/com/cyanogenmod/explorer/activities/BookmarksActivity.java
src/com/cyanogenmod/explorer/adapters/TwoColumnsMenuListAdapter.java
src/com/cyanogenmod/explorer/ui/widgets/TransparentNoFocusableButtonItem.java
tests/.gitignore [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..812ec5a
--- /dev/null
@@ -0,0 +1,8 @@
+/.settings
+/bin
+/gen
+/.checkstyle
+/.classpath
+/.project
+/lint.xml
+/project.properties
index e387be4..4339ef7 100644 (file)
@@ -19,6 +19,8 @@
 
   <original-package android:name="com.cyanogenmod.explorer" />
 
+  <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16" />
+
   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
 
index 1edf346..76c9d4f 100644 (file)
@@ -327,7 +327,7 @@ public class BookmarksActivity extends Activity implements OnItemClickListener,
 
         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$
@@ -337,13 +337,13 @@ public class BookmarksActivity extends Activity implements OnItemClickListener,
                     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()));
                 }
             }
@@ -388,6 +388,34 @@ public class BookmarksActivity extends Activity implements OnItemClickListener,
     }
 
     /**
+     * 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
index a5d04fc..75105cd 100644 (file)
@@ -199,7 +199,7 @@ public class TwoColumnsMenuListAdapter extends SimpleMenuListAdapter
             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);
index d4b903d..894394c 100644 (file)
@@ -66,6 +66,6 @@ public class TransparentNoFocusableButtonItem extends NoFocusableButtonItem {
      */
     private void init() {
         //Remove focus
-        setBackgroundDrawable(null);
+        setBackground(null);
     }
 }
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644 (file)
index 0000000..663bbca
--- /dev/null
@@ -0,0 +1,7 @@
+/.settings
+/bin
+/gen
+/.checkstyle
+/.classpath
+/.project
+/project.properties