From 7c8083846306886aa7a408640e4faa108ca6ec28 Mon Sep 17 00:00:00 2001 From: endian11 <Dana_Lee1016@126.com> Date: 星期四, 19 九月 2019 18:21:22 +0800 Subject: [PATCH] 拍照功能加入log;主界面退出系统点击后打开拍照界面; --- app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java | 28 ++++++++++++++++------------ app/src/main/java/safeluck/drive/evaluation/fragment/TakePhotoFragment.java | 12 ++++++++++-- app/src/main/AndroidManifest.xml | 4 ++-- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d2ccc85..13dd662 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - android:sharedUserId="android.uid.system" +android:sharedUserId="android.uid.system" package="safeluck.drive.evaluation"> <uses-permission android:name="android.permission.CAMERA" /> @@ -13,7 +13,7 @@ android:supportsRtl="true" android:name=".app" android:theme="@style/AppTheme"> - <activity android:name=".MainActivity" android:screenOrientation="landscape"> + <activity android:name=".MainActivity" android:screenOrientation="landscape" > <intent-filter> <action android:name="android.intent.action.MAIN" /> diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java index a7272a5..615a1bb 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java @@ -84,19 +84,23 @@ break; case R.id.exit_sys: //閫�鍑虹郴缁� - AlertDialog.Builder builder = new AlertDialog.Builder(_mActivity); - builder.setMessage("鎮ㄥ皢閫�鍑虹郴缁�,璇风‘璁ゆ暟鎹凡淇濆瓨").setPositiveButton("纭畾", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - _mActivity.finish(); +// AlertDialog.Builder builder = new AlertDialog.Builder(_mActivity); +// builder.setMessage("鎮ㄥ皢閫�鍑虹郴缁�,璇风‘璁ゆ暟鎹凡淇濆瓨").setPositiveButton("纭畾", new DialogInterface.OnClickListener() { +// @Override +// public void onClick(DialogInterface dialog, int which) { +// _mActivity.finish(); +// } +// }).setNegativeButton("鍙栨秷", new DialogInterface.OnClickListener() { +// @Override +// public void onClick(DialogInterface dialog, int which) { +// dialog.dismiss(); +// } +// }).show(); + TakePhotoFragment takePhotoFragment = findFragment(TakePhotoFragment.class); + if (takePhotoFragment == null){ + takePhotoFragment = TakePhotoFragment.newInstance(); } - }).setNegativeButton("鍙栨秷", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }).show(); - + start(takePhotoFragment); break; case R.id.system_setting: diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/TakePhotoFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/TakePhotoFragment.java index a86edb8..72be15e 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/TakePhotoFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/TakePhotoFragment.java @@ -58,6 +58,7 @@ import me.yokeyword.fragmentation.SupportFragment; import safeluck.drive.evaluation.R; import safeluck.drive.evaluation.customview.AutoFitTextureView; +import safeluck.drive.evaluation.util.MyLog; /** * MyApplication2 @@ -183,6 +184,7 @@ @Override public void onOpened(@NonNull CameraDevice cameraDevice) { // This method is called when the camera is opened. We start camera preview here. + MyLog.i(TAG,"Camera Device onOpened"); mCameraOpenCloseLock.release(); mCameraDevice = cameraDevice; createCameraPreviewSession(); @@ -190,6 +192,7 @@ @Override public void onDisconnected(@NonNull CameraDevice cameraDevice) { + MyLog.i(TAG,"Camera Device onDisconnected"); mCameraOpenCloseLock.release(); cameraDevice.close(); mCameraDevice = null; @@ -197,6 +200,7 @@ @Override public void onError(@NonNull CameraDevice cameraDevice, int error) { + MyLog.i(TAG,"Camera Device onError"); mCameraOpenCloseLock.release(); cameraDevice.close(); mCameraDevice = null; @@ -517,6 +521,7 @@ // Find out if we need to swap dimension to get the preview size relative to sensor // coordinate. int displayRotation = activity.getWindowManager().getDefaultDisplay().getRotation(); + MyLog.i(TAG,"displayRotation="+displayRotation); //noinspection ConstantConditions mSensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); boolean swappedDimensions = false; @@ -543,7 +548,7 @@ int rotatedPreviewHeight = height; int maxPreviewWidth = displaySize.x; int maxPreviewHeight = displaySize.y; - + MyLog.i(TAG,"swappedDimensions="+swappedDimensions); if (swappedDimensions) { rotatedPreviewWidth = height; rotatedPreviewHeight = width; @@ -565,9 +570,10 @@ mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, largest); - + MyLog.i(TAG,"chooseOptimalSize="+mPreviewSize.getWidth()+":"+mPreviewSize.getHeight()); // We fit the aspect ratio of TextureView to the size of preview we picked. int orientation = getResources().getConfiguration().orientation; + MyLog.i(TAG,"getResources().getConfiguration().orientation="+orientation); if (orientation == Configuration.ORIENTATION_LANDSCAPE) { mTextureView.setAspectRatio( mPreviewSize.getWidth(), mPreviewSize.getHeight()); @@ -581,6 +587,7 @@ mFlashSupported = available == null ? false : available; mCameraId = cameraId; + MyLog.i(TAG,"CameraID="+mCameraId+ " FlashSupported="+mFlashSupported); return; } } catch (CameraAccessException e) { @@ -745,6 +752,7 @@ RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth()); float centerX = viewRect.centerX(); float centerY = viewRect.centerY(); + MyLog.i(TAG,"configureTransform centerX="+centerX+" CenterY="+centerY+" getDefaultDisplay().getRotation()="+rotation); if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) { bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY()); matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL); -- Gitblit v1.8.0