}
@Override
+ public void onReload() {
+ setPreviewControlsVisibility(true);
+ }
+
+ @Override
+ public void onCurrentDataCentered(int dataID) {
+ if (dataID != 0 && !mFilmStripView.isCameraPreview()) {
+ // For now, We ignore all items that are not the camera preview.
+ return;
+ }
+
+ if(!arePreviewControlsVisible()) {
+ setPreviewControlsVisibility(true);
+ }
+ }
+
+ @Override
+ public void onCurrentDataOffCentered(int dataID) {
+ if (dataID != 0 && !mFilmStripView.isCameraPreview()) {
+ // For now, We ignore all items that are not the camera preview.
+ return;
+ }
+
+ if (arePreviewControlsVisible()) {
+ setPreviewControlsVisibility(false);
+ }
+ }
+
+ @Override
public void onDataFocusChanged(final int dataID, final boolean focused) {
// Delay hiding action bar if there is any user interaction
if (mMainHandler.hasMessages(HIDE_ACTION_BAR)) {
hidePanoStitchingProgress();
} else {
if (isCameraID) {
- mCurrentModule.onPreviewFocusChanged(true);
// Don't show the action bar in Camera
// preview.
CameraActivity.this.setSystemBarsVisibility(false);
+
if (mPendingDeletion) {
performDeletion();
}
}
}
+
+ /**
+ * Check whether camera controls are visible.
+ *
+ * @return whether controls are visible.
+ */
+ private boolean arePreviewControlsVisible() {
+ return mCurrentModule.arePreviewControlsVisible();
+ }
+
+ /**
+ * Show or hide the {@link CameraControls} using the current module's
+ * implementation of {@link #onPreviewFocusChanged}.
+ *
+ * @param showControls whether to show camera controls.
+ */
+ private void setPreviewControlsVisibility(boolean showControls) {
+ mCurrentModule.onPreviewFocusChanged(showControls);
+ }
+
// Accessor methods for getting latency times used in performance testing
public long getAutoFocusTime() {
return (mCurrentModule instanceof PhotoModule) ?
public void onShowSwitcherPopup();
public void onMediaSaveServiceConnected(MediaSaveService s);
+
+ public boolean arePreviewControlsVisible();
}
mUI.onPreviewFocusChanged(previewFocused);
}
+ @Override
+ public boolean arePreviewControlsVisible() {
+ return mUI.arePreviewControlsVisible();
+ }
+
// For debugging only.
public void setDebugUri(Uri uri) {
mDebugUri = uri;
mCameraControls.setVisibility(View.VISIBLE);
}
+ public boolean arePreviewControlsVisible() {
+ return (mCameraControls.getVisibility() == View.VISIBLE);
+ }
+
public void hideSwitcher() {
mSwitcher.closePopup();
mSwitcher.setVisibility(View.INVISIBLE);
forceFlashOff(!previewFocused);
}
+ @Override
+ public boolean arePreviewControlsVisible() {
+ return mUI.arePreviewControlsVisible();
+ }
+
private final class JpegPictureCallback implements CameraPictureCallback {
Location mLocation;
mCameraControls.setVisibility(View.VISIBLE);
}
+ public boolean arePreviewControlsVisible() {
+ return (mCameraControls.getVisibility() == View.VISIBLE);
+ }
+
public void hideSwitcher() {
mSwitcher.closePopup();
mSwitcher.setVisibility(View.INVISIBLE);
private OrientationManager mOrientationManager;
private ComboPreferences mPreferences;
private boolean mMosaicPreviewConfigured;
+ private boolean mPreviewFocused;
@Override
public void onPreviewUIReady() {
@Override
public void onPreviewFocusChanged(boolean previewFocused) {
- if (previewFocused) {
- mUI.showUI();
- } else {
- mUI.hideUI();
- }
+ mPreviewFocused = previewFocused;
+ mUI.onPreviewFocusChanged(previewFocused);
+ }
+
+ @Override
+ public boolean arePreviewControlsVisible() {
+ return mUI.arePreviewControlsVisible();
}
/**
mActivity.setSwipingEnabled(true);
// Orientation change will trigger onLayoutChange->configMosaicPreview->
// resetToPreview. Do not show the capture UI in film strip.
- mUI.showPreviewUI();
+ if (mPreviewFocused) {
+ mUI.showPreviewUI();
+ }
mMosaicFrameProcessor.reset();
}
mCameraControls.setVisibility(View.VISIBLE);
}
+ public void onPreviewFocusChanged(boolean previewFocused) {
+ if (previewFocused) {
+ showUI();
+ } else {
+ hideUI();
+ }
+ }
+
+ public boolean arePreviewControlsVisible() {
+ return (mCameraControls.getVisibility() == View.VISIBLE);
+ }
+
public void showSwitcher() {
mSwitcher.setVisibility(View.VISIBLE);
}
public void onDataFullScreenChange(int dataID, boolean fullScreen);
/**
+ * Called by {@link reload}.
+ */
+ public void onReload();
+
+ /**
+ * Called by {@link checkCurrentDataCentered} when the
+ * data is centered in the film strip.
+ *
+ * @param dataID the ID of the local data
+ */
+ public void onCurrentDataCentered(int dataID);
+
+ /**
+ * Called by {@link checkCurrentDataCentered} when the
+ * data is off centered in the film strip.
+ *
+ * @param dataID the ID of the local data
+ */
+ public void onCurrentDataOffCentered(int dataID);
+
+ /**
* The callback when the item is centered/off-centered.
*
* @param dataID The ID of the image data.
* @param id The id of the data to check.
* @return {@code True} if the data is currently at the center.
*/
- protected boolean isDataAtCenter(int id) {
+ private boolean isDataAtCenter(int id) {
if (mViewItem[mCurrentItem] == null) {
return false;
}
if (nearest == BUFFER_SIZE) {
return -1;
}
+
int min = Math.abs(pointX - mViewItem[nearest].getCenterX());
for (int itemID = nearest + 1; itemID < BUFFER_SIZE && mViewItem[itemID] != null; itemID++) {
if (stopScroll) {
mCenterX = curr.getCenterX();
}
+
return stopScroll;
}
/**
+ * Checks if the item is centered in the film strip, and calls
+ * {@link #onCurrentDataCentered} or {@link #onCurrentDataOffCentered}.
+ * TODO: refactor.
+ *
+ * @param dataID the ID of the image data.
+ */
+ private void checkCurrentDataCentered(int dataID) {
+ if (mListener != null) {
+ if (isDataAtCenter(dataID)) {
+ mListener.onCurrentDataCentered(dataID);
+ } else {
+ mListener.onCurrentDataOffCentered(dataID);
+ }
+ }
+ }
+
+ /**
* Reorders the child views to be consistent with their data ID. This
* method should be called after adding/removing views.
*/
return (mScale == FULL_SCREEN_SCALE);
}
+ public boolean isCameraPreview() {
+ return (getCurrentViewType() == ImageData.VIEW_TYPE_STICKY);
+ }
+
public boolean inCameraFullscreen() {
return isDataAtCenter(0) && inFullScreen()
&& (getCurrentViewType() == ImageData.VIEW_TYPE_STICKY);
}
newItem.copyGeometry(item);
mViewItem[itemID] = newItem;
- if (clampCenterX()) {
+
+ boolean stopScroll = clampCenterX();
+ checkCurrentDataCentered(getCurrentId());
+ if (stopScroll) {
mController.stopScrolling(true);
}
adjustChildZOrder();
invalidate();
if (mListener != null) {
+ mListener.onReload();
mListener.onDataFocusChanged(mViewItem[mCurrentItem].getId(), true);
}
}
@Override
public void onScrollUpdate(int currX, int currY) {
mCenterX = currX;
- if (clampCenterX()) {
+
+ boolean stopScroll = clampCenterX();
+ checkCurrentDataCentered(getCurrentId());
+ if (stopScroll) {
mController.stopScrolling(true);
}
invalidate();
return;
}
mCenterX += deltaX;
- if (clampCenterX()) {
+
+ boolean stopScroll = clampCenterX();
+ checkCurrentDataCentered(getCurrentId());
+ if (stopScroll) {
mController.stopScrolling(true);
}
invalidate();
mCanStopScroll = interruptible;
mScroller.startScroll(mCenterX, 0, position - mCenterX,
0, duration);
+
+ checkCurrentDataCentered(mViewItem[mCurrentItem].getId());
}
@Override