public void flipCamera(View view) {
   stopCamera();
   camera.flip();
   viewfinder.invalidate();
   startCamera();
   updateMenu();
 }
  private void layout() {
    Rect frame = camera.getFrame(viewfinder.getWidth(), viewfinder.getHeight());
    if (frame == null) {
      return;
    }

    Log.i(TAG, "Frame = " + frame + ", " + viewfinder.getWidth());
    ViewGroup.LayoutParams p = bottomView.getLayoutParams();
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview);
    p.height = surfaceView.getHeight() - frame.bottom;
    p.width = frame.width();
    bottomView.setLayoutParams(p);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && hasNavBar(this)) {
      // Don't draw over nav bar
      bottomView.setPadding(0, 0, 0, getNavBarHeight());
    }

    bottomView.requestLayout();
    viewfinder.invalidate();
  }