summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java14
-rw-r--r--src/com/android/camera/FocusManager.java23
-rwxr-xr-x[-rw-r--r--]src/com/android/camera/ShutterButton.java32
3 files changed, 58 insertions, 11 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index cd8a0b3..4a311de 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -82,7 +82,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
View.OnTouchListener, ShutterButton.OnShutterButtonListener,
SurfaceHolder.Callback, ModePicker.OnModeChangeListener,
FaceDetectionListener, CameraPreference.OnPreferenceChangedListener,
- LocationManager.Listener {
+ LocationManager.Listener, ShutterButton.OnShutterButtonLongPressListener {
private static final String TAG = "camera";
@@ -369,6 +369,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
// Initialize shutter button.
mShutterButton = (ShutterButton) findViewById(R.id.shutter_button);
mShutterButton.setOnShutterButtonListener(this);
+ mShutterButton.setOnShutterButtonLongPressListener(this);
mShutterButton.setVisibility(View.VISIBLE);
// Initialize focus UI.
@@ -1318,6 +1319,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
finish();
}
+ @Override
public void onShutterButtonFocus(ShutterButton button, boolean pressed) {
switch (button.getId()) {
case R.id.shutter_button:
@@ -1326,6 +1328,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
}
}
+ @Override
public void onShutterButtonClick(ShutterButton button) {
switch (button.getId()) {
case R.id.shutter_button:
@@ -1334,6 +1337,15 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
}
}
+ @Override
+ public void onShutterButtonLongPressed(ShutterButton button) {
+ if (mPausing || mCameraState == SNAPSHOT_IN_PROGRESS
+ || mCameraDevice == null || mPicturesRemaining <= 0) return;
+
+ Log.v(TAG, "onShutterButtonLongPressed");
+ mFocusManager.shutterLongPressed();
+ }
+
private OnScreenHint mStorageHint;
private void updateStorageHint() {
diff --git a/src/com/android/camera/FocusManager.java b/src/com/android/camera/FocusManager.java
index 87af8f2..6b9dbd6 100644
--- a/src/com/android/camera/FocusManager.java
+++ b/src/com/android/camera/FocusManager.java
@@ -54,6 +54,7 @@ public class FocusManager {
private boolean mInitialized;
private boolean mFocusAreaSupported;
+ private boolean mInLongPress;
private SoundPlayer mSoundPlayer;
private View mFocusIndicatorRotateLayout;
private FocusIndicatorView mFocusIndicator;
@@ -141,6 +142,22 @@ public class FocusManager {
}
}
+ public void shutterLongPressed() {
+ if (Parameters.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusMode)
+ && isSupported(Parameters.FOCUS_MODE_AUTO, mParameters.getSupportedFocusModes())) {
+ if (mState == STATE_IDLE || mState == STATE_FOCUSING_SNAP_ON_FINISH) {
+ Log.e(TAG, "Invalid focus state=" + mState);
+ }
+ mInLongPress = true;
+ // Cancel any outstanding Auto focus requests. The auto focus mode
+ // will be changed from CAF to auto in cancelAutoFocus.
+ doFocus(false);
+ // Call Autofocus
+ doFocus(true);
+ mInLongPress = false;
+ }
+ }
+
public void doSnap() {
if (!mInitialized) return;
@@ -334,7 +351,11 @@ public class FocusManager {
public String getFocusMode() {
if (mOverrideFocusMode != null) return mOverrideFocusMode;
- if (mFocusAreaSupported && mFocusArea != null) {
+ if (mInLongPress) {
+ // Users long-press the shutter button in CAF. Change it to auto
+ // mode, so it will do a full scan.
+ mFocusMode = Parameters.FOCUS_MODE_AUTO;
+ } else if (mFocusAreaSupported && mFocusArea != null) {
// Always use autofocus in tap-to-focus.
mFocusMode = Parameters.FOCUS_MODE_AUTO;
} else {
diff --git a/src/com/android/camera/ShutterButton.java b/src/com/android/camera/ShutterButton.java
index e1499a6..e44afe5 100644..100755
--- a/src/com/android/camera/ShutterButton.java
+++ b/src/com/android/camera/ShutterButton.java
@@ -18,6 +18,7 @@ package com.android.camera;
import android.content.Context;
import android.util.AttributeSet;
+import android.view.View;
import android.widget.ImageView;
/**
@@ -25,7 +26,7 @@ import android.widget.ImageView;
* It's currently an {@code ImageView} that can call a delegate when the
* pressed state changes.
*/
-public class ShutterButton extends ImageView {
+public class ShutterButton extends ImageView implements View.OnLongClickListener {
/**
* A callback to be invoked when a ShutterButton's pressed state changes.
*/
@@ -39,25 +40,30 @@ public class ShutterButton extends ImageView {
void onShutterButtonClick(ShutterButton b);
}
+ /**
+ * A callback to be invoked when a ShutterButton's long pressed.
+ */
+ public interface OnShutterButtonLongPressListener {
+ void onShutterButtonLongPressed(ShutterButton b);
+ }
+
private OnShutterButtonListener mListener;
+ private OnShutterButtonLongPressListener mLongPressListener;
private boolean mOldPressed;
- public ShutterButton(Context context) {
- super(context);
- }
-
public ShutterButton(Context context, AttributeSet attrs) {
super(context, attrs);
- }
-
- public ShutterButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
+ setOnLongClickListener(this);
}
public void setOnShutterButtonListener(OnShutterButtonListener listener) {
mListener = listener;
}
+ public void setOnShutterButtonLongPressListener(OnShutterButtonLongPressListener listener) {
+ mLongPressListener = listener;
+ }
+
/**
* Hook into the drawable state changing to get changes to isPressed -- the
* onPressed listener doesn't always get called when the pressed state
@@ -116,4 +122,12 @@ public class ShutterButton extends ImageView {
}
return result;
}
+
+ @Override
+ public boolean onLongClick(View v) {
+ if (mLongPressListener != null) {
+ mLongPressListener.onShutterButtonLongPressed(this);
+ }
+ return false;
+ }
}