更新機能 WIP

This commit is contained in:
r-ca 2024-01-29 05:27:29 +09:00
parent dbdb2b76d7
commit afb40170ca
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 35 additions and 7 deletions

View File

@ -35,6 +35,8 @@ 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.DocumentMeta;
import one.nem.lacerta.model.document.page.Page;
import one.nem.lacerta.processor.DocumentProcessor;
import one.nem.lacerta.processor.factory.DocumentProcessorFactory;
import one.nem.lacerta.utils.LacertaLogger;
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
@ -73,7 +75,9 @@ public class ScannerManagerActivity extends AppCompatActivity {
// Variables
private ArrayList<Bitmap> croppedImages = new ArrayList<>();
private boolean single = false;
private boolean update = false;
private String documentId;
private int index = 0;
View view;
@ -104,7 +108,7 @@ public class ScannerManagerActivity extends AppCompatActivity {
null
);
DocumentScanner documentScannerSingle = new DocumentScanner( // TODO-rca: ひどすぎるのでなんとかする
DocumentScanner documentScannerUpdate = new DocumentScanner( // TODO-rca: ひどすぎるのでなんとかする
this,
(croppedImageResults) -> {
logger.debug(TAG, "croppedImage size: " + croppedImageResults.size());
@ -160,11 +164,12 @@ public class ScannerManagerActivity extends AppCompatActivity {
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
if (bundle != null) {
this.single = bundle.getBoolean("single", false);
update = bundle.getBoolean("update", false);
documentId = bundle.getString("documentId");
index = bundle.getInt("index", 0);
}
if (this.single) {
documentScanner = documentScannerSingle;
if (this.update) {
documentScanner = documentScannerUpdate;
}
documentScanner.startScan();
// Init
@ -251,6 +256,22 @@ public class ScannerManagerActivity extends AppCompatActivity {
});
}
private void updatePage() {
logger.debug(TAG, "updatePage");
// Deprecatedだが中断機能が存在しないので操作をブロックする目的で(意図的に)使用
ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("保存中..."); // TODO-rca: テキストをリソースに移動
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
dialog.show();
document.getDocument(documentId).thenAccept((documentDetail) -> {
DocumentProcessor documentProcessor = documentProcessorFactory.create(documentDetail);
documentProcessor.updatePageAtIndex(croppedImages.get(0), index);
document.updateDocument(documentProcessor.getDocumentDetail()).join();
dialog.dismiss();
});
}
private void insertToExistDocument() {
logger.debug(TAG, "insertToExistDocument");
LacertaFilePickerDialog dialog = new LacertaFilePickerDialog();

View File

@ -1,5 +1,6 @@
package one.nem.lacerta.component.viewer;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
@ -16,6 +17,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.component.scanner.ScannerManagerActivity;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.utils.LacertaLogger;
@ -107,7 +109,12 @@ public class ViewerBodyFragment extends Fragment {
builder.setTitle("ページを更新しますか?");
builder.setPositiveButton("更新", (dialog, which) -> {
// update
// ScannerをIntent
Intent intent = new Intent(getActivity(), ScannerManagerActivity.class);
intent.putExtra("update", true);
intent.putExtra("documentId", documentId);
intent.putExtra("index", position);
startActivity(intent);
});
builder.setNegativeButton("キャンセル", (dialog, which) -> {
// cancel