Home | History | Annotate | Download | only in picasasource
      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 
     17 package com.android.gallery3d.picasasource;
     18 
     19 import android.app.Activity;
     20 import android.app.Dialog;
     21 import android.content.Context;
     22 import android.media.ExifInterface;
     23 import android.os.ParcelFileDescriptor;
     24 
     25 import com.android.gallery3d.app.GalleryApp;
     26 import com.android.gallery3d.data.MediaItem;
     27 import com.android.gallery3d.data.MediaObject;
     28 import com.android.gallery3d.data.MediaSet;
     29 import com.android.gallery3d.data.MediaSource;
     30 import com.android.gallery3d.data.Path;
     31 import com.android.gallery3d.data.PathMatcher;
     32 
     33 import java.io.FileNotFoundException;
     34 
     35 public 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 long getPicasaId(MediaObject image) {
    122         throw new UnsupportedOperationException();
    123     }
    124 
    125     public static String getUserAccount(Context context, MediaObject image) {
    126         throw new UnsupportedOperationException();
    127     }
    128 
    129     public static ParcelFileDescriptor openFile(Context context, MediaObject image, String mode)
    130             throws FileNotFoundException {
    131         throw new UnsupportedOperationException();
    132     }
    133 
    134     public static void initialize(Context context) {/*do nothing*/}
    135 
    136     public static void requestSync(Context context) {/*do nothing*/}
    137 
    138     public static void showSignInReminder(Activity context) {/*do nothing*/}
    139 
    140     public static void onPackageAdded(Context context, String packageName) {/*do nothing*/}
    141 
    142     public static void onPackageRemoved(Context context, String packageName) {/*do nothing*/}
    143 
    144     public static void onPackageChanged(Context context, String packageName) {/*do nothing*/}
    145 
    146     public static void extractExifValues(MediaObject item, ExifInterface exif) {/*do nothing*/}
    147 
    148     public static Dialog getVersionCheckDialog(Activity activity){
    149         return null;
    150     }
    151 }
    152