summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/PhotoModule.java7
-rw-r--r--src/com/android/camera/PhotoUI.java4
-rw-r--r--src/com/android/camera/ui/FilmStripView.java9
-rw-r--r--src/com/android/camera/ui/PieRenderer.java1
-rw-r--r--src/com/android/camera/ui/RotatableLayout.java25
-rw-r--r--src/com/android/camera/util/CameraUtil.java23
6 files changed, 46 insertions, 23 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index e9ca280b6..aeca3ddef 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -101,6 +101,7 @@ public class PhotoModule
private static final int CAMERA_OPEN_DONE = 8;
private static final int OPEN_CAMERA_FAIL = 9;
private static final int CAMERA_DISABLED = 10;
+ private static final int SWITCH_TO_GCAM_MODULE = 11;
// The subset of parameters we need to update in setCameraParameters().
private static final int UPDATE_PARAM_INITIALIZE = 1;
@@ -340,6 +341,10 @@ public class PhotoModule
R.string.camera_disabled);
break;
}
+
+ case SWITCH_TO_GCAM_MODULE: {
+ mActivity.onModuleSelected(ModuleSwitcher.GCAM_MODULE_INDEX);
+ }
}
}
}
@@ -1743,7 +1748,7 @@ public class PhotoModule
// Switch to gcam module if HDR+ was selected
if (doModeSwitch && !mIsImageCaptureIntent) {
- mActivity.onModuleSelected(ModuleSwitcher.GCAM_MODULE_INDEX);
+ mHandler.sendEmptyMessage(SWITCH_TO_GCAM_MODULE);
}
}
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 4f66a18cb..cd3b9a52f 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -613,6 +613,9 @@ public class PhotoUI implements PieListener,
}
public boolean collapseCameraControls() {
+ // TODO: Mode switcher should behave like a popup and should hide itself when there
+ // is a touch outside of it.
+ mSwitcher.closePopup();
// Remove all the popups/dialog boxes
boolean ret = false;
if (mPopup != null) {
@@ -847,6 +850,7 @@ public class PhotoUI implements PieListener,
@Override
public void onDisplayChanged() {
+ Log.d(TAG, "Device flip detected.");
mCameraControls.checkLayoutFlip();
mController.updateCameraOrientation();
}
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index 074f80b8a..564dd5d13 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -2695,7 +2695,11 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
@Override
public boolean onScroll(float x, float y, float dx, float dy) {
- if (mViewItem[mCurrentItem] == null) {
+ ViewItem currItem = mViewItem[mCurrentItem];
+ if (currItem == null) {
+ return false;
+ }
+ if (!mDataAdapter.canSwipeInFullScreen(currItem.getId())) {
return false;
}
// When image is zoomed in to be bigger than the screen
@@ -2760,6 +2764,9 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
if (currItem == null) {
return false;
}
+ if (!mDataAdapter.canSwipeInFullScreen(currItem.getId())) {
+ return false;
+ }
if (mController.isZoomStarted()) {
// Fling within the zoomed image
mController.flingInsideZoomView(velocityX, velocityY);
diff --git a/src/com/android/camera/ui/PieRenderer.java b/src/com/android/camera/ui/PieRenderer.java
index 666fa13b1..3967f7946 100644
--- a/src/com/android/camera/ui/PieRenderer.java
+++ b/src/com/android/camera/ui/PieRenderer.java
@@ -905,6 +905,7 @@ public class PieRenderer extends OverlayRenderer
}
public void setFocus(int x, int y) {
+ mOverlay.removeCallbacks(mDisappear);
mFocusX = x;
mFocusY = y;
setCircle(mFocusX, mFocusY);
diff --git a/src/com/android/camera/ui/RotatableLayout.java b/src/com/android/camera/ui/RotatableLayout.java
index 04c36331d..6867e6a8b 100644
--- a/src/com/android/camera/ui/RotatableLayout.java
+++ b/src/com/android/camera/ui/RotatableLayout.java
@@ -19,11 +19,8 @@ package com.android.camera.ui;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
-import android.graphics.Point;
import android.util.AttributeSet;
-import android.view.Display;
import android.view.Gravity;
-import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
@@ -73,14 +70,16 @@ public class RotatableLayout extends FrameLayout {
// we need to rotate the view if necessary. After that, onConfigurationChanged
// call will track all the subsequent device rotation.
if (mPrevRotation == UNKOWN_ORIENTATION) {
- calculateDefaultOrientation();
+ mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait((Activity) getContext());
if (mIsDefaultToPortrait) {
// Natural orientation for tablet is landscape
mPrevRotation = mInitialOrientation == Configuration.ORIENTATION_PORTRAIT ?
0 : 90;
} else {
+ // When tablet orientation is 0 or 270 (i.e. getUnifiedOrientation
+ // = 0 or 90), we load the layout resource without any rotation.
mPrevRotation = mInitialOrientation == Configuration.ORIENTATION_LANDSCAPE ?
- 0 : 90;
+ 0 : 270;
}
// check if there is any rotation before the view is attached to window
@@ -88,22 +87,6 @@ public class RotatableLayout extends FrameLayout {
}
}
- private void calculateDefaultOrientation() {
- Display currentDisplay = getDisplay();
- Point displaySize = new Point();
- currentDisplay.getSize(displaySize);
- int orientation = currentDisplay.getRotation();
- int naturalWidth, naturalHeight;
- if (orientation == Surface.ROTATION_0 || orientation == Surface.ROTATION_180) {
- naturalWidth = displaySize.x;
- naturalHeight = displaySize.y;
- } else {
- naturalWidth = displaySize.y;
- naturalHeight = displaySize.x;
- }
- mIsDefaultToPortrait = naturalWidth < naturalHeight;
- }
-
private void rotateIfNeeded() {
if (mPrevRotation == UNKOWN_ORIENTATION) {
return;
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index 458ae04f2..eff0c4078 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -43,6 +43,7 @@ import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
+import android.view.Display;
import android.view.OrientationEventListener;
import android.view.Surface;
import android.view.View;
@@ -411,6 +412,28 @@ public class CameraUtil {
return 0;
}
+ /**
+ * Calculate the default orientation of the device based on the width and
+ * height of the display when rotation = 0 (i.e. natural width and height)
+ * @param activity the activity context
+ * @return whether the default orientation of the device is portrait
+ */
+ public static boolean isDefaultToPortrait(Activity activity) {
+ Display currentDisplay = activity.getWindowManager().getDefaultDisplay();
+ Point displaySize = new Point();
+ currentDisplay.getSize(displaySize);
+ int orientation = currentDisplay.getRotation();
+ int naturalWidth, naturalHeight;
+ if (orientation == Surface.ROTATION_0 || orientation == Surface.ROTATION_180) {
+ naturalWidth = displaySize.x;
+ naturalHeight = displaySize.y;
+ } else {
+ naturalWidth = displaySize.y;
+ naturalHeight = displaySize.x;
+ }
+ return naturalWidth < naturalHeight;
+ }
+
public static int getDisplayOrientation(int degrees, int cameraId) {
// See android.hardware.Camera.setDisplayOrientation for
// documentation.