@Override
  protected void onPause() {
    mPausing = true;
    stopPreview();
    // Close the camera now because other activities may need to use it.
    closeCamera();
    resetScreenOn();
    if (mFirstTimeInitialized) {
      mOrientationListener.disable();
      hidePostCaptureAlert();
    }

    // If we are in an image capture intent and has taken
    // a picture, we just clear it in onPause.
    mImageCapture.clearLastData();
    mImageCapture = null;

    if (mStorageHint != null) {
      mStorageHint.cancel();
      mStorageHint = null;
    }

    // Remove the messages in the event queue.
    mHandler.removeMessages(RESTART_PREVIEW);
    mHandler.removeMessages(FIRST_TIME_INIT);

    super.onPause();
  }
 @Override
 public void onPause() {
   super.onPause();
   if (orientationListener != null) {
     orientationListener.disable();
     orientationListener = null;
   }
 }
  protected void onDestroy() {
    // Log.d(TAG, "enter ContShooting#onDestroy");
    super.onDestroy();
    if (mPreview != null) {
      mPreview.release();
    }

    mOrientationListener.disable();
  }
  // If the activity is paused and resumed, this method will be called in
  // onResume.
  private void initializeSecondTime() {
    // Start orientation listener as soon as possible because it takes
    // some time to get first orientation.
    mOrientationListener.enable();

    // Start location update if needed.
    installIntentFilter();
    keepMediaProviderInstance();
    checkStorage();
  }
 @SuppressWarnings("deprecation")
 @Override
 protected void onResume() {
   super.onResume();
   SurfaceHolder surfaceHolder = mSurfaceView.getHolder();
   if (hasSurface) {
     initCamera(surfaceHolder);
   } else {
     surfaceHolder.addCallback(this);
     surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
   }
   orientationEventListener.enable();
 }
 @Override
 public void onResume() {
   super.onResume();
   if (camera != null) {
     try {
       camera.reconnect();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   if (orientationListener == null) {
     initOrientationListener();
   }
   orientationListener.enable();
 }
 @Override
 protected void onPause() {
   super.onPause();
   if (mHandleTask != null) {
     if (mHandleTask.cancel(true)) ;
   }
   if (mCamera != null) {
     mCamera.setPreviewCallback(null);
     mCamera.stopPreview();
     mCamera.release();
     mCamera = null;
     mPreviewing = false;
     Log.d("mPreviewing", "mPreviewing changed to :" + mPreviewing);
   }
   orientationEventListener.disable();
 }
  @Override
  protected void onDestroy() {
    if (mOrientationHelper != null) {
      mOrientationHelper.disable();
      mOrientationHelper = null;
    }

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
      lc.removeListener(mListener);
    }

    instance = null;
    super.onDestroy();

    unbindDrawables(findViewById(R.id.topLayout));
    System.gc();
  }
  // Snapshots can only be taken after this is called. It should be called
  // once only. We could have done these things in onCreate() but we want to
  // make preview screen appear as soon as possible.
  private void initializeFirstTime() {
    if (mFirstTimeInitialized) return;

    // Create orientation listenter. This should be done first because it
    // takes some time to get first orientation.
    mOrientationListener =
        new OrientationEventListener(this) {
          @Override
          public void onOrientationChanged(int orientation) {
            // We keep the last known orientation. So if the user
            // first orient the camera then point the camera to
            if (orientation == ORIENTATION_UNKNOWN) return;
            mLastOrientation = roundOrientation(orientation);
            int orientationCompensation = mLastOrientation + getDisplayRotation();
            if (mOrientationCompensation != orientationCompensation) {
              mOrientationCompensation = orientationCompensation;
              setOrientationIndicator(mOrientationCompensation);
            }
          }
        };
    mOrientationListener.enable();
    keepMediaProviderInstance();
    checkStorage();

    // Initialize last picture button.
    mContentResolver = getContentResolver();

    // Initialize shutter button.
    mShutterButton = (ShutterButton) findViewById(R.id.shutter_button);
    mShutterButton.setOnShutterButtonListener(this);
    mShutterButton.setVisibility(View.VISIBLE);
    mFocusRectangle = (FocusRectangle) findViewById(R.id.focus_rectangle);
    updateFocusIndicator();
    initializeScreenBrightness();
    installIntentFilter();
    mFirstTimeInitialized = true;
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // Log.d(TAG, "enter ContShooting#onCreate");
    super.onCreate(savedInstanceState);
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);

    mOrientationListener =
        new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) {
          @Override
          public void onOrientationChanged(int orientation) {
            int degree = 0;
            if (orientation > 0 && orientation <= 45) {
              degree = 0;
            } else if (orientation > 45 && orientation <= 135) {
              degree = 90;
            } else if (orientation > 135 && orientation <= 225) {
              degree = 180;
            } else if (orientation > 225 && orientation <= 315) {
              degree = 270;
            } else {
              degree = 0;
            }
            if (mDegree != degree) {
              mDegree = degree;
              // 向きに応じてボタン等を回転させる
              rotate(degree);
            }
          }
        };
    mOrientationListener.enable();

    setTitle("");

    // mNum = getString(R.string.sc_number);
    mResolver = getContentResolver();

    // 設定値の取得
    String effect = ContShootingPreference.getCurrentEffect(this);
    String scene = ContShootingPreference.getCurrentSceneMode(this);
    String white = ContShootingPreference.getCurrentWhiteBalance(this);
    String size = ContShootingPreference.getCurrentPictureSize(this);
    mHiddenSizeIdx = Integer.parseInt(ContShootingPreference.getCurrentHiddenSize(this));

    // Log.d(TAG, "picsize = " + size);

    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    Display disp = wm.getDefaultDisplay();
    mWidth = disp.getWidth();
    mHeight = disp.getHeight();

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    SurfaceView sv = (SurfaceView) findViewById(R.id.camera);
    mHolder = sv.getHolder();

    mPreview = new CameraPreview(this);
    mPreview.setField(effect, scene, white, size, mWidth, mHeight);
    mHolder.addCallback(mPreview);
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    mText = (TextView) findViewById(R.id.text1);
    mText.setText(/*mNum + System.getProperty("line.separator") + */ "0" + " ");

    // 連写枚数設定
    String num = ContShootingPreference.getCurrentShootNum(this);
    if (!num.equals("0")) {
      mPreview.setShootNum(Integer.valueOf(num));
    }

    // 連写間隔設定
    String interval = ContShootingPreference.getCurrentInterval(this);
    if (!interval.equals("0")) {
      mPreview.setInterval(Integer.valueOf(interval));
    }

    // register UI Listener
    setListener();

    if (ContShootingPreference.isAutoShoot(this)) {
      mAutoFlag = true;
    }
  }
  private void init() {
    // make this view focusable
    setFocusable(true);

    // init fields
    viewportTransformation = new Matrix();
    newViewportTransformation = new Matrix();
    inverseViewportTransformation = new Matrix();

    selectionOffset = new float[2];
    touchPoint = new float[2];

    buffer = ByteBuffer.allocate(1024);

    scalingInterpolator = new TimedInterpolator();
    scalingInterpolator.setDuration(800);
    translationXInterpolator = new TimedInterpolator();
    translationXInterpolator.setDuration(800);
    translationYInterpolator = new TimedInterpolator();
    translationYInterpolator.setDuration(800);
    rotationInterpolator = new TimedInterpolator();
    rotationInterpolator.setDuration(800);
    centerRotationInterpolator = new TimedInterpolator();
    centerRotationInterpolator.setDuration(800);

    currentOrientation = getContext().getResources().getConfiguration().orientation;
    setOrientationFlag(true);

    if (SourcesView.paint == null) {
      SourcesView.paint = new Paint();
      SourcesView.paint.setAntiAlias(false);
      SourcesView.paint.setStrokeWidth(0);
      SourcesView.paint.setTextAlign(Paint.Align.CENTER);
      SourcesView.paint.setTextSize(9.0f);
    }

    // set up orientation event listener
    orientationEventListener =
        new OrientationEventListener(getContext(), SensorManager.SENSOR_DELAY_NORMAL) {
          @Override
          public void onOrientationChanged(int orientation) {
            if ((orientation >= 80 && orientation <= 100)
                || (orientation >= 260 && orientation <= 280)) { // landscape
              setOrientation(Configuration.ORIENTATION_LANDSCAPE);
            } else if ((orientation >= 350 || orientation <= 10)
                || (orientation >= 170 && orientation <= 190)) { // portrait
              setOrientation(Configuration.ORIENTATION_PORTRAIT);
            }
          }
        };
    if (!GlobalData
        .orientationTrackingEnabled) // orientation tracking and screen rotation tracking don't go
      // together
      orientationEventListener.enable();

    // set up gesture detector
    gestureDetector = new GestureDetector(getContext(), this);
    gestureDetector.setIsLongpressEnabled(false);
    gestureDetector.setOnDoubleTapListener(this);

    // init viewport transformation matrix
    recalculateViewportTransformation();
  }
Exemple #12
0
 @Override
 public void disable() {
   isEnabled = false;
   super.disable();
 }
Exemple #13
0
 @Override
 public void enable() {
   isEnabled = true;
   super.enable();
 }
 /** Register a sensor to track phoneOrientation changes */
 private synchronized void startOrientationSensor() {
   if (mOrientationHelper == null) {
     mOrientationHelper = new LocalOrientationEventListener(this);
   }
   mOrientationHelper.enable();
 }