예제 #1
0
  public void resetTouchFocus() {
    if (!mInitialized) return;

    splitMode = false;
    mMeteringIndicatorRotateLayout.setVisibility(View.GONE);

    // Put focus indicator to the center.
    RelativeLayout.LayoutParams p =
        (RelativeLayout.LayoutParams) mFocusIndicatorRotateLayout.getLayoutParams();
    int[] rules = p.getRules();
    rules[RelativeLayout.CENTER_IN_PARENT] = RelativeLayout.TRUE;
    p.setMargins(0, 0, 0, 0);

    mFocusArea = null;
    mMeteringArea = null;

    // allow driver to choose whatever it wants for focusing / metering
    // without these two lines Continuous focus is not re-enabled on HTC One
    int focusMode = getFocusMode();
    if ((focusMode == CameraParameters.AF_MODE_CONTINUOUS_PICTURE
            || focusMode == CameraParameters.AF_MODE_CONTINUOUS_VIDEO
            || focusMode == CameraParameters.AF_MODE_AUTO
            || focusMode == CameraParameters.AF_MODE_MACRO)
        && mFocusAreaSupported) {
      String modeName =
          PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext())
              .getString("defaultModeName", null);
      boolean isVideoRecording =
          PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext())
              .getBoolean("videorecording", false);
    }
  }
예제 #2
0
  @Override
  public void onGUICreate() {
    ApplicationScreen.getGUIManager().removeViews(modeSwitcher, R.id.specialPluginsLayout3);

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

    if (!CameraController.isRemoteCamera()) {
      ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout3))
          .addView(this.modeSwitcher, params);
    }

    this.modeSwitcher.setLayoutParams(params);

    if (ModePreference.compareTo("0") == 0)
      ApplicationScreen.getGUIManager()
          .showHelp(
              "Dro help",
              ApplicationScreen.getAppResources().getString(R.string.Dro_Help),
              R.drawable.plugin_help_dro,
              "droShowHelp");
  }
예제 #3
0
  public void initialize(boolean mirror, int displayOrientation) {
    mPreviewWidth = ApplicationScreen.getPreviewSurfaceLayoutWidth();
    mPreviewHeight = ApplicationScreen.getPreviewSurfaceLayoutHeight();

    Matrix matrix = new Matrix();
    Util.prepareMatrix(matrix, mirror, 90, mPreviewWidth, mPreviewHeight);
    // In face detection, the matrix converts the driver coordinates to UI
    // coordinates. In tap focus, the inverted matrix converts the UI
    // coordinates to driver coordinates.
    matrix.invert(mMatrix);

    mInitialized = true;
  }
예제 #4
0
  @Override
  public void onShutterClick() {
    if (needAutoFocusCall() && !focusOnShutterDisabled()) {
      if (mState == STATE_IDLE
          && !(preferenceFocusMode == CameraParameters.AF_MODE_CONTINUOUS_PICTURE
              || preferenceFocusMode == CameraParameters.AF_MODE_CONTINUOUS_VIDEO)
          && !ApplicationScreen.instance.getAutoFocusLock()) {
        if (preferenceFocusMode == CameraParameters.AF_MODE_CONTINUOUS_PICTURE
            || preferenceFocusMode == CameraParameters.AF_MODE_CONTINUOUS_VIDEO) {
          CameraController.setCameraFocusMode(CameraParameters.AF_MODE_AUTO);
        }
        setFocusParameters();
        setMeteringParameters();
        autoFocus();
      } else if (mState == STATE_FAIL) ApplicationScreen.getGUIManager().lockControls = false;
    } else {
      int focusMode = getFocusMode();
      if (focusMode == CameraParameters.AF_MODE_CONTINUOUS_PICTURE
          && (CameraController.isGalaxyS6
              || CameraController.isGalaxyS5
              || CameraController.isGalaxyNote4)) {
        final int[] supported_focus = CameraController.getSupportedFocusModes();
        int afMode = -1;
        if (CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_AUTO))
          afMode = CameraParameters.AF_MODE_AUTO;
        else if (CameraController.isModeAvailable(supported_focus, CameraParameters.AF_MODE_MACRO))
          afMode = CameraParameters.AF_MODE_MACRO;
        else afMode = supported_focus[0];

        CameraController.setCameraFocusMode(afMode);
        ApplicationScreen.instance.setAutoFocusLock(true);
      }
    }
  }
예제 #5
0
  @Override
  public void onResume() {
    inCapture = false;
    aboutToTakePicture = false;

    if (ModePreference.compareTo("0") == 0)
      ApplicationScreen.setCaptureFormat(CameraController.YUV);
    else {
      if (captureRAW && CameraController.isRAWCaptureSupported())
        ApplicationScreen.setCaptureFormat(CameraController.RAW);
      else {
        captureRAW = false;
        ApplicationScreen.setCaptureFormat(CameraController.JPEG);
      }
    }
  }
예제 #6
0
  private void cancelAutoFocus() {
    Log.e(TAG, "cancelAutofocus");
    // Note: CameraController.getFocusMode(); will return
    // 'FOCUS_MODE_AUTO' if actual
    // mode is in fact FOCUS_MODE_CONTINUOUS_PICTURE or
    // FOCUS_MODE_CONTINUOUS_VIDEO
    int fm = CameraController.getFocusMode();
    if (fm != CameraParameters.AF_MODE_UNSUPPORTED) {
      if (fm != preferenceFocusMode && preferenceFocusMode != CameraParameters.MF_MODE) {
        CameraController.cancelAutoFocus();
        CameraController.setCameraFocusMode(preferenceFocusMode);
      }
    }

    // Reset the tap area before calling mListener.cancelAutofocus.
    // Otherwise, focus mode stays at auto and the tap area passed to the
    // driver is not reset.
    CameraController.setCameraFocusAreas(null);
    ApplicationScreen.instance.setCameraMeteringMode(ApplicationScreen.getMeteringMode());
    resetTouchFocus();

    mState = STATE_IDLE;
    CameraController.setFocusState(CameraController.FOCUS_STATE_IDLE);

    updateFocusUI();
    mHandler.removeMessages(RESET_TOUCH_FOCUS);
  }
예제 #7
0
  private void createGyroUI() {
    LayoutInflater inflator = ApplicationScreen.instance.getLayoutInflater();
    mHorizonLayout = inflator.inflate(R.layout.plugin_vf_gyro_layout, null, false);
    mHorizonLayout.setVisibility(View.VISIBLE);

    ApplicationScreen.getGUIManager().removeViews(mHorizonLayout, R.id.specialPluginsLayout);

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout))
        .addView(mHorizonLayout, params);

    mHorizonIndicatorAim =
        (RotateImageView) mHorizonLayout.findViewById(R.id.horizon_indicator_aim);
    mHorizonIndicatorAimTopDown =
        (RotateImageView) mHorizonLayout.findViewById(R.id.horizon_indicator_aim_top_down);
    mHorizonIndicatorMarkRotation =
        (RotateImageView) mHorizonLayout.findViewById(R.id.horizon_indicator_mark_rotation);
    mHorizonIndicatorMarkHorizontal =
        (RotateImageView) mHorizonLayout.findViewById(R.id.horizon_indicator_mark_horizontal);
    mHorizonIndicatorMarkTopDown =
        (RotateImageView) mHorizonLayout.findViewById(R.id.horizon_indicator_mark_top_down);
    mHorizonIndicatorContainer =
        (RelativeLayout) mHorizonLayout.findViewById(R.id.horizon_indicator_container);
    mHorizonIndicatorMarkContainer =
        (RelativeLayout) mHorizonLayout.findViewById(R.id.horizon_indicator_mark_container);
  }
예제 #8
0
  void updatePreferences() {
    SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
    mGyroState = prefs.getBoolean("PrefGyroVF", false);

    if (!prefs.contains("PrefGyroTypeVF")) {
      Editor editor = prefs.edit();
      if (mGyroscope != null) {
        editor.putBoolean("PrefGyroTypeVF", true);
      } else {
        editor.putBoolean("PrefGyroTypeVF", false);
      }
      editor.commit();
    }
    mPrefHardwareGyroscope = prefs.getBoolean("PrefGyroTypeVF", false);

    if (mGyroState == ON) {
      CameraController.setNeedPreviewFrame(true);
      quickControlIconID = R.drawable.gui_almalence_settings_gyro;
      if (mHorizonIndicatorContainer != null) {
        mHorizonIndicatorContainer.setVisibility(View.VISIBLE);
      }
      initSensors();
    } else {
      quickControlIconID = R.drawable.gui_almalence_settings_gyro_off;
      if (mHorizonIndicatorContainer != null) {
        mHorizonIndicatorContainer.setVisibility(View.GONE);
      }
      releaseSensors();
    }
  }
예제 #9
0
 public GyroVFPlugin() {
   super(
       "com.almalence.plugins.gyrovf",
       R.xml.preferences_vf_gyro,
       0,
       R.drawable.gui_almalence_settings_gyro,
       ApplicationScreen.getAppResources().getString(R.string.Pref_TitleGyroVF));
 }
예제 #10
0
  @Override
  public void onStart() {
    // Get the xml/preferences.xml preferences
    SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
    ModePreference = prefs.getString("modeStandardPref", "1");

    captureRAW = prefs.getBoolean(ApplicationScreen.sCaptureRAWPref, false);
  }
  @Override
  public boolean handleMessage(Message msg) {
    switch (msg.what) {
      case MSG_END_OF_LOADING:
        setupSaveButton();
        postProcessingRun = true;
        break;
      case MSG_LEAVING:
        ApplicationScreen.getMessageHandler()
            .sendEmptyMessage(ApplicationInterface.MSG_POSTPROCESSING_FINISHED);

        PluginManager.getInstance()
            .sendMessage(
                ApplicationInterface.MSG_BROADCAST, ApplicationInterface.MSG_CONTROL_UNLOCKED);

        ApplicationScreen.getGUIManager().lockControls = false;

        postProcessingRun = false;
        return false;

      case MSG_REDRAW:
        if (PreviewBmp != null) PreviewBmp.recycle();
        if (finishing) return true;
        PreviewBmp = mAlmaCLRShot.getPreviewBitmap();
        if (PreviewBmp != null) {
          Matrix matrix = new Matrix();
          matrix.postRotate(90);
          Bitmap rotated =
              Bitmap.createBitmap(
                  PreviewBmp, 0, 0, PreviewBmp.getWidth(), PreviewBmp.getHeight(), matrix, true);
          mImgView.setImageBitmap(rotated);
          mImgView.setRotation(
              CameraController.isFrontCamera()
                  ? ((mDisplayOrientation == 0 || mDisplayOrientation == 180) ? 0 : 180)
                  : 0);
        }

        sequenceView.setEnabled(true);
        break;
      default:
        break;
    }
    return true;
  }
  @Override
  public void onClick(View v) {
    if (v == mSaveButton) {
      if (finishing) return;
      finishing = true;
      savePicture(ApplicationScreen.getMainContext());

      mHandler.sendEmptyMessage(MSG_LEAVING);
    }
  }
예제 #13
0
  @Override
  public void onStop() {
    // cancelAutoFocus();
    mState = STATE_INACTIVE;
    updateFocusUI();

    CameraController.setFocusState(CameraController.FOCUS_STATE_IDLE);

    ApplicationScreen.getGUIManager().removeViews(focusLayout, R.id.specialPluginsLayout);
  }
예제 #14
0
  @Override
  public void onCreate() {

    LayoutInflater inflator = ApplicationScreen.instance.getLayoutInflater();
    modeSwitcher =
        (Switch) inflator.inflate(R.layout.plugin_capture_standard_modeswitcher, null, false);

    SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
    ModePreference = prefs.getString("modeStandardPref", "1");
    singleModeEV = ApplicationScreen.instance.getEVPref();
    modeSwitcher.setTextOn("DRO On");
    modeSwitcher.setTextOff("DRO Off");
    modeSwitcher.setChecked(ModePreference.compareTo("0") == 0 ? true : false);
    modeSwitcher.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isDro) {

            SharedPreferences prefs =
                PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());

            if (isDro) {
              singleModeEV = ApplicationScreen.instance.getEVPref();

              ModePreference = "0";
              ApplicationScreen.setCaptureFormat(CameraController.YUV);
            } else {
              ModePreference = "1";
              ApplicationScreen.setCaptureFormat(CameraController.JPEG);
            }

            UpdateEv(isDro, singleModeEV);

            SharedPreferences.Editor editor = prefs.edit();
            editor.putString("modeStandardPref", ModePreference);
            editor.commit();

            ApplicationScreen.instance.relaunchCamera();

            if (ModePreference.compareTo("0") == 0)
              ApplicationScreen.getGUIManager()
                  .showHelp(
                      ApplicationScreen.instance.getString(R.string.Dro_Help_Header),
                      ApplicationScreen.getAppResources().getString(R.string.Dro_Help),
                      R.drawable.plugin_help_dro,
                      "droShowHelp");
          }
        });

    if (PluginManager.getInstance().getProcessingCounter() == 0) modeSwitcher.setEnabled(true);
  }
예제 #15
0
  @Override
  public void onGUICreate() {
    ApplicationScreen.getGUIManager().removeViews(focusLayout, R.id.specialPluginsLayout);

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);

    ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout))
        .addView(this.focusLayout, params);

    this.focusLayout.setLayoutParams(params);
    this.focusLayout.requestLayout();
  }
 public void setupSaveButton() {
   // put save button on screen
   mSaveButton = new Button(ApplicationScreen.instance);
   mSaveButton.setBackgroundResource(R.drawable.button_save_background);
   mSaveButton.setOnClickListener(this);
   LayoutParams saveLayoutParams =
       new LayoutParams(
           (int)
               (ApplicationScreen.getMainContext()
                   .getResources()
                   .getDimension(R.dimen.postprocessing_savebutton_size)),
           (int)
               (ApplicationScreen.getMainContext()
                   .getResources()
                   .getDimension(R.dimen.postprocessing_savebutton_size)));
   saveLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
   saveLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
   float density = ApplicationScreen.getAppResources().getDisplayMetrics().density;
   saveLayoutParams.setMargins((int) (density * 8), (int) (density * 8), 0, 0);
   ((RelativeLayout) postProcessingView.findViewById(R.id.sequenceLayout))
       .addView(mSaveButton, saveLayoutParams);
   mSaveButton.setRotation(mLayoutOrientationCurrent);
 }
예제 #17
0
  @Override
  public void onCameraParametersSetup() {
    SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
    if (ModePreference.equals("0")) {
      // FixMe: why not setting exposure if we are in dro-off mode?
      UpdateEv(true, singleModeEV);
    }

    if (CameraController.isRemoteCamera()) {
      Size imageSize = CameraController.getCameraImageSize();
      CameraController.setPictureSize(imageSize.getWidth(), imageSize.getHeight());
    }
  }
예제 #18
0
  @Override
  public void onCameraParametersSetup() {
    // replace here with [CF] mode as default.
    // Also, check if [CF] is available, and if not - set [AF], if [AF] is
    // not available - set first available
    preferenceFocusMode =
        ApplicationScreen.instance.getFocusModePref(ApplicationScreen.sDefaultFocusValue);

    int[] supportedFocusModes = CameraController.getSupportedFocusModes();
    if (supportedFocusModes != null && supportedFocusModes.length > 0) {
      if (!CameraController.isModeAvailable(supportedFocusModes, preferenceFocusMode)
          && preferenceFocusMode != CameraParameters.MF_MODE) {
        if (CameraController.isModeAvailable(supportedFocusModes, CameraParameters.AF_MODE_AUTO))
          preferenceFocusMode = CameraParameters.AF_MODE_AUTO;
        else preferenceFocusMode = supportedFocusModes[0];
      }
    }

    initializeParameters();

    initialize(CameraController.isFrontCamera(), 90);
    initializeSoundPlayers(
        ApplicationScreen.getAppResources().openRawResourceFd(R.raw.plugin_vf_focus_ok),
        ApplicationScreen.getAppResources().openRawResourceFd(R.raw.plugin_vf_focus_false));

    cancelAutoFocus();

    // Set the length of focus indicator according to preview frame size.
    int len = Math.min(mPreviewWidth, mPreviewHeight) / 25;
    ViewGroup.LayoutParams layout = mFocusIndicator.getLayoutParams();
    layout.width =
        (int)
            (len
                * ApplicationScreen.getAppResources()
                    .getInteger(R.integer.focusIndicator_cropFactor));
    layout.height =
        (int)
            (len
                * ApplicationScreen.getAppResources()
                    .getInteger(R.integer.focusIndicator_cropFactor));
    mFocusIndicator.requestLayout();

    layout = mMeteringIndicator.getLayoutParams();
    layout.width =
        (int)
            (len
                * ApplicationScreen.getAppResources()
                    .getInteger(R.integer.focusIndicator_cropFactor));
    layout.height =
        (int)
            (len
                * ApplicationScreen.getAppResources()
                    .getInteger(R.integer.focusIndicator_cropFactor));
    mMeteringIndicator.requestLayout();
  }
예제 #19
0
  @Override
  public void onQuickControlClick() {
    SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
    Editor editor = prefs.edit();

    if (mGyroState == ON) {
      quickControlIconID = R.drawable.gui_almalence_settings_gyro_off;
      editor.putBoolean("PrefGyroVF", false);
    } else {
      quickControlIconID = R.drawable.gui_almalence_settings_gyro;
      editor.putBoolean("PrefGyroVF", true);
    }
    editor.commit();

    updatePreferences();
  }
예제 #20
0
  @Override
  public void onImageTaken(int frame, byte[] frameData, int frame_len, int format) {
    framesCaptured++;
    boolean isRAW = (format == CameraController.RAW);

    PluginManager.getInstance()
        .addToSharedMem("frame" + framesCaptured + SessionID, String.valueOf(frame));
    PluginManager.getInstance()
        .addToSharedMem("framelen" + framesCaptured + SessionID, String.valueOf(frame_len));

    PluginManager.getInstance()
        .addToSharedMem("frameisraw" + framesCaptured + SessionID, String.valueOf(isRAW));

    PluginManager.getInstance()
        .addToSharedMem(
            "frameorientation" + framesCaptured + SessionID,
            String.valueOf(ApplicationScreen.getGUIManager().getDisplayOrientation()));
    PluginManager.getInstance()
        .addToSharedMem(
            "framemirrored" + framesCaptured + SessionID,
            String.valueOf(CameraController.isFrontCamera()));

    PluginManager.getInstance()
        .addToSharedMem("amountofcapturedframes" + SessionID, String.valueOf(framesCaptured));
    PluginManager.getInstance()
        .addToSharedMem("amountofcapturedrawframes" + SessionID, isRAW ? "1" : "0");

    PluginManager.getInstance().addToSharedMem("isdroprocessing" + SessionID, ModePreference);

    if ((captureRAW && framesCaptured == 2) || !captureRAW || ModePreference.compareTo("0") == 0) {
      PluginManager.getInstance()
          .sendMessage(ApplicationInterface.MSG_CAPTURE_FINISHED, String.valueOf(SessionID));
      inCapture = false;
      framesCaptured = 0;
      resultCompleted = 0;
    }
  }
예제 #21
0
  public void onTouchMeteringArea(MotionEvent e) {
    if (!mMeteringAreaSupported || CameraController.isGalaxyNote3) {
      if (e.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN
          || e.getActionMasked() == MotionEvent.ACTION_DOWN)
        Toast.makeText(
                ApplicationScreen.instance,
                R.string.manual_exposure_unsupported,
                Toast.LENGTH_SHORT)
            .show();

      return;
    }

    int xRaw = (int) e.getRawX();
    int yRaw = (int) e.getRawY();

    if (e.getPointerCount() > 1) {
      final int location[] = {0, 0};
      focusLayout.getLocationOnScreen(location);
      xRaw = (int) e.getX(1) + location[0];
      yRaw = (int) e.getY(1) + location[1];
    }

    int meteringWidth = mMeteringIndicatorRotateLayout.getWidth();
    int meteringHeight = mMeteringIndicatorRotateLayout.getHeight();
    int previewWidth = mPreviewWidth;
    int previewHeight = mPreviewHeight;
    int displayWidth = ApplicationScreen.getAppResources().getDisplayMetrics().widthPixels;
    int displayHeight = ApplicationScreen.getAppResources().getDisplayMetrics().heightPixels;
    int diffWidth = displayWidth - previewWidth;
    int diffHeight = displayHeight - previewHeight;

    // Initialize variables.
    int paramsLayoutHeight = 0;

    int xOffset = (focusLayout.getWidth() - previewWidth) / 2;
    int yOffset = (focusLayout.getHeight() - previewHeight) / 2;

    if (mMeteringArea == null) {
      mMeteringArea = new ArrayList<Area>();
      mMeteringArea.add(new Area(new Rect(), 1000));
    }

    // Use margin to set the metering indicator to the touched area.
    RelativeLayout.LayoutParams p =
        (RelativeLayout.LayoutParams) mMeteringIndicatorRotateLayout.getLayoutParams();
    int left =
        Util.clamp(
            xRaw - meteringWidth / 2 + xOffset,
            diffWidth / 2,
            (previewWidth - meteringWidth + xOffset * 2) - diffWidth / 2);
    int top =
        Util.clamp(
            yRaw - meteringHeight / 2 + yOffset - diffHeight / 2,
            0,
            previewHeight - meteringHeight + yOffset * 2);

    p.leftMargin = left;
    p.topMargin = top;

    mMeteringIndicatorRotateLayout.setLayoutParams(p);

    // Convert the coordinates to driver format.
    calculateTapAreaByTopLeft(
        meteringWidth,
        meteringHeight,
        1f,
        top,
        left,
        ApplicationScreen.getPreviewSurfaceView().getWidth(),
        ApplicationScreen.getPreviewSurfaceView().getHeight(),
        mMeteringArea.get(0).rect);

    // Set the focus area and metering area.
    if (e.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN
        || e.getActionMasked() == MotionEvent.ACTION_DOWN) {
      mMeteringIndicatorRotateLayout.setVisibility(View.VISIBLE);
    }

    if (e.getActionMasked() == MotionEvent.ACTION_POINTER_UP
        || e.getActionMasked() == MotionEvent.ACTION_UP) {
      setMeteringParameters();
    }

    mMeteringIndicatorRotateLayout.requestLayout();
  }
예제 #22
0
  @Override
  public boolean onTouch(View view, MotionEvent e) {
    if (CameraController.isRemoteCamera()) {
      if (e.getAction() == MotionEvent.ACTION_UP) {
        onTouchAreas(e);
      }
      return true;
    }

    updateCurrentTouch(e);

    if (e.getPointerCount() > 1) {
      splitMode = true;
      mHandler.removeMessages(START_TOUCH_FOCUS);

      onTouchMeteringArea(e);
      onTouchFocusArea(e);

      return true;
    }

    if (splitMode && e.getAction() == MotionEvent.ACTION_DOWN) {
      mMeteringIndicatorRotateLayout.setVisibility(View.GONE);
      ApplicationScreen.instance.setCameraMeteringMode(ApplicationScreen.getMeteringMode());
      splitMode = false;
    }

    if (splitMode) {
      return true;
    }

    // Check if it's double click
    if (e.getAction() == MotionEvent.ACTION_UP) {
      lastTouchTime1 = lastTouchTime2;
      lastTouchTime2 = System.currentTimeMillis();

      if (lastTouchTime2 - lastTouchTime1 < 1000) {
        isDoubleClick = true;

        // If shot on double click
        if (ApplicationScreen.instance.isShotOnTap() == 2) {
          // Cancel delayed focus, which was created by second click
          mHandler.removeMessages(START_TOUCH_FOCUS);

          // If state is Focused start capture
          if (mState == STATE_SUCCESS) {
            String modeID = PluginManager.getInstance().getActiveMode().modeID;
            if (!modeID.equals("video") && !currentTouch) {
              ApplicationScreen.getGUIManager().onHardwareShutterButtonPressed();
              isDoubleClick = false;
            }
          }
          return true;
        }
      } else {
        isDoubleClick = false;
      }
    }

    // Not handle touch event if no need of autoFocus and refuse 'shot on
    // tap' in video mode.
    if (!mInitialized
        || mState == STATE_FOCUSING_SNAP_ON_FINISH
        || mState == STATE_INACTIVE
        || mFocusDisabled
        || !CameraController.isFocusModeSupported()
        || (!(needAutoFocusCall() || isContinuousFocusMode())
            && !(ApplicationScreen.instance.isShotOnTap() > 0
                && !PluginManager.getInstance().getActiveMode().modeID.equals("video"))))
      return false;

    // Let users be able to cancel previous touch focus.
    if ((mState == STATE_FOCUSING)
        && !delayedFocus
        && ApplicationScreen.instance.isShotOnTap() != 2) {
      focusCanceled = true;
      cancelAutoFocus();
      int fm = CameraController.getFocusMode();
      if ((preferenceFocusMode == CameraParameters.AF_MODE_CONTINUOUS_PICTURE
              || preferenceFocusMode == CameraParameters.AF_MODE_CONTINUOUS_VIDEO)
          && fm != CameraParameters.AF_MODE_UNSUPPORTED
          && preferenceFocusMode != CameraController.getFocusMode()
          && preferenceFocusMode != CameraParameters.MF_MODE) {
        CameraController.setCameraFocusMode(preferenceFocusMode);
      } else if (CameraController.isGalaxyNote3 && preferenceFocusMode != CameraParameters.MF_MODE)
      // Kind of hack to
      // prevent Note 3 of
      // permanent 'auto focus
      // failed' state
      {
        CameraController.setCameraFocusMode(CameraParameters.AF_MODE_CONTINUOUS_PICTURE);
        CameraController.setCameraFocusMode(preferenceFocusMode);
      }
      return true;
    }

    switch (e.getAction()) {
      case MotionEvent.ACTION_DOWN:
        focusCanceled = false;
        delayedFocus = false;
        X = e.getX();
        Y = e.getY();

        lastEvent = MotionEvent.obtain(e);
        mHandler.sendEmptyMessageDelayed(START_TOUCH_FOCUS, START_TOUCH_FOCUS_DELAY);

        return true;
      case MotionEvent.ACTION_MOVE:
        {
          float difX = e.getX();
          float difY = e.getY();

          if ((Math.abs(difX - X) > 50 || Math.abs(difY - Y) > 50) && !focusCanceled) {
            focusCanceled = true;
            cancelAutoFocus();
            mHandler.removeMessages(START_TOUCH_FOCUS);
            return true;
          } else return true;
        }
      case MotionEvent.ACTION_UP:
        mHandler.removeMessages(START_TOUCH_FOCUS);
        if (focusCanceled || delayedFocus) return true;
        break;
      default:
        break;
    }

    onTouchAreas(e);

    return true;
  }
예제 #23
0
  public void onTouchFocusArea(MotionEvent e) {
    if (!mFocusAreaSupported) return;

    int xRaw = (int) e.getRawX();
    int yRaw = (int) e.getRawY();

    if (e.getPointerCount() > 1) {
      final int location[] = {0, 0};
      focusLayout.getLocationOnScreen(location);
      xRaw = (int) e.getX(0) + location[0];
      yRaw = (int) e.getY(0) + location[1];
    }

    // Initialize variables.
    int focusWidth = mFocusIndicatorRotateLayout.getWidth();
    int focusHeight = mFocusIndicatorRotateLayout.getHeight();
    int previewWidth = mPreviewWidth;
    int previewHeight = mPreviewHeight;
    int displayWidth = ApplicationScreen.getAppResources().getDisplayMetrics().widthPixels;
    int displayHeight = ApplicationScreen.getAppResources().getDisplayMetrics().heightPixels;
    int diffWidth = displayWidth - previewWidth;
    int diffHeight = displayHeight - previewHeight;

    // Initialize variables.
    int paramsLayoutHeight = 0;

    int xOffset = (focusLayout.getWidth() - previewWidth) / 2;
    int yOffset = (focusLayout.getHeight() - previewHeight) / 2;

    if (mFocusArea == null) {
      mFocusArea = new ArrayList<Area>();
      mFocusArea.add(new Area(new Rect(), 1000));
    }

    // Use margin to set the metering indicator to the touched area.
    RelativeLayout.LayoutParams p =
        (RelativeLayout.LayoutParams) mFocusIndicatorRotateLayout.getLayoutParams();
    int left =
        Util.clamp(
            xRaw - focusWidth / 2 + xOffset,
            diffWidth / 2,
            (previewWidth - focusWidth + xOffset * 2) - diffWidth / 2);
    int top =
        Util.clamp(
            yRaw - focusHeight / 2 + yOffset - diffHeight / 2,
            0,
            previewHeight - focusHeight + yOffset * 2);

    p.leftMargin = left;
    p.topMargin = top;

    int[] rules = p.getRules();
    rules[RelativeLayout.CENTER_IN_PARENT] = 0;

    mFocusIndicatorRotateLayout.setLayoutParams(p);

    calculateTapAreaByTopLeft(
        focusWidth,
        focusHeight,
        1f,
        top,
        left,
        ApplicationScreen.getPreviewSurfaceView().getWidth(),
        ApplicationScreen.getPreviewSurfaceView().getHeight(),
        mFocusArea.get(0).rect);

    // Set the focus area and metering area.
    if (mFocusAreaSupported
        && (e.getActionMasked() == MotionEvent.ACTION_UP
            || e.getActionMasked() == MotionEvent.ACTION_POINTER_UP)) {
      setFocusParameters();

      int focusMode = CameraController.getFocusMode();
      if (focusMode == CameraParameters.AF_MODE_AUTO
          || focusMode == CameraParameters.AF_MODE_MACRO) {
        CameraController.cancelAutoFocus();
        autoFocus();
      } else {
        mState = STATE_FOCUSING;
        updateFocusUI();
      }
    }
    mFocusIndicatorRotateLayout.requestLayout();
  }
  public void onStartProcessing(long SessionID) {
    finishing = false;
    Message msg = new Message();
    msg.what = ApplicationInterface.MSG_PROCESSING_BLOCK_UI;
    ApplicationScreen.getMessageHandler().sendMessage(msg);

    PluginManager.getInstance()
        .sendMessage(ApplicationInterface.MSG_BROADCAST, ApplicationInterface.MSG_CONTROL_LOCKED);

    ApplicationScreen.getGUIManager().lockControls = true;

    sessionID = SessionID;

    PluginManager.getInstance()
        .addToSharedMem(
            "modeSaveName" + sessionID, PluginManager.getInstance().getActiveMode().modeSaveName);

    mDisplayOrientation =
        Integer.valueOf(
            PluginManager.getInstance().getFromSharedMem("frameorientation1" + sessionID));
    int orientation = ApplicationScreen.getGUIManager().getLayoutOrientation();
    mLayoutOrientationCurrent =
        (orientation == 0 || orientation == 180) ? orientation : (orientation + 180) % 360;

    mCameraMirrored =
        Boolean.valueOf(PluginManager.getInstance().getFromSharedMem("framemirrored1" + sessionID));

    CameraController.Size imageSize = CameraController.getCameraImageSize();
    if (mDisplayOrientation == 0 || mDisplayOrientation == 180) {
      imgWidthOR = imageSize.getHeight();
      imgHeightOR = imageSize.getWidth();
    } else {
      imgWidthOR = imageSize.getWidth();
      imgHeightOR = imageSize.getHeight();
    }

    mAlmaCLRShot = AlmaCLRShot.getInstance();

    getPrefs();

    try {
      Size input = new Size(imageSize.getWidth(), imageSize.getHeight());
      int imagesAmount =
          Integer.parseInt(
              PluginManager.getInstance().getFromSharedMem("amountofcapturedframes" + sessionID));
      int minSize = 1000;
      if (mMinSize == 0) {
        minSize = 0;
      } else {
        minSize = input.getWidth() * input.getHeight() / mMinSize;
      }

      if (imagesAmount == 0) imagesAmount = 1;

      int iImageWidth = imageSize.getWidth();
      int iImageHeight = imageSize.getHeight();

      thumbnails.clear();
      int heightPixels = ApplicationScreen.getAppResources().getDisplayMetrics().heightPixels;
      for (int i = 1; i <= imagesAmount; i++) {
        thumbnails.add(
            Bitmap.createScaledBitmap(
                ImageConversion.decodeYUVfromBuffer(
                    mYUVBufferList.get(i - 1), iImageWidth, iImageHeight),
                heightPixels / imagesAmount,
                (int) (iImageHeight * (((float) heightPixels / imagesAmount) / iImageWidth)),
                false));
      }

      Display display =
          ((WindowManager) ApplicationScreen.instance.getSystemService(Context.WINDOW_SERVICE))
              .getDefaultDisplay();
      Point dis = new Point();
      display.getSize(dis);

      float imageRatio = (float) iImageWidth / (float) iImageHeight;
      float displayRatio = (float) dis.y / (float) dis.x;

      if (imageRatio > displayRatio) {
        mDisplayWidth = dis.y;
        mDisplayHeight = (int) ((float) dis.y / (float) imageRatio);
      } else {
        mDisplayWidth = (int) ((float) dis.x * (float) imageRatio);
        mDisplayHeight = dis.x;
      }

      Size preview = new Size(mDisplayWidth, mDisplayHeight);

      PluginManager.getInstance()
          .addToSharedMem("amountofresultframes" + sessionID, String.valueOf(imagesAmount));

      PluginManager.getInstance()
          .addToSharedMem("saveImageWidth" + sessionID, String.valueOf(imgWidthOR));
      PluginManager.getInstance()
          .addToSharedMem("saveImageHeight" + sessionID, String.valueOf(imgHeightOR));

      this.indexes = new int[imagesAmount];
      for (int i = 0; i < imagesAmount; i++) {
        this.indexes[i] = i;
      }

      // frames!!! should be taken from heap
      mAlmaCLRShot.addYUVInputFrame(mYUVBufferList, input);

      mAlmaCLRShot.initialize(
          preview,
          mAngle,
          /*
           * sensitivity for objection detection
           */
          mSensitivity - 15,
          /*
           * Minimum size of object to be able to detect -15 ~ 15 max -> easy
           * detection dull detection min ->
           */
          minSize,
          /*
           * ghosting parameter 0 : normal operation 1 : detect ghosted
           * objects but not remove them 2 : detect and remove all object
           */
          Integer.parseInt(mGhosting),
          indexes);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #25
0
 @Override
 public void onShowPreferences() {
   SharedPreferences prefs =
       PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
   ModePreference = prefs.getString("modeStandardPref", "1");
 }
예제 #26
0
 @Override
 public void onStop() {
   if (!CameraController.isRemoteCamera()) {
     ApplicationScreen.getGUIManager().removeViews(modeSwitcher, R.id.specialPluginsLayout3);
   }
 }
예제 #27
0
  @Override
  public void onCreate() {
    View v =
        LayoutInflater.from(ApplicationScreen.getMainContext())
            .inflate(R.layout.plugin_vf_focus_layout, null);
    focusLayout = (RelativeLayout) v.findViewById(R.id.focus_layout);

    RelativeLayout.LayoutParams viewLayoutParams =
        new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    viewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);

    mFocusIndicatorRotateLayout = (RotateLayout) v.findViewById(R.id.focus_indicator_rotate_layout);
    mMeteringIndicatorRotateLayout =
        (RotateLayout) v.findViewById(R.id.metering_indicator_rotate_layout);

    mFocusIndicatorRotateLayout.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            updateCurrentTouch(event);

            if (splitMode) {
              onTouchFocusArea(event);
              return true;
            } else {
              // Check if it's double click
              if (event.getAction() == MotionEvent.ACTION_UP) {
                lastTouchTime1 = lastTouchTime2;
                lastTouchTime2 = System.currentTimeMillis();

                if (lastTouchTime2 - lastTouchTime1 < 1000) {
                  isDoubleClick = true;
                } else {
                  isDoubleClick = false;
                }
              }

              onTouchFocusAndMeteringArea(event);
              return true;
            }
          }
        });

    mMeteringIndicatorRotateLayout.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            updateCurrentTouch(event);

            onTouchMeteringArea(event);
            return true;
          }
        });

    mFocusIndicator =
        (FocusIndicatorView) mFocusIndicatorRotateLayout.findViewById(R.id.focus_indicator);
    mMeteringIndicator =
        (ImageView) mMeteringIndicatorRotateLayout.findViewById(R.id.metering_indicator);

    resetTouchFocus();

    mPreferences =
        PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      mDefaultFocusMode = CameraParameters.AF_MODE_CONTINUOUS_PICTURE;
    } else {
      mDefaultFocusMode = CameraParameters.AF_MODE_AUTO;
    }
  }
예제 #28
0
  @Override
  public void onAutoFocus(boolean focused) {
    if (mState == STATE_FOCUSING_SNAP_ON_FINISH) {
      // Take the picture no matter focus succeeds or fails. No need
      // to play the AF sound if we're about to play the shutter
      // sound.
      if (focused) {
        mState = STATE_SUCCESS;
      } else {
        mState = STATE_FAIL;
        ApplicationScreen.getGUIManager().lockControls = false;
      }
      updateFocusUI();
    } else if (mState == STATE_FOCUSING) {
      // This happens when (1) user is half-pressing the focus key or
      // (2) touch focus is triggered. Play the focus tone. Do not
      // take the picture now.
      if (focused) {
        mState = STATE_SUCCESS;
        /*
         * Note: we are always using full-focus scan, even in continuous
         * modes
         *
         * // Do not play the sound in continuous autofocus mode. It
         * does // not do a full scan. The focus callback arrives before
         * doSnap // so the state is always STATE_FOCUSING. if
         * (!Parameters.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusMode)
         * && mSoundPlayerOK != null)
         */
        if (mSoundPlayerOK != null && !splitMode && !currentTouch)
          if (!ApplicationScreen.instance.isShutterSoundEnabled()
              && !ApplicationScreen.getPluginManager().muteSounds()) mSoundPlayerOK.play();

        // With enabled preference 'Shot on tap' perform shutter button
        // click after success focusing.
        String modeID = PluginManager.getInstance().getActiveMode().modeID;
        if (ApplicationScreen.instance.isShotOnTap() == 1
            && !modeID.equals("video")
            && !splitMode
            && !currentTouch) ApplicationScreen.getGUIManager().onHardwareShutterButtonPressed();

        if (ApplicationScreen.instance.isShotOnTap() == 2
            && !modeID.equals("video")
            && !splitMode
            && !currentTouch) {
          if (isDoubleClick) {
            ApplicationScreen.getGUIManager().onHardwareShutterButtonPressed();
            isDoubleClick = false;
          }
        }
      } else {
        if (mSoundPlayerFalse != null)
          if (!ApplicationScreen.instance.isShutterSoundEnabled()
              && !PluginManager.getInstance().muteSounds()) mSoundPlayerFalse.play();
        mState = STATE_FAIL;
      }
      updateFocusUI();

      if (!splitMode) mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
      // If this is triggered by touch focus, cancel focus after a
      // while.
    } else if (mState == STATE_IDLE) {
      // User has released the focus key before focus completes.
      // Do nothing.
    }
  }
예제 #29
0
  public void onTouchFocusAndMeteringArea(MotionEvent e) {
    if (!mFocusAreaSupported) return;

    int xRaw = (int) e.getRawX();
    int yRaw = (int) e.getRawY();

    // Initialize variables.
    int focusWidth = mFocusIndicatorRotateLayout.getWidth();
    int focusHeight = mFocusIndicatorRotateLayout.getHeight();
    int previewWidth = mPreviewWidth;
    int previewHeight = mPreviewHeight;
    int displayWidth = ApplicationScreen.getAppResources().getDisplayMetrics().widthPixels;
    int displayHeight = ApplicationScreen.getAppResources().getDisplayMetrics().heightPixels;
    int diffWidth = displayWidth - previewWidth;
    int diffHeight = displayHeight - previewHeight;

    // Initialize variables.
    int xOffset = (focusLayout.getWidth() - previewWidth) / 2;
    int yOffset = (focusLayout.getHeight() - previewHeight) / 2;

    if (mFocusArea == null) {
      mFocusArea = new ArrayList<Area>();
      mFocusArea.add(new Area(new Rect(), 1000));
    }

    if (mMeteringArea == null) {
      mMeteringArea = new ArrayList<Area>();
      mMeteringArea.add(new Area(new Rect(), 1000));
    }

    // Use margin to set the metering indicator to the touched area.
    RelativeLayout.LayoutParams p =
        (RelativeLayout.LayoutParams) mFocusIndicatorRotateLayout.getLayoutParams();
    int left =
        Util.clamp(
            xRaw - focusWidth / 2 + xOffset,
            diffWidth / 2,
            (previewWidth - focusWidth + xOffset * 2) - diffWidth / 2);
    int top =
        Util.clamp(
            yRaw - focusHeight / 2 + yOffset - diffHeight / 2,
            0,
            previewHeight - focusHeight + yOffset * 2);

    p.leftMargin = left;
    p.topMargin = top;

    int[] rules = p.getRules();
    rules[RelativeLayout.CENTER_IN_PARENT] = 0;

    mFocusIndicatorRotateLayout.setLayoutParams(p);

    calculateTapAreaByTopLeft(
        focusWidth,
        focusHeight,
        1f,
        top,
        left,
        ApplicationScreen.getPreviewSurfaceView().getWidth(),
        ApplicationScreen.getPreviewSurfaceView().getHeight(),
        mFocusArea.get(0).rect);

    if (ApplicationScreen.getMeteringMode() != -1
        && ApplicationScreen.getMeteringMode() == CameraParameters.meteringModeSpot)
      calculateTapAreaByTopLeft(
          focusWidth,
          focusHeight,
          1f,
          top,
          left,
          ApplicationScreen.getPreviewSurfaceView().getWidth(),
          ApplicationScreen.getPreviewSurfaceView().getHeight(),
          mMeteringArea.get(0).rect);
    else mMeteringArea = null;

    // Set the focus area and metering area.
    if ((mFocusAreaSupported && needAutoFocusCall() && (e.getAction() == MotionEvent.ACTION_UP))
        || CameraController.isRemoteCamera()) {
      CameraController.cancelAutoFocus();
      if (preferenceFocusMode == CameraParameters.AF_MODE_CONTINUOUS_PICTURE
          || preferenceFocusMode == CameraParameters.AF_MODE_CONTINUOUS_VIDEO) {
        CameraController.setCameraFocusMode(CameraParameters.AF_MODE_AUTO);
      }

      setFocusParameters();
      setMeteringParameters();
      autoFocus();

    } else if (e.getAction() == MotionEvent.ACTION_UP
        && ApplicationScreen.instance.isShotOnTap() == 1
        && !PluginManager.getInstance().getActiveMode().modeID.equals("video")
        && !currentTouch) {

      ApplicationScreen.getGUIManager().onHardwareShutterButtonPressed();
    } else if (e.getAction() == MotionEvent.ACTION_UP
        && ApplicationScreen.instance.isShotOnTap() == 2
        && !PluginManager.getInstance().getActiveMode().modeID.equals("video")
        && !currentTouch) {
      if (isDoubleClick) {
        ApplicationScreen.getGUIManager().onHardwareShutterButtonPressed();
        isDoubleClick = false;
      }
    } else if (e.getAction()
        == MotionEvent.ACTION_UP) { // Just show the indicator in all other cases.
      autoFocus();
      // updateFocusUI();
      // Reset the metering area in 3 seconds.
      mHandler.removeMessages(RESET_TOUCH_FOCUS);
      mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
    }

    mFocusIndicatorRotateLayout.requestLayout();
  }
예제 #30
0
  public void onTouchAreas(MotionEvent e) {
    // Initialize variables.
    int x = Math.round(e.getX());
    int y = Math.round(e.getY());
    int focusWidth = mFocusIndicatorRotateLayout.getWidth();
    int focusHeight = mFocusIndicatorRotateLayout.getHeight();
    int previewWidth = mPreviewWidth;
    int previewHeight = mPreviewHeight;
    int displayWidth = ApplicationScreen.getAppResources().getDisplayMetrics().widthPixels;
    int diffWidth = displayWidth - previewWidth;

    int paramsLayoutHeight = 0;

    int xOffset = (focusLayout.getWidth() - previewWidth) / 2;
    int yOffset = (focusLayout.getHeight() - previewHeight) / 2;

    if (mFocusArea == null) {
      mFocusArea = new ArrayList<Area>();
      mFocusArea.add(new Area(new Rect(), 1000));
    }

    if (mMeteringArea == null) {
      mMeteringArea = new ArrayList<Area>();
      mMeteringArea.add(new Area(new Rect(), 1000));
    }

    boolean isNexus6 = CameraController.isNexus6;
    // Convert the coordinates to driver format.
    // AE area is bigger because exposure is sensitive and
    // easy to over- or underexposure if area is too small.
    calculateTapArea(
        focusWidth,
        focusHeight,
        1f,
        x,
        y,
        ApplicationScreen.getPreviewSurfaceView().getWidth(),
        ApplicationScreen.getPreviewSurfaceView().getHeight(),
        mFocusArea.get(0).rect);
    if (ApplicationScreen.getMeteringMode() != -1
        && ApplicationScreen.getMeteringMode() == CameraParameters.meteringModeSpot)
      calculateTapArea(
          20 + (isNexus6 ? focusWidth : 0),
          20 + (isNexus6 ? focusHeight : 0),
          1f,
          x,
          y,
          ApplicationScreen.getPreviewSurfaceView().getWidth(),
          ApplicationScreen.getPreviewSurfaceView().getHeight(),
          mMeteringArea.get(0).rect);
    else mMeteringArea = null;

    if (mFocusAreaSupported) {
      // Use margin to set the focus indicator to the touched area.
      RelativeLayout.LayoutParams p =
          (RelativeLayout.LayoutParams) mFocusIndicatorRotateLayout.getLayoutParams();
      int left =
          Util.clamp(
              x - focusWidth / 2 + xOffset,
              diffWidth / 2,
              (previewWidth - focusWidth + xOffset * 2) - diffWidth / 2);
      int top =
          Util.clamp(
              y - focusHeight / 2 + yOffset,
              paramsLayoutHeight / 2,
              (previewHeight - focusHeight + yOffset * 2) - paramsLayoutHeight / 2);
      p.setMargins(left, top, 0, 0);
      // Disable "center" rule because we no longer want to put it in the
      // center.
      int[] rules = p.getRules();
      rules[RelativeLayout.CENTER_IN_PARENT] = 0;
      mFocusIndicatorRotateLayout.requestLayout();
    }

    // Set the focus area and metering area.
    if (mFocusAreaSupported && needAutoFocusCall() && (e.getAction() == MotionEvent.ACTION_UP)) {
      CameraController.cancelAutoFocus();
      if (preferenceFocusMode == CameraParameters.AF_MODE_CONTINUOUS_PICTURE
          || preferenceFocusMode == CameraParameters.AF_MODE_CONTINUOUS_VIDEO) {
        CameraController.setCameraFocusMode(CameraParameters.AF_MODE_AUTO);
      }

      setFocusParameters();
      setMeteringParameters();
      autoFocus();

    } else if (e.getAction() == MotionEvent.ACTION_UP
        && ApplicationScreen.instance.isShotOnTap() == 1
        && !PluginManager.getInstance().getActiveMode().modeID.equals("video")) {

      ApplicationScreen.getGUIManager().onHardwareShutterButtonPressed();
    } else if (e.getAction() == MotionEvent.ACTION_UP
        && ApplicationScreen.instance.isShotOnTap() == 2
        && !PluginManager.getInstance().getActiveMode().modeID.equals("video")) {
      if (isDoubleClick) {
        ApplicationScreen.getGUIManager().onHardwareShutterButtonPressed();
        isDoubleClick = false;
      }
    } else { // Just show the indicator in all other cases.
      autoFocus();
      // Reset the metering area in 3 seconds.
      mHandler.removeMessages(RESET_TOUCH_FOCUS);
      mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
    }
  }