CameraPreviewFragment.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. package com.epson.cameracopy.p006ui;
  2. import android.content.Intent;
  3. import android.hardware.Camera;
  4. import android.hardware.SensorManager;
  5. import android.os.AsyncTask;
  6. import android.os.Bundle;
  7. import android.support.p000v4.app.Fragment;
  8. import android.view.LayoutInflater;
  9. import android.view.Menu;
  10. import android.view.MenuInflater;
  11. import android.view.MenuItem;
  12. import android.view.View;
  13. import android.view.ViewGroup;
  14. import android.view.WindowManager;
  15. import android.widget.Button;
  16. import com.epson.cameracopy.alt.FileUtils;
  17. import com.epson.cameracopy.alt.UiCommon;
  18. import com.epson.cameracopy.device.AptSensorAdapter;
  19. import com.epson.cameracopy.device.CameraFile;
  20. import com.epson.cameracopy.device.CameraPreviewControl;
  21. import com.epson.cameracopy.device.OpenCvCameraView;
  22. import com.epson.cameracopy.device.RectangleDetector;
  23. import epson.print.imgsel.CameraCopyImageSelectActivity;
  24. import java.util.Date;
  25. import java.util.Iterator;
  26. import java.util.List;
  27. import org.opencv.android.CameraBridgeViewBase;
  28. import org.opencv.android.OpenCVLoader;
  29. import org.opencv.core.CvType;
  30. import org.opencv.core.Mat;
  31. import org.opencv.core.Point;
  32. import org.opencv.core.Scalar;
  33. import org.opencv.core.Size;
  34. import org.opencv.imgproc.Imgproc;
  35. /* renamed from: com.epson.cameracopy.ui.CameraPreviewFragment */
  36. public class CameraPreviewFragment extends Fragment implements CameraBridgeViewBase.CvCameraViewListener2, OpenCvCameraView.AutoFocusCallBack {
  37. private static final Scalar COLOR_BLACK = new Scalar(0.0d, 0.0d, 0.0d, 255.0d);
  38. private static final Scalar[] PAPER_SQUARE_COLOR = {new Scalar(255.0d, 0.0d, 0.0d, 255.0d), new Scalar(0.0d, 255.0d, 0.0d, 255.0d)};
  39. private static final Point POSITION_0_0 = new Point(0.0d, 0.0d);
  40. private static final double REFERENCE_ACCELARATION = 0.45d;
  41. private static final String TAG = "CameraPreviewFragment";
  42. private final double AUTO_PICTURE_RANGE_VALUE = AptSensorAdapter.getRangeCompValue(20);
  43. private final int INIT_SPAN = 2;
  44. private final double PAPER_DETECT_VALUE = AptSensorAdapter.getRangeCompValue(45);
  45. private boolean isFragmentVisible;
  46. private boolean mAutoPhotoMode;
  47. private final long mAutoPictureStillTime = 3000;
  48. private SimpleMessageDialogFragment mCameraPictureLowResolutionDialog;
  49. private CameraPreviewControl mCameraPreviewControl;
  50. private boolean mDisableSettingsButton = false;
  51. private float mDisplayDensity;
  52. private int mDisplayRotation;
  53. private View mFunctionBarView;
  54. private final Scalar mGridColor = new Scalar(255.0d, 163.0d, 0.0d, 255.0d);
  55. private final int mGridColorWidth = 1;
  56. private boolean mHasCamera;
  57. private int mInitCount;
  58. private OpenCvCameraView mOpenCvCameraView;
  59. private long mPAfTime;
  60. private final int mPaperSquareCircleSize = 20;
  61. private Button mPhotoSelectButton;
  62. private Button mPhtographButton;
  63. /* access modifiers changed from: private */
  64. public volatile boolean mPictureTaking;
  65. private final Scalar mPositionCursorColor = new Scalar(255.0d, 0.0d, 0.0d, 255.0d);
  66. private final float mPositionCursorDispRate = 0.05098581f;
  67. private volatile boolean mPreviewActivityStarted;
  68. private Mat mRgba;
  69. private final Point mScreenSize = new Point();
  70. /* access modifiers changed from: private */
  71. public final AptSensorAdapter mSensorEventListener = new AptSensorAdapter();
  72. private TakePictureTask mTakePictureTask;
  73. private boolean noCameraDialog;
  74. private void startInformationActivity() {
  75. }
  76. static {
  77. OpenCVLoader.initDebug();
  78. }
  79. public void setAppInitFlag(boolean z) {
  80. if (z) {
  81. this.noCameraDialog = true;
  82. }
  83. }
  84. public boolean isPreviewActivityStarted() {
  85. return this.mPreviewActivityStarted;
  86. }
  87. public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
  88. View inflate = layoutInflater.inflate(R.layout.fragment_camera_preview, viewGroup, false);
  89. setHasOptionsMenu(true);
  90. setButtonListener(inflate);
  91. this.mOpenCvCameraView = (OpenCvCameraView) inflate.findViewById(R.id.view1);
  92. if (CameraPreviewControl.hasBackCamera()) {
  93. this.mHasCamera = true;
  94. this.mOpenCvCameraView.setCvCameraViewListener((CameraBridgeViewBase.CvCameraViewListener2) this);
  95. } else {
  96. this.mHasCamera = false;
  97. UiCommon.setButtonEnabled(this.mPhtographButton, false);
  98. if (bundle == null && this.noCameraDialog) {
  99. this.noCameraDialog = false;
  100. SimpleMessageDialogFragment.newInstance(R.string.back_camera_not_exists_message).show(getFragmentManager(), "error-dialog");
  101. }
  102. }
  103. this.mOpenCvCameraView.setVisibility(0);
  104. this.mDisplayRotation = ((WindowManager) getActivity().getSystemService("window")).getDefaultDisplay().getRotation();
  105. this.mSensorEventListener.setDisplayRotation(this.mDisplayRotation);
  106. this.mSensorEventListener.setSensorManager((SensorManager) getActivity().getSystemService("sensor"));
  107. this.mSensorEventListener.setReferenceAccelaration(REFERENCE_ACCELARATION);
  108. this.mFunctionBarView = inflate.findViewById(R.id.function_bar);
  109. this.mDisplayDensity = getActivity().getResources().getDisplayMetrics().density;
  110. return inflate;
  111. }
  112. private void setButtonListener(View view) {
  113. this.mPhotoSelectButton = (Button) view.findViewById(R.id.photo_select_button);
  114. this.mPhotoSelectButton.setOnClickListener(new View.OnClickListener() {
  115. public void onClick(View view) {
  116. if (!CameraPreviewFragment.this.mPictureTaking) {
  117. CameraPreviewFragment.this.startPhotoSelectActivity();
  118. }
  119. }
  120. });
  121. this.mPhtographButton = (Button) view.findViewById(R.id.photograph_button);
  122. this.mPhtographButton.setOnClickListener(new View.OnClickListener() {
  123. public void onClick(View view) {
  124. if (!CameraPreviewFragment.this.mPictureTaking) {
  125. CameraPreviewFragment.this.takePicture();
  126. }
  127. }
  128. });
  129. }
  130. private void startSettingActivity() {
  131. startActivity(new Intent(getActivity(), CameraPreviewOptionActivity.class));
  132. }
  133. /* access modifiers changed from: private */
  134. public void startPhotoSelectActivity() {
  135. startActivity(new Intent(getActivity(), CameraCopyImageSelectActivity.class));
  136. }
  137. public void onCameraViewStarted(int i, int i2) {
  138. this.mRgba = new Mat(i, i2, CvType.CV_8UC4);
  139. savePictureSizeList();
  140. checkPictureSize();
  141. }
  142. private void savePictureSizeList() {
  143. List<Camera.Size> pictureSizeList;
  144. OpenCvCameraView openCvCameraView = this.mOpenCvCameraView;
  145. if (openCvCameraView != null && (pictureSizeList = openCvCameraView.getPictureSizeList()) != null) {
  146. Iterator<Camera.Size> it = pictureSizeList.iterator();
  147. while (it.hasNext()) {
  148. Camera.Size next = it.next();
  149. if (next.width * next.height < 1000000) {
  150. it.remove();
  151. }
  152. }
  153. CameraPreviewControl.getInstance(getActivity()).setCameraPictureSizes(pictureSizeList);
  154. }
  155. }
  156. private void checkPictureSize() {
  157. OpenCvCameraView openCvCameraView;
  158. Camera.Size cameraPictureSize;
  159. CameraPreviewControl instance = CameraPreviewControl.getInstance(getActivity());
  160. if (instance.getPictureResolutionMode() == 0 && (openCvCameraView = this.mOpenCvCameraView) != null && (cameraPictureSize = openCvCameraView.getCameraPictureSize()) != null && cameraPictureSize.width * cameraPictureSize.height < 1000000) {
  161. int i = R.string.camera_picture_low_message;
  162. List<android.graphics.Point> cameraPictureSizes = instance.getCameraPictureSizes();
  163. if (cameraPictureSizes == null || cameraPictureSizes.size() <= 0) {
  164. i = R.string.has_no_hireso_picture_message;
  165. }
  166. this.mCameraPictureLowResolutionDialog = SimpleMessageDialogFragment.newInstance(i);
  167. this.mCameraPictureLowResolutionDialog.show(getFragmentManager(), "camera-resolution-warning-dialog");
  168. }
  169. }
  170. public void onCameraViewStopped() {
  171. this.mRgba.release();
  172. SimpleMessageDialogFragment simpleMessageDialogFragment = this.mCameraPictureLowResolutionDialog;
  173. if (simpleMessageDialogFragment != null) {
  174. simpleMessageDialogFragment.dismiss();
  175. this.mCameraPictureLowResolutionDialog = null;
  176. }
  177. }
  178. private void drawSensorPos(Mat mat, boolean z) {
  179. int i;
  180. int height = mat.height();
  181. if (height > 0) {
  182. double scale = (double) (1.0f / this.mOpenCvCameraView.getScale());
  183. int height2 = (int) (((double) this.mFunctionBarView.getHeight()) * scale);
  184. int height3 = (int) (((double) this.mOpenCvCameraView.getHeight()) * scale);
  185. double d = (double) height;
  186. if (height2 + 0 + height > height3) {
  187. i = (int) (((double) 0) - (((double) (height3 - height)) / 2.0d));
  188. d = (double) ((height3 - 0) - height2);
  189. } else {
  190. i = 0;
  191. }
  192. Size size = this.mRgba.size();
  193. double d2 = size.width / 2.0d;
  194. double d3 = d / 10.0d;
  195. double d4 = scale;
  196. double d5 = (double) i;
  197. Point point = new Point();
  198. double d6 = d / 2.0d;
  199. Point point2 = new Point();
  200. double d7 = size.width / 10.0d;
  201. double d8 = d2 - 1.0d;
  202. point.f432x = d8;
  203. point.f433y = d5 + d3;
  204. point2.f432x = d8;
  205. double d9 = d5 + d;
  206. point2.f433y = d9 - d3;
  207. Imgproc.line(this.mRgba, point, point2, this.mGridColor, 1);
  208. double d10 = d7;
  209. point.f432x = d10;
  210. double d11 = d5 + d6;
  211. point.f433y = d11;
  212. Size size2 = size;
  213. double d12 = d2;
  214. point2.f432x = size2.width - d10;
  215. point2.f433y = d11;
  216. Imgproc.line(this.mRgba, point, point2, this.mGridColor, 1);
  217. double d13 = size2.width / 20.0d;
  218. double d14 = d / 20.0d;
  219. double d15 = d13 * 3.0d;
  220. double d16 = d14 + d5;
  221. double d17 = 3.0d * d14;
  222. double d18 = size2.width - d13;
  223. double d19 = d5 + d17;
  224. double d20 = d5;
  225. double d21 = d9 - d17;
  226. double d22 = d9 - d14;
  227. point.f432x = d13;
  228. double d23 = d16;
  229. point.f433y = d23;
  230. point2.f432x = d15;
  231. point2.f433y = d23;
  232. double d24 = d21;
  233. Imgproc.line(this.mRgba, point, point2, this.mGridColor, 2);
  234. double d25 = size2.width - d15;
  235. point.f432x = d25;
  236. point.f433y = d23;
  237. double d26 = d19;
  238. double d27 = d18;
  239. point2.f432x = d27;
  240. point2.f433y = d23;
  241. Imgproc.line(this.mRgba, point, point2, this.mGridColor, 2);
  242. point.f432x = d13;
  243. double d28 = d23;
  244. double d29 = d22;
  245. point.f433y = d29;
  246. point2.f432x = d15;
  247. point2.f433y = d29;
  248. Imgproc.line(this.mRgba, point, point2, this.mGridColor, 2);
  249. point.f432x = d25;
  250. point.f433y = d29;
  251. point2.f432x = d27;
  252. point2.f433y = d29;
  253. Imgproc.line(this.mRgba, point, point2, this.mGridColor, 2);
  254. point.f432x = d13;
  255. double d30 = d28;
  256. point.f433y = d30;
  257. point2.f432x = d13;
  258. double d31 = d26;
  259. point2.f433y = d31;
  260. Imgproc.line(this.mRgba, point, point2, this.mGridColor, 2);
  261. point.f432x = d13;
  262. double d32 = d24;
  263. point.f433y = d32;
  264. point2.f432x = d13;
  265. point2.f433y = d29;
  266. Imgproc.line(this.mRgba, point, point2, this.mGridColor, 2);
  267. point.f432x = d27;
  268. point.f433y = d30;
  269. point2.f432x = d27;
  270. point2.f433y = d31;
  271. Imgproc.line(this.mRgba, point, point2, this.mGridColor, 2);
  272. point.f432x = d27;
  273. point.f433y = d32;
  274. point2.f432x = d27;
  275. point2.f433y = d29;
  276. Imgproc.line(this.mRgba, point, point2, this.mGridColor, 2);
  277. if (z) {
  278. double posX = d12 - (((double) (this.mSensorEventListener.getPosX() * 0.05098581f)) * d12);
  279. double posY = d6 + (((double) (this.mSensorEventListener.getPosY() * 0.05098581f)) * d6) + d20;
  280. int i2 = (int) (d4 * 20.0d * ((double) this.mDisplayDensity));
  281. Imgproc.circle(this.mRgba, new Point(posX, posY), i2, this.mPositionCursorColor, 1);
  282. double d33 = (double) i2;
  283. Imgproc.line(this.mRgba, new Point(posX, posY - d33), new Point(posX, posY + d33), this.mPositionCursorColor);
  284. Imgproc.line(this.mRgba, new Point(posX - d33, posY), new Point(posX + d33, posY), this.mPositionCursorColor);
  285. }
  286. }
  287. }
  288. private void myDrawRect(Mat mat, Point[] pointArr, boolean z) {
  289. if (pointArr != null && pointArr.length >= 1 && pointArr.length >= 2) {
  290. Scalar[] scalarArr = PAPER_SQUARE_COLOR;
  291. Scalar scalar = scalarArr[0];
  292. if (z) {
  293. scalar = scalarArr[1];
  294. }
  295. Imgproc.line(mat, pointArr[0], pointArr[1], scalar, 2);
  296. if (pointArr.length >= 3) {
  297. Imgproc.line(mat, pointArr[1], pointArr[2], scalar, 2);
  298. if (pointArr.length >= 4) {
  299. Imgproc.line(mat, pointArr[0], pointArr[3], scalar, 2);
  300. Imgproc.line(mat, pointArr[2], pointArr[3], scalar, 2);
  301. }
  302. }
  303. }
  304. }
  305. private boolean checkAutoPictureAngle() {
  306. return this.mSensorEventListener.isTerminalAngleInRange(this.AUTO_PICTURE_RANGE_VALUE);
  307. }
  308. private boolean checkAccelerrationTime() {
  309. long lastOverTime2 = this.mSensorEventListener.getLastOverTime2();
  310. if (lastOverTime2 > 0 && System.currentTimeMillis() - lastOverTime2 >= 3000) {
  311. return true;
  312. }
  313. return false;
  314. }
  315. private boolean autofousTime() {
  316. return System.currentTimeMillis() - this.mSensorEventListener.getLastOverTime2() >= 500;
  317. }
  318. private void sensorAndCamera() {
  319. if (this.isFragmentVisible) {
  320. long currentTimeMillis = System.currentTimeMillis();
  321. if (this.mAutoPhotoMode && this.mSensorEventListener.isTerminalAngleInRange(this.PAPER_DETECT_VALUE)) {
  322. boolean checkAutoPictureAngle = checkAutoPictureAngle();
  323. int detectAndDrawRectangle2 = RectangleDetector.detectAndDrawRectangle2(this.mRgba.getNativeObjAddr(), 0, this.mFunctionBarView.getHeight(), checkAutoPictureAngle);
  324. if (checkAutoPictureAngle && detectAndDrawRectangle2 == 1 && checkAccelerrationTime()) {
  325. takePicture();
  326. return;
  327. } else if (detectAndDrawRectangle2 != 0) {
  328. this.mPAfTime = currentTimeMillis;
  329. }
  330. }
  331. if (!this.mPictureTaking && !this.mAutoPhotoMode && !this.mPictureTaking && currentTimeMillis - this.mPAfTime > 4000 && !this.mOpenCvCameraView.isInAutofocus() && autofousTime()) {
  332. this.mOpenCvCameraView.doAutofocus(this);
  333. this.mPAfTime = currentTimeMillis;
  334. }
  335. }
  336. }
  337. public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame cvCameraViewFrame) {
  338. this.mRgba = cvCameraViewFrame.rgba();
  339. if (!this.mHasCamera || this.mPictureTaking) {
  340. return this.mRgba;
  341. }
  342. int i = this.mInitCount;
  343. if (i < 2) {
  344. this.mInitCount = i + 1;
  345. this.mScreenSize.f432x = (double) this.mRgba.width();
  346. this.mScreenSize.f433y = (double) this.mRgba.height();
  347. Imgproc.rectangle(this.mRgba, POSITION_0_0, this.mScreenSize, COLOR_BLACK, -1);
  348. }
  349. sensorAndCamera();
  350. if (this.mCameraPreviewControl.getGuideMode()) {
  351. drawSensorPos(this.mRgba, this.mSensorEventListener.isTerminalAngleInRange(this.PAPER_DETECT_VALUE));
  352. }
  353. return this.mRgba;
  354. }
  355. public void onCreate(Bundle bundle) {
  356. super.onCreate(bundle);
  357. this.mCameraPreviewControl = CameraPreviewControl.getInstance(getActivity());
  358. this.mPictureTaking = false;
  359. }
  360. public void onResume() {
  361. super.onResume();
  362. if (this.mHasCamera) {
  363. enableAllButton();
  364. if (this.mOpenCvCameraView.checkBackCamera()) {
  365. this.mOpenCvCameraView.enableView();
  366. this.mSensorEventListener.start();
  367. this.mPAfTime = 0;
  368. } else {
  369. UiCommon.setButtonEnabled(this.mPhtographButton, false);
  370. disableSettingButton(true);
  371. SimpleMessageDialogFragment.newInstance(R.string.back_camera_not_exists_message).show(getFragmentManager(), "error-dialog");
  372. }
  373. this.mPictureTaking = false;
  374. }
  375. this.mInitCount = 0;
  376. if (this.mPreviewActivityStarted) {
  377. this.mPreviewActivityStarted = false;
  378. this.mPictureTaking = false;
  379. enableAllButton();
  380. }
  381. this.mAutoPhotoMode = this.mCameraPreviewControl.getAutoPictureMode();
  382. this.isFragmentVisible = true;
  383. }
  384. public void onPause() {
  385. this.isFragmentVisible = false;
  386. this.mSensorEventListener.stop();
  387. TakePictureTask takePictureTask = this.mTakePictureTask;
  388. if (takePictureTask != null) {
  389. takePictureTask.cancel(false);
  390. this.mTakePictureTask = null;
  391. }
  392. OpenCvCameraView openCvCameraView = this.mOpenCvCameraView;
  393. if (openCvCameraView != null) {
  394. openCvCameraView.cancelAutofocus();
  395. this.mOpenCvCameraView.disableView();
  396. }
  397. this.mPictureTaking = false;
  398. super.onPause();
  399. }
  400. public void onDestroy() {
  401. OpenCvCameraView openCvCameraView = this.mOpenCvCameraView;
  402. if (openCvCameraView != null) {
  403. openCvCameraView.cancelAutofocus();
  404. this.mOpenCvCameraView.disableView();
  405. this.mOpenCvCameraView.setCvCameraViewListener((CameraBridgeViewBase.CvCameraViewListener2) null);
  406. this.mOpenCvCameraView = null;
  407. }
  408. super.onDestroy();
  409. }
  410. /* access modifiers changed from: private */
  411. public void showErrorDialog() {
  412. SimpleMessageDialogFragment.newInstance(R.string.file_save_error_message).show(getFragmentManager(), "error-dialog");
  413. }
  414. public void takePicture() {
  415. if (!this.mPictureTaking) {
  416. this.mPictureTaking = true;
  417. getActivity().runOnUiThread(new Runnable() {
  418. public void run() {
  419. CameraPreviewFragment.this.disableAllButton();
  420. }
  421. });
  422. this.mSensorEventListener.stop();
  423. this.mTakePictureTask = new TakePictureTask(this.mOpenCvCameraView);
  424. this.mTakePictureTask.execute(new Void[0]);
  425. }
  426. }
  427. /* access modifiers changed from: private */
  428. public void takePictureStep2() {
  429. this.mOpenCvCameraView.takePicture(FileUtils.getNewTemporaryJpegFile(getActivity()).getPath(), new OpenCvCameraView.MyPictureTakeCallback() {
  430. public void onMyPictureTaken(boolean z, String str) {
  431. if (!z || str == null) {
  432. CameraPreviewFragment.this.enableAllButton();
  433. CameraPreviewFragment.this.mSensorEventListener.start();
  434. boolean unused = CameraPreviewFragment.this.mPictureTaking = false;
  435. CameraPreviewFragment.this.showErrorDialog();
  436. return;
  437. }
  438. CameraPreviewFragment.this.startPictureViewActivity(str);
  439. }
  440. });
  441. }
  442. /* access modifiers changed from: private */
  443. public void enableAllButton() {
  444. if (CameraPreviewControl.hasBackCamera()) {
  445. UiCommon.setButtonEnabled(this.mPhtographButton, true);
  446. disableSettingButton(false);
  447. }
  448. UiCommon.setButtonEnabled(this.mPhotoSelectButton, true);
  449. }
  450. /* access modifiers changed from: private */
  451. public void disableAllButton() {
  452. UiCommon.setButtonEnabled(this.mPhtographButton, false);
  453. disableSettingButton(true);
  454. UiCommon.setButtonEnabled(this.mPhotoSelectButton, false);
  455. }
  456. /* access modifiers changed from: private */
  457. public void startPictureViewActivity(String str) {
  458. Intent intent = new Intent(getActivity(), ImagePreviewActivity.class);
  459. intent.putExtra(ImagePreviewActivity.PARAM_CAMERA_FILE, new CameraFile(new Date(), str));
  460. startActivity(intent);
  461. this.mPreviewActivityStarted = true;
  462. }
  463. public void onAutoFocusCompleted(boolean z) {
  464. this.mPAfTime = System.currentTimeMillis();
  465. }
  466. private void disableSettingButton(boolean z) {
  467. this.mDisableSettingsButton = z;
  468. getActivity().invalidateOptionsMenu();
  469. }
  470. public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
  471. if (!this.mDisableSettingsButton) {
  472. menuInflater.inflate(R.C2138menu.camera_menu, menu);
  473. }
  474. super.onCreateOptionsMenu(menu, menuInflater);
  475. }
  476. public boolean onOptionsItemSelected(MenuItem menuItem) {
  477. if (menuItem.getItemId() != R.id.camera_setting) {
  478. return super.onOptionsItemSelected(menuItem);
  479. }
  480. if (this.mPictureTaking) {
  481. return false;
  482. }
  483. startSettingActivity();
  484. return true;
  485. }
  486. public boolean onBackPressed() {
  487. return !this.mPictureTaking;
  488. }
  489. /* renamed from: com.epson.cameracopy.ui.CameraPreviewFragment$TakePictureTask */
  490. class TakePictureTask extends AsyncTask<Void, Void, Void> {
  491. private OpenCvCameraView mMyOpenCvCameraView;
  492. public TakePictureTask(OpenCvCameraView openCvCameraView) {
  493. this.mMyOpenCvCameraView = openCvCameraView;
  494. }
  495. protected Void doInBackground(Void... voidArr) {
  496. System.currentTimeMillis();
  497. while (!isCancelled() && this.mMyOpenCvCameraView.isInAutofocus()) {
  498. try {
  499. Thread.sleep(100);
  500. } catch (InterruptedException e) {
  501. e.printStackTrace();
  502. }
  503. }
  504. return null;
  505. }
  506. protected void onPostExecute(Void voidR) {
  507. CameraPreviewFragment.this.takePictureStep2();
  508. }
  509. }
  510. }