@ Overridevoid surfaceCreated (SurfaceHolder surfaceHolder) {(surfaceHolder);
}
@ Overridevoid surfaceChanged (SurfaceHolder surfaceHolder, int i, int i2, int i3) {.startPreview ();
}
@ Overridevoid surfaceDestroyed (SurfaceHolder surfaceHolder) {();
}
//endregion
//region Camera callbacks
@ Overridevoid onPictureTaken (byte [] bytes, Camera camera) {.storeImage (correctImage (bytes)); ();
} void onAutoFocus (boolean b, Camera camera) {.takePicture (null, null, this);
}
//endregionbyte [] correctImage (byte [] data) {{realImage=BitmapFactory.decodeByteArray (data, 0, data.length); bitmap=rotateImage (realImage, Math.abs (iconOrientation - 90 )); stream=new ByteArrayOutputStream () ;. compress (Bitmap.CompressFormat.JPEG, 100, stream); [] newData=stream.toByteArray () ;. close () ;. d ( Camera raquo ;, String.format ( Image size:% d raquo ;, newData.length)); newData;
} catch (IOException e) {.printStackTrace ();
} null;
} Bitmap rotateImage (Bitmap bitmap, int degree) {width=bitmap.getWidth (); height=bitmap.getHeight (); matrix=new Matrix () ;. postRotate (degree); Bitmap. createBitmap (bitmap, 0, 0, width, height, matrix, true);
}
//region Visual state managementboolean bottomPanelHidden=true; void swapElementsVisibility () {= !bottomPanelHidden;.setEnabled(bottomPanelHidden);.setEnabled(bottomPanelHidden);.setEnabled(bottomPanelHidden);(bottomPanelHidden) {.setVisibility (View.GONE) ;. setVisibility (View.VISIBLE);
} else {.setVisibility (View.VISIBLE) ;. setVisibility (View.GONE);
} void rotatePopup (int toOrientation) {(popupWindow!=null) {needsToShow=popupWindow.isShowing () ;. dismiss (); view=popupWindow.getContentView();.setPivotY(popupWindowCenter);.setPivotX(popupWindowCenter);.setRotation(toOrientation);(needsToShow) {.showAsDropDown (settingsButton);
} void tryStartRotation (View view, int toOrientation) {(view!=null) {animation=getAnimation (toOrientation);// New animation object is needed to restore animation's center point.startAnimation (animation);
} void rotateImages (int toOrientation) {(logOutImageView, toOrientation); (flashImageView, toOrientation); (settingsImageView, toOrientation); (cameraIconImage, toOrientation);
} RotateAnimation getAnimation (int toOrientation) {animation=new RotateAnimation (, toOrientation, .RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f) ;. setFillAfter (true) ;. setDuration (600); animation;
} void updateFlashIcon () {(useFlash) {.setImageResource (R.drawable.ic_action_flash_on) ;. makeText (this, R.string.toast_flash_on, Toast.LENGTH_SHORT) .show ();
} else {.setImageResource (R.drawable.ic_action_flash_off) ;. makeText (this, R.string.toast_flash_off, Toast.LENGTH_SHORT) .show ();
}
//endregion
//region Setup methodsvoid setUpOrientationEventListener () {(orientationObserver == null) {= new OrientationEventListener (this, SensorManager.SENSOR_DELAY_NORMAL) {
@ Overridevoid onOrientationChanged (int i) {newOrientation=- 100; (i gt;=315 || i lt; 45) {= 0;
} else if (i gt;=45 amp; amp; i lt; 135) {= - 90;
} else if (i gt;=225 amp; amp; i lt; 315) {= 90;
} (newOrientation gt; - 100 amp; amp; iconOrientation!=newOrientation) {(newOrientation); (newOrientation);=newOrientation;
} PopupWindow setUpPopupWindow () {(popupWindow == null) {layoutInflater=(LayoutInflater) getBaseContext ()
. getSystemService (LAYOUT_INFLATER_SERVICE); popupView=layoutInflater.inflate (R.layout.menu_camera_popup, null); popupView!=null; list=(ListView) popupView.findViewById (R.id.qualitiesListView); dummy=(TextView) popupView.findViewById (R.id.dummyTextView); lt; String gt; humanReadableHeaders=getHumanReadableHeaders (); (list, humanReadableHeaders) ;. setOnItemClickListener (this) ;. setItemChecked (pictureSizeIndex, true);
//Measure is need to set PopupWindow width similar to WRAP_CONTENT behaviour
//Unfortunately this property of popupView is ignored and without this fix
//PopupWindow's width is equal to screen width..measure (View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); side=popupView.getMeasuredWidth ();=side/2;=getPopupWindow ( popupView, side, side) ;. setO...