private Handler mHandler;
Listener mListener;
private boolean mPreviousMoving;
- private boolean mFocusDefault;
private FocusUI mUI;
private final Rect mPreviewRect = new Rect(0, 0, 0, 0);
setParameters(parameters);
mListener = listener;
setMirror(mirror);
- mFocusDefault = true;
mUI = ui;
}
updateFocusUI();
// If this is triggered by touch focus, cancel focus after a
// while.
- if (!mFocusDefault) {
+ if (mFocusArea != null) {
mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
}
if (shutterButtonPressed) {
UsageStatistics.ACTION_TOUCH_FOCUS, x + "," + y);
// Let users be able to cancel previous touch focus.
- if ((!mFocusDefault) && (mState == STATE_FOCUSING ||
+ if ((mFocusArea != null) && (mState == STATE_FOCUSING ||
mState == STATE_SUCCESS || mState == STATE_FAIL)) {
cancelAutoFocus();
}
if (mPreviewRect.width() == 0 || mPreviewRect.height() == 0) return;
- mFocusDefault = false;
+ // Initialize variables.
// Initialize mFocusArea.
if (mFocusAreaSupported) {
initializeFocusAreas(x, y);
if (mParameters == null) return Parameters.FOCUS_MODE_AUTO;
List<String> supportedFocusModes = mParameters.getSupportedFocusModes();
- if (mFocusAreaSupported && !mFocusDefault) {
+ if (mFocusAreaSupported && mFocusArea != null) {
// Always use autofocus in tap-to-focus.
mFocusMode = Parameters.FOCUS_MODE_AUTO;
} else {
// Show only focus indicator or face indicator.
if (mState == STATE_IDLE) {
- if (mFocusDefault) {
+ if (mFocusArea == null) {
mUI.clearFocus();
} else {
// Users touch on the preview and the indicator represents the
// Put focus indicator to the center. clear reset position
mUI.clearFocus();
// Initialize mFocusArea.
- if (mFocusAreaSupported) {
- initializeFocusAreas(mPreviewRect.centerX(), mPreviewRect.centerY());
- }
- // Reset metering area when no specific region is selected.
- if (mMeteringAreaSupported) {
- resetMeteringAreas();
- }
- mFocusDefault = true;
+ mFocusArea = null;
+ mMeteringArea = null;
}
private void calculateTapArea(int x, int y, float areaMultiple, Rect rect) {