summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/camera/CameraActivity.java51
-rw-r--r--src/com/android/camera/CameraModule.java2
-rw-r--r--src/com/android/camera/PhotoModule.java5
-rw-r--r--src/com/android/camera/PhotoUI.java4
-rw-r--r--src/com/android/camera/VideoModule.java5
-rw-r--r--src/com/android/camera/VideoUI.java4
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java17
-rw-r--r--src/com/android/camera/WideAnglePanoramaUI.java12
-rw-r--r--src/com/android/camera/ui/FilmStripView.java64
9 files changed, 153 insertions, 11 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 52d0e4d47..ab46e0268 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -334,6 +334,35 @@ public class CameraActivity extends Activity
}
@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)) {
@@ -363,10 +392,10 @@ public class CameraActivity extends Activity
hidePanoStitchingProgress();
} else {
if (isCameraID) {
- mCurrentModule.onPreviewFocusChanged(true);
// Don't show the action bar in Camera
// preview.
CameraActivity.this.setSystemBarsVisibility(false);
+
if (mPendingDeletion) {
performDeletion();
}
@@ -1449,6 +1478,26 @@ public class CameraActivity extends Activity
}
}
+
+ /**
+ * 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) ?
diff --git a/src/com/android/camera/CameraModule.java b/src/com/android/camera/CameraModule.java
index 1283a982c..55cae9f0c 100644
--- a/src/com/android/camera/CameraModule.java
+++ b/src/com/android/camera/CameraModule.java
@@ -64,4 +64,6 @@ public interface CameraModule {
public void onShowSwitcherPopup();
public void onMediaSaveServiceConnected(MediaSaveService s);
+
+ public boolean arePreviewControlsVisible();
}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 8699ef092..bed8a2149 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1944,6 +1944,11 @@ public class PhotoModule
mUI.onPreviewFocusChanged(previewFocused);
}
+ @Override
+ public boolean arePreviewControlsVisible() {
+ return mUI.arePreviewControlsVisible();
+ }
+
// For debugging only.
public void setDebugUri(Uri uri) {
mDebugUri = uri;
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 9273e21fd..58df43657 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -398,6 +398,10 @@ public class PhotoUI implements PieListener,
mCameraControls.setVisibility(View.VISIBLE);
}
+ public boolean arePreviewControlsVisible() {
+ return (mCameraControls.getVisibility() == View.VISIBLE);
+ }
+
public void hideSwitcher() {
mSwitcher.closePopup();
mSwitcher.setVisibility(View.INVISIBLE);
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 83c5faf18..296385e53 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1717,6 +1717,11 @@ public class VideoModule implements CameraModule,
forceFlashOff(!previewFocused);
}
+ @Override
+ public boolean arePreviewControlsVisible() {
+ return mUI.arePreviewControlsVisible();
+ }
+
private final class JpegPictureCallback implements CameraPictureCallback {
Location mLocation;
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index f097d9344..23d08dbb4 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -345,6 +345,10 @@ public class VideoUI implements PieRenderer.PieListener,
mCameraControls.setVisibility(View.VISIBLE);
}
+ public boolean arePreviewControlsVisible() {
+ return (mCameraControls.getVisibility() == View.VISIBLE);
+ }
+
public void hideSwitcher() {
mSwitcher.closePopup();
mSwitcher.setVisibility(View.INVISIBLE);
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index 189bf99d1..f91b41e04 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -144,6 +144,7 @@ public class WideAnglePanoramaModule
private OrientationManager mOrientationManager;
private ComboPreferences mPreferences;
private boolean mMosaicPreviewConfigured;
+ private boolean mPreviewFocused;
@Override
public void onPreviewUIReady() {
@@ -308,11 +309,13 @@ public class WideAnglePanoramaModule
@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();
}
/**
@@ -705,7 +708,9 @@ public class WideAnglePanoramaModule
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();
}
diff --git a/src/com/android/camera/WideAnglePanoramaUI.java b/src/com/android/camera/WideAnglePanoramaUI.java
index 407160933..cf2c39847 100644
--- a/src/com/android/camera/WideAnglePanoramaUI.java
+++ b/src/com/android/camera/WideAnglePanoramaUI.java
@@ -137,6 +137,18 @@ public class WideAnglePanoramaUI implements
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);
}
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index 5de2d7cff..d17567d52 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -340,6 +340,27 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
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.
@@ -712,7 +733,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
* @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;
}
@@ -826,6 +847,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
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++) {
@@ -961,10 +983,28 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
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.
*/
@@ -1688,6 +1728,10 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
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);
@@ -1758,7 +1802,10 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
}
newItem.copyGeometry(item);
mViewItem[itemID] = newItem;
- if (clampCenterX()) {
+
+ boolean stopScroll = clampCenterX();
+ checkCurrentDataCentered(getCurrentId());
+ if (stopScroll) {
mController.stopScrolling(true);
}
adjustChildZOrder();
@@ -1883,6 +1930,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
invalidate();
if (mListener != null) {
+ mListener.onReload();
mListener.onDataFocusChanged(mViewItem[mCurrentItem].getId(), true);
}
}
@@ -1917,7 +1965,10 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
@Override
public void onScrollUpdate(int currX, int currY) {
mCenterX = currX;
- if (clampCenterX()) {
+
+ boolean stopScroll = clampCenterX();
+ checkCurrentDataCentered(getCurrentId());
+ if (stopScroll) {
mController.stopScrolling(true);
}
invalidate();
@@ -2056,7 +2107,10 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
return;
}
mCenterX += deltaX;
- if (clampCenterX()) {
+
+ boolean stopScroll = clampCenterX();
+ checkCurrentDataCentered(getCurrentId());
+ if (stopScroll) {
mController.stopScrolling(true);
}
invalidate();
@@ -2201,6 +2255,8 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
mCanStopScroll = interruptible;
mScroller.startScroll(mCenterX, 0, position - mCenterX,
0, duration);
+
+ checkCurrentDataCentered(mViewItem[mCurrentItem].getId());
}
@Override