portDialog=new ReportDialogFragment (R.string.error, messageId) ;. show (getFragmentManager (), REPORT_DIALOG_TAG) ;. dismiss () ;. setEnabled (true) ;
} void showRedirectDialog () {RedirectToSettingsDialogFragment ()
. show (getFragmentManager (), REDIRECT_DIALOG_TAG);
}
@ Overridevoid onClick (DialogInterface dialogInterface, int i) {.dismiss ();
}
//region Work with preferencesvoid restoreProperties () {= preferences.getBoolean (SAVE_CREDENTIALS_PROPERTY, false) ;. setChecked (saveCredetials); (saveCredetials) {login=preferences.getString (CommonConstants.LOGIN_FIELD, ); password=preferences.getString (CommonConstants.PASSWORD_FIELD, ) ;. setText (login) ;. setText (password);
} hostName=PreferenceManager. (this). (CommonConstants.HOST_NAME_PROPERTY, null); (hostName == null || hostName.isEmpty ()) {();
} void savePreferences () {= saveCredentialsCheckBox.isEnabled () ;. Editor editor=preferences.edit () ;. putBoolean (SAVE_CREDENTIALS_PROPERTY, saveCredetials); (saveCredetials) {.putString (CommonConstants.LOGIN_FIELD, loginEditText.getText (). toString ()) ;. putString (CommonConstants.PASSWORD_FIELD, passwordEditText.getText (). toString ());
}
editormit ();
}
Додаток Б
Оригінальний текст класу CameraActivityclass CameraActivityActivitySurfaceHolder.Callback,.PictureCallback,.OnClickListener,.AutoFocusCallback,.OnItemClickListener{static String PROPERTY_SIZE_INDEX= PictureSizeIndex raquo ;; static String PROPERTY_FLASH= Flash raquo ;; Camera camera; int cameraId; LinearLayout bottomPanel; RelativeLayout cameraButtonLayout; Button cameraButton; OrientationEventListener orientationObserver; int iconOrientation=Surface.ROTATION_0; Camera.Size [] pictureSizes; int pictureSizeIndex=0; SharedPreferences preferences; boolean useAutoFocus=false; boolean useFlash=false; boolean hasFlash=false; ActionBar actionBar=null; Button settingsButton; ImageView settingsImageView; Button logOutButton; ImageView logOutImageView; Button flashButton; ImageView flashImageView; ImageView cameraIconImage=null; PopupWindow popupWindow=null; int popupWindowCenter=0; SurfaceHolder surfaceHolder=null;
//region Activity lifecycle
@ Overridevoid onCreate (Bundle savedInstanceState) {.onCreate (savedInstanceState); (R.layout.activity_camera) ;. clean ();=tryGetBackCamera ();=getPictureSizes (camera);=PreferenceManager.getDefaultSharedPreferences (this);=preferences.getInt (PROPERTY_SIZE_INDEX, 0);=getFlashAvailability ();=hasFlash amp; amp; preferences.getBoolean (PROPERTY_FLASH, false);=((SurfaceView) findViewById (R.id.cameraSurface)). getHolder (); surfaceHolder!=null; .addCallback (this);=getActionBar (); actionBar!=null;.setDisplayShowTitleEnabled(false);.setDisplayUseLogoEnabled(false);.setDisplayShowHomeEnabled(false);.setDisplayShowCustomEnabled(true);(R.id.cameraButton).setOnClickListener(this);(R.id.cancelButton).setOnClickListener(this);(R.id.continueButton).setOnClickListener(this);= (LinearLayout) findViewById (R.id.bottomPanel);=(Button) findViewById (R.id.cameraButton);=(ImageView) findViewById (R.id.cameraIconImage);=(RelativeLayout) findViewById (R.id.cameraButtonLayout) ;
} void onPause () {.disable (); () ;. edit (). (PROPERTY_SIZE_INDEX, pictureSizeIndex). (PROPERTY_FLASH, useFlash). (); (! bottomPanelHidden) {();
}. onPause ();
}
@ Overridevoid onResume () {(); (); (settingsButton!=null) {.enable ();
} (camera == null) {= tryGetBackCamera ();
} (); (surfaceHolder) ;. startPreview () ;. onResume ();
}
//endregion
//region Methods for cameraCamera tryGetBackCamera () {(getPackageManager (). hasSystemFeature (PackageManager.FEATURE_CAMERA)) {= findBackFacingCamera (); (cameraId gt;=0) {Camera.open (cameraId) ;
} null;
} int findBackFacingCamera () {cameraId=- 1; numberOfCameras=Camera.getNumberOfCameras (); (int i=0; i lt; numberOfCameras; i ++) {.CameraInfo info=new Camera.CameraInfo ( ) ;. getCameraInfo (i, info); (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {= i ;;
} cameraId;
} void closeCamera () {(camera!=null) {.release ();=null;
} int getRotationValue () {rotation=this.getWindowManager (). getDefaultDisplay (). getRotation (); degrees=0; (rotation) {Surface.ROTATION_0: degrees=0; break; Surface.ROTATION_90: degrees=90; break; Surface.ROTATION_1...