From 356ffa04adff94a09fe60849b40397aa8ee018b8 Mon Sep 17 00:00:00 2001 From: Angus Kong Date: Wed, 19 Sep 2012 20:39:45 +0800 Subject: Support panorama progress items in Gallery. Bug 7259843 Add dummy files for showing panorama progress in filmstrip. Change-Id: I7ae92b90bbbd992fde00cfcfc68af69b34d34d74 --- src/com/android/gallery3d/app/GalleryApp.java | 2 ++ src/com/android/gallery3d/app/GalleryAppImpl.java | 9 ++++++++ src/com/android/gallery3d/app/PhotoPage.java | 5 +++++ .../gallery3d/app/StitchingChangeListener.java | 26 ++++++++++++++++++++++ src/com/android/gallery3d/data/DataManager.java | 3 +++ src/com/android/gallery3d/data/LocalAlbumSet.java | 8 ++++++- .../android/gallery3d/util/LightCycleHelper.java | 19 ++++++++++++++-- 7 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 src/com/android/gallery3d/app/StitchingChangeListener.java diff --git a/src/com/android/gallery3d/app/GalleryApp.java b/src/com/android/gallery3d/app/GalleryApp.java index a2d74945f..b56b8a82c 100644 --- a/src/com/android/gallery3d/app/GalleryApp.java +++ b/src/com/android/gallery3d/app/GalleryApp.java @@ -28,6 +28,8 @@ import com.android.gallery3d.util.ThreadPool; public interface GalleryApp { public DataManager getDataManager(); + + public StitchingProgressManager getStitchingProgressManager(); public ImageCacheService getImageCacheService(); public DownloadCache getDownloadCache(); public ThreadPool getThreadPool(); diff --git a/src/com/android/gallery3d/app/GalleryAppImpl.java b/src/com/android/gallery3d/app/GalleryAppImpl.java index 9576093a4..c4507b340 100644 --- a/src/com/android/gallery3d/app/GalleryAppImpl.java +++ b/src/com/android/gallery3d/app/GalleryAppImpl.java @@ -30,6 +30,7 @@ import com.android.gallery3d.gadget.WidgetUtils; import com.android.gallery3d.photoeditor.PhotoEditor; import com.android.gallery3d.picasasource.PicasaSource; import com.android.gallery3d.util.GalleryUtils; +import com.android.gallery3d.util.LightCycleHelper; import com.android.gallery3d.util.ThreadPool; import java.io.File; @@ -44,6 +45,7 @@ public class GalleryAppImpl extends Application implements GalleryApp { private DataManager mDataManager; private ThreadPool mThreadPool; private DownloadCache mDownloadCache; + private StitchingProgressManager mStitchingProgressManager; @Override public void onCreate() { @@ -59,6 +61,8 @@ public class GalleryAppImpl extends Application implements GalleryApp { getPackageManager().setComponentEnabledSetting( new ComponentName(this, PhotoEditor.class), state, PackageManager.DONT_KILL_APP); + + mStitchingProgressManager = LightCycleHelper.createStitchingManagerInstance(this); } @Override @@ -75,6 +79,11 @@ public class GalleryAppImpl extends Application implements GalleryApp { return mDataManager; } + @Override + public StitchingProgressManager getStitchingProgressManager() { + return mStitchingProgressManager; + } + @Override public ImageCacheService getImageCacheService() { // This method may block on file I/O so a dedicated lock is needed here. diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index c60c3b9e2..2a088b1fa 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -371,6 +371,11 @@ public class PhotoPage extends ActivityState implements mSetPathString = "/filter/empty/{"+mSetPathString+"}"; } + // Add support for showing panorama progress. + if (LightCycleHelper.hasLightCycleCapture(mActivity.getAndroidContext())) { + mSetPathString = LightCycleHelper.wrapGalleryPath(mSetPathString); + } + // Combine the original MediaSet with the one for ScreenNail // from AppBridge. mSetPathString = "/combo/item/{" + screenNailSetPath + diff --git a/src/com/android/gallery3d/app/StitchingChangeListener.java b/src/com/android/gallery3d/app/StitchingChangeListener.java new file mode 100644 index 000000000..901f37967 --- /dev/null +++ b/src/com/android/gallery3d/app/StitchingChangeListener.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.gallery3d.app; + + +public interface StitchingChangeListener { + public void onFileAdded(String filePath); + + public void onFileRemoved(String filePath); + + public void onProgressChanged(String filePath, int progress); +} diff --git a/src/com/android/gallery3d/data/DataManager.java b/src/com/android/gallery3d/data/DataManager.java index eeab8a885..e3b7bfc19 100644 --- a/src/com/android/gallery3d/data/DataManager.java +++ b/src/com/android/gallery3d/data/DataManager.java @@ -28,6 +28,7 @@ import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.MediaSet.ItemConsumer; import com.android.gallery3d.data.MediaSource.PathId; import com.android.gallery3d.picasasource.PicasaSource; +import com.android.gallery3d.util.LightCycleHelper; import java.util.ArrayList; import java.util.Comparator; @@ -130,6 +131,7 @@ public class DataManager { addSource(new SecureSource(mApplication)); addSource(new UriSource(mApplication)); addSource(new SnailSource(mApplication)); + addSource(LightCycleHelper.createMediaSourceInstance(mApplication)); if (mActiveCount > 0) { for (MediaSource source : mSourceMap.values()) { @@ -153,6 +155,7 @@ public class DataManager { // open for debug void addSource(MediaSource source) { + if (source == null) return; mSourceMap.put(source.getPrefix(), source); } diff --git a/src/com/android/gallery3d/data/LocalAlbumSet.java b/src/com/android/gallery3d/data/LocalAlbumSet.java index d737ca803..afaac4965 100644 --- a/src/com/android/gallery3d/data/LocalAlbumSet.java +++ b/src/com/android/gallery3d/data/LocalAlbumSet.java @@ -26,6 +26,7 @@ import com.android.gallery3d.app.GalleryApp; import com.android.gallery3d.data.BucketHelper.BucketEntry; import com.android.gallery3d.util.Future; import com.android.gallery3d.util.FutureListener; +import com.android.gallery3d.util.LightCycleHelper; import com.android.gallery3d.util.MediaSetUtils; import com.android.gallery3d.util.ThreadPool; import com.android.gallery3d.util.ThreadPool.JobContext; @@ -92,7 +93,7 @@ public class LocalAlbumSet extends MediaSet } private static int findBucket(BucketEntry entries[], int bucketId) { - for (int i = 0, n = entries.length; i < n ; ++i) { + for (int i = 0, n = entries.length; i < n; ++i) { if (entries[i].bucketId == bucketId) return i; } return -1; @@ -127,6 +128,11 @@ public class LocalAlbumSet extends MediaSet for (BucketEntry entry : entries) { MediaSet album = getLocalAlbum(dataManager, mType, mPath, entry.bucketId, entry.bucketName); + if (LightCycleHelper.hasLightCycleCapture(mApplication.getAndroidContext()) + && album.isCameraRoll()) { + album = dataManager.getMediaSet(Path.fromString( + LightCycleHelper.wrapGalleryPath(album.getPath().toString()))); + } albums.add(album); } return albums; diff --git a/src_pd/com/android/gallery3d/util/LightCycleHelper.java b/src_pd/com/android/gallery3d/util/LightCycleHelper.java index dcedc2d56..a4da43cb4 100644 --- a/src_pd/com/android/gallery3d/util/LightCycleHelper.java +++ b/src_pd/com/android/gallery3d/util/LightCycleHelper.java @@ -23,6 +23,9 @@ import android.content.Intent; import android.net.Uri; import com.android.camera.CameraModule; +import com.android.gallery3d.app.GalleryApp; +import com.android.gallery3d.app.StitchingProgressManager; +import com.android.gallery3d.data.MediaSource; public class LightCycleHelper { @@ -30,11 +33,11 @@ public class LightCycleHelper { /* Do nothing */ } - public static synchronized boolean hasLightCycleView(Context context) { + public static boolean hasLightCycleView(Context context) { return false; } - public static synchronized boolean hasLightCycleCapture(Context context) { + public static boolean hasLightCycleCapture(Context context) { return false; } @@ -49,4 +52,16 @@ public class LightCycleHelper { public static CameraModule createPanoramaModule() { return null; } + + public static StitchingProgressManager createStitchingManagerInstance(GalleryApp app) { + return null; + } + + public static MediaSource createMediaSourceInstance(GalleryApp app) { + return null; + } + + public static String wrapGalleryPath(String path) { + return path; + } } -- cgit v1.2.3