diff options
6 files changed, 60 insertions, 11 deletions
diff --git a/src/com/android/gallery3d/app/GalleryAppImpl.java b/src/com/android/gallery3d/app/GalleryAppImpl.java index c6e7a0b57..9c5f232df 100644 --- a/src/com/android/gallery3d/app/GalleryAppImpl.java +++ b/src/com/android/gallery3d/app/GalleryAppImpl.java @@ -36,6 +36,7 @@ public class GalleryAppImpl extends Application implements GalleryApp { private static final String DOWNLOAD_FOLDER = "download"; private static final long DOWNLOAD_CAPACITY = 64 * 1024 * 1024; // 64M + private static GalleryAppImpl sGalleryAppImpl; private ImageCacheService mImageCacheService; private Object mLock = new Object(); @@ -51,6 +52,7 @@ public class GalleryAppImpl extends Application implements GalleryApp { WidgetUtils.initialize(this); PicasaSource.initialize(this); UsageStatistics.initialize(this); + sGalleryAppImpl = this; } @Override @@ -58,6 +60,10 @@ public class GalleryAppImpl extends Application implements GalleryApp { return this; } + public static Context getContext() { + return sGalleryAppImpl; + } + @Override public synchronized DataManager getDataManager() { if (mDataManager == null) { diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 6e7901252..f00117702 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -483,7 +483,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } } if (!found) { - FilterRepresentation representation = new FilterDrawRepresentation(); + FilterRepresentation representation = + new FilterDrawRepresentation(getString(R.string.imageDraw)); Action action = new Action(this, representation); action.setIsDoubleAction(true); mCategoryGeometryAdapter.add(action); diff --git a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java index 275a40409..5c5e561ca 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java @@ -157,10 +157,10 @@ public class FilterDrawRepresentation extends FilterRepresentation { private Vector<StrokeData> mDrawing = new Vector<StrokeData>(); private StrokeData mCurrent; // used in the currently drawing style - public FilterDrawRepresentation() { - super("Draw"); + public FilterDrawRepresentation(String name) { + super(name); setFilterClass(ImageFilterDraw.class); - setSerializationName("DRAW"); + setSerializationName(name); setFilterType(FilterRepresentation.TYPE_VIGNETTE); setTextId(R.string.imageDraw); setEditorId(EditorDraw.ID); @@ -190,7 +190,7 @@ public class FilterDrawRepresentation extends FilterRepresentation { @Override public FilterRepresentation copy() { - FilterDrawRepresentation representation = new FilterDrawRepresentation(); + FilterDrawRepresentation representation = new FilterDrawRepresentation(getName()); copyAllParameters(representation); return representation; } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java index 8fd5b029e..da7de9379 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java @@ -29,6 +29,7 @@ import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import com.android.gallery3d.R; +import com.android.gallery3d.app.GalleryAppImpl; import com.android.gallery3d.app.Log; import com.android.gallery3d.filtershow.cache.ImageLoader; import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation.StrokeData; @@ -47,7 +48,8 @@ public class ImageFilterDraw extends ImageFilter { int mCachedStrokes = -1; int mCurrentStyle = 0; - FilterDrawRepresentation mParameters = new FilterDrawRepresentation(); + FilterDrawRepresentation mParameters = new FilterDrawRepresentation( + GalleryAppImpl.getContext().getString(R.string.imageDraw)); public ImageFilterDraw() { mName = "Image Draw"; @@ -69,7 +71,8 @@ public class ImageFilterDraw extends ImageFilter { @Override public FilterRepresentation getDefaultRepresentation() { - return new FilterDrawRepresentation(); + return new FilterDrawRepresentation( + GalleryAppImpl.getContext().getString(R.string.imageDraw)); } @Override diff --git a/src/org/codeaurora/gallery3d/ext/IMovieListLoader.java b/src/org/codeaurora/gallery3d/ext/IMovieListLoader.java index db4c71347..fe5999858 100644 --- a/src/org/codeaurora/gallery3d/ext/IMovieListLoader.java +++ b/src/org/codeaurora/gallery3d/ext/IMovieListLoader.java @@ -1,5 +1,6 @@ package org.codeaurora.gallery3d.ext; +import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -35,7 +36,7 @@ public interface IMovieListLoader { * @param l * @param item */ - void fillVideoList(Context context, Intent intent, LoaderListener l, IMovieItem item); + void fillVideoList(Activity context, Intent intent, LoaderListener l, IMovieItem item); /** * enable video list or not. * @param intent diff --git a/src/org/codeaurora/gallery3d/ext/MovieListLoader.java b/src/org/codeaurora/gallery3d/ext/MovieListLoader.java index 840477ff6..94e6afd86 100644 --- a/src/org/codeaurora/gallery3d/ext/MovieListLoader.java +++ b/src/org/codeaurora/gallery3d/ext/MovieListLoader.java @@ -1,5 +1,6 @@ package org.codeaurora.gallery3d.ext; +import android.app.Activity; import android.content.ContentResolver; import android.content.ContentUris; import android.content.Context; @@ -12,6 +13,9 @@ import android.provider.MediaStore; import android.provider.OpenableColumns; import android.util.Log; +import java.io.File; +import java.util.ArrayList; + /** * Movie list loader class. It will load videos from MediaProvider database. * If MoviePlayer starting activity doesn't set any thing, default OrderBy will be used. @@ -24,7 +28,41 @@ public class MovieListLoader implements IMovieListLoader { private MovieListFetcherTask mListTask; @Override - public void fillVideoList(Context context, Intent intent, LoaderListener l, IMovieItem item) { + public void fillVideoList(Activity activity, Intent intent, final LoaderListener l, + IMovieItem currentMovieItem) { + + // determine if a video playlist has been passed in through the intent + // if a playlist does exist, use that + ArrayList<Uri> uris = intent.getParcelableArrayListExtra("EXTRA_FILE_LIST"); + if (uris != null) { + final MovieList movieList = new MovieList(); + ContentResolver cr = activity.getContentResolver(); + + for(Uri uri : uris) { + // add currentMovieItem in its proper place in the video playlist + // 'Next' and 'Previous' functionality in MovieListHooker is dependent on reference + // matching currentMovieItem + if (currentMovieItem.getOriginalUri().equals(uri)) { + movieList.add(currentMovieItem); + continue; + } + + File videoFile = new File(uri.getPath()); + movieList.add(new MovieItem(uri, cr.getType(uri), videoFile.getName())); + } + + // notify callback on main thread + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + l.onListLoaded(movieList); + } + }); + + return; + } + + // proceed with creating a playlist if one isn't found boolean fetechAll = false; if (intent.hasExtra(EXTRA_ALL_VIDEO_FOLDER)) { fetechAll = intent.getBooleanExtra(EXTRA_ALL_VIDEO_FOLDER, false); @@ -35,8 +73,8 @@ public class MovieListLoader implements IMovieListLoader { orderBy = intent.getStringExtra(EXTRA_ORDERBY); } cancelList(); - mListTask = new MovieListFetcherTask(context, fetechAll, l, orderBy); - mListTask.execute(item); + mListTask = new MovieListFetcherTask(activity, fetechAll, l, orderBy); + mListTask.execute(currentMovieItem); if (LOG) { Log.v(TAG, "fillVideoList() fetechAll=" + fetechAll + ", orderBy=" + orderBy); } |