Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Revert "Merge "Remove long pressing shutter triggers autocous." into …
Browse files Browse the repository at this point in the history
…ics-mr0"

This reverts commit 4d55f6c, reversing
changes made to 174b8b7.
  • Loading branch information
The Android Automerger committed Nov 3, 2011
1 parent 03006c8 commit a067233
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/com/android/camera/Camera.java
Expand Up @@ -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";

Expand Down Expand Up @@ -370,6 +370,7 @@ private void initializeFirstTime() {
// Initialize shutter button.
mShutterButton = (ShutterButton) findViewById(R.id.shutter_button);
mShutterButton.setOnShutterButtonListener(this);
mShutterButton.setOnShutterButtonLongPressListener(this);
mShutterButton.setVisibility(View.VISIBLE);

// Initialize focus UI.
Expand Down Expand Up @@ -1392,6 +1393,15 @@ public void onShutterButtonClick() {
mFocusManager.doSnap();
}

@Override
public void onShutterButtonLongPressed() {
if (mPausing || mCameraState == SNAPSHOT_IN_PROGRESS
|| mCameraDevice == null || mPicturesRemaining <= 0) return;

Log.v(TAG, "onShutterButtonLongPressed");
mFocusManager.shutterLongPressed();
}

private OnScreenHint mStorageHint;

private void updateStorageHint() {
Expand Down
23 changes: 22 additions & 1 deletion src/com/android/camera/FocusManager.java
Expand Up @@ -56,6 +56,7 @@ public class FocusManager {

private boolean mInitialized;
private boolean mFocusAreaSupported;
private boolean mInLongPress;
private boolean mLockAeAwbNeeded;
private boolean mAeAwbLock;
private Matrix mMatrix;
Expand Down Expand Up @@ -173,6 +174,22 @@ public void onShutterUp() {
}
}

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.
onShutterUp();
// Call Autofocus
onShutterDown();
mInLongPress = false;
}
}

public void doSnap() {
if (!mInitialized) return;

Expand Down Expand Up @@ -362,7 +379,11 @@ public void releaseSoundPlayer() {
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 {
Expand Down
23 changes: 22 additions & 1 deletion src/com/android/camera/ShutterButton.java
Expand Up @@ -26,7 +26,7 @@
* 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.
*/
Expand All @@ -40,17 +40,30 @@ public interface OnShutterButtonListener {
void onShutterButtonClick();
}

/**
* A callback to be invoked when a ShutterButton's long pressed.
*/
public interface OnShutterButtonLongPressListener {
void onShutterButtonLongPressed();
}

private OnShutterButtonListener mListener;
private OnShutterButtonLongPressListener mLongPressListener;
private boolean mOldPressed;

public ShutterButton(Context context, AttributeSet attrs) {
super(context, attrs);
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
Expand Down Expand Up @@ -109,4 +122,12 @@ public boolean performClick() {
}
return result;
}

@Override
public boolean onLongClick(View v) {
if (mLongPressListener != null) {
mLongPressListener.onShutterButtonLongPressed();
}
return false;
}
}

0 comments on commit a067233

Please sign in to comment.