From 78ff41b3e39a87391e63212a0af2387c358bc23c Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 14 Jan 2024 17:34:32 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=93=E3=83=AB=E3=83=89=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E5=9B=9E=E9=81=BF=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=A2=E3=82=A6=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScannerDataManagerStubFragment.java | 201 +++++++++--------- .../feature/library/LibraryTopFragment.java | 8 +- 2 files changed, 105 insertions(+), 104 deletions(-) diff --git a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerDataManagerStubFragment.java b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerDataManagerStubFragment.java index 043f5cb7..9fd979b9 100644 --- a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerDataManagerStubFragment.java +++ b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerDataManagerStubFragment.java @@ -123,109 +123,110 @@ public class ScannerDataManagerStubFragment extends Fragment { public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - view.findViewById(R.id.button_call_camera).setOnClickListener(v -> { - Log.d("ScannerDataManagerStubFragment", "button_call_camera clicked"); - Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); - if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) { - File photoFile = null; - try { - String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); - String imageFileName = "JPEG_" + timeStamp + "_"; - File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES); - photoFile = File.createTempFile(imageFileName, ".jpg", storageDir); - } catch (IOException ex) { - Log.e("ScannerDataManagerStubFragment", "Error occurred while creating the file", ex); - } - if (photoFile != null) { - photoURI = FileProvider.getUriForFile(getActivity(), "one.nem.lacerta.provider", photoFile); - takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); - cameraLauncher.launch(takePictureIntent); - } - else { - Log.d("ScannerDataManagerStubFragment", "photoFile is null"); - } - } - else { - Log.d("ScannerDataManagerStubFragment", "camera not available"); - } - updateResults(); - }); - - view.findViewById(R.id.button_create_documnent).setOnClickListener(v -> { - Log.d("ScannerDataManagerStubFragment", "button_create_documnent clicked"); - Toast.makeText(getActivity(), "button_create_documnent clicked", Toast.LENGTH_LONG).show(); - - this.documentDetail = createSampleDocumentDetail(); - - }); - - view.findViewById(R.id.button_init_document_processor).setOnClickListener(v -> { - Log.d("ScannerDataManagerStubFragment", "button_init_document_processor clicked"); - Toast.makeText(getActivity(), "button_init_document_processor clicked", Toast.LENGTH_LONG).show(); - // TODO-rca: ここでDocumentProcessorを初期化する - if (this.documentDetail == null) { - Toast.makeText(getActivity(), "documentDetail is null", Toast.LENGTH_LONG).show(); - return; - } - this.documentProcessor = documentProcessorFactory.create(this.documentDetail); - Toast.makeText(getActivity(), "documentProcessor created", Toast.LENGTH_LONG).show(); - try { - this.documentProcessor.init(); - } catch (Exception e) { - Toast.makeText(getActivity(), "Error occurred while initializing documentProcessor", Toast.LENGTH_LONG).show(); - Log.e("ScannerDataManagerStubFragment", "Error occurred while initializing documentProcessor", e); - } - Toast.makeText(getActivity(), "documentProcessor initialized", Toast.LENGTH_LONG).show(); - }); - - view.findViewById(R.id.button_add_page).setOnClickListener(v -> { - Log.d("ScannerDataManagerStubFragment", "button_add_page clicked"); - Toast.makeText(getActivity(), "button_add_page clicked", Toast.LENGTH_LONG).show(); - if (this.documentProcessor == null) { - Toast.makeText(getActivity(), "documentProcessor is null", Toast.LENGTH_LONG).show(); - return; - } - Bitmap[] bitmaps = new Bitmap[results.size()]; - for (int i = 0; i < results.size(); i++) { - bitmaps[i] = results.get(i).getBitmap(); - } - - try { - this.documentProcessor.addNewPagesToLast(bitmaps); - } catch (Exception e) { - Toast.makeText(getActivity(), "Error occurred while adding pages", Toast.LENGTH_LONG).show(); - Log.e("ScannerDataManagerStubFragment", "Error occurred while adding pages", e); - } - - Toast.makeText(getActivity(), "pages added", Toast.LENGTH_LONG).show(); - - try { - this.documentProcessor.close(); - } catch (Exception e) { - Toast.makeText(getActivity(), "Error occurred while closing documentProcessor", Toast.LENGTH_LONG).show(); - Log.e("ScannerDataManagerStubFragment", "Error occurred while closing documentProcessor", e); - } - }); +// view.findViewById(R.id.button_call_camera).setOnClickListener(v -> { +// Log.d("ScannerDataManagerStubFragment", "button_call_camera clicked"); +// Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); +// if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) { +// File photoFile = null; +// try { +// String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); +// String imageFileName = "JPEG_" + timeStamp + "_"; +// File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES); +// photoFile = File.createTempFile(imageFileName, ".jpg", storageDir); +// } catch (IOException ex) { +// Log.e("ScannerDataManagerStubFragment", "Error occurred while creating the file", ex); +// } +// if (photoFile != null) { +// photoURI = FileProvider.getUriForFile(getActivity(), "one.nem.lacerta.provider", photoFile); +// takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); +// cameraLauncher.launch(takePictureIntent); +// } +// else { +// Log.d("ScannerDataManagerStubFragment", "photoFile is null"); +// } +// } +// else { +// Log.d("ScannerDataManagerStubFragment", "camera not available"); +// } +// updateResults(); +// }); +// +// view.findViewById(R.id.button_create_documnent).setOnClickListener(v -> { +// Log.d("ScannerDataManagerStubFragment", "button_create_documnent clicked"); +// Toast.makeText(getActivity(), "button_create_documnent clicked", Toast.LENGTH_LONG).show(); +// +// this.documentDetail = createSampleDocumentDetail(); +// +// }); +// +// view.findViewById(R.id.button_init_document_processor).setOnClickListener(v -> { +// Log.d("ScannerDataManagerStubFragment", "button_init_document_processor clicked"); +// Toast.makeText(getActivity(), "button_init_document_processor clicked", Toast.LENGTH_LONG).show(); +// // TODO-rca: ここでDocumentProcessorを初期化する +// if (this.documentDetail == null) { +// Toast.makeText(getActivity(), "documentDetail is null", Toast.LENGTH_LONG).show(); +// return; +// } +// this.documentProcessor = documentProcessorFactory.create(this.documentDetail); +// Toast.makeText(getActivity(), "documentProcessor created", Toast.LENGTH_LONG).show(); +// try { +// this.documentProcessor.init(); +// } catch (Exception e) { +// Toast.makeText(getActivity(), "Error occurred while initializing documentProcessor", Toast.LENGTH_LONG).show(); +// Log.e("ScannerDataManagerStubFragment", "Error occurred while initializing documentProcessor", e); +// } +// Toast.makeText(getActivity(), "documentProcessor initialized", Toast.LENGTH_LONG).show(); +// }); +// +// view.findViewById(R.id.button_add_page).setOnClickListener(v -> { +// Log.d("ScannerDataManagerStubFragment", "button_add_page clicked"); +// Toast.makeText(getActivity(), "button_add_page clicked", Toast.LENGTH_LONG).show(); +// if (this.documentProcessor == null) { +// Toast.makeText(getActivity(), "documentProcessor is null", Toast.LENGTH_LONG).show(); +// return; +// } +// Bitmap[] bitmaps = new Bitmap[results.size()]; +// for (int i = 0; i < results.size(); i++) { +// bitmaps[i] = results.get(i).getBitmap(); +// } +// +// try { +// this.documentProcessor.addNewPagesToLast(bitmaps); +// } catch (Exception e) { +// Toast.makeText(getActivity(), "Error occurred while adding pages", Toast.LENGTH_LONG).show(); +// Log.e("ScannerDataManagerStubFragment", "Error occurred while adding pages", e); +// } +// +// Toast.makeText(getActivity(), "pages added", Toast.LENGTH_LONG).show(); +// +// try { +// this.documentProcessor.close(); +// } catch (Exception e) { +// Toast.makeText(getActivity(), "Error occurred while closing documentProcessor", Toast.LENGTH_LONG).show(); +// Log.e("ScannerDataManagerStubFragment", "Error occurred while closing documentProcessor", e); +// } +// }); } public DocumentDetail createSampleDocumentDetail() { - - String id = UUID.randomUUID().toString(); - - Toast.makeText(getActivity(), "Generated id: " + id, Toast.LENGTH_LONG).show(); - //logger.debug("CreateSample", "Generated id: " + id); - - DocumentMeta meta = new DocumentMeta( - id, - "Sample" + DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now()), - new Date(), - new Date()); - - DocumentPath path = new DocumentPath( - deviceInfoUtils.getExternalStorageDirectoryString(), - "Sample" + DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now())); - - return new DocumentDetail(meta, path, "SampleAuthor", "SampleDefaultBranch"); +// +// String id = UUID.randomUUID().toString(); +// +// Toast.makeText(getActivity(), "Generated id: " + id, Toast.LENGTH_LONG).show(); +// //logger.debug("CreateSample", "Generated id: " + id); +// +// DocumentMeta meta = new DocumentMeta( +// id, +// "Sample" + DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now()), +// new Date(), +// new Date()); +// +// DocumentPath path = new DocumentPath( +// deviceInfoUtils.getExternalStorageDirectoryString(), +// "Sample" + DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now())); +// +// return new DocumentDetail(meta, path, "SampleAuthor", "SampleDefaultBranch"); + return null; } @Override diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java index eb672856..bbae876e 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java @@ -90,13 +90,13 @@ public class LibraryTopFragment extends Fragment { //データを取得 - List metas = document.getAllDocumentMetas(100); +// List metas = document.getAllDocumentMetas(100); - Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show(); +// Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show(); // Create and set the adapter - DocumentAdapter adapter = new DocumentAdapter(metas); - documentRecyclerView.setAdapter(adapter); +// DocumentAdapter adapter = new DocumentAdapter(metas); +// documentRecyclerView.setAdapter(adapter); // Use a LinearLayoutManager to specify the layout return view;