summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/data/LocalAlbum.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d/data/LocalAlbum.java')
-rw-r--r--src/com/android/gallery3d/data/LocalAlbum.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/data/LocalAlbum.java b/src/com/android/gallery3d/data/LocalAlbum.java
index 6c5feb5c8..7b7015af6 100644
--- a/src/com/android/gallery3d/data/LocalAlbum.java
+++ b/src/com/android/gallery3d/data/LocalAlbum.java
@@ -20,6 +20,7 @@ import android.content.ContentResolver;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
+import android.os.Environment;
import android.provider.MediaStore;
import android.provider.MediaStore.Images;
import android.provider.MediaStore.Images.ImageColumns;
@@ -29,9 +30,11 @@ import android.provider.MediaStore.Video.VideoColumns;
import com.android.gallery3d.R;
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.util.BucketNames;
import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.MediaSetUtils;
+import java.io.File;
import java.util.ArrayList;
// LocalAlbumSet lists all media items in one bucket on local storage.
@@ -290,4 +293,33 @@ public class LocalAlbum extends MediaSet {
return name;
}
}
+
+ // Relative path is the absolute path minus external storage path
+ public static String getRelativePath(int bucketId) {
+ String relativePath = "/";
+ if (bucketId == MediaSetUtils.CAMERA_BUCKET_ID) {
+ relativePath += BucketNames.CAMERA;
+ } else if (bucketId == MediaSetUtils.DOWNLOAD_BUCKET_ID) {
+ relativePath += BucketNames.DOWNLOAD;
+ } else if (bucketId == MediaSetUtils.IMPORTED_BUCKET_ID) {
+ relativePath += BucketNames.IMPORTED;
+ } else if (bucketId == MediaSetUtils.SNAPSHOT_BUCKET_ID) {
+ relativePath += BucketNames.SCREENSHOTS;
+ } else if (bucketId == MediaSetUtils.EDITED_ONLINE_PHOTOS_BUCKET_ID) {
+ relativePath += BucketNames.EDITED_ONLINE_PHOTOS;
+ } else {
+ // If the first few cases didn't hit the matching path, do a
+ // thorough search in the local directories.
+ File extStorage = Environment.getExternalStorageDirectory();
+ String path = GalleryUtils.searchDirForPath(extStorage, bucketId);
+ if (path == null) {
+ Log.w(TAG, "Relative path for bucket id: " + bucketId + " is not found.");
+ relativePath = null;
+ } else {
+ relativePath = path.substring(extStorage.getAbsolutePath().length());
+ }
+ }
+ return relativePath;
+ }
+
}