コード例 #1
0
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (data == null) {
      return;
    }

    if (requestCode == REQUEST_CODE) {
      if (resultCode == RESPONSE_COLOR_EFFECT) {
        if (mPreview != null) {
          mPreview.setColorValue(data.getStringExtra("effect"));
        }
      }
      if (resultCode == RESPONSE_SCENE_MODE) {
        if (mPreview != null) {
          mPreview.setSceneValue(data.getStringExtra("scene"));
        }
      }
      if (resultCode == RESPONSE_WHITE_BALANCE) {
        if (mPreview != null) {
          mPreview.setWhiteValue(data.getStringExtra("white"));
        }
      }
      if (resultCode == RESPONSE_PICTURE_SIZE) {
        if (mPreview != null) {
          mPreview.setSizeValue(data.getIntExtra("size", 0));
        }
      }
      if (resultCode == RESPONSE_SHOOT_NUM) {
        if (mPreview != null) {
          mPreview.setShootNum(data.getIntExtra("shoot", 0));
        }
      }
      if (resultCode == RESPONSE_INTERVAL) {
        if (mPreview != null) {
          mPreview.setInterval(data.getIntExtra("interval", 0));
        }
      }
      if (resultCode == RESPONSE_HIDDEN_SIZE) {
        // 隠しモードサイズ設定
        mHiddenSizeIdx = data.getIntExtra("hidden_size", 0);
        // 隠しモードの場合は、一旦戻す
        if (mMaskFlag) {
          setToNormal();
        }
      }
    }
  }
コード例 #2
0
  /** 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;
    }
  }