private float mUserDistance; // in pixel
private Future<Integer> mSyncTask = null;
private boolean mLaunchedFromPhotoPage;
+ private boolean mInCameraApp;
private int mLoadingBits = 0;
private boolean mInitialSynced = false;
} else if (mSelectionManager.inSelectionMode()) {
mSelectionManager.leaveSelectionMode();
} else {
+ if(mLaunchedFromPhotoPage) {
+ mActivity.getTransitionStore().putIfNotPresent(
+ PhotoPage.KEY_ALBUMPAGE_TRANSITION,
+ PhotoPage.MSG_ALBUMPAGE_RESUMED);
+ }
// TODO: fix this regression
// mAlbumView.savePositions(PositionRepository.getInstance(mActivity));
onUpPressed();
mLaunchedFromPhotoPage =
mActivity.getStateManager().hasStateClass(PhotoPage.class);
+ mInCameraApp = data.getBoolean(PhotoPage.KEY_APP_BRIDGE, false);
// Don't show animation if it is restored or switched from filmstrip
if (!mLaunchedFromPhotoPage && restoreState == null && data != null) {
clearLoadingBit(BIT_LOADING_SYNC);
}
mActionModeHandler.pause();
+
+ // The camera app should always launch in capture mode when
+ // resumed, so make the next resume faster by closing the grid
+ // view now
+ if (mInCameraApp) {
+ if (mActivity.getStateManager().getTopState() == this)
+ mActivity.getStateManager().finishState(this);
+ }
}
@Override
private void prepareAnimationBackToFilmstrip(int slotIndex) {
if (mAlbumDataAdapter == null || !mAlbumDataAdapter.isActive(slotIndex)) return;
+ MediaItem item = mAlbumDataAdapter.get(slotIndex);
+ if (item == null) return;
PreparePageFadeoutTexture.prepareFadeOutTexture(mActivity, mRootPane);
TransitionStore transitions = mActivity.getTransitionStore();
transitions.put(PhotoPage.KEY_INDEX_HINT, slotIndex);
- transitions.put(PhotoPage.KEY_MEDIA_ITEM_PATH,
- mAlbumDataAdapter.get(slotIndex).getPath());
transitions.put(PhotoPage.KEY_OPEN_ANIMATION_RECT,
mSlotView.getSlotRect(slotIndex, mRootPane));
}
int targetPhoto = mSlotView.getVisibleStart();
prepareAnimationBackToFilmstrip(targetPhoto);
if(mLaunchedFromPhotoPage) {
- mActivity.getTransitionStore().put(
- PhotoPage.KEY_ALBUMPAGE_TRANSITION,
- PhotoPage.MSG_ALBUMPAGE_RESUMED);
onBackPressed();
} else {
pickPhoto(targetPhoto, true);
if (mSetPathString != null) {
mAppBridge = (AppBridge) data.getParcelable(KEY_APP_BRIDGE);
if (mAppBridge != null) {
- mFlags |= FLAG_HIDE_ACTION_BAR | FLAG_HIDE_STATUS_BAR;
mShowBars = false;
mAppBridge.setServer(this);
@Override
public void onPhotoChanged(int index, Path item) {
+ int oldIndex = mCurrentIndex;
mCurrentIndex = index;
if (item != null) {
MediaItem photo = mModel.getMediaItem(0);
if (photo != null) updateCurrentPhoto(photo);
}
+ if (mAppBridge != null) {
+ if (oldIndex == 0 && mCurrentIndex > 0
+ && !mPhotoView.getFilmMode()) {
+ mPhotoView.setFilmMode(true);
+ }
+ }
updateBars();
+
+ // Reset the timeout for the bars after a swipe
+ refreshHidingMessage();
}
@Override
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);
- mActivity.getTransitionStore().put(
- KEY_RETURN_INDEX_HINT, mCurrentIndex);
+ 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;
private void transitionFromAlbumPageIfNeeded() {
TransitionStore transitions = mActivity.getTransitionStore();
- int resumeIndex = transitions.get(KEY_INDEX_HINT, -1);
- if (resumeIndex >= 0) {
- mCurrentIndex = resumeIndex;
- mModel.setCurrentPhoto((Path)transitions.get(KEY_MEDIA_SET_PATH), mCurrentIndex);
- mPhotoView.switchToImage(mCurrentIndex);
- }
-
int albumPageTransition = transitions.get(
KEY_ALBUMPAGE_TRANSITION, MSG_ALBUMPAGE_NONE);
- if(albumPageTransition != MSG_ALBUMPAGE_NONE) {
- mPhotoView.setFilmMode(mStartInFilmstrip
- && albumPageTransition == MSG_ALBUMPAGE_RESUMED);
+ if (albumPageTransition == MSG_ALBUMPAGE_NONE && mAppBridge != null) {
+ // Generally, resuming the PhotoPage when in Camera should
+ // reset to the capture mode to allow quick photo taking
+ mCurrentIndex = 0;
+ mPhotoView.resetToFirstPicture();
+ } else {
+ int resumeIndex = transitions.get(KEY_INDEX_HINT, -1);
+ if (resumeIndex >= 0) {
+ if (mAppBridge != null) {
+ // Account for live preview being the first item
+ resumeIndex++;
+ }
+ if (resumeIndex < mMediaSet.getMediaItemCount()) {
+ mCurrentIndex = resumeIndex;
+ mModel.moveTo(mCurrentIndex);
+ }
+ }
+ }
+
+ if (albumPageTransition == MSG_ALBUMPAGE_RESUMED) {
+ mPhotoView.setFilmMode(mStartInFilmstrip || mAppBridge != null);
+ } else if (albumPageTransition == MSG_ALBUMPAGE_PICKED) {
+ mPhotoView.setFilmMode(false);
}
mFadeOutTexture = transitions.get(PreparePageFadeoutTexture.KEY_FADE_TEXTURE);
mActionBar.setDisplayOptions(
((mSecureAlbum == null) && (mSetPathString != null)), true);
mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener);
-
- if (mAppBridge != null && !mHasActivityResult) {
- mPhotoView.resetToFirstPicture();
+ if (!mShowBars) {
+ mActionBar.hide();
+ mActivity.getGLRoot().setLightsOutMode(true);
}
+
mHasActivityResult = false;
mHandler.sendEmptyMessageDelayed(MSG_UNFREEZE_GLROOT, UNFREEZE_GLROOT_TIMEOUT);
}
mStorage.put(key, value);
}
+ public <T> void putIfNotPresent(Object key, T valueIfNull) {
+ mStorage.put(key, get(key, valueIfNull));
+ }
+
@SuppressWarnings("unchecked")
public <T> T get(Object key) {
return (T) mStorage.get(key);
private boolean mIsDeletable;
private int mLoadingState = Model.LOADING_INIT;
private Size mSize = new Size();
- private boolean mWasCameraCenter;
@Override
public void reload() {
mSize.height = getRotated(mRotation, h, w);
}
- private boolean mNeedToChangeToFilmstripWhenCentered = false;
@Override
public void draw(GLCanvas canvas, Rect r) {
drawTileView(canvas, r);
boolean isCenter = mPositionController.isCenter();
boolean isCameraCenter = mIsCamera && isCenter && !canUndoLastPicture();
- if (mWasCameraCenter && mIsCamera && !isCenter && !mFilmMode) {
- setFilmMode(false);
- mNeedToChangeToFilmstripWhenCentered = true;
- } else if (isCenter && mNeedToChangeToFilmstripWhenCentered) {
- setFilmMode(true);
- mNeedToChangeToFilmstripWhenCentered = false;
- }
- /*
- TODO: Come out of film mode if it was a short swipe rather than a fling
- else if (!mWasCameraCenter && isCameraCenter && mFilmMode) {
- setFilmMode(false);
- }
- */
-
if (isCameraCenter && !mFilmMode) {
// Move into camera in page mode, lock
mListener.lockOrientation();
}
-
- mWasCameraCenter = isCameraCenter;
}
@Override
mGestureListener.setSwipingEnabled(enabled);
}
+ private void updateActionBar() {
+ boolean isCamera = mPictures.get(0).isCamera();
+ if (isCamera && !mFilmMode) {
+ // Move into camera in page mode, lock
+ mListener.lockOrientation();
+ mListener.onActionBarAllowed(false);
+ } else {
+ mListener.onActionBarAllowed(true);
+ if (mFilmMode) mListener.onActionBarWanted();
+ }
+ }
+
public void setFilmMode(boolean enabled) {
if (mFilmMode == enabled) return;
mFilmMode = enabled;
mModel.setNeedFullImage(!enabled);
mModel.setFocusHintDirection(
mFilmMode ? Model.FOCUS_HINT_PREVIOUS : Model.FOCUS_HINT_NEXT);
+ updateActionBar();
mListener.onFilmModeChanged(enabled);
- boolean isCamera = mPictures.get(0).isCamera();
- if (isCamera && !enabled) {
- // Move into camera in page mode, lock
- mListener.lockOrientation();
- mListener.onActionBarAllowed(false);
- } else {
- mListener.onActionBarAllowed(true);
- if (enabled) mListener.onActionBarWanted();
- }
}
public boolean getFilmMode() {
// move to the camera preview and show controls after resume
public void resetToFirstPicture() {
mModel.moveTo(0);
- mListener.onActionBarAllowed(false);
setFilmMode(false);
}