diff options
author | Erin Dahlgren <edahlgren@google.com> | 2013-10-10 18:23:45 -0700 |
---|---|---|
committer | Erin Dahlgren <edahlgren@google.com> | 2013-10-14 13:40:45 -0700 |
commit | 3044d8c577432d6e9721fc8b26ac2afbbaf21266 (patch) | |
tree | eb9976bbe0b2bf5f74032af77b690dc56fd29bb3 /src/com/android/camera/ui/FilmStripView.java | |
parent | b27668f0d0a1d5049759a8448e1701e199e05c71 (diff) | |
download | android_packages_apps_Snap-3044d8c577432d6e9721fc8b26ac2afbbaf21266.tar.gz android_packages_apps_Snap-3044d8c577432d6e9721fc8b26ac2afbbaf21266.tar.bz2 android_packages_apps_Snap-3044d8c577432d6e9721fc8b26ac2afbbaf21266.zip |
Set camera controls visibility based on whether the camera preview is centered.
Bug: 10861015
Change-Id: Ib0c4945e35cee16b73a4bba913e11d0f79a26176
Diffstat (limited to 'src/com/android/camera/ui/FilmStripView.java')
-rw-r--r-- | src/com/android/camera/ui/FilmStripView.java | 64 |
1 files changed, 60 insertions, 4 deletions
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 |