From 97b180640726f85480ef529606bf95331d50598a Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 09:26:22 +0900 Subject: [PATCH 01/13] =?UTF-8?q?=E3=83=87=E3=82=A3=E3=83=AC=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=83=AA=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/component/common/picker/base/placeholder | 0 .../main/java/one/nem/lacerta/component/common/picker/placeholder | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/picker/base/placeholder create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/picker/placeholder diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/placeholder b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/placeholder new file mode 100644 index 00000000..e69de29b diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/placeholder b/component/common/src/main/java/one/nem/lacerta/component/common/picker/placeholder new file mode 100644 index 00000000..e69de29b From 7a106b1ed321eb8c0ad0c943ae9f2226ed06fd6c Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 09:56:37 +0900 Subject: [PATCH 02/13] =?UTF-8?q?FilePickerDialogBase=E5=AE=9F=E8=A3=85=20?= =?UTF-8?q?WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/LacertaFilePickerAdapterBase.java | 101 ++++++++++++++++++ .../base/LacertaFilePickerDialogBase.java | 60 +++++++++++ 2 files changed, 161 insertions(+) create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerAdapterBase.java create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerAdapterBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerAdapterBase.java new file mode 100644 index 00000000..551a2b69 --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerAdapterBase.java @@ -0,0 +1,101 @@ +package one.nem.lacerta.component.common.picker.base; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import one.nem.lacerta.component.common.LacertaSelectDirDialogInternalEventListener; +import one.nem.lacerta.model.LibraryItemPage; +import one.nem.lacerta.model.ListItem; +import one.nem.lacerta.model.ListItemType; + +public class LacertaFilePickerAdapterBase extends RecyclerView.Adapter { + + + private LibraryItemPage libraryItemPage; + LacertaSelectDirDialogInternalEventListener listener; + + public LacertaFilePickerAdapterBase(LacertaSelectDirDialogInternalEventListener listener) { + this.listener = listener; + } + + public void setListItems(LibraryItemPage libraryItemPage) { + this.libraryItemPage = libraryItemPage; + if (this.libraryItemPage.getPageId() != null) { // ルートディレクトリの場合は戻るボタンを表示しない + this.libraryItemPage.getListItems().add(0, new ListItem("戻る", " ", ListItemType.ITEM_TYPE_ACTION_BACK, null)); + } + } + + @NonNull + @Override + public LacertaFilePickerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false); + return new LacertaFilePickerViewHolder(view); + } + + @Override + public void onBindViewHolder(LacertaFilePickerViewHolder holder, int position) { + ListItem listItem = libraryItemPage.getListItems().get(position); + holder.title.setText(listItem.getTitle()); + holder.description.setText(listItem.getDescription()); + holder.icon.setImageResource(listItem.getItemType().getIconId()); + if(listItem.getItemType() == ListItemType.ITEM_TYPE_ACTION_BACK) { + holder.itemView.setOnClickListener(v -> listener.onBackSelected(this.libraryItemPage.getParentId())); + } else { + holder.itemView.setOnClickListener(v -> listener.onDirSelected(listItem.getTitle(), listItem.getItemId())); + } + } + + @Override + public int getItemCount() { + return this.libraryItemPage == null ? 0 : this.libraryItemPage.getListItems().size(); + } + + public String getCurrentId() { + if (this.libraryItemPage == null) { + return null; + } else { + if (this.libraryItemPage.getPageId() == null) { + return null; + } else { + return this.libraryItemPage.getPageId(); + } + } + } + + public String getCurrentPageTitle() { + if (this.libraryItemPage == null) { + return null; + } else { + if (this.libraryItemPage.getPageId() == null) { + return null; + } else { + return this.libraryItemPage.getPageTitle(); + } + } + } + + public static class LacertaFilePickerViewHolder extends RecyclerView.ViewHolder { + + TextView title; + TextView description; + + ImageView icon; + + + public LacertaFilePickerViewHolder(@NonNull View itemView) { + super(itemView); + + title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title); + description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description); + icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon); + description.setVisibility(View.GONE); // 暫定 + + } + } +} diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java new file mode 100644 index 00000000..79f54e29 --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java @@ -0,0 +1,60 @@ +package one.nem.lacerta.component.common.picker.base; + +import android.app.Dialog; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import androidx.fragment.app.DialogFragment; + +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + +import javax.inject.Inject; + +import one.nem.lacerta.component.common.LacertaSelectDirDialog; +import one.nem.lacerta.component.common.R; +import one.nem.lacerta.component.common.SelectDirDialogItemAdapter; +import one.nem.lacerta.data.LacertaLibrary; +import one.nem.lacerta.model.LibraryItemPage; +import one.nem.lacerta.model.ListItemType; +import one.nem.lacerta.utils.FeatureSwitch; +import one.nem.lacerta.utils.LacertaLogger; + +public class LacertaFilePickerDialogBase extends DialogFragment { + + @Inject + LacertaLibrary lacertaLibrary; + + @Inject + LacertaLogger logger; + + + // Methods + public void updateList(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage) { + int currentCount = adapter.getItemCount(); + String currentDirId = adapter.getCurrentId(); + if (currentDirId == null) { + // Rootが関わる推移 (Rootからの推移) + adapter.setListItems(libraryItemPage); + adapter.notifyItemRangeRemoved(0, currentCount); + adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size()); + } else if (libraryItemPage.getPageId() == null) { + // Rootが関わる推移 (Rootへの推移) + adapter.setListItems(libraryItemPage); + adapter.notifyItemRangeRemoved(0, currentCount); + adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size()); + } else if (libraryItemPage.getPageId() != null) { + // Rootが関わらない推移 + adapter.setListItems(libraryItemPage); + adapter.notifyItemRangeRemoved(1, currentCount); + adapter.notifyItemRangeInserted(1, libraryItemPage.getListItems().size()); + } else { + // その他の遷移(安全側に倒すため全アイテム更新) + logger.warn("FilePickerDialogBase", "Unknown transition."); + logger.warn("FilePickerDialogBase", "currentDirId: " + currentDirId + ", libraryItemPage.getPageId(): " + libraryItemPage.getPageId()); + adapter.setListItems(libraryItemPage); + adapter.notifyItemRangeRemoved(0, currentCount); + adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size()); + } + } +} From 1654700ee0bc7edbabc937d710bd1f618cab2fa2 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 10:11:26 +0900 Subject: [PATCH 03/13] =?UTF-8?q?=E3=82=AF=E3=83=A9=E3=82=B9=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E3=81=A8Setter=E3=82=92Base=E3=81=AB=E7=A7=BB?= =?UTF-8?q?=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/LacertaFilePickerDialogBase.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java index 79f54e29..973a41af 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java @@ -21,16 +21,34 @@ import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; public class LacertaFilePickerDialogBase extends DialogFragment { - - @Inject - LacertaLibrary lacertaLibrary; - @Inject LacertaLogger logger; + // Variables + protected String title; + protected String message; + protected String positiveButtonText; + protected String negativeButtonText; + + // Setter + public void setTitle(String title) { + this.title = title; + } + + public void setMessage(String message) { + this.message = message; + } + + public void setPositiveButtonText(String positiveButtonText) { + this.positiveButtonText = positiveButtonText; + } + + public void setNegativeButtonText(String negativeButtonText) { + this.negativeButtonText = negativeButtonText; + } // Methods - public void updateList(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage) { + protected void updateList(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage) { int currentCount = adapter.getItemCount(); String currentDirId = adapter.getCurrentId(); if (currentDirId == null) { From be64f5a18684fd66830a8a18312791588e856579 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 10:28:38 +0900 Subject: [PATCH 04/13] =?UTF-8?q?Adapter,=20Dialog=E3=83=99=E3=83=BC?= =?UTF-8?q?=E3=82=B9=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/LacertaFilePickerAdapterBase.java | 19 ++++++++++++++----- .../base/LacertaFilePickerDialogBase.java | 4 +--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerAdapterBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerAdapterBase.java index 551a2b69..e21b7c17 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerAdapterBase.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerAdapterBase.java @@ -9,19 +9,24 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import one.nem.lacerta.component.common.LacertaSelectDirDialogInternalEventListener; import one.nem.lacerta.model.LibraryItemPage; import one.nem.lacerta.model.ListItem; import one.nem.lacerta.model.ListItemType; public class LacertaFilePickerAdapterBase extends RecyclerView.Adapter { + // Listener + public interface LacertaFilePickerAdapterListener { + void onItemSelected(String dirId); + void onBackSelected(String dirId); + } private LibraryItemPage libraryItemPage; - LacertaSelectDirDialogInternalEventListener listener; - public LacertaFilePickerAdapterBase(LacertaSelectDirDialogInternalEventListener listener) { - this.listener = listener; + private LacertaFilePickerAdapterListener listener; + + // Empty constructor + public LacertaFilePickerAdapterBase() { } public void setListItems(LibraryItemPage libraryItemPage) { @@ -31,6 +36,10 @@ public class LacertaFilePickerAdapterBase extends RecyclerView.Adapter listener.onBackSelected(this.libraryItemPage.getParentId())); } else { - holder.itemView.setOnClickListener(v -> listener.onDirSelected(listItem.getTitle(), listItem.getItemId())); + holder.itemView.setOnClickListener(v -> listener.onItemSelected(listItem.getItemId())); } } diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java index 973a41af..0003f11e 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java @@ -48,9 +48,7 @@ public class LacertaFilePickerDialogBase extends DialogFragment { } // Methods - protected void updateList(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage) { - int currentCount = adapter.getItemCount(); - String currentDirId = adapter.getCurrentId(); + protected void updateList(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) { if (currentDirId == null) { // Rootが関わる推移 (Rootからの推移) adapter.setListItems(libraryItemPage); From c717f4c596274df07d1cd6787d201b398ccbc715 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 10:28:48 +0900 Subject: [PATCH 05/13] =?UTF-8?q?=E6=96=B0DirPicker=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/picker/LacertaDirPickerDialog.java | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java new file mode 100644 index 00000000..21698e59 --- /dev/null +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java @@ -0,0 +1,97 @@ +package one.nem.lacerta.component.common.picker; + +import android.app.Dialog; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + +import javax.inject.Inject; + +import dagger.hilt.android.AndroidEntryPoint; +import one.nem.lacerta.component.common.R; +import one.nem.lacerta.component.common.picker.base.LacertaFilePickerAdapterBase; +import one.nem.lacerta.component.common.picker.base.LacertaFilePickerDialogBase; +import one.nem.lacerta.data.LacertaLibrary; + +@AndroidEntryPoint +public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase { + + @Inject + LacertaLibrary lacertaLibrary; + + // Listener + public interface LacertaDirPickerDialogListener { + void onDirSelected(String name, String dirId); + } + + // Variables + LacertaDirPickerDialogListener listener; + + // Setter + public LacertaDirPickerDialog setListener(LacertaDirPickerDialogListener listener) { + this.listener = listener; + return this; + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + super.onCreateDialog(savedInstanceState); + + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + View view = LayoutInflater.from(getActivity()).inflate(R.layout.lacerta_dialog_select_dir, null); + RecyclerView recyclerView = view.findViewById(R.id.select_dir_recycler_view); + TextView currentDirTextView = view.findViewById(R.id.current_dir_text_view); + + LacertaFilePickerAdapterBase adapter = new LacertaFilePickerAdapterBase(); + adapter.setListener(new LacertaFilePickerAdapterBase.LacertaFilePickerAdapterListener() { + @Override + public void onItemSelected(String dirId) { + updateList(adapter, dirId); + currentDirTextView.setText(dirId); + } + + @Override + public void onBackSelected(String dirId) { + updateList(adapter, dirId); + currentDirTextView.setText(dirId); + } + }); + + recyclerView.setAdapter(adapter); + recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); + + this.updateList(adapter, null); // ルートディレクトリのリストを表示 + + // Init dialog + builder.setTitle(this.title == null ? "フォルダを選択" : this.title); + builder.setMessage(this.message == null ? "フォルダを選択してください" : this.message); + builder.setView(view); + builder.setPositiveButton(this.positiveButtonText == null ? "OK" : this.positiveButtonText, (dialog, which) -> { + if (listener != null) { + listener.onDirSelected( + adapter.getCurrentPageTitle(), + adapter.getCurrentId()); + } + }); + builder.setNegativeButton(this.negativeButtonText == null ? "キャンセル" : this.negativeButtonText, (dialog, which) -> { + if (listener != null) { + dismiss(); + } + }); + + return builder.create(); + } + + private void updateList(LacertaFilePickerAdapterBase adapter, String folderId) { + lacertaLibrary.getFolderList(folderId).thenAccept(libraryItemPage -> { + adapter.setListItems(libraryItemPage); + this.updateList(adapter, libraryItemPage, adapter.getItemCount(), adapter.getCurrentId()); + }); + } +} From e5ba889780bc0a2ff302730bb2dad119ff611786 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 10:31:40 +0900 Subject: [PATCH 06/13] =?UTF-8?q?Setter=E3=82=92=E3=83=A1=E3=82=BD?= =?UTF-8?q?=E3=83=83=E3=83=89=E3=83=81=E3=82=A7=E3=83=BC=E3=83=B3=E3=81=AB?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../picker/base/LacertaFilePickerDialogBase.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java index 0003f11e..d11ecf3f 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java @@ -31,20 +31,24 @@ public class LacertaFilePickerDialogBase extends DialogFragment { protected String negativeButtonText; // Setter - public void setTitle(String title) { + public LacertaFilePickerDialogBase setTitle(String title) { this.title = title; + return this; } - public void setMessage(String message) { + public LacertaFilePickerDialogBase setMessage(String message) { this.message = message; + return this; } - public void setPositiveButtonText(String positiveButtonText) { + public LacertaFilePickerDialogBase setPositiveButtonText(String positiveButtonText) { this.positiveButtonText = positiveButtonText; + return this; } - public void setNegativeButtonText(String negativeButtonText) { + public LacertaFilePickerDialogBase setNegativeButtonText(String negativeButtonText) { this.negativeButtonText = negativeButtonText; + return this; } // Methods From 8a656f673dfaa71f7891b3d202e2f70788f31aac Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 10:34:22 +0900 Subject: [PATCH 07/13] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E3=83=AA=E3=83=8D=E3=83=BC=E3=83=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/picker/LacertaDirPickerDialog.java | 2 +- .../picker/base/LacertaFilePickerDialogBase.java | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java index 21698e59..683f158a 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java @@ -91,7 +91,7 @@ public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase { private void updateList(LacertaFilePickerAdapterBase adapter, String folderId) { lacertaLibrary.getFolderList(folderId).thenAccept(libraryItemPage -> { adapter.setListItems(libraryItemPage); - this.updateList(adapter, libraryItemPage, adapter.getItemCount(), adapter.getCurrentId()); + this.updateListView(adapter, libraryItemPage, adapter.getItemCount(), adapter.getCurrentId()); }); } } diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java index d11ecf3f..07ec1ee2 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java @@ -1,23 +1,10 @@ package one.nem.lacerta.component.common.picker.base; -import android.app.Dialog; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.TextView; - import androidx.fragment.app.DialogFragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import javax.inject.Inject; -import one.nem.lacerta.component.common.LacertaSelectDirDialog; -import one.nem.lacerta.component.common.R; -import one.nem.lacerta.component.common.SelectDirDialogItemAdapter; -import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.LibraryItemPage; -import one.nem.lacerta.model.ListItemType; -import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; public class LacertaFilePickerDialogBase extends DialogFragment { @@ -52,7 +39,7 @@ public class LacertaFilePickerDialogBase extends DialogFragment { } // Methods - protected void updateList(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) { + protected void updateListView(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) { if (currentDirId == null) { // Rootが関わる推移 (Rootからの推移) adapter.setListItems(libraryItemPage); From 41776b360b56dbedd2945a97dc920d36d65d5a0f Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 10:36:30 +0900 Subject: [PATCH 08/13] =?UTF-8?q?updatePathTextView=E3=82=92Base=E5=81=B4?= =?UTF-8?q?=E3=81=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../picker/base/LacertaFilePickerDialogBase.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java index 07ec1ee2..b765690a 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java @@ -1,10 +1,13 @@ package one.nem.lacerta.component.common.picker.base; +import android.widget.TextView; + import androidx.fragment.app.DialogFragment; import javax.inject.Inject; import one.nem.lacerta.model.LibraryItemPage; +import one.nem.lacerta.model.PublicPath; import one.nem.lacerta.utils.LacertaLogger; public class LacertaFilePickerDialogBase extends DialogFragment { @@ -39,6 +42,14 @@ public class LacertaFilePickerDialogBase extends DialogFragment { } // Methods + + protected void updatePathTextView(TextView currentDirTextView, PublicPath publicPath) { + if (publicPath == null) { + currentDirTextView.setText("/"); + } else { + currentDirTextView.setText("/" + publicPath.parent().getStringPath()); // TODO-rca: PublicPath側の実装を治すべき + } + } protected void updateListView(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) { if (currentDirId == null) { // Rootが関わる推移 (Rootからの推移) From 13e8ee7d87dea51e8c41e36ca79f4964ea009787 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 10:58:22 +0900 Subject: [PATCH 09/13] =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=82=BB?= =?UTF-8?q?=E3=83=83=E3=83=88=E6=9B=B4=E6=96=B0=E3=82=92Ui=E3=82=B9?= =?UTF-8?q?=E3=83=AC=E3=83=83=E3=83=89=E3=81=A7=E3=82=84=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB(IndexOutOfBounds=E5=AF=BE=E7=AD=96,=20?= =?UTF-8?q?=E3=83=87=E3=83=90=E3=82=A4=E3=82=B9=E3=81=AE=E3=82=B9=E3=83=9A?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=81=AA=E3=81=A9=E3=81=AE=E9=83=BD=E5=90=88?= =?UTF-8?q?=E3=81=A7=E6=8C=BF=E5=85=A5=E3=81=8C=E6=9B=B4=E6=96=B0=E3=81=AB?= =?UTF-8?q?=E8=BF=BD=E3=81=84=E3=81=A4=E3=81=8B=E3=81=AA=E3=81=84=E3=81=A8?= =?UTF-8?q?=E5=A3=8A=E3=82=8C=E3=82=8B=E3=81=9F=E3=82=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/picker/LacertaDirPickerDialog.java | 20 +++++++++++++++---- .../base/LacertaFilePickerDialogBase.java | 6 +++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java index 683f158a..5d135b10 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java @@ -18,6 +18,8 @@ import one.nem.lacerta.component.common.R; import one.nem.lacerta.component.common.picker.base.LacertaFilePickerAdapterBase; import one.nem.lacerta.component.common.picker.base.LacertaFilePickerDialogBase; import one.nem.lacerta.data.LacertaLibrary; +import one.nem.lacerta.model.ListItemType; +import one.nem.lacerta.model.PublicPath; @AndroidEntryPoint public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase { @@ -53,13 +55,13 @@ public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase { @Override public void onItemSelected(String dirId) { updateList(adapter, dirId); - currentDirTextView.setText(dirId); + updatePublicPath(currentDirTextView, dirId); } @Override public void onBackSelected(String dirId) { updateList(adapter, dirId); - currentDirTextView.setText(dirId); + updatePublicPath(currentDirTextView, dirId); } }); @@ -88,10 +90,20 @@ public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase { return builder.create(); } + private void updatePublicPath(TextView currentDirTextView, String folderId) { + lacertaLibrary.getPublicPath(folderId, ListItemType.ITEM_TYPE_FOLDER).thenAccept(publicPath -> { + this.updatePathTextView(currentDirTextView, publicPath); + }); + } + private void updateList(LacertaFilePickerAdapterBase adapter, String folderId) { lacertaLibrary.getFolderList(folderId).thenAccept(libraryItemPage -> { - adapter.setListItems(libraryItemPage); - this.updateListView(adapter, libraryItemPage, adapter.getItemCount(), adapter.getCurrentId()); + int currentCount = adapter.getItemCount(); + String currentId = adapter.getCurrentId(); +// adapter.setListItems(libraryItemPage); + getActivity().runOnUiThread(() -> { + this.updateListView(adapter, libraryItemPage, currentCount, currentId); + }); }); } } diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java index b765690a..2fedd677 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java @@ -51,7 +51,11 @@ public class LacertaFilePickerDialogBase extends DialogFragment { } } protected void updateListView(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) { - if (currentDirId == null) { + if (currentCount == 0) { + // 初回表示 + adapter.setListItems(libraryItemPage); + adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size()); + } else if (currentDirId == null) { // Rootが関わる推移 (Rootからの推移) adapter.setListItems(libraryItemPage); adapter.notifyItemRangeRemoved(0, currentCount); From 4d7f38a0f71285ea039e950205a409a8d0be783f Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 10:59:28 +0900 Subject: [PATCH 10/13] =?UTF-8?q?PublicPath=E3=81=AE=E7=94=9F=E6=88=90?= =?UTF-8?q?=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/picker/base/LacertaFilePickerDialogBase.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java index 2fedd677..1ca073dd 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java @@ -7,6 +7,7 @@ import androidx.fragment.app.DialogFragment; import javax.inject.Inject; import one.nem.lacerta.model.LibraryItemPage; +import one.nem.lacerta.model.ListItemType; import one.nem.lacerta.model.PublicPath; import one.nem.lacerta.utils.LacertaLogger; @@ -43,11 +44,15 @@ public class LacertaFilePickerDialogBase extends DialogFragment { // Methods - protected void updatePathTextView(TextView currentDirTextView, PublicPath publicPath) { + protected void updatePathTextView(TextView currentDirTextView, PublicPath publicPath, ListItemType listItemType) { if (publicPath == null) { currentDirTextView.setText("/"); } else { - currentDirTextView.setText("/" + publicPath.parent().getStringPath()); // TODO-rca: PublicPath側の実装を治すべき + if (listItemType == ListItemType.ITEM_TYPE_FOLDER) { + currentDirTextView.setText("/" + publicPath.getStringPath()); // TODO-rca: PublicPath側の実装を治すべき + } else { + currentDirTextView.setText("/" + publicPath.parent().getStringPath()); // TODO-rca: PublicPath側の実装を治すべき + } } } protected void updateListView(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) { From 8256d01682d72ecfbcb8ad6879c55bb1ffe7317d Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 11:02:23 +0900 Subject: [PATCH 11/13] =?UTF-8?q?=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E9=AB=98=E3=81=95=E6=8C=87=E5=AE=9A,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/common/picker/LacertaDirPickerDialog.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java index 5d135b10..aec649c2 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/LacertaDirPickerDialog.java @@ -46,7 +46,13 @@ public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase { super.onCreateDialog(savedInstanceState); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + View view = LayoutInflater.from(getActivity()).inflate(R.layout.lacerta_dialog_select_dir, null); + + // 高さを画面の40%にする + int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.4); + view.setMinimumHeight(height); + RecyclerView recyclerView = view.findViewById(R.id.select_dir_recycler_view); TextView currentDirTextView = view.findViewById(R.id.current_dir_text_view); @@ -92,7 +98,7 @@ public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase { private void updatePublicPath(TextView currentDirTextView, String folderId) { lacertaLibrary.getPublicPath(folderId, ListItemType.ITEM_TYPE_FOLDER).thenAccept(publicPath -> { - this.updatePathTextView(currentDirTextView, publicPath); + this.updatePathTextView(currentDirTextView, publicPath, ListItemType.ITEM_TYPE_FOLDER); }); } From f71aabed2a73c4194deb627a59ab440089075905 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 11:02:28 +0900 Subject: [PATCH 12/13] =?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 --- .../common/picker/base/LacertaFilePickerDialogBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java index 1ca073dd..e497f642 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/picker/base/LacertaFilePickerDialogBase.java @@ -55,6 +55,7 @@ public class LacertaFilePickerDialogBase extends DialogFragment { } } } + protected void updateListView(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) { if (currentCount == 0) { // 初回表示 From 383a7020ce68a2766da3eb9d65980cb909914466 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 11:02:44 +0900 Subject: [PATCH 13/13] =?UTF-8?q?=E6=96=B0=E3=83=80=E3=82=A4=E3=82=A2?= =?UTF-8?q?=E3=83=AD=E3=82=B0=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/ViewerListFragment.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java index 349bc99a..65518a10 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java @@ -23,6 +23,7 @@ import one.nem.lacerta.component.common.LacertaSelectDirDialog; import one.nem.lacerta.component.common.LacertaSelectDirDialogListener; import one.nem.lacerta.component.common.LacertaSelectRevDialog; import one.nem.lacerta.component.common.LacertaSelectRevDialogListener; +import one.nem.lacerta.component.common.picker.LacertaDirPickerDialog; import one.nem.lacerta.data.Document; import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.ListItemType; @@ -239,29 +240,21 @@ public class ViewerListFragment extends Fragment { builder.show(); return true; } else if (item.getItemId() == R.id.action_move) { - LacertaSelectDirDialog lacertaSelectDirDialog = new LacertaSelectDirDialog(); - lacertaSelectDirDialog.setListener(new LacertaSelectDirDialogListener() { - @Override - public void onDirSelected(String name, String itemId) { - logger.debug(TAG, "Selected dir: " + name + ", " + itemId); - document.moveDocument(documentId, itemId).thenAccept(aVoid -> { - getActivity().runOnUiThread(() -> { - // Stop Activity - getActivity().finish(); // TODO-rca: ファイル移動後に終了するべきかは検討 - }); + LacertaDirPickerDialog lacertaDirPickerDialog = new LacertaDirPickerDialog(); + lacertaDirPickerDialog.setListener((name, dirId) -> { + logger.debug(TAG, "Selected dir: " + name + ", " + dirId); + document.moveDocument(documentId, dirId).thenAccept(aVoid -> { + getActivity().runOnUiThread(() -> { + // Stop Activity + getActivity().finish(); // TODO-rca: ファイル移動後に終了するべきかは検討 }); - } - - @Override - public void onCanceled() { - logger.debug(TAG, "Canceled"); - } + }); }); - lacertaSelectDirDialog.setTitle("ファイルの移動") - .setMessage("ファイルを移動するフォルダを選択してください。") - .setPositiveButtonText("移動") - .setNegativeButtonText("キャンセル"); - lacertaSelectDirDialog.show(getParentFragmentManager(), "select_dir_dialog"); + lacertaDirPickerDialog.setTitle("ファイルの移動") + .setMessage("ファイルを移動するフォルダを選択してください。") + .setPositiveButtonText("移動") + .setNegativeButtonText("キャンセル"); + lacertaDirPickerDialog.show(getParentFragmentManager(), "select_dir_dialog"); return true; } else { return false;