1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.gallery3d.picasasource;
18
19import android.app.Activity;
20import android.app.Dialog;
21import android.content.Context;
22import android.media.ExifInterface;
23import android.os.ParcelFileDescriptor;
24
25import com.android.gallery3d.app.GalleryApp;
26import com.android.gallery3d.data.MediaItem;
27import com.android.gallery3d.data.MediaObject;
28import com.android.gallery3d.data.MediaSet;
29import com.android.gallery3d.data.MediaSource;
30import com.android.gallery3d.data.Path;
31import com.android.gallery3d.data.PathMatcher;
32
33import java.io.FileNotFoundException;
34
35public class PicasaSource extends MediaSource {
36    private static final String TAG = "PicasaSource";
37
38    private static final int NO_MATCH = -1;
39    private static final int IMAGE_MEDIA_ID = 1;
40
41    private static final int PICASA_ALBUMSET = 0;
42    private static final int MAP_BATCH_COUNT = 100;
43
44    private GalleryApp mApplication;
45    private PathMatcher mMatcher;
46
47    public static final Path ALBUM_PATH = Path.fromString("/picasa/all");
48
49    public PicasaSource(GalleryApp application) {
50        super("picasa");
51        mApplication = application;
52        mMatcher = new PathMatcher();
53        mMatcher.add("/picasa/all", PICASA_ALBUMSET);
54        mMatcher.add("/picasa/image", PICASA_ALBUMSET);
55        mMatcher.add("/picasa/video", PICASA_ALBUMSET);
56    }
57
58    private static class EmptyAlbumSet extends MediaSet {
59
60        public EmptyAlbumSet(Path path, long version) {
61            super(path, version);
62        }
63
64        @Override
65        public String getName() {
66            return "picasa";
67        }
68
69        @Override
70        public long reload() {
71            return mDataVersion;
72        }
73    }
74
75    @Override
76    public MediaObject createMediaObject(Path path) {
77        switch (mMatcher.match(path)) {
78            case PICASA_ALBUMSET:
79                return new EmptyAlbumSet(path, MediaObject.nextVersionNumber());
80            default:
81                throw new RuntimeException("bad path: " + path);
82        }
83    }
84
85    public static MediaItem getFaceItem(Context context, MediaItem item, int faceIndex) {
86        throw new UnsupportedOperationException();
87    }
88
89    public static boolean isPicasaImage(MediaObject object) {
90        return false;
91    }
92
93    public static String getImageTitle(MediaObject image) {
94        throw new UnsupportedOperationException();
95    }
96
97    public static int getImageSize(MediaObject image) {
98        throw new UnsupportedOperationException();
99    }
100
101    public static String getContentType(MediaObject image) {
102        throw new UnsupportedOperationException();
103    }
104
105    public static long getDateTaken(MediaObject image) {
106        throw new UnsupportedOperationException();
107    }
108
109    public static double getLatitude(MediaObject image) {
110        throw new UnsupportedOperationException();
111    }
112
113    public static double getLongitude(MediaObject image) {
114        throw new UnsupportedOperationException();
115    }
116
117    public static int getRotation(MediaObject image) {
118        throw new UnsupportedOperationException();
119    }
120
121    public static ParcelFileDescriptor openFile(Context context, MediaObject image, String mode)
122            throws FileNotFoundException {
123        throw new UnsupportedOperationException();
124    }
125
126    public static void initialize(Context context) {/*do nothing*/}
127
128    public static void requestSync(Context context) {/*do nothing*/}
129
130    public static void showSignInReminder(Activity context) {/*do nothing*/}
131
132    public static void onPackageAdded(Context context, String packageName) {/*do nothing*/}
133
134    public static void onPackageRemoved(Context context, String packageName) {/*do nothing*/}
135
136    public static void onPackageChanged(Context context, String packageName) {/*do nothing*/}
137
138    public static void extractExifValues(MediaObject item, ExifInterface exif) {/*do nothing*/}
139
140    public static Dialog getVersionCheckDialog(Activity activity){
141        return null;
142    }
143}
144