From 972487fec14753e8bfcc55e6f47e41aec1661d08 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 02:06:51 +0900 Subject: [PATCH] =?UTF-8?q?Combined=E3=81=AA=E3=83=89=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE=E5=90=8D=E5=89=8D=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E3=81=A7=E3=81=8D=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 --- .../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する *