diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/gallery3d/app/AlbumPage.java | 36 | ||||
-rw-r--r-- | src/com/android/gallery3d/app/GalleryActionBar.java | 87 | ||||
-rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 108 | ||||
-rw-r--r-- | src/com/android/gallery3d/data/ComboAlbum.java | 6 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/FilterShowActivity.java | 6 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/cache/ImageLoader.java | 18 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java (renamed from src/com/android/gallery3d/filtershow/filters/ImageFilterBrightness.java) | 7 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java | 1 |
8 files changed, 182 insertions, 87 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index addee0ed7..ae6418cce 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -56,7 +56,7 @@ import com.android.gallery3d.util.GalleryUtils; import com.android.gallery3d.util.MediaSetUtils; public class AlbumPage extends ActivityState implements GalleryActionBar.ClusterRunner, - SelectionManager.SelectionListener, MediaSet.SyncListener { + SelectionManager.SelectionListener, MediaSet.SyncListener, GalleryActionBar.OnAlbumModeSelectedListener { @SuppressWarnings("unused") private static final String TAG = "AlbumPage"; @@ -399,7 +399,9 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster boolean enableHomeButton = (mActivity.getStateManager().getStateCount() > 1) | mParentMediaSetString != null; - mActivity.getGalleryActionBar().setDisplayOptions(enableHomeButton, true); + GalleryActionBar actionBar = mActivity.getGalleryActionBar(); + actionBar.setDisplayOptions(enableHomeButton, false); + actionBar.enableAlbumModeMenu(GalleryActionBar.ALBUM_GRID_MODE_SELECTED, this); // Set the reload bit here to prevent it exit this page in clearLoadingBit(). setLoadingBit(BIT_LOADING_RELOAD); @@ -423,6 +425,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster mAlbumDataAdapter.pause(); mAlbumView.pause(); DetailsHelper.pause(); + mActivity.getGalleryActionBar().disableAlbumModeMenu(true); if (mSyncTask != null) { mSyncTask.cancel(); @@ -560,6 +563,17 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster mSlotView.getSlotRect(slotIndex, mRootPane)); } + private void switchToFilmstrip() { + if (mAlbumDataAdapter.size() < 1) return; + int targetPhoto = mSlotView.getVisibleStart(); + prepareAnimationBackToFilmstrip(targetPhoto); + if(mLaunchedFromPhotoPage) { + onBackPressed(); + } else { + pickPhoto(targetPhoto, true); + } + } + @Override protected boolean onItemSelected(MenuItem item) { switch (item.getItemId()) { @@ -587,17 +601,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster SlideshowPage.class, REQUEST_SLIDESHOW, data); return true; } - case R.id.action_filmstrip: { - if (mAlbumDataAdapter.size() < 1) return true; - int targetPhoto = mSlotView.getVisibleStart(); - prepareAnimationBackToFilmstrip(targetPhoto); - if(mLaunchedFromPhotoPage) { - onBackPressed(); - } else { - pickPhoto(targetPhoto, true); - } - return true; - } case R.id.action_details: { if (mShowDetails) { hideDetails(); @@ -750,4 +753,11 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster } } } + + @Override + public void onAlbumModeSelected(int mode) { + if (mode == GalleryActionBar.ALBUM_FILMSTRIP_MODE_SELECTED) { + switchToFilmstrip(); + } + } } diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java index 2630c3e4a..f253c8c49 100644 --- a/src/com/android/gallery3d/app/GalleryActionBar.java +++ b/src/com/android/gallery3d/app/GalleryActionBar.java @@ -22,6 +22,8 @@ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.Resources; +import android.text.TextUtils.TruncateAt; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -53,10 +55,20 @@ public class GalleryActionBar implements OnNavigationListener { private int mCurrentIndex; private ClusterAdapter mAdapter = new ClusterAdapter(); + private AlbumModeAdapter mAlbumModeAdapter; + private OnAlbumModeSelectedListener mAlbumModeListener; + private CharSequence [] mAlbumModes; + public static final int ALBUM_FILMSTRIP_MODE_SELECTED = 0; + public static final int ALBUM_GRID_MODE_SELECTED = 1; + public interface ClusterRunner { public void doCluster(int id); } + public interface OnAlbumModeSelectedListener { + public void onAlbumModeSelected(int mode); + } + private static class ActionItem { public int action; public boolean enabled; @@ -123,6 +135,45 @@ public class GalleryActionBar implements OnNavigationListener { } } + private class AlbumModeAdapter extends BaseAdapter { + @Override + public int getCount() { + return mAlbumModes.length; + } + + @Override + public Object getItem(int position) { + return mAlbumModes[position]; + } + + @Override + public long getItemId(int position) { + return position; + } + + private View getView(CharSequence label, View convertView, + ViewGroup parent, boolean ellipsize) { + if (convertView == null) { + convertView = mInflater.inflate(R.layout.action_bar_text, + parent, false); + } + TextView view = (TextView) convertView; + view.setEllipsize(ellipsize ? TruncateAt.END : null); + view.setText(label); + return convertView; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + return getView(mActionBar.getTitle(), convertView, parent, true); + } + + @Override + public View getDropDownView(int position, View convertView, ViewGroup parent) { + return getView((CharSequence) getItem(position), convertView, parent, false); + } + } + public static String getClusterByTypeString(Context context, int type) { for (ActionItem item : sClusterItems) { if (item.action == type) { @@ -202,6 +253,33 @@ public class GalleryActionBar implements OnNavigationListener { } } + public void enableAlbumModeMenu(int selected, OnAlbumModeSelectedListener listener) { + if (mActionBar != null) { + if (mAlbumModeAdapter == null) { + // Initialize the album mode options if they haven't been already + Resources res = mActivity.getResources(); + mAlbumModes = new CharSequence[] { + res.getString(R.string.switch_photo_filmstrip), + res.getString(R.string.switch_photo_grid)}; + mAlbumModeAdapter = new AlbumModeAdapter(); + } + mAlbumModeListener = null; + mActionBar.setListNavigationCallbacks(mAlbumModeAdapter, this); + mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); + mActionBar.setSelectedNavigationItem(selected); + mAlbumModeListener = listener; + } + } + + public void disableAlbumModeMenu(boolean hideMenu) { + if (mActionBar != null) { + mAlbumModeListener = null; + if (hideMenu) { + mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); + } + } + } + public void showClusterDialog(final ClusterRunner clusterRunner) { createDialogData(); final ArrayList<Integer> actions = mActions; @@ -283,12 +361,17 @@ public class GalleryActionBar implements OnNavigationListener { @Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { - if (itemPosition != mCurrentIndex && mClusterRunner != null) { + if (itemPosition != mCurrentIndex && mClusterRunner != null + || mAlbumModeListener != null) { // Need to lock rendering when operations invoked by system UI (main thread) are // modifying slot data used in GL thread for rendering. mActivity.getGLRoot().lockRenderThread(); try { - mClusterRunner.doCluster(sClusterItems[itemPosition].action); + if (mAlbumModeListener != null) { + mAlbumModeListener.onAlbumModeSelected(itemPosition); + } else { + mClusterRunner.doCluster(sClusterItems[itemPosition].action); + } } finally { mActivity.getGLRoot().unlockRenderThread(); } diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 74dc7a95d..8c2319547 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -42,6 +42,7 @@ import com.android.gallery3d.R; import com.android.gallery3d.anim.FloatAnimation; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.Utils; +import com.android.gallery3d.data.ComboAlbum; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.FilterDeleteSet; import com.android.gallery3d.data.MediaDetails; @@ -78,7 +79,7 @@ import com.android.gallery3d.util.LightCycleHelper; public class PhotoPage extends ActivityState implements PhotoView.Listener, OrientationManager.Listener, AppBridge.Server, - PhotoPageBottomControls.Delegate { + PhotoPageBottomControls.Delegate, GalleryActionBar.OnAlbumModeSelectedListener { private static final String TAG = "PhotoPage"; private static final int MSG_HIDE_BARS = 1; @@ -88,9 +89,8 @@ public class PhotoPage extends ActivityState implements private static final int MSG_UPDATE_ACTION_BAR = 5; private static final int MSG_UNFREEZE_GLROOT = 6; private static final int MSG_WANT_BARS = 7; - private static final int MSG_REFRESH_GRID_BUTTON = 8; - private static final int MSG_REFRESH_BOTTOM_CONTROLS = 9; - private static final int MSG_ON_CAMERA_CENTER = 10; + private static final int MSG_REFRESH_BOTTOM_CONTROLS = 8; + private static final int MSG_ON_CAMERA_CENTER = 9; private static final int HIDE_BARS_TIMEOUT = 3500; private static final int UNFREEZE_GLROOT_TIMEOUT = 250; @@ -260,10 +260,6 @@ public class PhotoPage extends ActivityState implements hideBars(); break; } - case MSG_REFRESH_GRID_BUTTON: { - setGridButtonVisibility(mPhotoView.getFilmMode()); - break; - } case MSG_REFRESH_BOTTOM_CONTROLS: { if (mBottomControls != null) mBottomControls.refresh(); break; @@ -330,7 +326,6 @@ public class PhotoPage extends ActivityState implements mStartedFromAlbumPage = data.getInt(KEY_ALBUMPAGE_TRANSITION, MSG_ALBUMPAGE_NONE) == MSG_ALBUMPAGE_STARTED; - setGridButtonVisibility(!mStartedFromAlbumPage); if (mSetPathString != null) { mAppBridge = (AppBridge) data.getParcelable(KEY_APP_BRIDGE); if (mAppBridge != null) { @@ -375,6 +370,11 @@ public class PhotoPage extends ActivityState implements MediaSet originalSet = mActivity.getDataManager() .getMediaSet(mSetPathString); + if (originalSet instanceof ComboAlbum) { + // Use the name of the camera album rather than the default + // ComboAlbum behavior + ((ComboAlbum) originalSet).useNameOfChild(1); + } mSelectionManager.setSourceMediaSet(originalSet); mSetPathString = "/filter/delete/{" + mSetPathString + "}"; mMediaSet = (FilterDeleteSet) mActivity.getDataManager() @@ -591,7 +591,6 @@ public class PhotoPage extends ActivityState implements } updateMenuOperations(); - updateTitle(); if (mBottomControls != null) mBottomControls.refresh(); if (mShowDetails) { mDetailsHelper.reloadDetails(); @@ -602,25 +601,12 @@ public class PhotoPage extends ActivityState implements } } - private void updateTitle() { - if (mCurrentPhoto == null) return; - boolean showTitle = mActivity.getAndroidContext().getResources().getBoolean( - R.bool.show_action_bar_title); - if (showTitle && mCurrentPhoto.getName() != null) { - mActionBar.setTitle(mCurrentPhoto.getName()); - } else { - mActionBar.setTitle(""); - } - } - private void updateMenuOperations() { Menu menu = mActionBar.getMenu(); // it could be null if onCreateActionBar has not been called yet if (menu == null) return; - setGridButtonVisibility(mPhotoView.getFilmMode()); - MenuItem item = menu.findItem(R.id.action_slideshow); if (item != null) { item.setVisible((mSecureAlbum == null) && canDoSlideShow()); @@ -800,7 +786,7 @@ public class PhotoPage extends ActivityState implements mActionBar.createActionBarMenu(R.menu.photo, menu); mHaveImageEditor = GalleryUtils.isEditorAvailable(mActivity, "image/*"); updateMenuOperations(); - updateTitle(); + mActionBar.setTitle(mMediaSet != null ? mMediaSet.getName() : ""); return true; } @@ -826,6 +812,34 @@ public class PhotoPage extends ActivityState implements public void onProgressStart() {} }; + private void switchToGrid() { + if (mStartedFromAlbumPage) { + onUpPressed(); + } else { + if (mOriginalSetPathString == null) return; + preparePhotoFallbackView(); + Bundle data = new Bundle(getData()); + data.putString(AlbumPage.KEY_MEDIA_PATH, mOriginalSetPathString); + data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH, + mActivity.getDataManager().getTopSetPath( + DataManager.INCLUDE_ALL)); + + // We only show cluster menu in the first AlbumPage in stack + // TODO: Enable this when running from the camera app + boolean inAlbum = mActivity.getStateManager().hasStateClass(AlbumPage.class); + data.putBoolean(AlbumPage.KEY_SHOW_CLUSTER_MENU, !inAlbum + && mAppBridge == null); + + data.putBoolean(PhotoPage.KEY_APP_BRIDGE, mAppBridge != null); + + // Account for live preview being first item + mActivity.getTransitionStore().put(KEY_RETURN_INDEX_HINT, + mAppBridge != null ? mCurrentIndex - 1 : mCurrentIndex); + + mActivity.getStateManager().startState(AlbumPage.class, data); + } + } + @Override protected boolean onItemSelected(MenuItem item) { if (mModel == null) return true; @@ -848,33 +862,6 @@ public class PhotoPage extends ActivityState implements onUpPressed(); return true; } - case R.id.action_grid: { - if (mStartedFromAlbumPage) { - onUpPressed(); - } else { - preparePhotoFallbackView(); - Bundle data = new Bundle(getData()); - data.putString(AlbumPage.KEY_MEDIA_PATH, mOriginalSetPathString); - data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH, - mActivity.getDataManager().getTopSetPath( - DataManager.INCLUDE_ALL)); - - // We only show cluster menu in the first AlbumPage in stack - // TODO: Enable this when running from the camera app - boolean inAlbum = mActivity.getStateManager().hasStateClass(AlbumPage.class); - data.putBoolean(AlbumPage.KEY_SHOW_CLUSTER_MENU, !inAlbum - && mAppBridge == null); - - data.putBoolean(PhotoPage.KEY_APP_BRIDGE, mAppBridge != null); - - // Account for live preview being first item - mActivity.getTransitionStore().put(KEY_RETURN_INDEX_HINT, - mAppBridge != null ? mCurrentIndex - 1 : mCurrentIndex); - - mActivity.getStateManager().startState(AlbumPage.class, data); - } - return true; - } case R.id.action_slideshow: { Bundle data = new Bundle(); data.putString(SlideshowPage.KEY_SET_PATH, mMediaSet.getPath().toString()); @@ -1176,6 +1163,7 @@ public class PhotoPage extends ActivityState implements mPhotoView.pause(); mHandler.removeMessages(MSG_HIDE_BARS); mActionBar.removeOnMenuVisibilityListener(mMenuVisibilityListener); + mActionBar.disableAlbumModeMenu(true); onCommitDeleteImage(); mMenuExecutor.pause(); @@ -1187,15 +1175,7 @@ public class PhotoPage extends ActivityState implements mActivity.getGLRoot().unfreeze(); } - private void setGridButtonVisibility(boolean enabled) { - Menu menu = mActionBar.getMenu(); - if (menu == null) return; - MenuItem item = menu.findItem(R.id.action_grid); - if (item != null) item.setVisible((mSecureAlbum == null) && enabled); - } - public void onFilmModeChanged(boolean enabled) { - mHandler.sendEmptyMessage(MSG_REFRESH_GRID_BUTTON); mHandler.sendEmptyMessage(MSG_REFRESH_BOTTOM_CONTROLS); if (enabled) { mHandler.removeMessages(MSG_HIDE_BARS); @@ -1265,8 +1245,9 @@ public class PhotoPage extends ActivityState implements mModel.resume(); mPhotoView.resume(); mActionBar.setDisplayOptions( - ((mSecureAlbum == null) && (mSetPathString != null)), true); + ((mSecureAlbum == null) && (mSetPathString != null)), false); mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener); + mActionBar.enableAlbumModeMenu(GalleryActionBar.ALBUM_FILMSTRIP_MODE_SELECTED, this); if (!mShowBars) { mActionBar.hide(); mActivity.getGLRoot().setLightsOutMode(true); @@ -1317,4 +1298,11 @@ public class PhotoPage extends ActivityState implements return mModel.getCurrentIndex(); } } + + @Override + public void onAlbumModeSelected(int mode) { + if (mode == GalleryActionBar.ALBUM_GRID_MODE_SELECTED) { + switchToGrid(); + } + } } diff --git a/src/com/android/gallery3d/data/ComboAlbum.java b/src/com/android/gallery3d/data/ComboAlbum.java index e100dc3e6..cadd9f8af 100644 --- a/src/com/android/gallery3d/data/ComboAlbum.java +++ b/src/com/android/gallery3d/data/ComboAlbum.java @@ -27,7 +27,7 @@ public class ComboAlbum extends MediaSet implements ContentListener { @SuppressWarnings("unused") private static final String TAG = "ComboAlbum"; private final MediaSet[] mSets; - private final String mName; + private String mName; public ComboAlbum(Path path, MediaSet[] mediaSets, String name) { super(path, nextVersionNumber()); @@ -76,6 +76,10 @@ public class ComboAlbum extends MediaSet implements ContentListener { return mName; } + public void useNameOfChild(int i) { + if (i < mSets.length) mName = mSets[i].getName(); + } + @Override public long reload() { boolean changed = false; diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index eb95d7452..4570eb017 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -753,14 +753,14 @@ public class FilterShowActivity extends Activity implements OnItemClickListener mImageShow.setVisibility(View.VISIBLE); mImageShow.setShowControls(true); ImagePreset preset = mImageShow.getImagePreset(); - ImageFilter filter = preset.getFilter("Brightness"); + ImageFilter filter = preset.getFilter("Exposure"); if (filter == null) { - ImageFilterBrightness bright = new ImageFilterBrightness(); + ImageFilterExposure bright = new ImageFilterExposure(); ImagePreset copy = new ImagePreset(preset); copy.add(bright); copy.setHistoryName(bright.getName()); copy.setIsFx(false); - filter = copy.getFilter("Brightness"); + filter = copy.getFilter("Exposure"); mImageShow.setImagePreset(copy); } mImageShow.setCurrentFilter(filter); diff --git a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java index 19a841a4b..2c8fff9a2 100644 --- a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java +++ b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Vector; +import com.android.gallery3d.common.Utils; import com.android.gallery3d.filtershow.FilterShowActivity; import com.android.gallery3d.filtershow.HistoryAdapter; import com.android.gallery3d.filtershow.imageshow.ImageShow; @@ -17,6 +18,7 @@ import com.android.gallery3d.R; import android.content.Context; import android.content.res.Resources; import android.database.Cursor; +import android.database.sqlite.SQLiteException; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; @@ -58,11 +60,17 @@ public class ImageLoader { } private int getOrientation(Uri uri) { - Cursor cursor = mContext.getContentResolver().query(uri, - new String[] { - MediaStore.Images.ImageColumns.ORIENTATION - }, - null, null, null); + Cursor cursor = null; + try { + cursor = mContext.getContentResolver().query(uri, + new String[] { + MediaStore.Images.ImageColumns.ORIENTATION + }, + null, null, null); + } catch (SQLiteException e){ + Utils.closeSilently(cursor); + return ExifInterface.ORIENTATION_UNDEFINED; + } if (cursor.getCount() != 1) { return -1; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBrightness.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java index ab61a00c2..85b6e4f6b 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBrightness.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java @@ -3,14 +3,15 @@ package com.android.gallery3d.filtershow.filters; import android.graphics.Bitmap; -public class ImageFilterBrightness extends ImageFilter { +public class ImageFilterExposure extends ImageFilter { - public ImageFilterBrightness() { - mName = "Brightness"; + public ImageFilterExposure() { + mName = "Exposure"; } native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright); + @Override public void apply(Bitmap bitmap) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); diff --git a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java index ee5fe3dcb..1930e3877 100644 --- a/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java +++ b/src/com/android/gallery3d/ui/SurfaceTextureScreenNail.java @@ -60,6 +60,7 @@ public abstract class SurfaceTextureScreenNail implements ScreenNail, @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) private static void releaseSurfaceTexture(SurfaceTexture st) { + st.setOnFrameAvailableListener(null); if (ApiHelper.HAS_RELEASE_SURFACE_TEXTURE) { st.release(); } |