mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 17:53:14 +00:00
WIP
This commit is contained in:
parent
8329769028
commit
beef661e3b
|
@ -30,7 +30,9 @@ import java.util.concurrent.CompletableFuture;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
import one.nem.lacerta.component.common.picker.LacertaFilePickerDialog;
|
||||||
import one.nem.lacerta.data.Document;
|
import one.nem.lacerta.data.Document;
|
||||||
|
import one.nem.lacerta.data.LacertaLibrary;
|
||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
import one.nem.lacerta.model.document.DocumentDetail;
|
||||||
import one.nem.lacerta.model.document.DocumentMeta;
|
import one.nem.lacerta.model.document.DocumentMeta;
|
||||||
import one.nem.lacerta.processor.factory.DocumentProcessorFactory;
|
import one.nem.lacerta.processor.factory.DocumentProcessorFactory;
|
||||||
|
@ -48,6 +50,9 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
||||||
@Inject
|
@Inject
|
||||||
Document document;
|
Document document;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
LacertaLibrary lacertaLibrary;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DocumentProcessorFactory documentProcessorFactory;
|
DocumentProcessorFactory documentProcessorFactory;
|
||||||
|
|
||||||
|
@ -168,15 +173,13 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
||||||
public boolean onOptionsItemSelected(android.view.MenuItem item) {
|
public boolean onOptionsItemSelected(android.view.MenuItem item) {
|
||||||
if (item.getItemId() == R.id.action_save_new) {
|
if (item.getItemId() == R.id.action_save_new) {
|
||||||
// 新ドキュメントとして保存
|
// 新ドキュメントとして保存
|
||||||
Toast.makeText(this, "保存処理", Toast.LENGTH_SHORT).show();
|
|
||||||
saveNewDocument();
|
saveNewDocument();
|
||||||
return true;
|
return true;
|
||||||
// }
|
}
|
||||||
// else if (item.getItemId() == R.id.action_insert_exist) {
|
else if (item.getItemId() == R.id.action_insert_exist) {
|
||||||
// // 既存ドキュメントに挿入
|
// 既存ドキュメントに挿入
|
||||||
// Toast.makeText(this, "Work in progress", Toast.LENGTH_SHORT).show();
|
insertToExistDocument();
|
||||||
// insertToExistDocument();
|
return true;
|
||||||
// return true;
|
|
||||||
} else if (item.getItemId() == android.R.id.home) {
|
} else if (item.getItemId() == android.R.id.home) {
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
|
@ -217,7 +220,7 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
||||||
Bitmap[] bitmaps = new Bitmap[croppedImages.size()];
|
Bitmap[] bitmaps = new Bitmap[croppedImages.size()];
|
||||||
croppedImages.toArray(bitmaps);
|
croppedImages.toArray(bitmaps);
|
||||||
logger.debug(TAG, "bitmaps.length: " + bitmaps.length);
|
logger.debug(TAG, "bitmaps.length: " + bitmaps.length);
|
||||||
addPagesToDocumentDetail(documentDetail, bitmaps).join();
|
addPagesToDocumentDetail(documentDetail, bitmaps, null).join();
|
||||||
document.updateDocument(documentDetail).join();
|
document.updateDocument(documentDetail).join();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
finish();
|
finish();
|
||||||
|
@ -225,11 +228,11 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompletableFuture<Void> addPagesToDocumentDetail(DocumentDetail documentDetail, Bitmap[] bitmaps) {
|
private CompletableFuture<Void> addPagesToDocumentDetail(DocumentDetail documentDetail, Bitmap[] bitmaps, String commitMessage) {
|
||||||
return CompletableFuture.runAsync(() -> {
|
return CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
document.updateDocument(documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps).getDocumentDetail()).join();
|
document.updateDocument(documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps).getDocumentDetail()).join();
|
||||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit");
|
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent(commitMessage == null ? "Update" : commitMessage);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(TAG, "Error: " + e.getMessage());
|
logger.error(TAG, "Error: " + e.getMessage());
|
||||||
logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a");
|
logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a");
|
||||||
|
@ -239,7 +242,17 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private void insertToExistDocument() {
|
private void insertToExistDocument() {
|
||||||
logger.debug(TAG, "insertToExistDocument");
|
logger.debug(TAG, "insertToExistDocument");
|
||||||
// TODO-rca: 実装
|
LacertaFilePickerDialog dialog = new LacertaFilePickerDialog();
|
||||||
|
dialog.setListener(((name, fileId) -> {
|
||||||
|
document.getDocument(fileId).thenAccept((documentDetail) -> {
|
||||||
|
Bitmap[] bitmaps = new Bitmap[croppedImages.size()];
|
||||||
|
croppedImages.toArray(bitmaps);
|
||||||
|
logger.debug(TAG, "bitmaps.length: " + bitmaps.length);
|
||||||
|
addPagesToDocumentDetail(documentDetail, bitmaps, "ページを追加").join();
|
||||||
|
document.updateDocument(documentDetail).join();
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateResultView(ArrayList<Bitmap> resultImages) {
|
private void updateResultView(ArrayList<Bitmap> resultImages) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user