summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngus Kong <shkong@google.com>2013-08-14 16:07:54 -0700
committerAngus Kong <shkong@google.com>2013-08-15 16:54:25 -0700
commit4ff5a1ab360577c6a7ec953f9197778c84c9d334 (patch)
tree8dc83a1808a8772f4d86e48af558ba18e6d34d49
parent394023fb7e3c8d07d4aeafc30bf4b66ed481ebb7 (diff)
downloadandroid_packages_apps_Snap-4ff5a1ab360577c6a7ec953f9197778c84c9d334.tar.gz
android_packages_apps_Snap-4ff5a1ab360577c6a7ec953f9197778c84c9d334.tar.bz2
android_packages_apps_Snap-4ff5a1ab360577c6a7ec953f9197778c84c9d334.zip
Set views in filmstrip invisible when alpha = 0.
bug:10096747 Change-Id: Idcb62448acbf38d581af3a08a9bcbc0cad0ab6be
-rw-r--r--src/com/android/camera/data/CameraDataAdapter.java7
-rw-r--r--src/com/android/camera/data/FixedFirstDataAdapter.java9
-rw-r--r--src/com/android/camera/data/FixedLastDataAdapter.java11
-rw-r--r--src/com/android/camera/data/LocalData.java1
-rw-r--r--src/com/android/camera/ui/FilmStripView.java92
5 files changed, 65 insertions, 55 deletions
diff --git a/src/com/android/camera/data/CameraDataAdapter.java b/src/com/android/camera/data/CameraDataAdapter.java
index 2cdb2c172..2b9e77754 100644
--- a/src/com/android/camera/data/CameraDataAdapter.java
+++ b/src/com/android/camera/data/CameraDataAdapter.java
@@ -113,13 +113,6 @@ public class CameraDataAdapter implements LocalDataAdapter {
}
@Override
- public void onDataFullScreen(int dataID, boolean fullScreen) {
- if (dataID < mImages.size() && dataID >= 0) {
- mImages.get(dataID).onFullScreen(fullScreen);
- }
- }
-
- @Override
public boolean canSwipeInFullScreen(int dataID) {
if (dataID < mImages.size() && dataID > 0) {
return mImages.get(dataID).canSwipeInFullScreen();
diff --git a/src/com/android/camera/data/FixedFirstDataAdapter.java b/src/com/android/camera/data/FixedFirstDataAdapter.java
index 9f3c4107b..53eb3bb86 100644
--- a/src/com/android/camera/data/FixedFirstDataAdapter.java
+++ b/src/com/android/camera/data/FixedFirstDataAdapter.java
@@ -123,15 +123,6 @@ public class FixedFirstDataAdapter extends AbstractLocalDataAdapterWrapper
}
@Override
- public void onDataFullScreen(int dataID, boolean fullScreen) {
- if (dataID == 0) {
- mFirstData.onFullScreen(fullScreen);
- } else {
- mAdapter.onDataFullScreen(dataID - 1, fullScreen);
- }
- }
-
- @Override
public void setListener(Listener listener) {
mListener = listener;
mAdapter.setListener((listener == null) ? null : this);
diff --git a/src/com/android/camera/data/FixedLastDataAdapter.java b/src/com/android/camera/data/FixedLastDataAdapter.java
index b8325ec72..a0b78aa98 100644
--- a/src/com/android/camera/data/FixedLastDataAdapter.java
+++ b/src/com/android/camera/data/FixedLastDataAdapter.java
@@ -135,17 +135,6 @@ public class FixedLastDataAdapter extends AbstractLocalDataAdapterWrapper {
}
@Override
- public void onDataFullScreen(int dataID, boolean fullScreen) {
- int totalNumber = mAdapter.getTotalNumber();
-
- if (dataID < totalNumber) {
- mAdapter.onDataFullScreen(dataID, fullScreen);
- } else if (dataID == totalNumber) {
- mLastData.onFullScreen(fullScreen);
- }
- }
-
- @Override
public boolean canSwipeInFullScreen(int dataID) {
int totalNumber = mAdapter.getTotalNumber();
diff --git a/src/com/android/camera/data/LocalData.java b/src/com/android/camera/data/LocalData.java
index 2b617d7e1..e25e93327 100644
--- a/src/com/android/camera/data/LocalData.java
+++ b/src/com/android/camera/data/LocalData.java
@@ -80,6 +80,7 @@ public interface LocalData extends FilmStripView.ImageData {
*/
boolean isDataActionSupported(int actions);
+ /** Removes the data from the storage if possible. */
boolean delete(Context c);
void onFullScreen(boolean fullScreen);
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index 22ef9c0e1..40f46b650 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -43,7 +43,7 @@ public class FilmStripView extends ViewGroup {
private static final int BUFFER_SIZE = 5;
private static final int DURATION_GEOMETRY_ADJUST = 200;
private static final float FILM_STRIP_SCALE = 0.6f;
- private static final float FULLSCREEN_SCALE = 1f;
+ private static final float FULL_SCREEN_SCALE = 1f;
// Only check for intercepting touch events within first 500ms
private static final int SWIPE_TIME_OUT = 500;
@@ -207,7 +207,7 @@ public class FilmStripView extends ViewGroup {
/**
* An interface which defines the listener for data events over
- * {@link ImageData}.
+ * {@link ImageData}. Usually {@link FilmStripView} itself.
*/
public interface Listener {
// Called when the whole data loading is done. No any assumption
@@ -262,16 +262,6 @@ public class FilmStripView extends ViewGroup {
public void setListener(Listener listener);
/**
- * The callback when the item enters/leaves full-screen.
- * TODO: Call this function actually.
- *
- * @param dataID The ID of the image data.
- * @param fullScreen {@code true} if the data is entering full-screen.
- * {@code false} otherwise.
- */
- public void onDataFullScreen(int dataID, boolean fullScreen);
-
- /**
* Returns {@code true} if the view of the data can be moved by swipe
* gesture when in full-screen.
*
@@ -300,7 +290,15 @@ public class FilmStripView extends ViewGroup {
*/
public void onDataDemoted(int dataID);
- public void onDataFullScreenChange(int dataID, boolean full);
+ /**
+ * The callback when the item enters/leaves full-screen.
+ * TODO: Call this function actually.
+ *
+ * @param dataID The ID of the image data.
+ * @param fullScreen {@code true} if the data is entering full-screen.
+ * {@code false} otherwise.
+ */
+ public void onDataFullScreenChange(int dataID, boolean fullScreen);
/**
* Callback when entering/leaving camera mode.
@@ -362,6 +360,11 @@ public class FilmStripView extends ViewGroup {
private View mView;
private RectF mViewArea;
+ /**
+ * Constructor.
+ * @param id The id of the data from {@link DataAdapter}.
+ * @param v The {@code View} representing the data.
+ */
public ViewInfo(int id, View v) {
v.setPivotX(0f);
v.setPivotY(0f);
@@ -371,38 +374,47 @@ public class FilmStripView extends ViewGroup {
mViewArea = new RectF();
}
+ /** Returns the data id from {@link DataAdapter}. */
public int getID() {
return mDataID;
}
+ /** Sets the data id from {@link DataAdapter}. */
public void setID(int id) {
mDataID = id;
}
+ /** Sets the left position of the view in the whole filmstrip. */
public void setLeftPosition(int pos) {
mLeftPosition = pos;
}
+ /** Returns the left position of the view in the whole filmstrip. */
public int getLeftPosition() {
return mLeftPosition;
}
+ /** Returns the translation of Y regarding the view scale. */
public float getTranslationY(float scale) {
return mView.getTranslationY() / scale;
}
+ /** Returns the translation of X regarding the view scale. */
public float getTranslationX(float scale) {
return mView.getTranslationX();
}
+ /** Sets the translation of Y regarding the view scale. */
public void setTranslationY(float transY, float scale) {
mView.setTranslationY(transY * scale);
}
+ /** Sets the translation of X regarding the view scale. */
public void setTranslationX(float transX, float scale) {
mView.setTranslationX(transX * scale);
}
+ /** Adjusts the translation of X regarding the view scale. */
public void translateXBy(float transX, float scale) {
mView.setTranslationX(mView.getTranslationX() + transX * scale);
}
@@ -411,6 +423,7 @@ public class FilmStripView extends ViewGroup {
return mLeftPosition + mView.getWidth() / 2;
}
+ /** Gets the view representing the data. */
public View getView() {
return mView;
}
@@ -420,10 +433,16 @@ public class FilmStripView extends ViewGroup {
top + mView.getMeasuredHeight());
}
+ /**
+ * Layouts the view in the area assuming the center of the area is at
+ * a specific point of the whole filmstrip.
+ *
+ * @param drawArea The area when filmstrip will show in.
+ * @param refCenter The absolute X coordination in the whole filmstrip
+ * of the center of {@code drawArea}.
+ * @param scale The current scale of the filmstrip.
+ */
public void layoutIn(Rect drawArea, int refCenter, float scale) {
- // drawArea is where to layout in.
- // refCenter is the absolute horizontal position of the center of
- // drawArea.
int left = (int) (drawArea.centerX() + (mLeftPosition - refCenter) * scale);
int top = (int) (drawArea.centerY() - (mView.getMeasuredHeight() / 2) * scale);
layoutAt(left, top);
@@ -438,6 +457,7 @@ public class FilmStripView extends ViewGroup {
t + mView.getHeight() * scale);
}
+ /** Returns true if the point is in the view. */
public boolean areaContains(float x, float y) {
return mViewArea.contains(x, y);
}
@@ -821,7 +841,7 @@ public class FilmStripView extends ViewGroup {
}
if (getCurrentViewType() == ImageData.TYPE_STICKY_VIEW
&& !mController.isScalling()
- && mScale != FULLSCREEN_SCALE) {
+ && mScale != FULL_SCREEN_SCALE) {
mController.gotoFullScreen();
}
}
@@ -847,8 +867,13 @@ public class FilmStripView extends ViewGroup {
int currentViewLeft = mViewInfo[mCurrentInfo].getLeftPosition();
int currentViewCenter = mViewInfo[mCurrentInfo].getCenterX();
int fullScreenWidth = mDrawArea.width() + mViewGap;
+ /**
+ * Transformed scale fraction between 0 and 1. 0 if the scale is
+ * {@link FILM_STRIP_SCALE}. 1 if the scale is
+ * {@link FULL_SCREEN_SCALE}.
+ */
float scaleFraction = mViewAnimInterpolator.getInterpolation(
- (mScale - FILM_STRIP_SCALE) / (FULLSCREEN_SCALE - FILM_STRIP_SCALE));
+ (mScale - FILM_STRIP_SCALE) / (FULL_SCREEN_SCALE - FILM_STRIP_SCALE));
// images on the left
for (int infoID = mCurrentInfo - 1; infoID >= 0; infoID--) {
@@ -882,13 +907,21 @@ public class FilmStripView extends ViewGroup {
prev.getLeftPosition() + prev.getView().getMeasuredWidth() + mViewGap;
curr.setLeftPosition(myLeft);
curr.layoutIn(mDrawArea, mCenterX, mScale);
- if (infoID == mCurrentInfo + 1) {
- curr.getView().setAlpha(1f - scaleFraction);
+ View currView = curr.getView();
+ if (scaleFraction == 1) {
+ currView.setVisibility(INVISIBLE);
} else {
- if (scaleFraction == 0f) {
- curr.getView().setAlpha(1f);
+ if (currView.getVisibility() == INVISIBLE) {
+ currView.setVisibility(VISIBLE);
+ }
+ if (infoID == mCurrentInfo + 1) {
+ currView.setAlpha(1f - scaleFraction);
} else {
- curr.getView().setAlpha(0f);
+ if (scaleFraction == 0f) {
+ currView.setAlpha(1f);
+ } else {
+ currView.setVisibility(INVISIBLE);
+ }
}
}
curr.setTranslationX((currentViewLeft - myLeft) * scaleFraction, mScale);
@@ -1171,7 +1204,7 @@ public class FilmStripView extends ViewGroup {
}
public boolean inFullScreen() {
- return (mScale == FULLSCREEN_SCALE);
+ return (mScale == FULL_SCREEN_SCALE);
}
public boolean inCameraFullscreen() {
@@ -1181,7 +1214,7 @@ public class FilmStripView extends ViewGroup {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
- if (inFilmStrip()) {
+ if (!inFullScreen() || mController.isScrolling()) {
return true;
}
@@ -1577,7 +1610,10 @@ public class FilmStripView extends ViewGroup {
@Override
public void onAnimationEnd(Animator anim) {
ViewInfo info = mViewInfo[mCurrentInfo];
- if (info != null && mCenterX == info.getCenterX()) {
+ if (info == null) {
+ return;
+ }
+ if (mCenterX == info.getCenterX()) {
if (inFullScreen()) {
lockAtCurrentView();
} else if (inFilmStrip()) {
@@ -1747,8 +1783,8 @@ public class FilmStripView extends ViewGroup {
if (mScale <= FILM_STRIP_SCALE) {
mScale = FILM_STRIP_SCALE;
}
- if (mScale >= FULLSCREEN_SCALE) {
- mScale = FULLSCREEN_SCALE;
+ if (mScale >= FULL_SCREEN_SCALE) {
+ mScale = FULL_SCREEN_SCALE;
}
layoutChildren();
return true;