From 33766fbe1841f20aeacb28c750fd7ab5f7828927 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 23:56:26 +0900 Subject: [PATCH 01/56] =?UTF-8?q?ApplyTagListItem=E4=BD=9C=E6=88=90=20?= =?UTF-8?q?=E4=BB=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/layout/apply_tag_list_item.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 component/common/src/main/res/layout/apply_tag_list_item.xml diff --git a/component/common/src/main/res/layout/apply_tag_list_item.xml b/component/common/src/main/res/layout/apply_tag_list_item.xml new file mode 100644 index 00000000..5cb9079c --- /dev/null +++ b/component/common/src/main/res/layout/apply_tag_list_item.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file From 8ca05fe45496574c7e77e416131446559b8d5a07 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 23:57:03 +0900 Subject: [PATCH 02/56] =?UTF-8?q?=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E5=86=85=E5=AE=B9=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/layout/lacerta_dialog_apply_tag.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 component/common/src/main/res/layout/lacerta_dialog_apply_tag.xml diff --git a/component/common/src/main/res/layout/lacerta_dialog_apply_tag.xml b/component/common/src/main/res/layout/lacerta_dialog_apply_tag.xml new file mode 100644 index 00000000..49e79fe8 --- /dev/null +++ b/component/common/src/main/res/layout/lacerta_dialog_apply_tag.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file From 1515e53484e805d9470a0d537ef2df29a9127691 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:06:28 +0900 Subject: [PATCH 03/56] =?UTF-8?q?Adapter=E5=AE=9F=E8=A3=85=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/LacertaApplyTagAdapter.java | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java new file mode 100644 index 00000000..08440304 --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java @@ -0,0 +1,78 @@ +package one.nem.lacerta.component.common; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CheckBox; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; + +import one.nem.lacerta.model.document.tag.DocumentTag; + +public class LacertaApplyTagAdapter extends RecyclerView.Adapter{ + + // Listener + public interface LacertaApplyTagDialogListener { + void itemChecked(View view, int position); + void itemUnchecked(View view, int position); + } + + // Variables + private ArrayList documentTagArrayList; + private LacertaApplyTagDialogListener listener; + + // Setter + public LacertaApplyTagAdapter setListener(LacertaApplyTagDialogListener listener) { + this.listener = listener; + return this; + } + + public LacertaApplyTagAdapter setDocumentTagArrayList(ArrayList documentTagArrayList) { + this.documentTagArrayList = documentTagArrayList; + return this; + } + + // Constructor + public LacertaApplyTagAdapter(ArrayList documentTagArrayList) { + this.documentTagArrayList = documentTagArrayList; + } + + @NonNull + @Override + public LacertaApplyTagAdapter.LacertaApplyTagViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.lacerta_dialog_apply_tag, parent, false); + return new LacertaApplyTagAdapter.LacertaApplyTagViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull LacertaApplyTagAdapter.LacertaApplyTagViewHolder holder, int position) { + DocumentTag documentTag = documentTagArrayList.get(position); + holder.checkBox.setText(documentTag.getName()); + holder.checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> { + if (isChecked) { + listener.itemChecked(buttonView, position); + } else { + listener.itemUnchecked(buttonView, position); + } + }); + } + + @Override + public int getItemCount() { + return documentTagArrayList == null ? 0 : documentTagArrayList.size(); + } + + public class LacertaApplyTagViewHolder extends RecyclerView.ViewHolder { + + CheckBox checkBox; + + public LacertaApplyTagViewHolder(@NonNull View itemView) { + super(itemView); + + checkBox = itemView.findViewById(R.id.checkBox); + } + } +} From dcd10b7d2b9773386ec2190d0b75dabf94c9ca38 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:12:02 +0900 Subject: [PATCH 04/56] =?UTF-8?q?Dialog=E3=81=A7=E4=BD=BF=E3=81=86?= =?UTF-8?q?=E6=8B=A1=E5=BC=B5=E3=83=A2=E3=83=87=E3=83=AB=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ocumentTagApplyTagDialogExtendedModel.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java b/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java new file mode 100644 index 00000000..622d38e7 --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java @@ -0,0 +1,24 @@ +package one.nem.lacerta.component.common.model; + +import one.nem.lacerta.model.document.tag.DocumentTag; + +/** + * DocumentTagを設定するダイアログで使うための拡張モデル + * チェックボックスの状態を保持するように + */ +public class DocumentTagApplyTagDialogExtendedModel extends DocumentTag { + + private boolean isChecked; + + public DocumentTagApplyTagDialogExtendedModel(DocumentTag documentTag) { + super(documentTag.getId(), documentTag.getName(), documentTag.getColor()); + } + + public boolean getIsChecked() { + return isChecked; + } + + public void setIsChecked(boolean checked) { + isChecked = checked; + } +} From 425616c3359a329ee5613d4075396b59dee6d66a Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:12:28 +0900 Subject: [PATCH 05/56] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/model/DocumentTagApplyTagDialogExtendedModel.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java b/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java index 622d38e7..6f631244 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java @@ -2,6 +2,8 @@ package one.nem.lacerta.component.common.model; import one.nem.lacerta.model.document.tag.DocumentTag; +// TODO-rca: クラス名が長すぎ + /** * DocumentTagを設定するダイアログで使うための拡張モデル * チェックボックスの状態を保持するように From d56244777762267fb42f717bf1365739e30392f6 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:14:02 +0900 Subject: [PATCH 06/56] =?UTF-8?q?=E6=8B=A1=E5=BC=B5=E3=83=A2=E3=83=87?= =?UTF-8?q?=E3=83=AB=E3=82=92=E4=BD=BF=E3=81=86=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=82=A2=E3=83=80=E3=83=97=E3=82=BF=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/common/LacertaApplyTagAdapter.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java index 08440304..1c9954d4 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java @@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; +import one.nem.lacerta.component.common.model.DocumentTagApplyTagDialogExtendedModel; import one.nem.lacerta.model.document.tag.DocumentTag; public class LacertaApplyTagAdapter extends RecyclerView.Adapter{ @@ -21,7 +22,7 @@ public class LacertaApplyTagAdapter extends RecyclerView.Adapter documentTagArrayList; + private ArrayList documentTagArrayList; private LacertaApplyTagDialogListener listener; // Setter @@ -30,14 +31,13 @@ public class LacertaApplyTagAdapter extends RecyclerView.Adapter documentTagArrayList) { + public LacertaApplyTagAdapter setDocumentTagArrayList(ArrayList documentTagArrayList) { this.documentTagArrayList = documentTagArrayList; return this; } - // Constructor - public LacertaApplyTagAdapter(ArrayList documentTagArrayList) { - this.documentTagArrayList = documentTagArrayList; + // Empty constructor + public LacertaApplyTagAdapter() { } @NonNull @@ -49,8 +49,9 @@ public class LacertaApplyTagAdapter extends RecyclerView.Adapter { if (isChecked) { listener.itemChecked(buttonView, position); From 6847af9b9ad392ddf685fca6e4a19c47bc019d4b Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:23:18 +0900 Subject: [PATCH 07/56] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=AB=E3=83=90?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=81=AB=E3=82=BF=E3=82=B0=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E3=81=86=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/common/LacertaApplyTagAdapter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java index 1c9954d4..90229cff 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java @@ -17,8 +17,8 @@ public class LacertaApplyTagAdapter extends RecyclerView.Adapter { if (isChecked) { - listener.itemChecked(buttonView, position); + listener.itemChecked(buttonView, documentTag.getId()); } else { - listener.itemUnchecked(buttonView, position); + listener.itemUnchecked(buttonView, documentTag.getId()); } }); } From 79a64c3108431cc40d3230d64cab47125954309f Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:25:20 +0900 Subject: [PATCH 08/56] =?UTF-8?q?=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E5=AE=9F=E8=A3=85WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/LacertaApplyTagDialog.java | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java new file mode 100644 index 00000000..aefa9cf6 --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -0,0 +1,154 @@ +package one.nem.lacerta.component.common; + +import android.app.Dialog; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.CheckBox; +import android.widget.Checkable; +import android.widget.EditText; +import android.widget.Toast; + +import androidx.fragment.app.DialogFragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +import javax.inject.Inject; + +import dagger.hilt.android.AndroidEntryPoint; +import one.nem.lacerta.component.common.model.DocumentTagApplyTagDialogExtendedModel; +import one.nem.lacerta.data.LacertaLibrary; +import one.nem.lacerta.model.document.tag.DocumentTag; +import one.nem.lacerta.utils.LacertaLogger; + +@AndroidEntryPoint +public class LacertaApplyTagDialog extends DialogFragment { + + @Inject + LacertaLogger logger; + + @Inject + LacertaLibrary lacertaLibrary; + + // Listener + public interface LacertaApplyTagDialogListener { + void onDialogPositiveClick(DialogFragment dialog); + void onDialogNegativeClick(DialogFragment dialog); + } + + // Variables + private String title; + private String message; + private String positiveButtonText; + private String negativeButtonText; + private String documentId; + private LacertaApplyTagDialogListener listener; + + // Setter + + public LacertaApplyTagDialog setListener(LacertaApplyTagDialogListener listener) { + this.listener = listener; + return this; + } + + public LacertaApplyTagDialog setTitle(String title) { + this.title = title; + return this; + } + + public LacertaApplyTagDialog setMessage(String message) { + this.message = message; + return this; + } + + public LacertaApplyTagDialog setPositiveButtonText(String positiveButtonText) { + this.positiveButtonText = positiveButtonText; + return this; + } + + public LacertaApplyTagDialog setNegativeButtonText(String negativeButtonText) { + this.negativeButtonText = negativeButtonText; + return this; + } + + public LacertaApplyTagDialog setDocumentId(String documentId) { + this.documentId = documentId; + return this; + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + LayoutInflater inflater = requireActivity().getLayoutInflater(); + View view = inflater.inflate(R.layout.lacerta_dialog_apply_tag, null); + + // RecyclerView + RecyclerView recyclerView = view.findViewById(R.id.apply_tag_list); + + LacertaApplyTagAdapter lacertaApplyTagAdapter = new LacertaApplyTagAdapter(); + lacertaApplyTagAdapter.setListener(new LacertaApplyTagAdapter.LacertaApplyTagDialogListener() { + @Override + public void itemChecked(View view, String tagId) { + // Do something + Toast.makeText(view.getContext(), tagId, Toast.LENGTH_SHORT).show(); + } + + @Override + public void itemUnchecked(View view, String tagId) { + // Do something + Toast.makeText(view.getContext(), tagId, Toast.LENGTH_SHORT).show(); + } + }); + + recyclerView.setAdapter(lacertaApplyTagAdapter); + recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext())); + + getDocumentTagArrayList(documentId).thenAccept(documentTagArrayList -> { + lacertaApplyTagAdapter.setDocumentTagArrayList(documentTagArrayList); + lacertaApplyTagAdapter.notifyDataSetChanged(); // TODO-rca: アニメーション + }); + + // Set the dialog title + builder.setTitle(title) + .setMessage(message) + .setView(view) + .setPositiveButton(positiveButtonText, (dialog, id) -> { + // Send the positive button event back to the host activity + listener.onDialogPositiveClick(LacertaApplyTagDialog.this); + }) + .setNegativeButton(negativeButtonText, (dialog, id) -> { + // Send the negative button event back to the host activity + listener.onDialogNegativeClick(LacertaApplyTagDialog.this); + }); + return builder.create(); + } + + private CompletableFuture> getDocumentTagArrayList(String documentId) { + return CompletableFuture.supplyAsync(() -> { + ArrayList documentTagArrayList = new ArrayList<>(); + lacertaLibrary.getTagList().thenAccept(documentTags -> { + ArrayList appliedTags = lacertaLibrary.getAppliedTagList(documentId).join(); + for (int i = 0; i < documentTags.size(); i++) { + boolean isChecked = false; + for (int j = 0; j < appliedTags.size(); j++) { + if (documentTags.get(i).getId().equals(appliedTags.get(j).getId())) { + isChecked = true; + break; + } + } + documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( + new DocumentTag(documentTags.get(i).getId(), documentTags.get(i).getName(), documentTags.get(i).getColor()), isChecked)); + } + }); + + return documentTagArrayList; + }); + } + +} From 67a8f42ef145d3ff3a81a696e24afcb0762a4bcc Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:25:30 +0900 Subject: [PATCH 09/56] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=A9=E3=82=AF=E3=82=BF=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/model/DocumentTagApplyTagDialogExtendedModel.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java b/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java index 6f631244..c6bf1861 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/model/DocumentTagApplyTagDialogExtendedModel.java @@ -16,6 +16,11 @@ public class DocumentTagApplyTagDialogExtendedModel extends DocumentTag { super(documentTag.getId(), documentTag.getName(), documentTag.getColor()); } + public DocumentTagApplyTagDialogExtendedModel(DocumentTag documentTag, boolean isChecked) { + super(documentTag.getId(), documentTag.getName(), documentTag.getColor()); + this.isChecked = isChecked; + } + public boolean getIsChecked() { return isChecked; } From 0d5c3c43371d02bc14053680548224be6bb25e0a Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:26:20 +0900 Subject: [PATCH 10/56] =?UTF-8?q?=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/viewer/src/main/res/menu/viewer_menu.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/component/viewer/src/main/res/menu/viewer_menu.xml b/component/viewer/src/main/res/menu/viewer_menu.xml index 231419b6..92dab962 100644 --- a/component/viewer/src/main/res/menu/viewer_menu.xml +++ b/component/viewer/src/main/res/menu/viewer_menu.xml @@ -20,4 +20,12 @@ android:id="@+id/action_combine" android:title="結合" /> + + + + \ No newline at end of file From d794bb97b6e1c11ee981d2de29108c5701462898 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:28:03 +0900 Subject: [PATCH 11/56] =?UTF-8?q?=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E3=81=AE=E3=82=A4=E3=83=99?= =?UTF-8?q?=E3=83=B3=E3=83=88=E5=AE=9F=E8=A3=85(=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerContainerFragment.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index 7636eb97..da799b80 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -22,6 +22,7 @@ import com.google.android.material.textfield.TextInputLayout; import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; +import one.nem.lacerta.component.common.LacertaApplyTagDialog; import one.nem.lacerta.component.common.picker.LacertaFilePickerDialog; import one.nem.lacerta.data.Document; import one.nem.lacerta.data.LacertaLibrary; @@ -187,6 +188,9 @@ public class ViewerContainerFragment extends Fragment { } else if (item.getItemId() == R.id.action_combine) { combineDocument(); return true; + } else if (item.getItemId() == R.id.action_apply_tag) { + applyTag(); + return true; } else { return false; } @@ -194,6 +198,16 @@ public class ViewerContainerFragment extends Fragment { }); } + private void applyTag() { + LacertaApplyTagDialog lacertaApplyTagDialog = new LacertaApplyTagDialog(); + lacertaApplyTagDialog + .setTitle("タグの適用") + .setMessage("タグを適用するファイルを選択してください") + .setNegativeButtonText("キャンセル") + .setDocumentId(documentId) + .show(getChildFragmentManager(), "LacertaApplyTagDialog"); + } + private void combineDocument() { LacertaFilePickerDialog lacertaFilePickerDialog = new LacertaFilePickerDialog(); lacertaFilePickerDialog.setListener((fileName, selectedId) -> { From 4770977e666013d0410cc091b737b65143f2657e Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:32:17 +0900 Subject: [PATCH 12/56] =?UTF-8?q?CheckBox=E3=81=AEId=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/common/LacertaApplyTagAdapter.java | 6 +++++- .../common/src/main/res/layout/apply_tag_list_item.xml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java index 90229cff..ae8e2a6a 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java @@ -1,5 +1,6 @@ package one.nem.lacerta.component.common; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -50,6 +51,9 @@ public class LacertaApplyTagAdapter extends RecyclerView.Adapter { @@ -73,7 +77,7 @@ public class LacertaApplyTagAdapter extends RecyclerView.Adapter Date: Mon, 29 Jan 2024 00:32:54 +0900 Subject: [PATCH 13/56] =?UTF-8?q?Inflate=E3=81=99=E3=82=8B=E3=83=AC?= =?UTF-8?q?=E3=82=A4=E3=82=A2=E3=82=A6=E3=83=88=E3=82=92=E9=96=93=E9=81=95?= =?UTF-8?q?=E3=81=88=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/common/LacertaApplyTagAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java index ae8e2a6a..4e533a5a 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagAdapter.java @@ -44,7 +44,7 @@ public class LacertaApplyTagAdapter extends RecyclerView.Adapter Date: Mon, 29 Jan 2024 00:35:51 +0900 Subject: [PATCH 14/56] =?UTF-8?q?AppliedTag=E3=82=92=E3=82=AF=E3=83=A9?= =?UTF-8?q?=E3=82=B9=E5=A4=89=E6=95=B0=E3=81=A7=E6=8C=81=E3=81=A4=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/common/LacertaApplyTagDialog.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index aefa9cf6..14508239 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -49,6 +49,7 @@ public class LacertaApplyTagDialog extends DialogFragment { private String negativeButtonText; private String documentId; private LacertaApplyTagDialogListener listener; + private ArrayList appliedTags; // Setter @@ -133,11 +134,11 @@ public class LacertaApplyTagDialog extends DialogFragment { return CompletableFuture.supplyAsync(() -> { ArrayList documentTagArrayList = new ArrayList<>(); lacertaLibrary.getTagList().thenAccept(documentTags -> { - ArrayList appliedTags = lacertaLibrary.getAppliedTagList(documentId).join(); + setAppliedTagList(documentId); for (int i = 0; i < documentTags.size(); i++) { boolean isChecked = false; - for (int j = 0; j < appliedTags.size(); j++) { - if (documentTags.get(i).getId().equals(appliedTags.get(j).getId())) { + for (int j = 0; j < this.appliedTags.size(); j++) { + if (documentTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { isChecked = true; break; } @@ -151,4 +152,10 @@ public class LacertaApplyTagDialog extends DialogFragment { }); } + private void setAppliedTagList(String documentId) { + lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTags -> { + this.appliedTags = documentTags; + }); + } + } From 9a4d3a1310448639acb6f864df82189c9e2ee116 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:38:03 +0900 Subject: [PATCH 15/56] =?UTF-8?q?=E9=9D=9E=E5=90=8C=E6=9C=9F=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/common/LacertaApplyTagDialog.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 14508239..596a2d01 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -18,6 +18,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; import javax.inject.Inject; @@ -49,6 +50,7 @@ public class LacertaApplyTagDialog extends DialogFragment { private String negativeButtonText; private String documentId; private LacertaApplyTagDialogListener listener; + private ArrayList registeredTags; private ArrayList appliedTags; // Setter @@ -152,9 +154,17 @@ public class LacertaApplyTagDialog extends DialogFragment { }); } - private void setAppliedTagList(String documentId) { - lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTags -> { - this.appliedTags = documentTags; + private CompletableFuture setAppliedTagList(String documentId) { + return CompletableFuture.runAsync(() -> { + lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTags -> { + this.appliedTags = documentTags; + }); + }); + } + + private void setRegisteredTagList() { + lacertaLibrary.getTagList().thenAccept(documentTags -> { + this.registeredTags = documentTags; }); } From f2f4c77016114ae9188f0ac7aa31eae9ec13162f Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:40:06 +0900 Subject: [PATCH 16/56] =?UTF-8?q?=E7=99=BB=E9=8C=B2=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=82=8B=E3=82=BF=E3=82=B0=E4=B8=80=E8=A6=A7?= =?UTF-8?q?=E3=81=AE=E5=8F=96=E5=BE=97=E3=82=92=E5=88=87=E3=82=8A=E5=87=BA?= =?UTF-8?q?=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/LacertaApplyTagDialog.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 596a2d01..913621a8 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -135,21 +135,20 @@ public class LacertaApplyTagDialog extends DialogFragment { private CompletableFuture> getDocumentTagArrayList(String documentId) { return CompletableFuture.supplyAsync(() -> { ArrayList documentTagArrayList = new ArrayList<>(); - lacertaLibrary.getTagList().thenAccept(documentTags -> { - setAppliedTagList(documentId); - for (int i = 0; i < documentTags.size(); i++) { + setRegisteredTagList().thenAccept(Void -> { + setAppliedTagList(documentId).join(); + for (int i = 0; i < this.registeredTags.size(); i++) { boolean isChecked = false; for (int j = 0; j < this.appliedTags.size(); j++) { - if (documentTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { + if (this.registeredTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { isChecked = true; break; } } documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( - new DocumentTag(documentTags.get(i).getId(), documentTags.get(i).getName(), documentTags.get(i).getColor()), isChecked)); + new DocumentTag(this.registeredTags.get(i).getId(), this.registeredTags.get(i).getName(), this.registeredTags.get(i).getColor()), isChecked)); } }); - return documentTagArrayList; }); } @@ -162,9 +161,11 @@ public class LacertaApplyTagDialog extends DialogFragment { }); } - private void setRegisteredTagList() { - lacertaLibrary.getTagList().thenAccept(documentTags -> { - this.registeredTags = documentTags; + private CompletableFuture setRegisteredTagList() { + return CompletableFuture.runAsync(() -> { + lacertaLibrary.getTagList().thenAccept(documentTags -> { + this.registeredTags = documentTags; + }); }); } From d66546a567d5da1fa87ceba914cd6032e3e6f1c3 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:44:02 +0900 Subject: [PATCH 17/56] =?UTF-8?q?CheckBox=E3=81=AE=E5=A4=89=E5=8C=96?= =?UTF-8?q?=E3=81=AB=E5=BF=9C=E3=81=98=E3=81=A6=E3=82=A4=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E3=83=B3=E3=82=B9=E5=A4=89=E6=95=B0=E3=81=AETagList?= =?UTF-8?q?=E3=82=92=E5=A4=89=E5=8C=96=E3=81=95=E3=81=9B=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/common/LacertaApplyTagDialog.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 913621a8..aabc81d5 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -98,14 +98,12 @@ public class LacertaApplyTagDialog extends DialogFragment { lacertaApplyTagAdapter.setListener(new LacertaApplyTagAdapter.LacertaApplyTagDialogListener() { @Override public void itemChecked(View view, String tagId) { - // Do something - Toast.makeText(view.getContext(), tagId, Toast.LENGTH_SHORT).show(); + applyChangeToVariable(true, tagId); } @Override public void itemUnchecked(View view, String tagId) { - // Do something - Toast.makeText(view.getContext(), tagId, Toast.LENGTH_SHORT).show(); + applyChangeToVariable(false, tagId); } }); @@ -132,6 +130,14 @@ public class LacertaApplyTagDialog extends DialogFragment { return builder.create(); } + private void applyChangeToVariable(boolean isChecked, String tagId) { + if (isChecked) { + this.registeredTags.stream().findAny().filter(tag -> tag.getId().equals(tagId)).ifPresent(tag -> this.appliedTags.add(tag)); + } else { + this.appliedTags.stream().findAny().filter(tag -> tag.getId().equals(tagId)).ifPresent(tag -> this.appliedTags.remove(tag)); + } + } + private CompletableFuture> getDocumentTagArrayList(String documentId) { return CompletableFuture.supplyAsync(() -> { ArrayList documentTagArrayList = new ArrayList<>(); From 8542869a6345896d4819838e0e2c0a77a0ab74ee Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:45:10 +0900 Subject: [PATCH 18/56] =?UTF-8?q?=E9=81=B8=E6=8A=9E=E8=82=A2=E3=81=AE?= =?UTF-8?q?=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88=E3=81=8C=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=81=AE=E6=97=A2=E5=AE=9A=E5=80=A4=E3=82=92=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/common/LacertaApplyTagDialog.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index aabc81d5..f8f562f1 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -119,11 +119,11 @@ public class LacertaApplyTagDialog extends DialogFragment { builder.setTitle(title) .setMessage(message) .setView(view) - .setPositiveButton(positiveButtonText, (dialog, id) -> { + .setPositiveButton(positiveButtonText == null ? "OK" : positiveButtonText, (dialog, id) -> { // Send the positive button event back to the host activity listener.onDialogPositiveClick(LacertaApplyTagDialog.this); }) - .setNegativeButton(negativeButtonText, (dialog, id) -> { + .setNegativeButton(negativeButtonText == null ? "Cancel" : negativeButtonText, (dialog, id) -> { // Send the negative button event back to the host activity listener.onDialogNegativeClick(LacertaApplyTagDialog.this); }); From 3715627c07f0c39d5e7b72dc590b123bc978b37e Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:47:34 +0900 Subject: [PATCH 19/56] =?UTF-8?q?=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92Container=E3=81=BE=E3=81=A7=E4=BC=9D=E9=81=94=E3=81=95?= =?UTF-8?q?=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/common/LacertaApplyTagDialog.java | 8 ++++---- .../component/viewer/ViewerContainerFragment.java | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index f8f562f1..39d9cf13 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -39,8 +39,8 @@ public class LacertaApplyTagDialog extends DialogFragment { // Listener public interface LacertaApplyTagDialogListener { - void onDialogPositiveClick(DialogFragment dialog); - void onDialogNegativeClick(DialogFragment dialog); + void onDialogPositiveClick(ArrayList appliedTags); + void onDialogNegativeClick(); } // Variables @@ -121,11 +121,11 @@ public class LacertaApplyTagDialog extends DialogFragment { .setView(view) .setPositiveButton(positiveButtonText == null ? "OK" : positiveButtonText, (dialog, id) -> { // Send the positive button event back to the host activity - listener.onDialogPositiveClick(LacertaApplyTagDialog.this); + listener.onDialogPositiveClick(this.appliedTags); }) .setNegativeButton(negativeButtonText == null ? "Cancel" : negativeButtonText, (dialog, id) -> { // Send the negative button event back to the host activity - listener.onDialogNegativeClick(LacertaApplyTagDialog.this); + listener.onDialogNegativeClick(); }); return builder.create(); } diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index da799b80..8f91f666 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -19,6 +19,8 @@ import com.google.android.material.tabs.TabLayoutMediator; import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputLayout; +import java.util.ArrayList; + import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; @@ -27,6 +29,7 @@ import one.nem.lacerta.component.common.picker.LacertaFilePickerDialog; import one.nem.lacerta.data.Document; import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.document.page.Page; +import one.nem.lacerta.model.document.tag.DocumentTag; import one.nem.lacerta.model.pref.ToxiDocumentModel; import one.nem.lacerta.utils.LacertaLogger; @@ -205,6 +208,17 @@ public class ViewerContainerFragment extends Fragment { .setMessage("タグを適用するファイルを選択してください") .setNegativeButtonText("キャンセル") .setDocumentId(documentId) + .setListener(new LacertaApplyTagDialog.LacertaApplyTagDialogListener() { + @Override + public void onDialogPositiveClick(ArrayList appliedTags) { + // 適用 + } + + @Override + public void onDialogNegativeClick() { + lacertaApplyTagDialog.dismiss(); + } + }) .show(getChildFragmentManager(), "LacertaApplyTagDialog"); } From fa4f074871233dec9162c0a306354965caa23556 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 00:52:44 +0900 Subject: [PATCH 20/56] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/common/LacertaApplyTagDialog.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 39d9cf13..40ad1a24 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -160,18 +160,20 @@ public class LacertaApplyTagDialog extends DialogFragment { } private CompletableFuture setAppliedTagList(String documentId) { - return CompletableFuture.runAsync(() -> { + return CompletableFuture.supplyAsync(() -> { lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTags -> { this.appliedTags = documentTags; }); + return null; }); } private CompletableFuture setRegisteredTagList() { - return CompletableFuture.runAsync(() -> { + return CompletableFuture.supplyAsync(() -> { lacertaLibrary.getTagList().thenAccept(documentTags -> { this.registeredTags = documentTags; }); + return null; }); } From a13f6e28ec560a32451557f1c5e40b7dbb692fee Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:02:43 +0900 Subject: [PATCH 21/56] WIP --- .../common/LacertaApplyTagDialog.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 40ad1a24..7047837b 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -141,39 +141,44 @@ public class LacertaApplyTagDialog extends DialogFragment { private CompletableFuture> getDocumentTagArrayList(String documentId) { return CompletableFuture.supplyAsync(() -> { ArrayList documentTagArrayList = new ArrayList<>(); - setRegisteredTagList().thenAccept(Void -> { - setAppliedTagList(documentId).join(); - for (int i = 0; i < this.registeredTags.size(); i++) { - boolean isChecked = false; - for (int j = 0; j < this.appliedTags.size(); j++) { - if (this.registeredTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { - isChecked = true; - break; - } + + setRegisteredTagList().join(); + setAppliedTagList(documentId).join(); + + logger.debug("getDocumentTagArrayList", "this.registeredTags.size(): " + this.registeredTags.size()); + logger.debug("getDocumentTagArrayList", "this.appliedTags.size(): " + this.appliedTags.size()); + + for (int i = 0; i < this.registeredTags.size(); i++) { + boolean isChecked = false; + for (int j = 0; j < this.appliedTags.size(); j++) { + if (this.registeredTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { + isChecked = true; + break; } - documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( - new DocumentTag(this.registeredTags.get(i).getId(), this.registeredTags.get(i).getName(), this.registeredTags.get(i).getColor()), isChecked)); } - }); + documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( + new DocumentTag(this.registeredTags.get(i).getId(), this.registeredTags.get(i).getName(), this.registeredTags.get(i).getColor()), isChecked)); + } + return documentTagArrayList; }); } - private CompletableFuture setAppliedTagList(String documentId) { + private CompletableFuture> setAppliedTagList(String documentId) { return CompletableFuture.supplyAsync(() -> { lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTags -> { this.appliedTags = documentTags; }); - return null; + return this.appliedTags; }); } - private CompletableFuture setRegisteredTagList() { + private CompletableFuture> setRegisteredTagList() { return CompletableFuture.supplyAsync(() -> { lacertaLibrary.getTagList().thenAccept(documentTags -> { this.registeredTags = documentTags; }); - return null; + return this.registeredTags; }); } From efdf9c1fea4557edba312cdd4f6b5bcfaf7bb179 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:03:14 +0900 Subject: [PATCH 22/56] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/common/LacertaApplyTagDialog.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 7047837b..a8261f8e 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -164,21 +164,21 @@ public class LacertaApplyTagDialog extends DialogFragment { }); } - private CompletableFuture> setAppliedTagList(String documentId) { + private CompletableFuture setAppliedTagList(String documentId) { return CompletableFuture.supplyAsync(() -> { lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTags -> { this.appliedTags = documentTags; }); - return this.appliedTags; + return null; }); } - private CompletableFuture> setRegisteredTagList() { + private CompletableFuture setRegisteredTagList() { return CompletableFuture.supplyAsync(() -> { lacertaLibrary.getTagList().thenAccept(documentTags -> { this.registeredTags = documentTags; }); - return this.registeredTags; + return null; }); } From 68dddbabee18efe390ae5f2a2a2012cfa8f0a036 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:07:41 +0900 Subject: [PATCH 23/56] WIP --- .../common/LacertaApplyTagDialog.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index a8261f8e..61fbdcdb 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -142,24 +142,22 @@ public class LacertaApplyTagDialog extends DialogFragment { return CompletableFuture.supplyAsync(() -> { ArrayList documentTagArrayList = new ArrayList<>(); - setRegisteredTagList().join(); - setAppliedTagList(documentId).join(); + setRegisteredTagList().thenRun(() -> setAppliedTagList(documentId)).thenAccept(Void -> { + logger.debug("getDocumentTagArrayList", "this.registeredTags.size(): " + this.registeredTags.size()); + logger.debug("getDocumentTagArrayList", "this.appliedTags.size(): " + this.appliedTags.size()); - logger.debug("getDocumentTagArrayList", "this.registeredTags.size(): " + this.registeredTags.size()); - logger.debug("getDocumentTagArrayList", "this.appliedTags.size(): " + this.appliedTags.size()); - - for (int i = 0; i < this.registeredTags.size(); i++) { - boolean isChecked = false; - for (int j = 0; j < this.appliedTags.size(); j++) { - if (this.registeredTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { - isChecked = true; - break; + for (int i = 0; i < this.registeredTags.size(); i++) { + boolean isChecked = false; + for (int j = 0; j < this.appliedTags.size(); j++) { + if (this.registeredTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { + isChecked = true; + break; + } } + documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( + new DocumentTag(this.registeredTags.get(i).getId(), this.registeredTags.get(i).getName(), this.registeredTags.get(i).getColor()), isChecked)); } - documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( - new DocumentTag(this.registeredTags.get(i).getId(), this.registeredTags.get(i).getName(), this.registeredTags.get(i).getColor()), isChecked)); - } - + }).join(); return documentTagArrayList; }); } @@ -167,7 +165,11 @@ public class LacertaApplyTagDialog extends DialogFragment { private CompletableFuture setAppliedTagList(String documentId) { return CompletableFuture.supplyAsync(() -> { lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTags -> { - this.appliedTags = documentTags; + if (documentTags == null) { + this.appliedTags = new ArrayList<>(); + } else { + this.appliedTags = documentTags; + } }); return null; }); From 141c91e1d74d4ac32a06fbb30d25d72d850ec37d Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:07:54 +0900 Subject: [PATCH 24/56] WIP --- .../common/src/main/res/layout/lacerta_dialog_edit_meta.xml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 component/common/src/main/res/layout/lacerta_dialog_edit_meta.xml diff --git a/component/common/src/main/res/layout/lacerta_dialog_edit_meta.xml b/component/common/src/main/res/layout/lacerta_dialog_edit_meta.xml new file mode 100644 index 00000000..77d9ef65 --- /dev/null +++ b/component/common/src/main/res/layout/lacerta_dialog_edit_meta.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file From 4ed8d96caa2d64a737f60bfe1af08ed02c2801cd Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:12:51 +0900 Subject: [PATCH 25/56] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/LacertaApplyTagDialog.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 61fbdcdb..51439f9a 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -24,6 +24,7 @@ import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.component.common.model.DocumentTagApplyTagDialogExtendedModel; +import one.nem.lacerta.data.Document; import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.document.tag.DocumentTag; import one.nem.lacerta.utils.LacertaLogger; @@ -162,26 +163,25 @@ public class LacertaApplyTagDialog extends DialogFragment { }); } - private CompletableFuture setAppliedTagList(String documentId) { - return CompletableFuture.supplyAsync(() -> { - lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTags -> { - if (documentTags == null) { - this.appliedTags = new ArrayList<>(); - } else { - this.appliedTags = documentTags; - } - }); - return null; - }); - } - private CompletableFuture setRegisteredTagList() { - return CompletableFuture.supplyAsync(() -> { - lacertaLibrary.getTagList().thenAccept(documentTags -> { - this.registeredTags = documentTags; - }); - return null; + return CompletableFuture.runAsync(() -> { + this.registeredTags = new ArrayList<>(); + this.lacertaLibrary.getTagList().thenAccept(documentTagList -> { + for (int i = 0; i < documentTagList.size(); i++) { + this.registeredTags.add(new DocumentTag(documentTagList.get(i).getId(), documentTagList.get(i).getName(), documentTagList.get(i).getColor())); + } + }).join(); }); } + private CompletableFuture setAppliedTagList(String documentId) { + return CompletableFuture.runAsync(() -> { + this.appliedTags = new ArrayList<>(); + this.lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTagList -> { + for (int i = 0; i < documentTagList.size(); i++) { + this.appliedTags.add(new DocumentTag(documentTagList.get(i).getId(), documentTagList.get(i).getName(), documentTagList.get(i).getColor())); + } + }).join(); + }); + } } From bbc8674c0bf92518f82b1468e1f60a6b3a81ed4c Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:13:10 +0900 Subject: [PATCH 26/56] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/common/src/main/res/layout/apply_tag_list_item.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/common/src/main/res/layout/apply_tag_list_item.xml b/component/common/src/main/res/layout/apply_tag_list_item.xml index 538654de..e52e6eae 100644 --- a/component/common/src/main/res/layout/apply_tag_list_item.xml +++ b/component/common/src/main/res/layout/apply_tag_list_item.xml @@ -1,7 +1,7 @@ + android:layout_height="wrap_content"> Date: Mon, 29 Jan 2024 01:13:35 +0900 Subject: [PATCH 27/56] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/common/src/main/res/layout/apply_tag_list_item.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/component/common/src/main/res/layout/apply_tag_list_item.xml b/component/common/src/main/res/layout/apply_tag_list_item.xml index e52e6eae..cc5b331e 100644 --- a/component/common/src/main/res/layout/apply_tag_list_item.xml +++ b/component/common/src/main/res/layout/apply_tag_list_item.xml @@ -8,7 +8,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="16sp" - android:layout_margin="16dp" + android:layout_marginHorizontal="16dp" + android:layout_marginVertical="8dp" android:text="CheckBox" /> \ No newline at end of file From b32ce60ad89ae6a2194129c01088770e7d8995ac Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:14:00 +0900 Subject: [PATCH 28/56] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/common/src/main/res/layout/apply_tag_list_item.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/common/src/main/res/layout/apply_tag_list_item.xml b/component/common/src/main/res/layout/apply_tag_list_item.xml index cc5b331e..dcf37d34 100644 --- a/component/common/src/main/res/layout/apply_tag_list_item.xml +++ b/component/common/src/main/res/layout/apply_tag_list_item.xml @@ -9,7 +9,7 @@ android:layout_height="wrap_content" android:textSize="16sp" android:layout_marginHorizontal="16dp" - android:layout_marginVertical="8dp" + android:layout_marginVertical="4dp" android:text="CheckBox" /> \ No newline at end of file From 1e0ba33519880122029dabca1addd3ec14daade3 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:17:46 +0900 Subject: [PATCH 29/56] =?UTF-8?q?applyTagListToDocument=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/data/LacertaLibrary.java | 2 ++ .../nem/lacerta/data/impl/LacertaLibraryImpl.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java index 764dcb5a..446758e3 100644 --- a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java +++ b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java @@ -45,6 +45,8 @@ public interface LacertaLibrary { CompletableFuture addTagToDocument(String documentId, String tagId); + CompletableFuture applyTagListToDocument(String documentId, ArrayList tagList); + CompletableFuture removeTagFromDocument(String documentId, String tagId); // Combined Document diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java index 5c65a2af..b36998a1 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java @@ -321,6 +321,20 @@ public class LacertaLibraryImpl implements LacertaLibrary { }); } + @Override + public CompletableFuture applyTagListToDocument(String documentId, ArrayList tagArrayList) { + return CompletableFuture.supplyAsync(() -> { // TODO-rca: 必要なものだけInsertするべき, 時間があれば... + // 一旦全てのタグを削除 + database.toxiDocumentTagDao().deleteByDocumentId(documentId); + logger.debug("LacertaLibraryImpl", "Database Query: Deleted ToxiDocumentTagEntity"); + // タグを追加 + for (DocumentTag documentTag : tagArrayList) { + addTagToDocument(documentId, documentTag.getId()); + } + return null; + }); + } + @Override public CompletableFuture removeTagFromDocument(String documentId, String tagId) { return CompletableFuture.supplyAsync(() -> { From 50f00411caed8d63e7c946ea5bc290a4877c8d94 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:18:29 +0900 Subject: [PATCH 30/56] =?UTF-8?q?PositiveButton=E3=82=92=E6=8A=BC=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AB=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/viewer/ViewerContainerFragment.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index 8f91f666..e4a5dc30 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -211,7 +211,12 @@ public class ViewerContainerFragment extends Fragment { .setListener(new LacertaApplyTagDialog.LacertaApplyTagDialogListener() { @Override public void onDialogPositiveClick(ArrayList appliedTags) { - // 適用 + lacertaLibrary.applyTagListToDocument(documentId, appliedTags).thenAccept(aVoid -> { + getActivity().runOnUiThread(() -> { + Toast.makeText(getContext(), "タグを適用しました", Toast.LENGTH_SHORT).show(); + lacertaApplyTagDialog.dismiss(); + }); + }); } @Override From ea345c45e4420c0abfc2b80cdeb400c9005583f4 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:29:50 +0900 Subject: [PATCH 31/56] =?UTF-8?q?StreamAPI=E3=81=A7=E6=9B=B8=E3=81=8D?= =?UTF-8?q?=E7=9B=B4=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/LacertaApplyTagDialog.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 51439f9a..c8709a20 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; +import java.util.stream.Collectors; import javax.inject.Inject; @@ -147,17 +148,14 @@ public class LacertaApplyTagDialog extends DialogFragment { logger.debug("getDocumentTagArrayList", "this.registeredTags.size(): " + this.registeredTags.size()); logger.debug("getDocumentTagArrayList", "this.appliedTags.size(): " + this.appliedTags.size()); - for (int i = 0; i < this.registeredTags.size(); i++) { - boolean isChecked = false; - for (int j = 0; j < this.appliedTags.size(); j++) { - if (this.registeredTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { - isChecked = true; - break; - } - } - documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( - new DocumentTag(this.registeredTags.get(i).getId(), this.registeredTags.get(i).getName(), this.registeredTags.get(i).getColor()), isChecked)); - } + documentTagArrayList.addAll(this.registeredTags.stream().map(tag -> { + DocumentTagApplyTagDialogExtendedModel documentTag = new DocumentTagApplyTagDialogExtendedModel( + new DocumentTag(tag.getId(), tag.getName(), tag.getColor()), + this.appliedTags.stream().anyMatch(appliedTag -> appliedTag.getId().equals(tag.getId())) + ); + return documentTag; + }).collect(Collectors.toCollection(ArrayList::new))); + }).join(); return documentTagArrayList; }); From 0735c90d5e54ec67ac65503461468befd33a9443 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:33:14 +0900 Subject: [PATCH 32/56] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/common/LacertaApplyTagDialog.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index c8709a20..3a76ebf5 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -143,8 +143,7 @@ public class LacertaApplyTagDialog extends DialogFragment { private CompletableFuture> getDocumentTagArrayList(String documentId) { return CompletableFuture.supplyAsync(() -> { ArrayList documentTagArrayList = new ArrayList<>(); - - setRegisteredTagList().thenRun(() -> setAppliedTagList(documentId)).thenAccept(Void -> { + setRegisteredTagList().thenRun(() -> setAppliedTagList(documentId).join()).thenAccept(Void -> { logger.debug("getDocumentTagArrayList", "this.registeredTags.size(): " + this.registeredTags.size()); logger.debug("getDocumentTagArrayList", "this.appliedTags.size(): " + this.appliedTags.size()); From 331a520be00e3e025c7cc5a1abc470dd996957aa Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:38:52 +0900 Subject: [PATCH 33/56] =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E3=81=AB=E5=88=87?= =?UTF-8?q?=E3=82=8A=E6=9B=BF=E3=81=88=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/common/LacertaApplyTagDialog.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index 3a76ebf5..c5acb14b 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -133,10 +133,14 @@ public class LacertaApplyTagDialog extends DialogFragment { } private void applyChangeToVariable(boolean isChecked, String tagId) { + logger.debug("applyChangeToVariable", "isChecked: " + isChecked); + logger.debug("applyChangeToVariable", "tagId: " + tagId); + logger.debug("applyChangeToVariable", "this.registeredTags.size(): " + this.registeredTags.size()); + logger.debug("applyChangeToVariable", "this.appliedTags.size(): " + this.appliedTags.size()); if (isChecked) { - this.registeredTags.stream().findAny().filter(tag -> tag.getId().equals(tagId)).ifPresent(tag -> this.appliedTags.add(tag)); + this.registeredTags.stream().filter(tag -> tag.getId().equals(tagId)).findFirst().ifPresent(tag -> this.appliedTags.add(tag)); } else { - this.appliedTags.stream().findAny().filter(tag -> tag.getId().equals(tagId)).ifPresent(tag -> this.appliedTags.remove(tag)); + this.appliedTags.stream().filter(tag -> tag.getId().equals(tagId)).findFirst().ifPresent(tag -> this.appliedTags.remove(tag)); } } From 4e17c5636ca067ad4f4aaa75a81a479ab3b2e5c1 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:39:06 +0900 Subject: [PATCH 34/56] =?UTF-8?q?=E3=83=87=E3=83=90=E3=83=83=E3=82=B0?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/common/LacertaApplyTagDialog.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index c5acb14b..5233528c 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -133,10 +133,6 @@ public class LacertaApplyTagDialog extends DialogFragment { } private void applyChangeToVariable(boolean isChecked, String tagId) { - logger.debug("applyChangeToVariable", "isChecked: " + isChecked); - logger.debug("applyChangeToVariable", "tagId: " + tagId); - logger.debug("applyChangeToVariable", "this.registeredTags.size(): " + this.registeredTags.size()); - logger.debug("applyChangeToVariable", "this.appliedTags.size(): " + this.appliedTags.size()); if (isChecked) { this.registeredTags.stream().filter(tag -> tag.getId().equals(tagId)).findFirst().ifPresent(tag -> this.appliedTags.add(tag)); } else { From 74784a76d3614c8aca3421785365322beb2f4349 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:39:16 +0900 Subject: [PATCH 35/56] =?UTF-8?q?=E3=83=AD=E3=82=B0=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/viewer/ViewerContainerFragment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index e4a5dc30..d8032868 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -211,6 +211,7 @@ public class ViewerContainerFragment extends Fragment { .setListener(new LacertaApplyTagDialog.LacertaApplyTagDialogListener() { @Override public void onDialogPositiveClick(ArrayList appliedTags) { + logger.debug("ViewerContainerFragment", "Dialog Result: appliedTags: " + appliedTags.size()); lacertaLibrary.applyTagListToDocument(documentId, appliedTags).thenAccept(aVoid -> { getActivity().runOnUiThread(() -> { Toast.makeText(getContext(), "タグを適用しました", Toast.LENGTH_SHORT).show(); From 6d73bede6b5e275ef8717bb68e2791cf8c4eafc8 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:41:28 +0900 Subject: [PATCH 36/56] =?UTF-8?q?=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E7=B7=A8=E9=9B=86=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E5=AE=9F=E8=A3=85WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/common/LacertaEditMetaDialog.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/LacertaEditMetaDialog.java diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaEditMetaDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaEditMetaDialog.java new file mode 100644 index 00000000..d16c019c --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaEditMetaDialog.java @@ -0,0 +1,4 @@ +package one.nem.lacerta.component.common; + +public class LacertaEditMetaDialog { +} From c849fdae2e20b61355dd3406f6f3c93659638b68 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:43:18 +0900 Subject: [PATCH 37/56] WIP --- .../res/layout/lacerta_dialog_edit_meta.xml | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/component/common/src/main/res/layout/lacerta_dialog_edit_meta.xml b/component/common/src/main/res/layout/lacerta_dialog_edit_meta.xml index 77d9ef65..8d016a39 100644 --- a/component/common/src/main/res/layout/lacerta_dialog_edit_meta.xml +++ b/component/common/src/main/res/layout/lacerta_dialog_edit_meta.xml @@ -1,6 +1,21 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> - \ No newline at end of file + + + + + + \ No newline at end of file From 9084613e387cf660e06d48f6cbcfdd609c7890a0 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:55:06 +0900 Subject: [PATCH 38/56] =?UTF-8?q?Fragment=E3=81=A7=E3=81=AF=E3=81=AA?= =?UTF-8?q?=E3=81=8FTargetId=E3=82=92=E6=8C=81=E3=81=A4=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerViewPagerAdapter.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java index e3f998fe..3c91cde5 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java @@ -13,13 +13,13 @@ import java.util.ArrayList; public class ViewerViewPagerAdapter extends FragmentStateAdapter { // Variables - private ArrayList fragmentArrayList = new ArrayList<>(); + private ArrayList fragmentTargetIdList = new ArrayList<>(); private ArrayList fragmentTitleList = new ArrayList<>(); // Setter - public void addFragment(Fragment fragment, String title){ - fragmentArrayList.add(fragment); - fragmentTitleList.add(title); + + public void setFragmentTargetIdList(ArrayList fragmentTargetIdList) { + this.fragmentTargetIdList = fragmentTargetIdList; } public ViewerViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) { @@ -29,12 +29,12 @@ public class ViewerViewPagerAdapter extends FragmentStateAdapter { @NonNull @Override public Fragment createFragment(int position) { - return fragmentArrayList.get(position); + return ViewerListFragment.newInstance(fragmentTargetIdList.get(position), fragmentTitleList.get(position)); } @Override public int getItemCount() { - return fragmentArrayList == null ? 0 : fragmentArrayList.size(); + return fragmentTargetIdList == null ? 0 : fragmentTargetIdList.size(); } @Nullable From 7086582fad10a8c9f85ccf8f84a2e6bf1d44f379 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:56:57 +0900 Subject: [PATCH 39/56] =?UTF-8?q?getItemCount=E3=81=A7=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=82=BF=E3=83=B3=E3=82=B9=E5=A4=89=E6=95=B0=E3=81=AE?= =?UTF-8?q?=E4=B8=AD=E8=BA=AB=E3=82=92=E8=BB=BD=E3=81=8F=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/viewer/ViewerViewPagerAdapter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java index 3c91cde5..b6db3f6d 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java @@ -34,7 +34,13 @@ public class ViewerViewPagerAdapter extends FragmentStateAdapter { @Override public int getItemCount() { - return fragmentTargetIdList == null ? 0 : fragmentTargetIdList.size(); + if (fragmentTargetIdList == null || fragmentTitleList == null) { + return 0; + } else if (fragmentTargetIdList.size() != fragmentTitleList.size()) { + throw new IllegalStateException("fragmentTargetIdList.size() != fragmentTitleList.size()"); + } else { + return fragmentTargetIdList.size(); + } } @Nullable From fcdb7c838b5d051f10712f67b36c1ad566e433a1 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:59:44 +0900 Subject: [PATCH 40/56] =?UTF-8?q?=E4=B8=8D=E8=B6=B3=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9FSetter=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/viewer/ViewerViewPagerAdapter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java index b6db3f6d..8b30e772 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java @@ -22,6 +22,10 @@ public class ViewerViewPagerAdapter extends FragmentStateAdapter { this.fragmentTargetIdList = fragmentTargetIdList; } + public void setFragmentTitleList(ArrayList fragmentTitleList) { + this.fragmentTitleList = fragmentTitleList; + } + public ViewerViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) { super(fragmentActivity); } From da78f5eef163db5bb9ee6d2a8b33fb46e0d87e03 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:00:32 +0900 Subject: [PATCH 41/56] =?UTF-8?q?Adapter=E3=81=AE=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=E3=81=AB=E8=BF=BD=E5=BE=93,=20StreamAPI=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../viewer/ViewerContainerFragment.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index d8032868..be70a03d 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -20,6 +20,7 @@ import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputLayout; import java.util.ArrayList; +import java.util.stream.Collectors; import javax.inject.Inject; @@ -120,18 +121,19 @@ public class ViewerContainerFragment extends Fragment { logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined); lacertaLibrary.getCombinedDocumentToxiList(documentId).thenAccept(combinedDocumentToxiList -> { logger.debug("ViewerContainerFragment", "combinedDocumentToxiList: " + combinedDocumentToxiList.size()); - for (ToxiDocumentModel toxiDocumentModel : combinedDocumentToxiList) { - logger.debug("ViewerContainerFragment", "titleCache: " + toxiDocumentModel.getTitleCache()); - viewerViewPagerAdapter - .addFragment(ViewerBodyFragment.newInstance(toxiDocumentModel.getChildDocumentId(), toxiDocumentModel.getTitleCache()), - toxiDocumentModel.getTitleCache()); - } + ArrayList pageIdList = combinedDocumentToxiList.stream().map(ToxiDocumentModel::getChildDocumentId).collect(Collectors.toCollection(ArrayList::new)); + ArrayList pageTitleList = combinedDocumentToxiList.stream().map(ToxiDocumentModel::getTitleCache).collect(Collectors.toCollection(ArrayList::new)); + viewerViewPagerAdapter.setFragmentTargetIdList(pageIdList); + viewerViewPagerAdapter.setFragmentTitleList(pageTitleList); viewerViewPagerAdapter.notifyItemRangeChanged(0, combinedDocumentToxiList.size()); }); } else { logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined); tabLayout.setVisibility(View.GONE); - viewerViewPagerAdapter.addFragment(ViewerBodyFragment.newInstance(documentId, documentName), documentName); + ArrayList pageIdList = new ArrayList<>(); + ArrayList pageTitleList = new ArrayList<>(); + pageIdList.add(documentId); + pageTitleList.add(documentName); viewerViewPagerAdapter.notifyItemRangeChanged(0, 1); } @@ -144,7 +146,7 @@ public class ViewerContainerFragment extends Fragment { ImageButton imageButton = customView.findViewById(R.id.tab_modify); imageButton.setOnClickListener(v -> { - Toast.makeText(getContext(), "Working!, Index:" + position, Toast.LENGTH_SHORT).show(); + }); tab.setCustomView(customView); From 7bcb2f07ab9641538846c43181e137f4b057f5d0 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:01:18 +0900 Subject: [PATCH 42/56] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerContainerFragment.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index be70a03d..28adb7d6 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -121,10 +121,12 @@ public class ViewerContainerFragment extends Fragment { logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined); lacertaLibrary.getCombinedDocumentToxiList(documentId).thenAccept(combinedDocumentToxiList -> { logger.debug("ViewerContainerFragment", "combinedDocumentToxiList: " + combinedDocumentToxiList.size()); - ArrayList pageIdList = combinedDocumentToxiList.stream().map(ToxiDocumentModel::getChildDocumentId).collect(Collectors.toCollection(ArrayList::new)); - ArrayList pageTitleList = combinedDocumentToxiList.stream().map(ToxiDocumentModel::getTitleCache).collect(Collectors.toCollection(ArrayList::new)); - viewerViewPagerAdapter.setFragmentTargetIdList(pageIdList); - viewerViewPagerAdapter.setFragmentTitleList(pageTitleList); + + viewerViewPagerAdapter.setFragmentTargetIdList( + combinedDocumentToxiList.stream().map(ToxiDocumentModel::getChildDocumentId).collect(Collectors.toCollection(ArrayList::new))); + viewerViewPagerAdapter.setFragmentTitleList( + combinedDocumentToxiList.stream().map(ToxiDocumentModel::getTitleCache).collect(Collectors.toCollection(ArrayList::new))); + viewerViewPagerAdapter.notifyItemRangeChanged(0, combinedDocumentToxiList.size()); }); } else { From 53ae1dadb870ce3a015cf716f582b88d50e01246 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:02:01 +0900 Subject: [PATCH 43/56] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/viewer/ViewerContainerFragment.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index 28adb7d6..ed4b0109 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -132,10 +132,8 @@ public class ViewerContainerFragment extends Fragment { } else { logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined); tabLayout.setVisibility(View.GONE); - ArrayList pageIdList = new ArrayList<>(); - ArrayList pageTitleList = new ArrayList<>(); - pageIdList.add(documentId); - pageTitleList.add(documentName); + viewerViewPagerAdapter.setFragmentTargetIdList(new ArrayList(){{add(documentId);}}); // TODO-rca: 読みにくいので直接追加できるようにする + viewerViewPagerAdapter.setFragmentTitleList(new ArrayList(){{add(documentName);}}); viewerViewPagerAdapter.notifyItemRangeChanged(0, 1); } From 8b1af8e2d7ad6642b647e17bc53a635190ea8755 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:02:58 +0900 Subject: [PATCH 44/56] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/viewer/ViewerContainerFragment.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index ed4b0109..bb652cc2 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -117,7 +117,8 @@ public class ViewerContainerFragment extends Fragment { Toolbar toolbar = view.findViewById(R.id.toolbar); initToolbar(toolbar, true, documentName); - if (this.hasCombined) { + // Get document page + if (this.hasCombined) { // 結合親の場合 logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined); lacertaLibrary.getCombinedDocumentToxiList(documentId).thenAccept(combinedDocumentToxiList -> { logger.debug("ViewerContainerFragment", "combinedDocumentToxiList: " + combinedDocumentToxiList.size()); @@ -129,7 +130,7 @@ public class ViewerContainerFragment extends Fragment { viewerViewPagerAdapter.notifyItemRangeChanged(0, combinedDocumentToxiList.size()); }); - } else { + } else { // それ以外の場合 logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined); tabLayout.setVisibility(View.GONE); viewerViewPagerAdapter.setFragmentTargetIdList(new ArrayList(){{add(documentId);}}); // TODO-rca: 読みにくいので直接追加できるようにする From 1fd992fb4a935825fcf78cc0ada33ca897154874 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:03:55 +0900 Subject: [PATCH 45/56] =?UTF-8?q?Getter=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerViewPagerAdapter.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java index 8b30e772..ba263d06 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java @@ -51,4 +51,14 @@ public class ViewerViewPagerAdapter extends FragmentStateAdapter { public CharSequence getTabTitle(int position) { return fragmentTitleList.get(position); } + + // Getter + + public String getFragmentTargetId(int position) { + return fragmentTargetIdList.get(position); + } + + public String getFragmentTitle(int position) { + return fragmentTitleList.get(position); + } } From 972487fec14753e8bfcc55e6f47e41aec1661d08 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:06:51 +0900 Subject: [PATCH 46/56] =?UTF-8?q?Combined=E3=81=AA=E3=83=89=E3=82=AD?= =?UTF-8?q?=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE=E5=90=8D=E5=89=8D?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../viewer/ViewerContainerFragment.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index bb652cc2..5ee47489 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -147,13 +147,39 @@ public class ViewerContainerFragment extends Fragment { ImageButton imageButton = customView.findViewById(R.id.tab_modify); imageButton.setOnClickListener(v -> { - + renameCombinedDocument(viewerViewPagerAdapter.getFragmentTargetId(position), viewerViewPagerAdapter.getFragmentTitle(position)); }); tab.setCustomView(customView); }).attach(); } + private void renameCombinedDocument(String documentId, String current) { + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); + builder.setTitle("アイテム名の変更"); + builder.setMessage("アイテム名を入力してください"); + + View view = LayoutInflater.from(getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.lacerta_dialog_edit_text_layout, null); + TextInputEditText textInputEditText = view.findViewById(one.nem.lacerta.shared.ui.R.id.custom_edit_text); + TextInputLayout textInputLayout = view.findViewById(one.nem.lacerta.shared.ui.R.id.custom_text_input_layout); + textInputEditText.setText(current); + textInputLayout.setHint("アイテム名"); + builder.setView(view); + + builder.setPositiveButton("変更", (dialog, which) -> { + document.renameDocument(documentId, textInputEditText.getText().toString()).thenAccept(aVoid -> { + getActivity().runOnUiThread(() -> { + this.documentName = textInputEditText.getText().toString(); + }); + }); + }); + builder.setNegativeButton("キャンセル", (dialog, which) -> { + dialog.cancel(); + }); + + builder.show(); + } + /** * Toolbarをinitする * From f2bbfca36cdf97e495332c5c90c3cd7c302cf91c Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:09:54 +0900 Subject: [PATCH 47/56] =?UTF-8?q?=E3=83=9F=E3=82=B9=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/viewer/ViewerViewPagerAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java index ba263d06..b189bf07 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java @@ -33,7 +33,7 @@ public class ViewerViewPagerAdapter extends FragmentStateAdapter { @NonNull @Override public Fragment createFragment(int position) { - return ViewerListFragment.newInstance(fragmentTargetIdList.get(position), fragmentTitleList.get(position)); + return ViewerBodyFragment.newInstance(fragmentTargetIdList.get(position), fragmentTitleList.get(position)); } @Override From dcfb22f6a0ace486ebca1af6de0b313848412a44 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:15:00 +0900 Subject: [PATCH 48/56] =?UTF-8?q?findByParentIdAndChildId=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/source/database/dao/ToxiDocumentDao.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/ToxiDocumentDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/ToxiDocumentDao.java index 201a5d37..05923d03 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/ToxiDocumentDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/ToxiDocumentDao.java @@ -15,6 +15,9 @@ public interface ToxiDocumentDao { @Query("SELECT * FROM toxi_document WHERE parent_document_id = :parentId AND is_active = 1 ORDER BY `order` ASC") List findByParentId(String parentId); + @Query("SELECT * FROM toxi_document WHERE parent_document_id = :parentId AND child_document_id = :childId AND is_active = 1") + ToxiDocumentEntity findByParentIdAndChildId(String parentId, String childId); + @Insert void insert(ToxiDocumentEntity toxiDocument); From 6fdef14eec449f16b25bb80ae47f1b7cbbc02141 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:16:03 +0900 Subject: [PATCH 49/56] =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB?= =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/data/LacertaLibrary.java | 2 ++ .../nem/lacerta/data/impl/LacertaLibraryImpl.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java index 446758e3..e1ce346e 100644 --- a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java +++ b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java @@ -53,6 +53,8 @@ public interface LacertaLibrary { CompletableFuture combineDocument(String parentId, String childId); + CompletableFuture updateTitleCache(String parentId, String childId, String titleCache); + CompletableFuture uncombineDocument(String parentId, String childId); // CompletableFuture combineDocument(String parentId, ArrayList childIdList); diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java index b36998a1..f35dee8c 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java @@ -389,6 +389,21 @@ public class LacertaLibraryImpl implements LacertaLibrary { logger.debug("LacertaLibraryImpl", "Database Query: Inserted ToxiDocumentEntity"); } + @Override + public CompletableFuture updateTitleCache(String parentId, String documentId, String titleCache) { + return CompletableFuture.supplyAsync(() -> { + ToxiDocumentEntity toxiDocumentEntity = database.toxiDocumentDao().findByParentIdAndChildId(parentId, documentId); + if (toxiDocumentEntity == null) { + logger.warn("LacertaLibraryImpl", "ToxiDocumentEntity is not found."); + return null; + } + toxiDocumentEntity.titleCache = titleCache; + database.toxiDocumentDao().update(toxiDocumentEntity); + logger.debug("LacertaLibraryImpl", "Database Query: Updated ToxiDocumentEntity"); + return null; + }); + } + @Override public CompletableFuture uncombineDocument(String parentId, String childId) { return CompletableFuture.supplyAsync(() -> { From f673954befc1471508eaa00f046959ba4235407f Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:37:16 +0900 Subject: [PATCH 50/56] =?UTF-8?q?=E3=83=AA=E3=83=8D=E3=83=BC=E3=83=A0?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerContainerFragment.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index 5ee47489..5c3a67a8 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -147,14 +147,14 @@ public class ViewerContainerFragment extends Fragment { ImageButton imageButton = customView.findViewById(R.id.tab_modify); imageButton.setOnClickListener(v -> { - renameCombinedDocument(viewerViewPagerAdapter.getFragmentTargetId(position), viewerViewPagerAdapter.getFragmentTitle(position)); + renameCombinedDocument(this.documentId, viewerViewPagerAdapter.getFragmentTargetId(position), viewerViewPagerAdapter.getFragmentTitle(position)); }); tab.setCustomView(customView); }).attach(); } - private void renameCombinedDocument(String documentId, String current) { + private void renameCombinedDocument(String parentId, String childId, String current) { MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); builder.setTitle("アイテム名の変更"); builder.setMessage("アイテム名を入力してください"); @@ -167,11 +167,14 @@ public class ViewerContainerFragment extends Fragment { builder.setView(view); builder.setPositiveButton("変更", (dialog, which) -> { - document.renameDocument(documentId, textInputEditText.getText().toString()).thenAccept(aVoid -> { - getActivity().runOnUiThread(() -> { - this.documentName = textInputEditText.getText().toString(); + document.renameDocument(childId, textInputEditText.getText().toString()).thenCombine( + lacertaLibrary.updateTitleCache(parentId, childId, textInputEditText.getText().toString()), (aVoid, aVoid2) -> { + getActivity().runOnUiThread(() -> { + Toast.makeText(getContext(), "変更しました", Toast.LENGTH_SHORT).show(); + dialog.dismiss(); + }); + return null; }); - }); }); builder.setNegativeButton("キャンセル", (dialog, which) -> { dialog.cancel(); From 19f6eb1683cf4d437fd1d04f3b31cdad206b3059 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:38:47 +0900 Subject: [PATCH 51/56] =?UTF-8?q?Adapter=E3=82=92=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=82=BF=E3=83=B3=E3=82=B9=E5=A4=89=E6=95=B0=E3=81=AB=E6=8C=81?= =?UTF-8?q?=E3=81=9F=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/viewer/ViewerContainerFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index 5c3a67a8..7054fe87 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -57,6 +57,7 @@ public class ViewerContainerFragment extends Fragment { private String documentId; private String documentName; private boolean hasCombined = false; + private ViewerViewPagerAdapter viewerViewPagerAdapter; public ViewerContainerFragment() { // Required empty public constructor @@ -107,7 +108,7 @@ public class ViewerContainerFragment extends Fragment { ViewPager2 viewPager = view.findViewById(R.id.view_pager); // Init view pager adapter - ViewerViewPagerAdapter viewerViewPagerAdapter = new ViewerViewPagerAdapter(requireActivity()); + this.viewerViewPagerAdapter = new ViewerViewPagerAdapter(requireActivity()); viewPager.setAdapter(viewerViewPagerAdapter); // Init tab layout From 1a2cf77f62d540183324df1009c73e30466680ab Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:39:30 +0900 Subject: [PATCH 52/56] =?UTF-8?q?Revert=20"Adapter=E3=82=92=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=82=BF=E3=83=B3=E3=82=B9=E5=A4=89=E6=95=B0=E3=81=AB?= =?UTF-8?q?=E6=8C=81=E3=81=9F=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 19f6eb1683cf4d437fd1d04f3b31cdad206b3059. --- .../nem/lacerta/component/viewer/ViewerContainerFragment.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index 7054fe87..5c3a67a8 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -57,7 +57,6 @@ public class ViewerContainerFragment extends Fragment { private String documentId; private String documentName; private boolean hasCombined = false; - private ViewerViewPagerAdapter viewerViewPagerAdapter; public ViewerContainerFragment() { // Required empty public constructor @@ -108,7 +107,7 @@ public class ViewerContainerFragment extends Fragment { ViewPager2 viewPager = view.findViewById(R.id.view_pager); // Init view pager adapter - this.viewerViewPagerAdapter = new ViewerViewPagerAdapter(requireActivity()); + ViewerViewPagerAdapter viewerViewPagerAdapter = new ViewerViewPagerAdapter(requireActivity()); viewPager.setAdapter(viewerViewPagerAdapter); // Init tab layout From c44fd3ae8bcca89ba5f5c9d660a7a2a6eb3d607d Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:40:55 +0900 Subject: [PATCH 53/56] =?UTF-8?q?Revert=20"Revert=20"Adapter=E3=82=92?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=BF=E3=83=B3=E3=82=B9=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E3=81=AB=E6=8C=81=E3=81=9F=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1a2cf77f62d540183324df1009c73e30466680ab. --- .../nem/lacerta/component/viewer/ViewerContainerFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index 5c3a67a8..7054fe87 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -57,6 +57,7 @@ public class ViewerContainerFragment extends Fragment { private String documentId; private String documentName; private boolean hasCombined = false; + private ViewerViewPagerAdapter viewerViewPagerAdapter; public ViewerContainerFragment() { // Required empty public constructor @@ -107,7 +108,7 @@ public class ViewerContainerFragment extends Fragment { ViewPager2 viewPager = view.findViewById(R.id.view_pager); // Init view pager adapter - ViewerViewPagerAdapter viewerViewPagerAdapter = new ViewerViewPagerAdapter(requireActivity()); + this.viewerViewPagerAdapter = new ViewerViewPagerAdapter(requireActivity()); viewPager.setAdapter(viewerViewPagerAdapter); // Init tab layout From e85c8a7ed0a121f715031516e6b506ff6cb9d2c3 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:43:11 +0900 Subject: [PATCH 54/56] =?UTF-8?q?Getter=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/viewer/ViewerViewPagerAdapter.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java index b189bf07..66a6d8a9 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerViewPagerAdapter.java @@ -61,4 +61,12 @@ public class ViewerViewPagerAdapter extends FragmentStateAdapter { public String getFragmentTitle(int position) { return fragmentTitleList.get(position); } + + public ArrayList getFragmentTargetIdList() { + return fragmentTargetIdList; + } + + public ArrayList getFragmentTitleList() { + return fragmentTitleList; + } } From d691ee0126cb58ad25e07c2584e44d915609c47a Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:44:15 +0900 Subject: [PATCH 55/56] =?UTF-8?q?=E3=82=BF=E3=83=96=E3=82=BF=E3=82=A4?= =?UTF-8?q?=E3=83=88=E3=83=AB=E6=9B=B4=E6=96=B0=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/viewer/ViewerContainerFragment.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index 7054fe87..ff1834e6 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -184,6 +184,13 @@ public class ViewerContainerFragment extends Fragment { builder.show(); } + private void updateTabTitle(int position, String title) { + ArrayList fragmentTitleList = viewerViewPagerAdapter.getFragmentTitleList(); + fragmentTitleList.set(position, title); + viewerViewPagerAdapter.setFragmentTitleList(fragmentTitleList); + viewerViewPagerAdapter.notifyItemChanged(position); + } + /** * Toolbarをinitする * From d393087ff65b08da10235cb3ab12464125c8b32f Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:49:04 +0900 Subject: [PATCH 56/56] =?UTF-8?q?=E7=B7=A8=E9=9B=86=E3=81=AB=E8=BF=BD?= =?UTF-8?q?=E5=BE=93=E3=81=97=E3=81=A6=E3=82=BF=E3=83=96=E3=81=AE=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E3=83=88=E3=83=AB=E3=82=82=E6=AD=A3=E3=81=97=E3=81=8F?= =?UTF-8?q?=E5=A4=89=E3=82=8F=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerContainerFragment.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index ff1834e6..6152d199 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -148,14 +148,18 @@ public class ViewerContainerFragment extends Fragment { ImageButton imageButton = customView.findViewById(R.id.tab_modify); imageButton.setOnClickListener(v -> { - renameCombinedDocument(this.documentId, viewerViewPagerAdapter.getFragmentTargetId(position), viewerViewPagerAdapter.getFragmentTitle(position)); + renameCombinedDocument( + this.documentId, + viewerViewPagerAdapter.getFragmentTargetId(position), + viewerViewPagerAdapter.getFragmentTitle(position), + position); }); tab.setCustomView(customView); }).attach(); } - private void renameCombinedDocument(String parentId, String childId, String current) { + private void renameCombinedDocument(String parentId, String childId, String current, int position) { // TODO-rca: 無理やりpositionを渡してるのでなんとかする MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); builder.setTitle("アイテム名の変更"); builder.setMessage("アイテム名を入力してください"); @@ -172,6 +176,7 @@ public class ViewerContainerFragment extends Fragment { lacertaLibrary.updateTitleCache(parentId, childId, textInputEditText.getText().toString()), (aVoid, aVoid2) -> { getActivity().runOnUiThread(() -> { Toast.makeText(getContext(), "変更しました", Toast.LENGTH_SHORT).show(); + updateTabTitle(position, textInputEditText.getText().toString()); dialog.dismiss(); }); return null;