summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d')
-rw-r--r--src/com/android/gallery3d/app/GalleryActionBar.java20
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java52
-rw-r--r--src/com/android/gallery3d/data/LocalImage.java7
-rw-r--r--src/com/android/gallery3d/data/MediaObject.java1
-rw-r--r--src/com/android/gallery3d/ui/AbstractSlotRenderer.java8
-rw-r--r--src/com/android/gallery3d/ui/PhotoView.java15
-rw-r--r--src/com/android/gallery3d/ui/TextureUploader.java2
-rw-r--r--src/com/android/gallery3d/ui/TileImageView.java13
8 files changed, 74 insertions, 44 deletions
diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java
index 0f7579e60..0aac60e77 100644
--- a/src/com/android/gallery3d/app/GalleryActionBar.java
+++ b/src/com/android/gallery3d/app/GalleryActionBar.java
@@ -298,27 +298,27 @@ public class GalleryActionBar implements OnNavigationListener {
private Menu mActionBarMenu;
private MenuItem mShareMenuItem;
+ private Intent mShareIntent;
public void createActionBarMenu(int menuRes, Menu menu) {
mActivity.getSupportMenuInflater().inflate(menuRes, menu);
mActionBarMenu = menu;
mShareMenuItem = menu.findItem(R.id.action_share);
+ if (mShareMenuItem != null) {
+ ((ShareActionProvider) mShareMenuItem.getActionProvider())
+ .setShareIntent(mShareIntent);
+ }
}
public Menu getMenu() {
return mActionBarMenu;
}
- public boolean hasShareMenuItem() {
- return mShareMenuItem != null;
- }
-
public void setShareIntent(Intent shareIntent) {
- ((ShareActionProvider) mShareMenuItem.getActionProvider())
- .setShareIntent(shareIntent);
- }
-
- public MenuItem findMenuItem(int itemId) {
- return mActionBarMenu.findItem(itemId);
+ mShareIntent = shareIntent;
+ if (mShareMenuItem != null) {
+ ((ShareActionProvider) mShareMenuItem.getActionProvider())
+ .setShareIntent(shareIntent);
+ }
}
}
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index b50f0b762..d101aac7b 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -37,9 +37,11 @@ import com.actionbarsherlock.view.MenuItem;
import com.android.gallery3d.R;
import com.android.gallery3d.anim.FloatAnimation;
import com.android.gallery3d.common.ApiHelper;
+import com.android.gallery3d.common.LightCycleHelper;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.FilterDeleteSet;
+import com.android.gallery3d.data.LocalImage;
import com.android.gallery3d.data.MediaDetails;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
@@ -53,13 +55,13 @@ import com.android.gallery3d.data.SnailItem;
import com.android.gallery3d.data.SnailSource;
import com.android.gallery3d.picasasource.PicasaSource;
import com.android.gallery3d.ui.AnimationTime;
+import com.android.gallery3d.ui.BitmapScreenNail;
import com.android.gallery3d.ui.DetailsHelper;
import com.android.gallery3d.ui.DetailsHelper.CloseListener;
import com.android.gallery3d.ui.DetailsHelper.DetailsSource;
import com.android.gallery3d.ui.GLCanvas;
import com.android.gallery3d.ui.GLRoot;
import com.android.gallery3d.ui.GLRoot.OnGLIdleListener;
-import com.android.gallery3d.ui.BitmapScreenNail;
import com.android.gallery3d.ui.GLView;
import com.android.gallery3d.ui.ImportCompleteListener;
import com.android.gallery3d.ui.MenuExecutor;
@@ -108,7 +110,6 @@ public class PhotoPage extends ActivityState implements
private PhotoPage.Model mModel;
private DetailsHelper mDetailsHelper;
private boolean mShowDetails;
- private Path mPendingSharePath;
// mMediaSet could be null if there is no KEY_MEDIA_SET_PATH supplied.
// E.g., viewing a photo in gmail attachment
@@ -183,15 +184,15 @@ public class PhotoPage extends ActivityState implements
private final GLView mRootPane = new GLView() {
@Override
protected void renderBackground(GLCanvas view) {
- if(mFadeOutTexture != null) {
- if(mBackgroundFade.calculate(AnimationTime.get())) invalidate();
- if(!mBackgroundFade.isActive()) {
+ if (mFadeOutTexture != null) {
+ if (mBackgroundFade.calculate(AnimationTime.get())) invalidate();
+ if (!mBackgroundFade.isActive()) {
mFadeOutTexture = null;
mOpenAnimationRect = null;
BitmapScreenNail.enableDrawPlaceholder();
} else {
float fadeAlpha = mBackgroundFade.get();
- if(fadeAlpha < 1f) {
+ if (fadeAlpha < 1f) {
view.clearBuffer(getBackgroundColor());
view.setAlpha(fadeAlpha);
}
@@ -225,7 +226,7 @@ public class PhotoPage extends ActivityState implements
mPhotoView = new PhotoView(mActivity);
mPhotoView.setListener(this);
mRootPane.addComponent(mPhotoView);
- mApplication = (GalleryApp)((Activity) mActivity).getApplication();
+ mApplication = (GalleryApp) ((Activity) mActivity).getApplication();
mOrientationManager = mActivity.getOrientationManager();
mOrientationManager.addListener(this);
mActivity.getGLRoot().setOrientationSource(mOrientationManager);
@@ -365,7 +366,7 @@ public class PhotoPage extends ActivityState implements
// start the opening animation only if it's not restored.
if (restoreState == null) {
mFadeOutTexture = mActivity.getTransitionStore().get(AlbumPage.KEY_FADE_TEXTURE);
- if(mFadeOutTexture != null) {
+ if (mFadeOutTexture != null) {
mBackgroundFade.start();
BitmapScreenNail.disableDrawPlaceholder();
mOpenAnimationRect = (Rect) data.getParcelable(KEY_OPEN_ANIMATION_RECT);
@@ -377,7 +378,7 @@ public class PhotoPage extends ActivityState implements
@TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
private void setNfcBeamPushUris(Uri[] uris) {
if (mNfcAdapter != null && ApiHelper.HAS_SET_BEAM_PUSH_URIS) {
- mNfcAdapter.setBeamPushUris(uris, (Activity)mActivity);
+ mNfcAdapter.setBeamPushUris(uris, mActivity);
}
}
@@ -393,16 +394,10 @@ public class PhotoPage extends ActivityState implements
}
private void updateShareURI(Path path) {
- if (mActionBar.hasShareMenuItem()) {
- DataManager manager = mActivity.getDataManager();
- Uri uri = manager.getContentUri(path);
- mActionBar.setShareIntent(createShareIntent(path));
- setNfcBeamPushUris(new Uri[]{uri});
- mPendingSharePath = null;
- } else {
- // This happens when ActionBar is not created yet.
- mPendingSharePath = path;
- }
+ DataManager manager = mActivity.getDataManager();
+ Uri uri = manager.getContentUri(path);
+ mActionBar.setShareIntent(createShareIntent(path));
+ setNfcBeamPushUris(new Uri[]{uri});
}
private void updateCurrentPhoto(MediaItem photo) {
@@ -432,16 +427,22 @@ public class PhotoPage extends ActivityState implements
}
private void updateMenuOperations() {
- MenuItem item = mActionBar.findMenuItem(R.id.action_slideshow);
+ Menu menu = mActionBar.getMenu();
+
+ // it could be null if onCreateActionBar has not been called yet
+ if (menu == null) return;
+
+ MenuItem item = menu.findItem(R.id.action_slideshow);
item.setVisible((mSecureAlbum == null) && canDoSlideShow());
if (mCurrentPhoto == null) return;
+
int supportedOperations = mCurrentPhoto.getSupportedOperations();
if (mSecureAlbum != null) {
- supportedOperations = supportedOperations & MediaObject.SUPPORT_DELETE;
+ supportedOperations &= MediaObject.SUPPORT_DELETE;
} else if (!GalleryUtils.isEditorAvailable(mActivity, "image/*")) {
supportedOperations &= ~MediaObject.SUPPORT_EDIT;
}
- MenuExecutor.updateMenuOperation(mActionBar.getMenu(), supportedOperations);
+ MenuExecutor.updateMenuOperation(menu, supportedOperations);
}
private boolean canDoSlideShow() {
@@ -600,7 +601,6 @@ public class PhotoPage extends ActivityState implements
@Override
protected boolean onCreateActionBar(Menu menu) {
mActionBar.createActionBarMenu(R.menu.photo, menu);
- if (mPendingSharePath != null) updateShareURI(mPendingSharePath);
updateMenuOperations();
updateTitle();
return true;
@@ -753,6 +753,8 @@ public class PhotoPage extends ActivityState implements
boolean playVideo = (mSecureAlbum == null) &&
((item.getSupportedOperations() & MediaItem.SUPPORT_PLAY) != 0);
+ boolean viewPanorama =
+ (item.getSupportedOperations() & MediaItem.SUPPORT_VIEW_PANORAMA) != 0;
if (playVideo) {
// determine if the point is at center (1/6) of the photo view.
@@ -765,6 +767,10 @@ public class PhotoPage extends ActivityState implements
if (playVideo) {
playVideo(mActivity, item.getPlayUri(), item.getName());
+ } else if (viewPanorama) {
+ LocalImage img = (LocalImage) item;
+ LightCycleHelper.viewPanorama(
+ mActivity, img.getContentUri(), img.getMimeType());
} else {
toggleBars();
}
diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java
index b10b96289..93287bca1 100644
--- a/src/com/android/gallery3d/data/LocalImage.java
+++ b/src/com/android/gallery3d/data/LocalImage.java
@@ -34,6 +34,7 @@ import android.util.Log;
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.BitmapUtils;
+import com.android.gallery3d.common.LightCycleHelper;
import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.ThreadPool.Job;
import com.android.gallery3d.util.ThreadPool.JobContext;
@@ -239,6 +240,12 @@ public class LocalImage extends LocalMediaItem {
if (GalleryUtils.isValidLocation(latitude, longitude)) {
operation |= SUPPORT_SHOW_ON_MAP;
}
+
+ if (LightCycleHelper.isPanorama(caption) &&
+ LightCycleHelper.hasLightCycleView(
+ mApplication.getAndroidContext().getPackageManager())) {
+ operation |= SUPPORT_VIEW_PANORAMA;
+ }
return operation;
}
diff --git a/src/com/android/gallery3d/data/MediaObject.java b/src/com/android/gallery3d/data/MediaObject.java
index 45f425fdd..87f567d7a 100644
--- a/src/com/android/gallery3d/data/MediaObject.java
+++ b/src/com/android/gallery3d/data/MediaObject.java
@@ -37,6 +37,7 @@ public abstract class MediaObject {
public static final int SUPPORT_INFO = 1 << 10;
public static final int SUPPORT_IMPORT = 1 << 11;
public static final int SUPPORT_TRIM = 1 << 12;
+ public static final int SUPPORT_VIEW_PANORAMA = 1 << 13;
public static final int SUPPORT_ALL = 0xffffffff;
// These are the bits returned from getMediaType():
diff --git a/src/com/android/gallery3d/ui/AbstractSlotRenderer.java b/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
index 98eae568b..c36847d69 100644
--- a/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
@@ -42,15 +42,13 @@ public abstract class AbstractSlotRenderer implements SlotView.SlotRenderer {
Texture content, int width, int height, int rotation) {
canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
+ // The content is always rendered in to the largest square that fits
+ // inside the slot, aligned to the top of the slot.
+ width = height = Math.min(width, height);
if (rotation != 0) {
canvas.translate(width / 2, height / 2);
canvas.rotate(rotation, 0, 0, 1);
canvas.translate(-width / 2, -height / 2);
- if (((rotation % 90) & 1) != 0) {
- int temp = height;
- height = width;
- width = height;
- }
}
// Fit the content into the box
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index 25d3154a9..5c4c1e970 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -21,6 +21,7 @@ import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.Rect;
+import android.os.Build;
import android.os.Message;
import android.util.FloatMath;
import android.view.MotionEvent;
@@ -29,6 +30,7 @@ import android.view.animation.AccelerateInterpolator;
import com.android.gallery3d.R;
import com.android.gallery3d.app.AbstractGalleryActivity;
+import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
@@ -945,6 +947,19 @@ public class PhotoView extends GLView {
@Override
public boolean onSingleTapUp(float x, float y) {
+ // On crespo running Android 2.3.6 (gingerbread), a pinch out gesture results in the
+ // following call sequence: onDown(), onUp() and then onSingleTapUp(). The correct
+ // sequence for a single-tap-up gesture should be: onDown(), onSingleTapUp() and onUp().
+ // The call sequence for a pinch out gesture in JB is: onDown(), then onUp() and there's
+ // no onSingleTapUp(). Base on these observations, the following condition is added to
+ // filter out the false alarm where onSingleTapUp() is called within a pinch out
+ // gesture. The framework fix went into ICS. Refer to b/4588114.
+ if (Build.VERSION.SDK_INT < ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ if ((mHolding & HOLD_TOUCH_DOWN) == 0) {
+ return true;
+ }
+ }
+
// We do this in addition to onUp() because we want the snapback of
// setFilmMode to happen.
mHolding &= ~HOLD_TOUCH_DOWN;
diff --git a/src/com/android/gallery3d/ui/TextureUploader.java b/src/com/android/gallery3d/ui/TextureUploader.java
index 714b09795..9a8c47fc6 100644
--- a/src/com/android/gallery3d/ui/TextureUploader.java
+++ b/src/com/android/gallery3d/ui/TextureUploader.java
@@ -29,7 +29,7 @@ public class TextureUploader implements OnGLIdleListener {
private final ArrayDeque<UploadedTexture> mBgTextures =
new ArrayDeque<UploadedTexture>(INIT_CAPACITY);
private final GLRoot mGLRoot;
- private transient boolean mIsQueued = false;
+ private volatile boolean mIsQueued = false;
public TextureUploader(GLRoot root) {
mGLRoot = root;
diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java
index fc61efd64..9eb4f4787 100644
--- a/src/com/android/gallery3d/ui/TileImageView.java
+++ b/src/com/android/gallery3d/ui/TileImageView.java
@@ -270,6 +270,7 @@ public class TileImageView extends GLView {
protected synchronized void invalidateTiles() {
mDecodeQueue.clean();
mUploadQueue.clean();
+
// TODO disable decoder
int n = mActiveTiles.size();
for (int i = 0; i < n; i++) {
@@ -553,21 +554,23 @@ public class TileImageView extends GLView {
@Override
public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) {
- if (renderRequested) return false;
+ // Skips uploading if there is a pending rendering request.
+ // Returns true to keep uploading in next rendering loop.
+ if (renderRequested) return true;
int quota = UPLOAD_LIMIT;
- Tile tile;
- while (true) {
+ Tile tile = null;
+ while (quota > 0) {
synchronized (TileImageView.this) {
tile = mUploadQueue.pop();
}
- if (tile == null || quota <= 0) break;
+ if (tile == null) break;
if (!tile.isContentValid()) {
Utils.assertTrue(tile.mTileState == STATE_DECODED);
tile.updateContent(canvas);
--quota;
}
}
- mActive.set(tile != null);
+ if (tile == null) mActive.set(false);
return tile != null;
}
}