From 064c4edfbe5b3ed46c3d21ced635fec968b43219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 17:20:39 +0900 Subject: [PATCH 01/49] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E5=BE=A9=E5=85=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/activity_main.xml | 59 +++++------------------ 1 file changed, 11 insertions(+), 48 deletions(-) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 262b305b..59d77a93 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,61 +1,24 @@ + + android:theme="@style/Theme.Lacerta" + tools:context=".MainActivity"> - - - - - - - - - - - - - - - + app:layout_constraintTop_toTopOf="parent" + app:navGraph="@navigation/main_nav" + tools:layout="@layout/fragment_home_top" /> Date: Mon, 22 Jan 2024 17:21:30 +0900 Subject: [PATCH 02/49] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E5=BE=A9=E5=85=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/layout/fragment_home_top.xml | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/feature/home/src/main/res/layout/fragment_home_top.xml b/feature/home/src/main/res/layout/fragment_home_top.xml index 73850323..3fc0b723 100644 --- a/feature/home/src/main/res/layout/fragment_home_top.xml +++ b/feature/home/src/main/res/layout/fragment_home_top.xml @@ -1,11 +1,50 @@ + android:layout_height="match_parent" + android:background="@color/colorSurface"> - + android:layout_height="match_parent"> + + + + + + + + + + + + + + \ No newline at end of file From 6bc43869c9ca594908663301a6fc08a1af376e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 17:21:54 +0900 Subject: [PATCH 03/49] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E5=BE=A9=E5=85=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/layout/fragment_library_top.xml | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/feature/library/src/main/res/layout/fragment_library_top.xml b/feature/library/src/main/res/layout/fragment_library_top.xml index 06e32e35..89a2538a 100644 --- a/feature/library/src/main/res/layout/fragment_library_top.xml +++ b/feature/library/src/main/res/layout/fragment_library_top.xml @@ -1,11 +1,50 @@ + android:layout_height="match_parent" + android:background="@color/colorSurface"> - + android:layout_height="match_parent"> + + + + + + + + + + + + + + \ No newline at end of file From 3d8ab69742a8edaa2260e486e7fabacbe7ff4edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 17:22:41 +0900 Subject: [PATCH 04/49] =?UTF-8?q?=E5=AE=9F=E8=A3=85=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/MainActivity.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 66985ad0..f6b61dd6 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -89,22 +89,8 @@ public class MainActivity extends AppCompatActivity { } }); - Toolbar toolbar = findViewById(R.id.toolbar); - setSupportActionBar(toolbar); } - // Public - public void setActionBarTitle(String title) { - getSupportActionBar().setTitle(title); - } - - public void setActionBarBackButton(boolean isEnabled) { - getSupportActionBar().setDisplayHomeAsUpEnabled(isEnabled); - } - - public void setActionBarMenuItem(int itemId, boolean isEnabled) { - - } private void initializeApp() { Log.d("Init", "Initializing app"); From 0dc69e1d739db9bb7fe51658c44d2e7b6ff0e0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 17:22:52 +0900 Subject: [PATCH 05/49] =?UTF-8?q?=E5=AE=9F=E8=A3=85=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/MainActivity.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index f6b61dd6..85ba4ded 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -71,24 +71,6 @@ public class MainActivity extends AppCompatActivity { // Set status bar color getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface)); - // Set app bar color - AppBarLayout appBarLayout = findViewById(R.id.app_bar_layout); - appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { - @Override - public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { - if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) { - // Collapsed - getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); - } else if (verticalOffset == 0) { - // Expanded - getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), one.nem.lacerta.shared.ui.R.color.colorSurface)); - } else { - // Somewhere in between - // Here you can add a color transition if you want - } - } - }); - } From d1a5cd2f23ae44c798361b844d4f1f0235613a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 17:24:05 +0900 Subject: [PATCH 06/49] =?UTF-8?q?=E5=AE=9F=E8=A3=85=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/feature/library/LibraryTopFragment.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java index 172246f4..30f31b4e 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryTopFragment.java @@ -38,8 +38,6 @@ import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.tag.DocumentTag; import one.nem.lacerta.utils.LacertaLogger; -import one.nem.lacerta.utils.TextInputDialog; - /** * A simple {@link Fragment} subclass. From ab39cd4d004755570852817b0b4fdcb01f167175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 17:26:03 +0900 Subject: [PATCH 07/49] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E5=BE=A9=E5=85=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/layout/fragment_setting_top.xml | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/feature/setting/src/main/res/layout/fragment_setting_top.xml b/feature/setting/src/main/res/layout/fragment_setting_top.xml index 032d6463..ee8463ca 100644 --- a/feature/setting/src/main/res/layout/fragment_setting_top.xml +++ b/feature/setting/src/main/res/layout/fragment_setting_top.xml @@ -1,11 +1,50 @@ + android:layout_height="match_parent" + android:background="@color/colorSurface"> - + android:layout_height="match_parent"> + + + + + + + + + + + + + + \ No newline at end of file From 1ceb3e29b7db31a7f97feac38020edfc6442f76a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 18:14:11 +0900 Subject: [PATCH 08/49] =?UTF-8?q?=E5=AE=9F=E8=A3=85=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/MainActivity.java | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 9146c04f..5e08f927 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -3,6 +3,7 @@ package one.nem.lacerta; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.navigation.NavController; import androidx.navigation.fragment.NavHostFragment; @@ -89,20 +90,7 @@ public class MainActivity extends AppCompatActivity { } }); - - Toolbar toolbar = findViewById(R.id.toolbar); - setSupportActionBar(toolbar); } - - // Public - public void setActionBarTitle(String title) { - getSupportActionBar().setTitle(title); - } - - public void setActionBarBackButton(boolean isEnabled) { - getSupportActionBar().setDisplayHomeAsUpEnabled(isEnabled); - } - private void initializeApp() { Log.d("Init", "Initializing app"); // Set feature switch override to default value From afef0742420c89261316118c3c2ced8b6905ee53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 18:14:42 +0900 Subject: [PATCH 09/49] =?UTF-8?q?=E3=83=93=E3=83=AB=E3=83=89=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E5=9B=9E=E9=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/MainActivity.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 5e08f927..71fd31ee 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -106,11 +106,11 @@ public class MainActivity extends AppCompatActivity { if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId); } - @Override - public void navigateToFragment(Fragment fragment) { - getSupportFragmentManager().beginTransaction() - .replace(R.id.nav_host_fragment, fragment) - .addToBackStack(null) - .commit(); - } +// @Override +// public void navigateToFragment(Fragment fragment) { +// getSupportFragmentManager().beginTransaction() +// .replace(R.id.nav_host_fragment, fragment) +// .addToBackStack(null) +// .commit(); +// } } From 3b684bec5352a3138734a4e6b1e5f3dca2f178a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 18:15:41 +0900 Subject: [PATCH 10/49] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E5=AE=9F?= =?UTF-8?q?=E8=A3=85=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/MainActivity.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 71fd31ee..1261b5a2 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -72,24 +72,6 @@ public class MainActivity extends AppCompatActivity { // Set status bar color getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface)); - // Set app bar color - AppBarLayout appBarLayout = findViewById(R.id.app_bar_layout); - appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { - @Override - public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { - if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) { - // Collapsed - getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); - } else if (verticalOffset == 0) { - // Expanded - getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), one.nem.lacerta.shared.ui.R.color.colorSurface)); - } else { - // Somewhere in between - // Here you can add a color transition if you want - } - } - }); - } private void initializeApp() { Log.d("Init", "Initializing app"); From 20828e2f0f71a05a5e18bfc99dbb79fed376de71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 18:18:12 +0900 Subject: [PATCH 11/49] =?UTF-8?q?=E3=82=B9=E3=83=86=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=82=B9=E3=83=90=E3=83=BC=E3=81=AE=E8=89=B2=E3=82=92=E5=90=88?= =?UTF-8?q?=E3=82=8F=E3=81=9B=E3=82=8B=E5=87=A6=E7=90=86=E3=82=92=E7=A7=BB?= =?UTF-8?q?=E6=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/library/LibraryPageFragment.java | 19 +++++++++++++++++++ .../main/res/layout/fragment_library_top.xml | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 4b62e086..957cd947 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -150,6 +150,25 @@ public class LibraryPageFragment extends Fragment { this.currentTotalItemCount = libraryItemPage.getListItems().size(); }); } + + + // Set status bar color + AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout); + appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { + @Override + public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { + if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) { + // Collapsed + getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); + } else if (verticalOffset == 0) { + // Expanded + getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSurface)); + } else { + // Somewhere in between + // Here you can add a color transition if you want + } + } + }); } @Override diff --git a/feature/library/src/main/res/layout/fragment_library_top.xml b/feature/library/src/main/res/layout/fragment_library_top.xml index 89a2538a..f9d53d56 100644 --- a/feature/library/src/main/res/layout/fragment_library_top.xml +++ b/feature/library/src/main/res/layout/fragment_library_top.xml @@ -29,7 +29,7 @@ app:layout_scrollFlags="scroll|exitUntilCollapsed"> Date: Mon, 22 Jan 2024 18:24:53 +0900 Subject: [PATCH 12/49] =?UTF-8?q?setupToolbar=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/library/LibraryPageFragment.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 957cd947..95e970ca 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -63,6 +63,7 @@ public class LibraryPageFragment extends Fragment { public LibraryPageFragment() { // Required empty public constructor } + public static LibraryPageFragment newInstance(String folderId) { LibraryPageFragment fragment = new LibraryPageFragment(); Bundle args = new Bundle(); @@ -169,6 +170,49 @@ public class LibraryPageFragment extends Fragment { } } }); + + } + + private void toolbarSetup(Toolbar toolbar, boolean showBackButton, String title, String subtitle) { + if (showBackButton) { + toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); + toolbar.setNavigationOnClickListener(v -> { + getParentFragmentManager().popBackStack(); + }); + } else { + toolbar.setNavigationIcon(null); + } + toolbar.setTitle(title); + if (subtitle != null) toolbar.setSubtitle(subtitle); + toolbar.inflateMenu(R.menu.dir_menu); + toolbar.setOnMenuItemClickListener(item -> { + if (item.getItemId() == R.id.menu_item_create_new_folder) { + createFolder(); + return true; + } else { + return false; + } + }); + } + + private void createFolder() { + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle("フォルダの作成"); + builder.setMessage("フォルダ名を入力してください"); + final android.widget.EditText input = new android.widget.EditText(getContext()); + input.setText("フォルダ名"); + builder.setView(input); + builder.setPositiveButton("作成", (dialog, which) -> { + lacertaLibrary.createFolder(null, input.getText().toString()).thenAccept(folderId -> { + logger.debug("LibraryTopFragment", "folderId: " + folderId); + }); + // Refresh + updateItem(); + }); + builder.setNegativeButton("キャンセル", (dialog, which) -> { + dialog.cancel(); + }); + builder.show(); } @Override From 734f75b4c7a5be1e9500df9a8ffc07b13c078bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 18:35:18 +0900 Subject: [PATCH 13/49] iroiro --- .../feature/library/LibraryPageFragment.java | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 95e970ca..71f5fb16 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -107,6 +107,7 @@ public class LibraryPageFragment extends Fragment { public void onFolderSelected(String folderId, String folderName) { logger.debug("LibraryTopFragment", "Folder selected! folderId: " + folderId + ", folderName: " + folderName); // 画面遷移 + Toast.makeText(getContext(), "Folder selected! folderId: " + folderId + ", folderName: " + folderName, Toast.LENGTH_SHORT).show(); FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); assert fragmentNavigation != null; fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId)); @@ -129,10 +130,7 @@ public class LibraryPageFragment extends Fragment { logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); listItemAdapter.setLibraryItemPage(libraryItemPage); getActivity().runOnUiThread(() -> { - // ActionBarのタイトルを変更する - getActivity().setTitle("ライブラリ"); - // ActionBarに戻るボタンを非表示にする -// getActivity().getActionBar().setDisplayHomeAsUpEnabled(false); + toolbarSetup(view.findViewById(R.id.library_toolbar), false, "ライブラリ", "Placeholder"); listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1); }); this.currentTotalItemCount = libraryItemPage.getListItems().size(); @@ -141,11 +139,8 @@ public class LibraryPageFragment extends Fragment { lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> { logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); listItemAdapter.setLibraryItemPage(libraryItemPage); + toolbarSetup(view.findViewById(R.id.library_toolbar), true, libraryItemPage.getPageTitle(), "Placeholder"); getActivity().runOnUiThread(() -> { - // ActionBarのタイトルを変更する - getActivity().setTitle(libraryItemPage.getPageTitle()); - // ActionBarに戻るボタンを表示する -// getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1); }); this.currentTotalItemCount = libraryItemPage.getListItems().size(); @@ -174,24 +169,26 @@ public class LibraryPageFragment extends Fragment { } private void toolbarSetup(Toolbar toolbar, boolean showBackButton, String title, String subtitle) { - if (showBackButton) { - toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); - toolbar.setNavigationOnClickListener(v -> { - getParentFragmentManager().popBackStack(); - }); - } else { - toolbar.setNavigationIcon(null); - } - toolbar.setTitle(title); - if (subtitle != null) toolbar.setSubtitle(subtitle); - toolbar.inflateMenu(R.menu.dir_menu); - toolbar.setOnMenuItemClickListener(item -> { - if (item.getItemId() == R.id.menu_item_create_new_folder) { - createFolder(); - return true; + getActivity().runOnUiThread(() -> { + if (showBackButton) { + toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); + toolbar.setNavigationOnClickListener(v -> { + getParentFragmentManager().popBackStack(); + }); } else { - return false; + toolbar.setNavigationIcon(null); } + toolbar.setTitle(title); + if (subtitle != null) toolbar.setSubtitle(subtitle); + toolbar.inflateMenu(R.menu.dir_menu); + toolbar.setOnMenuItemClickListener(item -> { + if (item.getItemId() == R.id.menu_item_create_new_folder) { + createFolder(); + return true; + } else { + return false; + } + }); }); } From 611c5b516d79480228a82f4ef9a0c0392b406cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 18:40:24 +0900 Subject: [PATCH 14/49] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E5=AE=9F?= =?UTF-8?q?=E8=A3=85=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/library/LibraryPageFragment.java | 37 +------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 71f5fb16..e5f70c48 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -91,8 +91,6 @@ public class LibraryPageFragment extends Fragment { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_library_top, container, false); - setHasOptionsMenu(true); - return view; } @@ -193,6 +191,7 @@ public class LibraryPageFragment extends Fragment { } private void createFolder() { + // TODO-rca: デザインをMaterial Design 3に合わせたカスタムダイアログにする AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle("フォルダの作成"); builder.setMessage("フォルダ名を入力してください"); @@ -211,40 +210,6 @@ public class LibraryPageFragment extends Fragment { }); builder.show(); } - - @Override - public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { - inflater.inflate(R.menu.dir_menu, menu); - super.onCreateOptionsMenu(menu, inflater); - } - - // Selected - @Override - public boolean onOptionsItemSelected(@NonNull MenuItem item) { - if (item.getItemId() == R.id.menu_item_create_new_folder) { - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - builder.setTitle("フォルダの作成"); - builder.setMessage("フォルダ名を入力してください"); - final android.widget.EditText input = new android.widget.EditText(getContext()); - input.setText("フォルダ名"); - builder.setView(input); - builder.setPositiveButton("作成", (dialog, which) -> { - lacertaLibrary.createFolder(null, input.getText().toString()).thenAccept(folderId -> { - logger.debug("LibraryTopFragment", "folderId: " + folderId); - }); - // Refresh - updateItem(); - }); - builder.setNegativeButton("キャンセル", (dialog, which) -> { - dialog.cancel(); - }); - builder.show(); - return true; - } else { - return super.onOptionsItemSelected(item); - } - } - private void updateItem() { lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> { logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); From 04db1605483c71d2e6a4008095b737ed99c1cfcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 18:41:24 +0900 Subject: [PATCH 15/49] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80?= =?UTF-8?q?=E5=90=8D=E3=82=92=E5=BC=95=E6=95=B0=E3=81=AB=E3=81=A8=E3=82=8B?= =?UTF-8?q?=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 --- .../one/nem/lacerta/feature/library/LibraryPageFragment.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index e5f70c48..a8e772be 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -49,6 +49,7 @@ public class LibraryPageFragment extends Fragment { // Param private String folderId; + private String title; @Inject LacertaLibrary lacertaLibrary; @@ -64,10 +65,11 @@ public class LibraryPageFragment extends Fragment { // Required empty public constructor } - public static LibraryPageFragment newInstance(String folderId) { + public static LibraryPageFragment newInstance(String folderId, String title) { LibraryPageFragment fragment = new LibraryPageFragment(); Bundle args = new Bundle(); args.putString("folderId", folderId); + args.putString("title", title); fragment.setArguments(args); return fragment; } @@ -76,6 +78,7 @@ public class LibraryPageFragment extends Fragment { LibraryPageFragment fragment = new LibraryPageFragment(); Bundle args = new Bundle(); args.putString("folderId", null); + args.putString("title", null); fragment.setArguments(args); return fragment; } From 1648e0b7c1f13ef28c3cc9c1441a3da445a76e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 18:42:50 +0900 Subject: [PATCH 16/49] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80?= =?UTF-8?q?=E5=90=8D=E3=82=92=E5=BC=95=E6=95=B0=E3=81=AB=E3=81=A8=E3=82=8B?= =?UTF-8?q?=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 --- .../one/nem/lacerta/feature/library/LibraryPageFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index a8e772be..e6f42152 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -111,7 +111,7 @@ public class LibraryPageFragment extends Fragment { Toast.makeText(getContext(), "Folder selected! folderId: " + folderId + ", folderName: " + folderName, Toast.LENGTH_SHORT).show(); FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); assert fragmentNavigation != null; - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId)); + fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName)); } @Override From c06d7e6b150df62af793df34461d2fcc9e019efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 18:43:46 +0900 Subject: [PATCH 17/49] =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=81=AE=E3=83=95?= =?UTF-8?q?=E3=82=A9=E3=83=AB=E3=83=80=E5=90=8D=E3=82=92=E4=BD=BF=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E5=8F=96=E5=BE=97=E9=96=8B=E5=A7=8B=E5=89=8D=E3=81=AB?= =?UTF-8?q?ToolBar=E3=82=92init=E3=81=99=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 --- .../one/nem/lacerta/feature/library/LibraryPageFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index e6f42152..4f757d1e 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -127,20 +127,20 @@ public class LibraryPageFragment extends Fragment { } if (this.folderId == null) { // Root + toolbarSetup(view.findViewById(R.id.library_toolbar), false, "ライブラリ", "Placeholder"); lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> { logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); listItemAdapter.setLibraryItemPage(libraryItemPage); getActivity().runOnUiThread(() -> { - toolbarSetup(view.findViewById(R.id.library_toolbar), false, "ライブラリ", "Placeholder"); listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1); }); this.currentTotalItemCount = libraryItemPage.getListItems().size(); }); } else { // Root以外 + toolbarSetup(view.findViewById(R.id.library_toolbar), true, this.title, "Placeholder"); lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> { logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); listItemAdapter.setLibraryItemPage(libraryItemPage); - toolbarSetup(view.findViewById(R.id.library_toolbar), true, libraryItemPage.getPageTitle(), "Placeholder"); getActivity().runOnUiThread(() -> { listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1); }); From 305cbcd679eaeab80797f997f4edc9e63ffe59fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 19:17:09 +0900 Subject: [PATCH 18/49] WIP --- .../java/one/nem/lacerta/MainActivity.java | 17 +++++++------- .../feature/library/LibraryPageFragment.java | 22 +++++++++++++++---- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 1261b5a2..0ef81860 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -16,6 +16,7 @@ import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; +import one.nem.lacerta.model.FragmentNavigation; import one.nem.lacerta.model.pref.FeatureSwitchOverride; import one.nem.lacerta.utils.FeatureSwitch; @@ -31,7 +32,7 @@ import one.nem.lacerta.utils.repository.SharedPrefUtils; import javax.inject.Inject; @AndroidEntryPoint -public class MainActivity extends AppCompatActivity { +public class MainActivity extends AppCompatActivity implements FragmentNavigation { @Inject SharedPrefUtils sharedPrefUtils; @@ -88,11 +89,11 @@ public class MainActivity extends AppCompatActivity { if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId); } -// @Override -// public void navigateToFragment(Fragment fragment) { -// getSupportFragmentManager().beginTransaction() -// .replace(R.id.nav_host_fragment, fragment) -// .addToBackStack(null) -// .commit(); -// } + @Override + public void navigateToFragment(Fragment fragment) { + getSupportFragmentManager().beginTransaction() + .replace(R.id.nav_host_fragment, fragment) + .addToBackStack(null) + .commit(); + } } diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 4f757d1e..620feefd 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -36,6 +36,7 @@ import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.data.Document; import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.FragmentNavigation; +import one.nem.lacerta.model.PublicPath; import one.nem.lacerta.utils.LacertaLogger; @@ -50,6 +51,8 @@ public class LibraryPageFragment extends Fragment { // Param private String folderId; private String title; + private String publicPath; + private PublicPath currentPublicPath; @Inject LacertaLibrary lacertaLibrary; @@ -65,11 +68,12 @@ public class LibraryPageFragment extends Fragment { // Required empty public constructor } - public static LibraryPageFragment newInstance(String folderId, String title) { + public static LibraryPageFragment newInstance(String folderId, String title, String publicPath) { LibraryPageFragment fragment = new LibraryPageFragment(); Bundle args = new Bundle(); args.putString("folderId", folderId); args.putString("title", title); + args.putString("publicPath", publicPath); fragment.setArguments(args); return fragment; } @@ -79,6 +83,7 @@ public class LibraryPageFragment extends Fragment { Bundle args = new Bundle(); args.putString("folderId", null); args.putString("title", null); + args.putString("publicPath", null); fragment.setArguments(args); return fragment; } @@ -93,7 +98,6 @@ public class LibraryPageFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_library_top, container, false); - return view; } @@ -111,7 +115,7 @@ public class LibraryPageFragment extends Fragment { Toast.makeText(getContext(), "Folder selected! folderId: " + folderId + ", folderName: " + folderName, Toast.LENGTH_SHORT).show(); FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); assert fragmentNavigation != null; - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName)); + fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, currentPublicPath.resolve(folderName).getStringPath())); } @Override @@ -124,11 +128,20 @@ public class LibraryPageFragment extends Fragment { if (getArguments() != null) { this.folderId = getArguments().getString("folderId"); + this.title = getArguments().getString("title"); + this.publicPath = getArguments().getString("publicPath"); + // Log + logger.debug("LibraryTopFragment", "args" + + ", folderId: " + this.folderId + + ", title: " + this.title + + ", publicPath: " + this.publicPath); } if (this.folderId == null) { // Root toolbarSetup(view.findViewById(R.id.library_toolbar), false, "ライブラリ", "Placeholder"); lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> { + this.currentPublicPath = new PublicPath().resolve("/"); + logger.debug("LibraryInit(ROOT)",currentPublicPath.getStringPath()); logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); listItemAdapter.setLibraryItemPage(libraryItemPage); getActivity().runOnUiThread(() -> { @@ -139,6 +152,8 @@ public class LibraryPageFragment extends Fragment { } else { // Root以外 toolbarSetup(view.findViewById(R.id.library_toolbar), true, this.title, "Placeholder"); lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> { + this.currentPublicPath = new PublicPath().parse(this.publicPath); + logger.debug("LibraryInit(NON_ROOT)",currentPublicPath.getStringPath()); logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); listItemAdapter.setLibraryItemPage(libraryItemPage); getActivity().runOnUiThread(() -> { @@ -180,7 +195,6 @@ public class LibraryPageFragment extends Fragment { toolbar.setNavigationIcon(null); } toolbar.setTitle(title); - if (subtitle != null) toolbar.setSubtitle(subtitle); toolbar.inflateMenu(R.menu.dir_menu); toolbar.setOnMenuItemClickListener(item -> { if (item.getItemId() == R.id.menu_item_create_new_folder) { From e77fafc108f064eff6c5eb2e4365ddcfe0bac211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 19:22:15 +0900 Subject: [PATCH 19/49] WIP --- .../nem/lacerta/feature/library/LibraryPageFragment.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 620feefd..a59d24cf 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -115,7 +115,7 @@ public class LibraryPageFragment extends Fragment { Toast.makeText(getContext(), "Folder selected! folderId: " + folderId + ", folderName: " + folderName, Toast.LENGTH_SHORT).show(); FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); assert fragmentNavigation != null; - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, currentPublicPath.resolve(folderName).getStringPath())); + fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, new PublicPath().parse(publicPath).resolve(folderName).getStringPath())); } @Override @@ -140,8 +140,6 @@ public class LibraryPageFragment extends Fragment { if (this.folderId == null) { // Root toolbarSetup(view.findViewById(R.id.library_toolbar), false, "ライブラリ", "Placeholder"); lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> { - this.currentPublicPath = new PublicPath().resolve("/"); - logger.debug("LibraryInit(ROOT)",currentPublicPath.getStringPath()); logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); listItemAdapter.setLibraryItemPage(libraryItemPage); getActivity().runOnUiThread(() -> { @@ -152,8 +150,6 @@ public class LibraryPageFragment extends Fragment { } else { // Root以外 toolbarSetup(view.findViewById(R.id.library_toolbar), true, this.title, "Placeholder"); lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> { - this.currentPublicPath = new PublicPath().parse(this.publicPath); - logger.debug("LibraryInit(NON_ROOT)",currentPublicPath.getStringPath()); logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); listItemAdapter.setLibraryItemPage(libraryItemPage); getActivity().runOnUiThread(() -> { @@ -189,6 +185,7 @@ public class LibraryPageFragment extends Fragment { if (showBackButton) { toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); toolbar.setNavigationOnClickListener(v -> { + this.publicPath = new PublicPath().parse(this.publicPath).resolve("..").getStringPath(); getParentFragmentManager().popBackStack(); }); } else { @@ -216,7 +213,7 @@ public class LibraryPageFragment extends Fragment { input.setText("フォルダ名"); builder.setView(input); builder.setPositiveButton("作成", (dialog, which) -> { - lacertaLibrary.createFolder(null, input.getText().toString()).thenAccept(folderId -> { + lacertaLibrary.createFolder(this.currentPublicPath.getStringPath(), input.getText().toString()).thenAccept(folderId -> { logger.debug("LibraryTopFragment", "folderId: " + folderId); }); // Refresh From bc304f8535a1035352ba8c65f14bff8b9c8e6555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 19:22:24 +0900 Subject: [PATCH 20/49] WIP --- .../one/nem/lacerta/feature/library/LibraryPageFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index a59d24cf..506fe2d7 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -185,7 +185,7 @@ public class LibraryPageFragment extends Fragment { if (showBackButton) { toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); toolbar.setNavigationOnClickListener(v -> { - this.publicPath = new PublicPath().parse(this.publicPath).resolve("..").getStringPath(); + this.publicPath = new PublicPath().parse(this.publicPath).parent().getStringPath(); getParentFragmentManager().popBackStack(); }); } else { From fe4999384a855aea07bf2ac4a2c3f9e30234c291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 19:28:42 +0900 Subject: [PATCH 21/49] Fix --- .../feature/library/LibraryPageFragment.java | 3 ++- .../one/nem/lacerta/model/PublicPath.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 506fe2d7..412bbbbb 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -115,7 +115,8 @@ public class LibraryPageFragment extends Fragment { Toast.makeText(getContext(), "Folder selected! folderId: " + folderId + ", folderName: " + folderName, Toast.LENGTH_SHORT).show(); FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); assert fragmentNavigation != null; - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, new PublicPath().parse(publicPath).resolve(folderName).getStringPath())); + logger.debug("LibraryTopFragment", "publicPath: " + publicPath); + fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, publicPath == null ? new PublicPath().parse("/").resolve(folderName).getStringPath() : new PublicPath().parse(publicPath).resolve(folderName).getStringPath())); } @Override diff --git a/model/src/main/java/one/nem/lacerta/model/PublicPath.java b/model/src/main/java/one/nem/lacerta/model/PublicPath.java index ccd902cb..d1639a7d 100644 --- a/model/src/main/java/one/nem/lacerta/model/PublicPath.java +++ b/model/src/main/java/one/nem/lacerta/model/PublicPath.java @@ -39,14 +39,19 @@ public class PublicPath { } public PublicPath parse(String path) { - if (path.startsWith("/")) { + if (path == null) { this.path.clear(); - path = path.substring(1); - } - String[] pathArray = path.split("/"); - for (String p : pathArray) { - Log.d("PublicPath", "parse: " + p); - resolveInternal(p); + this.path.add("/"); + } else { + if (path.startsWith("/")) { + this.path.clear(); + path = path.substring(1); + } + String[] pathArray = path.split("/"); + for (String p : pathArray) { + Log.d("PublicPath", "parse: " + p); + resolveInternal(p); + } } return this; } From a0f89de1ac19f7eb23b09b46ad13bc36ada750f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 19:41:54 +0900 Subject: [PATCH 22/49] WIP --- .../feature/library/LibraryPageFragment.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 412bbbbb..922076d8 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -52,6 +52,8 @@ public class LibraryPageFragment extends Fragment { private String folderId; private String title; private String publicPath; + private String currentId; + private String parentId; private PublicPath currentPublicPath; @Inject @@ -68,12 +70,12 @@ public class LibraryPageFragment extends Fragment { // Required empty public constructor } - public static LibraryPageFragment newInstance(String folderId, String title, String publicPath) { + public static LibraryPageFragment newInstance(String folderId, String title, String parentId) { LibraryPageFragment fragment = new LibraryPageFragment(); Bundle args = new Bundle(); args.putString("folderId", folderId); args.putString("title", title); - args.putString("publicPath", publicPath); + args.putString("publicPath", parentId); fragment.setArguments(args); return fragment; } @@ -130,17 +132,18 @@ public class LibraryPageFragment extends Fragment { if (getArguments() != null) { this.folderId = getArguments().getString("folderId"); this.title = getArguments().getString("title"); - this.publicPath = getArguments().getString("publicPath"); + this.parentId = getArguments().getString("parentId"); // Log logger.debug("LibraryTopFragment", "args" + ", folderId: " + this.folderId + ", title: " + this.title - + ", publicPath: " + this.publicPath); + + ", parentId: " + this.parentId); } if (this.folderId == null) { // Root toolbarSetup(view.findViewById(R.id.library_toolbar), false, "ライブラリ", "Placeholder"); lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> { + this.currentId = libraryItemPage.getPageId(); // Currentを保存 logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); listItemAdapter.setLibraryItemPage(libraryItemPage); getActivity().runOnUiThread(() -> { @@ -151,6 +154,7 @@ public class LibraryPageFragment extends Fragment { } else { // Root以外 toolbarSetup(view.findViewById(R.id.library_toolbar), true, this.title, "Placeholder"); lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> { + this.currentId = libraryItemPage.getPageId(); // Currentを保存 logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); listItemAdapter.setLibraryItemPage(libraryItemPage); getActivity().runOnUiThread(() -> { @@ -214,7 +218,8 @@ public class LibraryPageFragment extends Fragment { input.setText("フォルダ名"); builder.setView(input); builder.setPositiveButton("作成", (dialog, which) -> { - lacertaLibrary.createFolder(this.currentPublicPath.getStringPath(), input.getText().toString()).thenAccept(folderId -> { + logger.debug("LibraryTopFragment", "Creating folder: Name: " + input.getText().toString() + ", publicPath: " + publicPath); + lacertaLibrary.createFolder("hoge", input.getText().toString()).thenAccept(folderId -> { logger.debug("LibraryTopFragment", "folderId: " + folderId); }); // Refresh From 58e06863046d44c4c483fb850186d1b143b65cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 19:58:20 +0900 Subject: [PATCH 23/49] =?UTF-8?q?Entity=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/source/database/entity/FolderEntity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java b/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java index f3a9091d..8b745e39 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java +++ b/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java @@ -16,7 +16,7 @@ public class FolderEntity { @ColumnInfo(name = "title") public String name; // フォルダ名 - @ColumnInfo(name = "public_path") - public String publicPath; // 公開パス + @ColumnInfo(name = "parent_id") + public String parentId; // 親フォルダID } From 9df033af735925ee7e4533bed777ec8e3221d54d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 19:58:59 +0900 Subject: [PATCH 24/49] =?UTF-8?q?Entity=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/source/database/entity/DocumentEntity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java b/source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java index 90a17b1d..2c4e03ab 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java +++ b/source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java @@ -40,6 +40,6 @@ public class DocumentEntity { @ColumnInfo(name = "tag_ids") public List tagIds; // タグ - @ColumnInfo(name = "public_path") - public String publicPath; // 公開パス + @ColumnInfo(name = "parent_id") + public String parentId; // 親フォルダID } From b87b635d2b63516464232bd3d0c06d4bc1b7d0a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 19:59:21 +0900 Subject: [PATCH 25/49] =?UTF-8?q?DB=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=A4=E3=83=B3=E3=82=AF=E3=83=AA=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/source/database/LacertaDatabase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java b/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java index 47e0e4bb..e3d6a6b9 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java +++ b/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java @@ -19,7 +19,7 @@ import one.nem.lacerta.source.database.dao.LibraryDao; import one.nem.lacerta.source.database.dao.VcsRevDao; import one.nem.lacerta.source.database.dao.VcsLogDao; -@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class}, version = 4) +@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class}, version = 5) public abstract class LacertaDatabase extends RoomDatabase { public abstract TagDao tagDao(); public abstract DocumentDao documentDao(); From 253c77d6f56876ed95deb507a073e3a258f7a0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 20:00:45 +0900 Subject: [PATCH 26/49] =?UTF-8?q?Dao=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/source/database/dao/DocumentDao.java | 4 ++-- .../one/nem/lacerta/source/database/dao/FolderDao.java | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java index f5f1eb61..f3a3fd2b 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java @@ -29,8 +29,8 @@ public interface DocumentDao { @Query("SELECT * FROM Document WHERE id IN (:ids)") List findByIds(List ids); - @Query("SELECT * FROM Document WHERE public_path = :publicPath LIMIT :limit") - List findByPublicPathWithLimit(String publicPath, int limit); + @Query("SELECT * FROM Document WHERE parent_id = :parentId") + List findByParentId(String parentId); @Query("SELECT * FROM Document ORDER BY created_at DESC LIMIT :limit") List getRecentDocument(int limit); diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java index 451854e5..af5e92d4 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java @@ -15,11 +15,8 @@ public interface FolderDao { @Query("SELECT * FROM Folder WHERE id = :id") FolderEntity findById(String id); - @Query("SELECT * FROM Folder WHERE public_path = :publicPath") - FolderEntity findByPublicPath(String publicPath); - - @Query("SELECT * FROM Folder WHERE public_path = :publicPath LIMIT :limit") - List findByPublicPathWithLimit(String publicPath, int limit); + @Query("SELECT * FROM Folder WHERE parent_id = :parentId") + List findByParentId(String parentId); @Insert void insert(FolderEntity folderEntity); From d40b188f87456d046a65738787065b7796d75c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 20:03:42 +0900 Subject: [PATCH 27/49] =?UTF-8?q?Model=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/model/LibraryItemPage.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/model/src/main/java/one/nem/lacerta/model/LibraryItemPage.java b/model/src/main/java/one/nem/lacerta/model/LibraryItemPage.java index 825c2396..c354d5ff 100644 --- a/model/src/main/java/one/nem/lacerta/model/LibraryItemPage.java +++ b/model/src/main/java/one/nem/lacerta/model/LibraryItemPage.java @@ -6,14 +6,16 @@ public class LibraryItemPage { String pageTitle; String pageId; + String parentId; ArrayList listItems; // Constructor - public LibraryItemPage(String pageTitle, String pageId, ArrayList listItems) { + public LibraryItemPage(String pageTitle, String pageId, ArrayList listItems, String parentId) { this.pageTitle = pageTitle; this.pageId = pageId; this.listItems = listItems; + this.parentId = parentId; } public LibraryItemPage() { @@ -30,6 +32,10 @@ public class LibraryItemPage { return pageId; } + public String getParentId() { + return parentId; + } + public ArrayList getListItems() { return listItems; } @@ -44,6 +50,10 @@ public class LibraryItemPage { this.pageId = pageId; } + public void setParentId(String parentId) { + this.parentId = parentId; + } + public void setListItems(ArrayList listItems) { this.listItems = listItems; } From df3edbf3549666f0978127a41fb589ec49a48985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 20:03:56 +0900 Subject: [PATCH 28/49] =?UTF-8?q?Model=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/model/LibraryItemPage.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/model/src/main/java/one/nem/lacerta/model/LibraryItemPage.java b/model/src/main/java/one/nem/lacerta/model/LibraryItemPage.java index c354d5ff..42933640 100644 --- a/model/src/main/java/one/nem/lacerta/model/LibraryItemPage.java +++ b/model/src/main/java/one/nem/lacerta/model/LibraryItemPage.java @@ -18,6 +18,12 @@ public class LibraryItemPage { this.parentId = parentId; } + public LibraryItemPage(String pageTitle, String pageId, ArrayList listItems) { + this.pageTitle = pageTitle; + this.pageId = pageId; + this.listItems = listItems; + } + public LibraryItemPage() { // Empty constructor } From fc6cbb9d376cbd34c35a330f72f1e4128bf1d639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 20:06:19 +0900 Subject: [PATCH 29/49] =?UTF-8?q?=E4=B8=80=E9=83=A8=E5=BB=83=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/data/LacertaLibrary.java | 4 +- .../lacerta/data/impl/LacertaLibraryImpl.java | 68 ------------------- 2 files changed, 1 insertion(+), 71 deletions(-) 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 6d424179..eda15fce 100644 --- a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java +++ b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java @@ -15,9 +15,7 @@ public interface LacertaLibrary { CompletableFuture> getRecentDocument(int limit); CompletableFuture> getRecentDocument(int limit, int offset); - // Get Library page - CompletableFuture getLibraryPage(int limit); - CompletableFuture getLibraryPage(int limit, int offset); + // Get Library Page CompletableFuture getLibraryPage(String pageId, int limit); CompletableFuture getLibraryPage(String pageId, int limit, int offset); 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 f1897557..6b2e981b 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 @@ -64,74 +64,6 @@ public class LacertaLibraryImpl implements LacertaLibrary { return null; // TODO-rca: Implement } - // Internal - private CompletableFuture> getFolderEntitiesByPublicPath(String publicPath) { - return CompletableFuture.supplyAsync(() -> { - return database.folderDao().findByPublicPathWithLimit(publicPath, 10); // TODO-rca: ハードコーディングやめる - }); - } - - private CompletableFuture> getDocumentEntitiesByPublicPath(String publicPath) { - return CompletableFuture.supplyAsync(() -> { - return database.documentDao().findByPublicPathWithLimit(publicPath, 10); // TODO-rca: ハードコーディングやめる - }); - } - - @Override - public CompletableFuture getLibraryPage(int limit) { - return CompletableFuture.supplyAsync(() -> { - - // 5秒フリーズさせる - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - LibraryItemPage libraryItemPage = new LibraryItemPage(); - - List folderEntities = getFolderEntitiesByPublicPath("/").join(); - logger.debug("LacertaLibraryImpl", "folderEntities.size(): " + folderEntities.size()); - List documentEntities = getDocumentEntitiesByPublicPath("/").join(); - logger.debug("LacertaLibraryImpl", "documentEntities.size(): " + documentEntities.size()); - - ArrayList listItems = new ArrayList<>(); - for (FolderEntity folderEntity : folderEntities) { - logger.debug("LacertaLibraryImpl", "folderEntity.name: " + folderEntity.name); - ListItem listItem = new ListItem(); - listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER); - listItem.setTitle(folderEntity.name); - listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる - listItem.setItemId(folderEntity.id); - listItems.add(listItem); - } - for (DocumentEntity documentEntity : documentEntities) { - logger.debug("LacertaLibraryImpl", "documentEntity.title: " + documentEntity.title); - ListItem listItem = new ListItem(); - listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT); - listItem.setTitle(documentEntity.title); -// listItem.setDescription(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm").format(documentEntity.updatedAt.toInstant())); - listItem.setItemId(documentEntity.id); - listItems.add(listItem); - } - - libraryItemPage.setPageTitle("/"); - libraryItemPage.setPageId("root"); - libraryItemPage.setListItems(listItems); - - logger.debug("LacertaLibraryImpl", "libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); - - return libraryItemPage; - }); - } - - @Override - public CompletableFuture getLibraryPage(int limit, int offset) { - return CompletableFuture.supplyAsync(() -> { - return null; - }); - } - @Override public CompletableFuture getLibraryPage(String pageId, int limit) { return CompletableFuture.supplyAsync(() -> { From 7f71e818a84ec83704dd07198d5130725b533de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 20:10:04 +0900 Subject: [PATCH 30/49] fix --- .../nem/lacerta/data/impl/LacertaLibraryImpl.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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 6b2e981b..797306c1 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 @@ -20,6 +20,7 @@ import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.common.DateTypeConverter; import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.source.database.entity.FolderEntity; +import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; public class LacertaLibraryImpl implements LacertaLibrary { @@ -71,18 +72,13 @@ public class LacertaLibraryImpl implements LacertaLibrary { FolderEntity folderEntity = database.folderDao().findById(pageId); if (folderEntity == null) { + logger.warn("LacertaLibraryImpl", pageId + " is not found."); return null; } - PublicPath publicPath = new PublicPath().parse(folderEntity.publicPath); - - String resolvedPublicPath = publicPath.resolve(folderEntity.name).getStringPath(); - - logger.debug("LacertaLibraryImpl", "Resolved publicPath: " + resolvedPublicPath); - - List folderEntities = getFolderEntitiesByPublicPath(resolvedPublicPath).join(); + List folderEntities = database.folderDao().findByParentId(pageId); logger.debug("LacertaLibraryImpl", "folderEntities.size(): " + folderEntities.size()); - List documentEntities = getDocumentEntitiesByPublicPath(resolvedPublicPath).join(); + List documentEntities = database.documentDao().findByParentId(pageId); logger.debug("LacertaLibraryImpl", "documentEntities.size(): " + documentEntities.size()); ArrayList listItems = new ArrayList<>(); @@ -108,6 +104,7 @@ public class LacertaLibraryImpl implements LacertaLibrary { libraryItemPage.setPageTitle(folderEntity.name); libraryItemPage.setPageId(folderEntity.id); + libraryItemPage.setParentId(folderEntity.parentId); libraryItemPage.setListItems(listItems); logger.debug("LacertaLibraryImpl", "libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); From f7d07b0ec313af84a6208d3f5b9b0949678f4865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 20:21:01 +0900 Subject: [PATCH 31/49] =?UTF-8?q?=E3=83=91=E3=82=B9=E8=A7=A3=E6=B1=BA?= =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/data/impl/LacertaLibraryImpl.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) 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 797306c1..46b8dc23 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 @@ -4,6 +4,7 @@ import java.text.DateFormat; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -140,4 +141,55 @@ public class LacertaLibraryImpl implements LacertaLibrary { return folderEntity.id; }); } + + @Override + public CompletableFuture getPublicPath(String itemId, ListItemType itemType) { + return CompletableFuture.supplyAsync(() -> { + if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) { + DocumentEntity documentEntity = database.documentDao().findById(itemId); + if (documentEntity == null) { + return null; + } + return new PublicPath().resolve(documentEntity.publicPath); + } else if (itemType == ListItemType.ITEM_TYPE_FOLDER) { + FolderEntity folderEntity = database.folderDao().findById(itemId); + if (folderEntity == null) { + return null; + } + return new PublicPath().resolve(folderEntity.publicPath); + } else { + return null; + } + }); + } + + /** + * 再帰的にパスを解決する + * + * @param folderId + * @return + */ + private PublicPath recursiveResolve(String folderId) { + String current = folderId; + boolean continueFlag = true; + ArrayList folderNames = new ArrayList<>(); + while (continueFlag) { + FolderEntity folderEntity = database.folderDao().findById(current); + if (folderEntity == null) { // 存在しないフォルダIDが指定された場合 + continueFlag = false; + } else { + folderNames.add(folderEntity.name); + current = folderEntity.parentId; + if (current == null) { // ルートフォルダに到達した場合 + continueFlag = false; + } + } + } + + // フォルダ名を逆順にしてListに変換 + Collections.reverse(folderNames); + List folderNamesReversed = new ArrayList<>(folderNames); + + return new PublicPath(folderNamesReversed); + } } From da8d4fb4fcb1ca6c6405bee8a59191528e4c7c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 20:22:51 +0900 Subject: [PATCH 32/49] =?UTF-8?q?PublicPath=E3=82=92=E7=94=9F=E6=88=90?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E4=BD=9C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/data/LacertaLibrary.java | 4 ++++ .../one/nem/lacerta/data/impl/LacertaLibraryImpl.java | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) 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 eda15fce..1269d255 100644 --- a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java +++ b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java @@ -7,6 +7,7 @@ import one.nem.lacerta.model.ListItem; import one.nem.lacerta.model.ListItemType; import one.nem.lacerta.model.LibraryItemPage; +import one.nem.lacerta.model.PublicPath; import one.nem.lacerta.model.document.DocumentDetail; public interface LacertaLibrary { @@ -22,4 +23,7 @@ public interface LacertaLibrary { // Create Folder CompletableFuture createFolder(String path, String name); + // Get Public Path + CompletableFuture getPublicPath(String itemId, ListItemType itemType); + } 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 46b8dc23..16a9235c 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 @@ -148,16 +148,20 @@ public class LacertaLibraryImpl implements LacertaLibrary { if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) { DocumentEntity documentEntity = database.documentDao().findById(itemId); if (documentEntity == null) { + logger.warn("LacertaLibraryImpl", itemId + " is not found."); return null; } - return new PublicPath().resolve(documentEntity.publicPath); + PublicPath publicPath = recursiveResolve(documentEntity.parentId); + publicPath.resolve(documentEntity.title); + return publicPath; } else if (itemType == ListItemType.ITEM_TYPE_FOLDER) { FolderEntity folderEntity = database.folderDao().findById(itemId); if (folderEntity == null) { return null; } - return new PublicPath().resolve(folderEntity.publicPath); + return recursiveResolve(folderEntity.id); } else { + logger.warn("LacertaLibraryImpl", "Unknown ListItemType: " + itemType); return null; } }); From 68fb0b719b969b328024a1c882c92d9ffa903bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 20:23:36 +0900 Subject: [PATCH 33/49] =?UTF-8?q?CreateFolder=E6=94=B9=E4=BF=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/data/impl/LacertaLibraryImpl.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) 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 16a9235c..2403426e 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 @@ -124,19 +124,10 @@ public class LacertaLibraryImpl implements LacertaLibrary { @Override public CompletableFuture createFolder(String parentId, String name) { return CompletableFuture.supplyAsync(() -> { - - FolderEntity parentFolderEntity = database.folderDao().findById(parentId); - PublicPath publicPath; - if (parentFolderEntity == null) { - publicPath = new PublicPath().resolve("/"); - } else { - publicPath = new PublicPath().resolve(parentFolderEntity.publicPath); - } - FolderEntity folderEntity = new FolderEntity(); folderEntity.id = UUID.randomUUID().toString(); folderEntity.name = name; - folderEntity.publicPath = publicPath.getStringPath(); + folderEntity.parentId = parentId; database.folderDao().insert(folderEntity); return folderEntity.id; }); From 52f41881fd3310e836776862593fecd646346bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 20:48:47 +0900 Subject: [PATCH 34/49] Iroiro --- .../one/nem/lacerta/data/LacertaLibrary.java | 2 +- .../feature/library/LibraryPageFragment.java | 222 +++++++++--------- 2 files changed, 113 insertions(+), 111 deletions(-) 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 1269d255..c5957e8b 100644 --- a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java +++ b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java @@ -21,7 +21,7 @@ public interface LacertaLibrary { CompletableFuture getLibraryPage(String pageId, int limit, int offset); // Create Folder - CompletableFuture createFolder(String path, String name); + CompletableFuture createFolder(String parentId, String name); // Get Public Path CompletableFuture getPublicPath(String itemId, ListItemType itemType); diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 922076d8..4566b638 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -36,6 +36,7 @@ import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.data.Document; import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.FragmentNavigation; +import one.nem.lacerta.model.LibraryItemPage; import one.nem.lacerta.model.PublicPath; import one.nem.lacerta.utils.LacertaLogger; @@ -48,13 +49,15 @@ import one.nem.lacerta.utils.LacertaLogger; @AndroidEntryPoint public class LibraryPageFragment extends Fragment { - // Param - private String folderId; - private String title; - private String publicPath; - private String currentId; - private String parentId; - private PublicPath currentPublicPath; + // Variables + // このインスタンスで表示されているページ + LibraryItemPage libraryItemPage; + + // Arguments + String folderId; + String title; + String parentId; + @Inject LacertaLibrary lacertaLibrary; @@ -64,8 +67,6 @@ public class LibraryPageFragment extends Fragment { ListItemAdapter listItemAdapter; - int currentTotalItemCount = 0; - public LibraryPageFragment() { // Required empty public constructor } @@ -100,70 +101,6 @@ public class LibraryPageFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_library_top, container, false); - return view; - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view); - - this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() { - @Override - public void onFolderSelected(String folderId, String folderName) { - logger.debug("LibraryTopFragment", "Folder selected! folderId: " + folderId + ", folderName: " + folderName); - // 画面遷移 - Toast.makeText(getContext(), "Folder selected! folderId: " + folderId + ", folderName: " + folderName, Toast.LENGTH_SHORT).show(); - FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); - assert fragmentNavigation != null; - logger.debug("LibraryTopFragment", "publicPath: " + publicPath); - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, publicPath == null ? new PublicPath().parse("/").resolve(folderName).getStringPath() : new PublicPath().parse(publicPath).resolve(folderName).getStringPath())); - } - - @Override - public void onDocumentSelected(String documentId, String documentName) { - Toast.makeText(getContext(), "Document selected! documentId: " + documentId + ", documentName: " + documentName, Toast.LENGTH_SHORT).show(); - } - }); - recyclerView.setAdapter(listItemAdapter); - recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - - if (getArguments() != null) { - this.folderId = getArguments().getString("folderId"); - this.title = getArguments().getString("title"); - this.parentId = getArguments().getString("parentId"); - // Log - logger.debug("LibraryTopFragment", "args" - + ", folderId: " + this.folderId - + ", title: " + this.title - + ", parentId: " + this.parentId); - } - - if (this.folderId == null) { // Root - toolbarSetup(view.findViewById(R.id.library_toolbar), false, "ライブラリ", "Placeholder"); - lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> { - this.currentId = libraryItemPage.getPageId(); // Currentを保存 - logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); - listItemAdapter.setLibraryItemPage(libraryItemPage); - getActivity().runOnUiThread(() -> { - listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1); - }); - this.currentTotalItemCount = libraryItemPage.getListItems().size(); - }); - } else { // Root以外 - toolbarSetup(view.findViewById(R.id.library_toolbar), true, this.title, "Placeholder"); - lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> { - this.currentId = libraryItemPage.getPageId(); // Currentを保存 - logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); - listItemAdapter.setLibraryItemPage(libraryItemPage); - getActivity().runOnUiThread(() -> { - listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1); - }); - this.currentTotalItemCount = libraryItemPage.getListItems().size(); - }); - } - // Set status bar color AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout); @@ -182,15 +119,114 @@ public class LibraryPageFragment extends Fragment { } } }); - + return view; } + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + if (getArguments() != null) { + this.folderId = getArguments().getString("folderId"); + this.title = getArguments().getString("title"); + this.parentId = getArguments().getString("parentId"); + // Log + logger.debug("LibraryTopFragment", "Args: folderId: " + folderId + ", title: " + title + ", parentId: " + parentId); + } else { + logger.debug("LibraryTopFragment", "getArguments() is null(maybe root)"); + this.libraryItemPage = new LibraryItemPage(); + } + + // RecyclerView Setup + + RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view); + this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() { + @Override + public void onFolderSelected(String folderId, String folderName) { + logger.debug("LibraryTopFragment", "Folder selected! folderId: " + folderId + ", folderName: " + folderName); + // 画面遷移 + FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); + // folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親) + fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage.getPageId())); + } + + @Override + public void onDocumentSelected(String documentId, String documentName) { + Toast.makeText(getContext(), "Document selected! documentId: " + documentId + ", documentName: " + documentName, Toast.LENGTH_SHORT).show(); + } + }); + + recyclerView.setAdapter(listItemAdapter); + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + + // Get library page and update RecyclerView items + lacertaLibrary.getLibraryPage(this.libraryItemPage.getPageId(), 10).thenAccept(libraryItemPage -> { + this.libraryItemPage = libraryItemPage; + logger.debug("LibraryTopFragment", "Item selected! Total item page: " + this.libraryItemPage.getListItems().size()); + getActivity().runOnUiThread(() -> { // TODO-rca: 実行条件を考える? + listItemAdapter.notifyItemRangeRemoved(0, this.libraryItemPage.getListItems().size() - 1); + }); + listItemAdapter.setLibraryItemPage(this.libraryItemPage); + getActivity().runOnUiThread(() -> { + listItemAdapter.notifyItemRangeInserted(0, this.libraryItemPage.getListItems().size() - 1); + }); + }); + } + + /** + * Currentにフォルダを作成する + */ + private void createFolder(String pageId) { + // TODO-rca: デザインをMaterial Design 3に合わせたカスタムダイアログにする + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle("フォルダの作成"); + builder.setMessage("フォルダ名を入力してください"); + final android.widget.EditText input = new android.widget.EditText(getContext()); + input.setText("フォルダ名"); + builder.setView(input); + builder.setPositiveButton("作成", (dialog, which) -> { + lacertaLibrary.createFolder(pageId, input.getText().toString()).thenAccept(folderId -> { + // Refresh + updateItem(pageId); + }); + }); + builder.setNegativeButton("キャンセル", (dialog, which) -> { + dialog.cancel(); + }); + builder.show(); + } + + /** + * RecyclerViewのアイテムを更新する + */ + private void updateItem(String pageId) { + lacertaLibrary.getLibraryPage(pageId, 10).thenAccept(libraryItemPage -> { + this.libraryItemPage = libraryItemPage; + logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); + getActivity().runOnUiThread(() -> { + listItemAdapter.notifyItemRangeRemoved(0, libraryItemPage.getListItems().size() - 1); + }); + listItemAdapter.setLibraryItemPage(libraryItemPage); + getActivity().runOnUiThread(() -> { + listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1); + }); + }); + } + + /** + * ToolbarをInitする + * + * @param toolbar Toolbar + * @param showBackButton 戻るボタンを表示するか + * @param title タイトル + * @param subtitle サブタイトル + */ private void toolbarSetup(Toolbar toolbar, boolean showBackButton, String title, String subtitle) { getActivity().runOnUiThread(() -> { if (showBackButton) { toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); toolbar.setNavigationOnClickListener(v -> { - this.publicPath = new PublicPath().parse(this.publicPath).parent().getStringPath(); + this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join(); getParentFragmentManager().popBackStack(); }); } else { @@ -200,7 +236,7 @@ public class LibraryPageFragment extends Fragment { toolbar.inflateMenu(R.menu.dir_menu); toolbar.setOnMenuItemClickListener(item -> { if (item.getItemId() == R.id.menu_item_create_new_folder) { - createFolder(); + createFolder(this.folderId); return true; } else { return false; @@ -209,38 +245,4 @@ public class LibraryPageFragment extends Fragment { }); } - private void createFolder() { - // TODO-rca: デザインをMaterial Design 3に合わせたカスタムダイアログにする - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - builder.setTitle("フォルダの作成"); - builder.setMessage("フォルダ名を入力してください"); - final android.widget.EditText input = new android.widget.EditText(getContext()); - input.setText("フォルダ名"); - builder.setView(input); - builder.setPositiveButton("作成", (dialog, which) -> { - logger.debug("LibraryTopFragment", "Creating folder: Name: " + input.getText().toString() + ", publicPath: " + publicPath); - lacertaLibrary.createFolder("hoge", input.getText().toString()).thenAccept(folderId -> { - logger.debug("LibraryTopFragment", "folderId: " + folderId); - }); - // Refresh - updateItem(); - }); - builder.setNegativeButton("キャンセル", (dialog, which) -> { - dialog.cancel(); - }); - builder.show(); - } - private void updateItem() { - lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> { - logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); - getActivity().runOnUiThread(() -> { - listItemAdapter.notifyItemRangeRemoved(0, this.currentTotalItemCount - 1); - }); - listItemAdapter.setLibraryItemPage(libraryItemPage); - getActivity().runOnUiThread(() -> { - listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1); - }); - this.currentTotalItemCount = libraryItemPage.getListItems().size(); - }); - } } From 2a7e329ad7e08b90e3937268471adfafa992c93f Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 22 Jan 2024 23:20:39 +0900 Subject: [PATCH 35/49] =?UTF-8?q?parentId=E3=81=AB=E5=88=87=E3=82=8A?= =?UTF-8?q?=E6=9B=BF=E3=81=88=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/data/impl/DocumentImpl.java | 6 ++--- .../lacerta/model/document/DocumentMeta.java | 22 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java index 47f8e9a2..888a47f6 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java @@ -79,7 +79,7 @@ public class DocumentImpl implements Document { documentEntity.defaultBranch = meta.getDefaultBranch(); documentEntity.updatedAt = meta.getUpdatedAt(); documentEntity.createdAt = meta.getCreatedAt(); - documentEntity.publicPath = meta.getPath().getStringPath(); + documentEntity.parentId = meta.getParentId(); documentEntity.tagIds = meta.getTagIds(); database.documentDao().insert(documentEntity); @@ -104,7 +104,7 @@ public class DocumentImpl implements Document { meta.setDefaultBranch("master"); meta.setUpdatedAt(new Date()); meta.setCreatedAt(new Date()); - meta.setPath(new PublicPath().getRoot()); // TODO-rca: 2回インスタンスを生成していて無駄なのでなんとかする + meta.setParentId(null); meta.setTags(new ArrayList<>()); return createDocument(meta); } @@ -138,7 +138,7 @@ public class DocumentImpl implements Document { meta.setDefaultBranch(documentEntity.defaultBranch); meta.setUpdatedAt(documentEntity.updatedAt); meta.setCreatedAt(documentEntity.createdAt); - meta.setPath(new PublicPath().resolve(documentEntity.publicPath)); + meta.setParentId(documentEntity.parentId); meta.setTags(new ArrayList<>()); // TODO-rca: タグを取得する DocumentDetail detail = new DocumentDetail(); diff --git a/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java b/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java index 2fc0f4bc..1093188e 100644 --- a/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java +++ b/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java @@ -37,7 +37,7 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応 */ List tags; - PublicPath path; + String parentId; String author; @@ -54,7 +54,7 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応 this.tags = new ArrayList<>(); this.author = ""; // TODO-rca: 作者のデフォルト値を設定できるようにする this.defaultBranch = "main"; // TODO-rca: デフォルトブランチのデフォルト値を設定できるようにする - this.path = new PublicPath().getRoot(); + this.parentId = null; this.updatedAt = new Date(); this.createdAt = new Date(); } @@ -85,13 +85,13 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応 this.defaultBranch = defaultBranch; } - public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, List tags, PublicPath path, String author, String defaultBranch) { + public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, List tags, String parentId, String author, String defaultBranch) { this.id = id; this.title = title; this.updatedAt = updatedAt; this.createdAt = createdAt; this.tags = tags; - this.path = path; + this.parentId = parentId; this.author = author; this.defaultBranch = defaultBranch; } @@ -145,10 +145,10 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応 } /** - * PublicPathを取得する + * ドキュメントの親フォルダのID(String)を取得する */ - public PublicPath getPath() { - return path; + public String getParentId() { + return parentId; } /** @@ -208,11 +208,11 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応 } /** - * PublicPathを設定する - * @param path PublicPath + * ドキュメントの親フォルダのID(String)を設定する + * @param parentId ドキュメントの親フォルダのID */ - public void setPath(PublicPath path) { - this.path = path; + public void setParentId(String parentId) { + this.parentId = parentId; } /** From c7f2a3eebee793b2258152f8739abbb99e5e7044 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 22 Jan 2024 23:28:15 +0900 Subject: [PATCH 36/49] =?UTF-8?q?Dao=E3=82=AF=E3=82=A8=E3=83=AA=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/source/database/dao/DocumentDao.java | 3 +++ .../java/one/nem/lacerta/source/database/dao/FolderDao.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java index f3a3fd2b..21e1cc2e 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java @@ -32,6 +32,9 @@ public interface DocumentDao { @Query("SELECT * FROM Document WHERE parent_id = :parentId") List findByParentId(String parentId); + @Query("SELECT * FROM Document WHERE parent_id IS NULL") + List findRootDocuments(); + @Query("SELECT * FROM Document ORDER BY created_at DESC LIMIT :limit") List getRecentDocument(int limit); diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java index af5e92d4..404b53f8 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java @@ -18,6 +18,9 @@ public interface FolderDao { @Query("SELECT * FROM Folder WHERE parent_id = :parentId") List findByParentId(String parentId); + @Query("SELECT * FROM Folder WHERE parent_id IS NULL") + List findRootFolders(); + @Insert void insert(FolderEntity folderEntity); From de30eb241c49e3626f33db4f2dba4df736fd71a1 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 22 Jan 2024 23:29:49 +0900 Subject: [PATCH 37/49] =?UTF-8?q?=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=82=92=E6=AD=A3=E5=B8=B8=E3=81=AB=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/data/impl/LacertaLibraryImpl.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) 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 2403426e..2d5d1f93 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 @@ -71,16 +71,29 @@ public class LacertaLibraryImpl implements LacertaLibrary { return CompletableFuture.supplyAsync(() -> { LibraryItemPage libraryItemPage = new LibraryItemPage(); - FolderEntity folderEntity = database.folderDao().findById(pageId); - if (folderEntity == null) { - logger.warn("LacertaLibraryImpl", pageId + " is not found."); - return null; - } + List folderEntities; + List documentEntities; - List folderEntities = database.folderDao().findByParentId(pageId); - logger.debug("LacertaLibraryImpl", "folderEntities.size(): " + folderEntities.size()); - List documentEntities = database.documentDao().findByParentId(pageId); - logger.debug("LacertaLibraryImpl", "documentEntities.size(): " + documentEntities.size()); + if (pageId == null) { // When root folder + libraryItemPage.setPageTitle("ライブラリ"); + libraryItemPage.setPageId(null); + libraryItemPage.setParentId(null); + + folderEntities = database.folderDao().findRootFolders(); + documentEntities = database.documentDao().findRootDocuments(); + } else { + FolderEntity folderEntity = database.folderDao().findById(pageId); + if (folderEntity == null) { + logger.warn("LacertaLibraryImpl", pageId + " is not found."); + return null; + } + libraryItemPage.setPageTitle(folderEntity.name); + libraryItemPage.setPageId(folderEntity.id); + libraryItemPage.setParentId(folderEntity.parentId); + + folderEntities = database.folderDao().findByParentId(pageId); + documentEntities = database.documentDao().findByParentId(pageId); + } ArrayList listItems = new ArrayList<>(); for (FolderEntity childFolderEntity : folderEntities) { @@ -103,9 +116,6 @@ public class LacertaLibraryImpl implements LacertaLibrary { listItems.add(listItem); } - libraryItemPage.setPageTitle(folderEntity.name); - libraryItemPage.setPageId(folderEntity.id); - libraryItemPage.setParentId(folderEntity.parentId); libraryItemPage.setListItems(listItems); logger.debug("LacertaLibraryImpl", "libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); From 004bedb45f4c7795bda1ae6949ebaacf7757f1df Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 22 Jan 2024 23:35:30 +0900 Subject: [PATCH 38/49] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80?= =?UTF-8?q?=E3=82=92=E6=AD=A3=E5=B8=B8=E3=81=AB=E5=8F=96=E5=BE=97=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB,=20=E4=BD=9C?= =?UTF-8?q?=E6=88=90=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 --- .../nem/lacerta/feature/library/LibraryPageFragment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 4566b638..2317d84b 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -137,6 +137,9 @@ public class LibraryPageFragment extends Fragment { this.libraryItemPage = new LibraryItemPage(); } + // Toolbar Setup + toolbarSetup(view.findViewById(R.id.library_toolbar), this.folderId != null, this.title != null ? this.title : "ライブラリ"); + // RecyclerView Setup RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view); @@ -219,9 +222,8 @@ public class LibraryPageFragment extends Fragment { * @param toolbar Toolbar * @param showBackButton 戻るボタンを表示するか * @param title タイトル - * @param subtitle サブタイトル */ - private void toolbarSetup(Toolbar toolbar, boolean showBackButton, String title, String subtitle) { + private void toolbarSetup(Toolbar toolbar, boolean showBackButton, String title) { getActivity().runOnUiThread(() -> { if (showBackButton) { toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); From 3178e9233b1428cd389ab6f017dcf9b4bc463530 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 22 Jan 2024 23:46:23 +0900 Subject: [PATCH 39/49] iroiro --- .../one/nem/lacerta/feature/library/LibraryPageFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 2317d84b..b968693d 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -150,7 +150,7 @@ public class LibraryPageFragment extends Fragment { // 画面遷移 FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); // folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親) - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage.getPageId())); + fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage != null ? libraryItemPage.getParentId() : null)); } @Override @@ -163,7 +163,7 @@ public class LibraryPageFragment extends Fragment { recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // Get library page and update RecyclerView items - lacertaLibrary.getLibraryPage(this.libraryItemPage.getPageId(), 10).thenAccept(libraryItemPage -> { + lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> { this.libraryItemPage = libraryItemPage; logger.debug("LibraryTopFragment", "Item selected! Total item page: " + this.libraryItemPage.getListItems().size()); getActivity().runOnUiThread(() -> { // TODO-rca: 実行条件を考える? From d5df291c81d2ccf58e176fe7b21ee018124a45fa Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 22 Jan 2024 23:47:46 +0900 Subject: [PATCH 40/49] =?UTF-8?q?=E3=83=90=E3=83=83=E3=82=AF=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E3=83=83=E3=82=AF=E3=81=AB=E7=A9=8D=E3=81=BE=E3=81=9A?= =?UTF-8?q?=E3=81=AB=E3=83=8A=E3=83=93=E3=82=B2=E3=83=BC=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=81=99=E3=82=8B=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/MainActivity.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index 0ef81860..e97093e1 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -96,4 +96,18 @@ public class MainActivity extends AppCompatActivity implements FragmentNavigatio .addToBackStack(null) .commit(); } + + @Override + public void navigateToFragment(Fragment fragment, boolean addToBackStack) { + if (addToBackStack) { + getSupportFragmentManager().beginTransaction() + .replace(R.id.nav_host_fragment, fragment) + .addToBackStack(null) + .commit(); + } else { + getSupportFragmentManager().beginTransaction() + .replace(R.id.nav_host_fragment, fragment) + .commit(); + } + } } From 37a18704e342c7836de4ac8584f8c78d7f02550e Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 22 Jan 2024 23:48:09 +0900 Subject: [PATCH 41/49] =?UTF-8?q?=E3=83=90=E3=83=83=E3=82=AF=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E3=83=83=E3=82=AF=E3=81=AB=E7=A9=8D=E3=81=BE=E3=81=9A?= =?UTF-8?q?=E3=81=AB=E3=83=8A=E3=83=93=E3=82=B2=E3=83=BC=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=81=99=E3=82=8B=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/one/nem/lacerta/model/FragmentNavigation.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/model/src/main/java/one/nem/lacerta/model/FragmentNavigation.java b/model/src/main/java/one/nem/lacerta/model/FragmentNavigation.java index f7cddea6..0eb3487d 100644 --- a/model/src/main/java/one/nem/lacerta/model/FragmentNavigation.java +++ b/model/src/main/java/one/nem/lacerta/model/FragmentNavigation.java @@ -4,4 +4,6 @@ import androidx.fragment.app.Fragment; public interface FragmentNavigation { void navigateToFragment(Fragment fragment); + + void navigateToFragment(Fragment fragment, boolean addToBackStack); } From 1105c17fcaa20dab752f412cf0839178f547b95e Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 00:36:26 +0900 Subject: [PATCH 42/49] WIp --- .../java/one/nem/lacerta/MainActivity.java | 44 ++++++++++++++++ .../feature/library/LibraryPageFragment.java | 51 ++++++++++++++++--- .../nem/lacerta/model/FragmentNavigation.java | 4 ++ 3 files changed, 91 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index e97093e1..725c1063 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -5,6 +5,7 @@ import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; import androidx.navigation.NavController; import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.ui.NavigationUI; @@ -110,4 +111,47 @@ public class MainActivity extends AppCompatActivity implements FragmentNavigatio .commit(); } } + + @Override + public void navigateToFragment(Fragment fragment, boolean addToBackStack, boolean clearBackStack) { + if (clearBackStack) { + getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); + } + if (addToBackStack) { + getSupportFragmentManager().beginTransaction() + .replace(R.id.nav_host_fragment, fragment) + .addToBackStack(null) + .commit(); + } else { + getSupportFragmentManager().beginTransaction() + .replace(R.id.nav_host_fragment, fragment) + .commit(); + } + } + + public void navigateToFragmentAlternate(Fragment fragment, boolean addToBackStack) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + + // get the current fragment + Fragment currentFragment = getSupportFragmentManager().getPrimaryNavigationFragment(); + + // hide the current fragment + if (currentFragment != null) { + transaction.hide(currentFragment); + } + + // Add the new fragment + transaction.add(R.id.nav_host_fragment, fragment); + + // Add the transaction to the back stack if needed + if (addToBackStack) { + transaction.addToBackStack(null); + } + + // Commit the transaction + transaction.commit(); + + // Update the primary navigation fragment + getSupportFragmentManager().beginTransaction().setPrimaryNavigationFragment(fragment).commit(); + } } diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index b968693d..905fafa8 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -81,6 +81,16 @@ public class LibraryPageFragment extends Fragment { return fragment; } + public static LibraryPageFragment newInstance(String folderId) { // Back action + LibraryPageFragment fragment = new LibraryPageFragment(); + Bundle args = new Bundle(); + args.putString("folderId", folderId); + args.putString("title", null); + args.putString("publicPath", null); + fragment.setArguments(args); + return fragment; + } + public static LibraryPageFragment newInstance() { LibraryPageFragment fragment = new LibraryPageFragment(); Bundle args = new Bundle(); @@ -127,11 +137,13 @@ public class LibraryPageFragment extends Fragment { super.onViewCreated(view, savedInstanceState); if (getArguments() != null) { - this.folderId = getArguments().getString("folderId"); - this.title = getArguments().getString("title"); - this.parentId = getArguments().getString("parentId"); - // Log - logger.debug("LibraryTopFragment", "Args: folderId: " + folderId + ", title: " + title + ", parentId: " + parentId); + this.folderId = getArguments().getString("folderId"); // Required + if (getArguments().getString("title") == null && getArguments().getString("publicPath") == null) { + this.libraryItemPage = new LibraryItemPage(); + } else { + this.title = getArguments().getString("title"); + this.parentId = getArguments().getString("publicPath"); + } } else { logger.debug("LibraryTopFragment", "getArguments() is null(maybe root)"); this.libraryItemPage = new LibraryItemPage(); @@ -150,7 +162,7 @@ public class LibraryPageFragment extends Fragment { // 画面遷移 FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); // folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親) - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage != null ? libraryItemPage.getParentId() : null)); + fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage != null ? libraryItemPage.getParentId() : null), false); } @Override @@ -165,6 +177,16 @@ public class LibraryPageFragment extends Fragment { // Get library page and update RecyclerView items lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> { this.libraryItemPage = libraryItemPage; + + if (this.parentId == null) { + this.parentId = libraryItemPage.getParentId(); + } + if (this.title == null) { + this.title = libraryItemPage.getPageTitle(); + // Toolbar init again + toolbarSetup(view.findViewById(R.id.library_toolbar), this.folderId != null, this.title != null ? this.title : "ライブラリ"); + } + logger.debug("LibraryTopFragment", "Item selected! Total item page: " + this.libraryItemPage.getListItems().size()); getActivity().runOnUiThread(() -> { // TODO-rca: 実行条件を考える? listItemAdapter.notifyItemRangeRemoved(0, this.libraryItemPage.getListItems().size() - 1); @@ -228,8 +250,8 @@ public class LibraryPageFragment extends Fragment { if (showBackButton) { toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); toolbar.setNavigationOnClickListener(v -> { - this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join(); - getParentFragmentManager().popBackStack(); + //this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join(); + processBack(); }); } else { toolbar.setNavigationIcon(null); @@ -247,4 +269,17 @@ public class LibraryPageFragment extends Fragment { }); } + /** + * Backボタンが押された時の処理 + */ + private void processBack() { + if (this.parentId != null) { + FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); + fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(this.parentId)); + } else { // Root + FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); + fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance()); + } + } + } diff --git a/model/src/main/java/one/nem/lacerta/model/FragmentNavigation.java b/model/src/main/java/one/nem/lacerta/model/FragmentNavigation.java index 0eb3487d..d9e4326c 100644 --- a/model/src/main/java/one/nem/lacerta/model/FragmentNavigation.java +++ b/model/src/main/java/one/nem/lacerta/model/FragmentNavigation.java @@ -6,4 +6,8 @@ public interface FragmentNavigation { void navigateToFragment(Fragment fragment); void navigateToFragment(Fragment fragment, boolean addToBackStack); + + void navigateToFragment(Fragment fragment, boolean addToBackStack, boolean clearBackStack); + + void navigateToFragmentAlternate(Fragment fragment, boolean addToBackStack); } From 14ff9abab9ee434ead52126dcf9cfb4c50ecef0b Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 00:37:23 +0900 Subject: [PATCH 43/49] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=86=E3=83=8A?= =?UTF-8?q?=E3=83=95=E3=83=A9=E3=82=B0=E3=83=A1=E3=83=B3=E3=83=88=E4=BD=9C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/LibraryContainerFragment.java | 64 +++++++++++++++++++ .../res/layout/fragment_library_container.xml | 14 ++++ 2 files changed, 78 insertions(+) create mode 100644 feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java create mode 100644 feature/library/src/main/res/layout/fragment_library_container.xml diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java new file mode 100644 index 00000000..67db747c --- /dev/null +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java @@ -0,0 +1,64 @@ +package one.nem.lacerta.feature.library; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * A simple {@link Fragment} subclass. + * Use the {@link LibraryContainerFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class LibraryContainerFragment extends Fragment { + + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; + + public LibraryContainerFragment() { + // Required empty public constructor + } + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param param1 Parameter 1. + * @param param2 Parameter 2. + * @return A new instance of fragment LibraryContainerFragment. + */ + // TODO: Rename and change types and number of parameters + public static LibraryContainerFragment newInstance(String param1, String param2) { + LibraryContainerFragment fragment = new LibraryContainerFragment(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_library_container, container, false); + } +} \ No newline at end of file diff --git a/feature/library/src/main/res/layout/fragment_library_container.xml b/feature/library/src/main/res/layout/fragment_library_container.xml new file mode 100644 index 00000000..5623a029 --- /dev/null +++ b/feature/library/src/main/res/layout/fragment_library_container.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file From 4714e3d8cbe79e011eb58992abe8c4fddd1e845c Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 00:38:17 +0900 Subject: [PATCH 44/49] =?UTF-8?q?=E5=BC=95=E6=95=B0=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=81=AA=E3=81=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/LibraryContainerFragment.java | 26 +------------------ .../res/layout/fragment_library_container.xml | 11 ++++---- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java index 67db747c..30b76002 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java @@ -15,33 +15,13 @@ import android.view.ViewGroup; */ public class LibraryContainerFragment extends Fragment { - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "param1"; - private static final String ARG_PARAM2 = "param2"; - - // TODO: Rename and change types of parameters - private String mParam1; - private String mParam2; - public LibraryContainerFragment() { // Required empty public constructor } - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment LibraryContainerFragment. - */ - // TODO: Rename and change types and number of parameters - public static LibraryContainerFragment newInstance(String param1, String param2) { + public static LibraryContainerFragment newInstance() { LibraryContainerFragment fragment = new LibraryContainerFragment(); Bundle args = new Bundle(); - args.putString(ARG_PARAM1, param1); - args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } @@ -49,10 +29,6 @@ public class LibraryContainerFragment extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - } } @Override diff --git a/feature/library/src/main/res/layout/fragment_library_container.xml b/feature/library/src/main/res/layout/fragment_library_container.xml index 5623a029..5227d789 100644 --- a/feature/library/src/main/res/layout/fragment_library_container.xml +++ b/feature/library/src/main/res/layout/fragment_library_container.xml @@ -5,10 +5,9 @@ android:layout_height="match_parent" tools:context=".LibraryContainerFragment"> - - - + \ No newline at end of file From 113a2fd3d2a09084711fe00a4112744faa6febb5 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 00:45:02 +0900 Subject: [PATCH 45/49] WIP --- .../library/LibraryContainerFragment.java | 34 ++++++++++++++++++- .../navigation/feature_library_navigation.xml | 10 +++--- .../library/src/main/res/values/strings.xml | 2 ++ .../one/nem/lacerta/utils/FeatureSwitch.java | 2 +- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java index 30b76002..1aca7af7 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java @@ -3,17 +3,22 @@ package one.nem.lacerta.feature.library; import android.os.Bundle; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentContainerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import one.nem.lacerta.model.FragmentNavigation; + /** * A simple {@link Fragment} subclass. * Use the {@link LibraryContainerFragment#newInstance} factory method to * create an instance of this fragment. */ -public class LibraryContainerFragment extends Fragment { +public class LibraryContainerFragment extends Fragment implements FragmentNavigation { + + FragmentContainerView fragmentContainerView; public LibraryContainerFragment() { // Required empty public constructor @@ -37,4 +42,31 @@ public class LibraryContainerFragment extends Fragment { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_library_container, container, false); } + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + fragmentContainerView = view.findViewById(R.id.fragmentContainerView); + } + + @Override + public void navigateToFragment(Fragment fragment) { + this.navigateToFragment(fragment, true); + } + + @Override + public void navigateToFragment(Fragment fragment, boolean addToBackStack) { + this.navigateToFragment(fragment, addToBackStack, false); + } + + @Override + public void navigateToFragment(Fragment fragment, boolean addToBackStack, boolean clearBackStack) { + if (fragmentContainerView != null) { + } + } + + @Override + public void navigateToFragmentAlternate(Fragment fragment, boolean addToBackStack) { + + } } \ No newline at end of file diff --git a/feature/library/src/main/res/navigation/feature_library_navigation.xml b/feature/library/src/main/res/navigation/feature_library_navigation.xml index 136b7b98..6439368e 100644 --- a/feature/library/src/main/res/navigation/feature_library_navigation.xml +++ b/feature/library/src/main/res/navigation/feature_library_navigation.xml @@ -3,10 +3,10 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/feature_library_navigation" - app:startDestination="@id/feature_library_top_fragment"> + app:startDestination="@id/libraryContainerFragment"> + android:id="@+id/libraryContainerFragment" + android:name="one.nem.lacerta.feature.library.LibraryContainerFragment" + android:label="fragment_library_container" + tools:layout="@layout/fragment_library_container" /> \ No newline at end of file diff --git a/feature/library/src/main/res/values/strings.xml b/feature/library/src/main/res/values/strings.xml index 1049ca2d..b3506433 100644 --- a/feature/library/src/main/res/values/strings.xml +++ b/feature/library/src/main/res/values/strings.xml @@ -1,3 +1,5 @@ Library + + Hello blank fragment \ No newline at end of file diff --git a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java index 5d8dbc57..5a1d18c1 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java +++ b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java @@ -8,7 +8,7 @@ public class FeatureSwitch { public static class FeatureMaster { public static boolean enableSearch = false; - public static boolean enableDebugMenu = false; + public static boolean enableDebugMenu = true; } public static class Setting { From d8d8a5932bf4f80f350f021c517fdd4c1b36e13b Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 00:45:14 +0900 Subject: [PATCH 46/49] Revert "WIP" This reverts commit 113a2fd3d2a09084711fe00a4112744faa6febb5. --- .../library/LibraryContainerFragment.java | 34 +------------------ .../navigation/feature_library_navigation.xml | 10 +++--- .../library/src/main/res/values/strings.xml | 2 -- .../one/nem/lacerta/utils/FeatureSwitch.java | 2 +- 4 files changed, 7 insertions(+), 41 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java index 1aca7af7..30b76002 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java @@ -3,22 +3,17 @@ package one.nem.lacerta.feature.library; import android.os.Bundle; import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentContainerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import one.nem.lacerta.model.FragmentNavigation; - /** * A simple {@link Fragment} subclass. * Use the {@link LibraryContainerFragment#newInstance} factory method to * create an instance of this fragment. */ -public class LibraryContainerFragment extends Fragment implements FragmentNavigation { - - FragmentContainerView fragmentContainerView; +public class LibraryContainerFragment extends Fragment { public LibraryContainerFragment() { // Required empty public constructor @@ -42,31 +37,4 @@ public class LibraryContainerFragment extends Fragment implements FragmentNaviga // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_library_container, container, false); } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - fragmentContainerView = view.findViewById(R.id.fragmentContainerView); - } - - @Override - public void navigateToFragment(Fragment fragment) { - this.navigateToFragment(fragment, true); - } - - @Override - public void navigateToFragment(Fragment fragment, boolean addToBackStack) { - this.navigateToFragment(fragment, addToBackStack, false); - } - - @Override - public void navigateToFragment(Fragment fragment, boolean addToBackStack, boolean clearBackStack) { - if (fragmentContainerView != null) { - } - } - - @Override - public void navigateToFragmentAlternate(Fragment fragment, boolean addToBackStack) { - - } } \ No newline at end of file diff --git a/feature/library/src/main/res/navigation/feature_library_navigation.xml b/feature/library/src/main/res/navigation/feature_library_navigation.xml index 6439368e..136b7b98 100644 --- a/feature/library/src/main/res/navigation/feature_library_navigation.xml +++ b/feature/library/src/main/res/navigation/feature_library_navigation.xml @@ -3,10 +3,10 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/feature_library_navigation" - app:startDestination="@id/libraryContainerFragment"> + app:startDestination="@id/feature_library_top_fragment"> + android:id="@+id/feature_library_top_fragment" + android:name="one.nem.lacerta.feature.library.LibraryPageFragment" + android:label="fragment_library_top" + tools:layout="@layout/fragment_library_top" /> \ No newline at end of file diff --git a/feature/library/src/main/res/values/strings.xml b/feature/library/src/main/res/values/strings.xml index b3506433..1049ca2d 100644 --- a/feature/library/src/main/res/values/strings.xml +++ b/feature/library/src/main/res/values/strings.xml @@ -1,5 +1,3 @@ Library - - Hello blank fragment \ No newline at end of file diff --git a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java index 5a1d18c1..5d8dbc57 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java +++ b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java @@ -8,7 +8,7 @@ public class FeatureSwitch { public static class FeatureMaster { public static boolean enableSearch = false; - public static boolean enableDebugMenu = true; + public static boolean enableDebugMenu = false; } public static class Setting { From e104b3d8ff2574303d2367a75e933092216f4889 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 00:45:15 +0900 Subject: [PATCH 47/49] =?UTF-8?q?Revert=20"=E5=BC=95=E6=95=B0=E5=89=8A?= =?UTF-8?q?=E9=99=A4=E3=81=AA=E3=81=A9"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4714e3d8cbe79e011eb58992abe8c4fddd1e845c. --- .../library/LibraryContainerFragment.java | 26 ++++++++++++++++++- .../res/layout/fragment_library_container.xml | 11 ++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java index 30b76002..67db747c 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java @@ -15,13 +15,33 @@ import android.view.ViewGroup; */ public class LibraryContainerFragment extends Fragment { + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; + public LibraryContainerFragment() { // Required empty public constructor } - public static LibraryContainerFragment newInstance() { + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param param1 Parameter 1. + * @param param2 Parameter 2. + * @return A new instance of fragment LibraryContainerFragment. + */ + // TODO: Rename and change types and number of parameters + public static LibraryContainerFragment newInstance(String param1, String param2) { LibraryContainerFragment fragment = new LibraryContainerFragment(); Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } @@ -29,6 +49,10 @@ public class LibraryContainerFragment extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } } @Override diff --git a/feature/library/src/main/res/layout/fragment_library_container.xml b/feature/library/src/main/res/layout/fragment_library_container.xml index 5227d789..5623a029 100644 --- a/feature/library/src/main/res/layout/fragment_library_container.xml +++ b/feature/library/src/main/res/layout/fragment_library_container.xml @@ -5,9 +5,10 @@ android:layout_height="match_parent" tools:context=".LibraryContainerFragment"> - + + + \ No newline at end of file From 5fafbec247bade96062c402e49bc9f08c943d77c Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 00:45:15 +0900 Subject: [PATCH 48/49] =?UTF-8?q?Revert=20"=E3=82=B3=E3=83=B3=E3=83=86?= =?UTF-8?q?=E3=83=8A=E3=83=95=E3=83=A9=E3=82=B0=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E4=BD=9C=E6=88=90"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 14ff9abab9ee434ead52126dcf9cfb4c50ecef0b. --- .../library/LibraryContainerFragment.java | 64 ------------------- .../res/layout/fragment_library_container.xml | 14 ---- 2 files changed, 78 deletions(-) delete mode 100644 feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java delete mode 100644 feature/library/src/main/res/layout/fragment_library_container.xml diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java deleted file mode 100644 index 67db747c..00000000 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryContainerFragment.java +++ /dev/null @@ -1,64 +0,0 @@ -package one.nem.lacerta.feature.library; - -import android.os.Bundle; - -import androidx.fragment.app.Fragment; - -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -/** - * A simple {@link Fragment} subclass. - * Use the {@link LibraryContainerFragment#newInstance} factory method to - * create an instance of this fragment. - */ -public class LibraryContainerFragment extends Fragment { - - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "param1"; - private static final String ARG_PARAM2 = "param2"; - - // TODO: Rename and change types of parameters - private String mParam1; - private String mParam2; - - public LibraryContainerFragment() { - // Required empty public constructor - } - - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment LibraryContainerFragment. - */ - // TODO: Rename and change types and number of parameters - public static LibraryContainerFragment newInstance(String param1, String param2) { - LibraryContainerFragment fragment = new LibraryContainerFragment(); - Bundle args = new Bundle(); - args.putString(ARG_PARAM1, param1); - args.putString(ARG_PARAM2, param2); - fragment.setArguments(args); - return fragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_library_container, container, false); - } -} \ No newline at end of file diff --git a/feature/library/src/main/res/layout/fragment_library_container.xml b/feature/library/src/main/res/layout/fragment_library_container.xml deleted file mode 100644 index 5623a029..00000000 --- a/feature/library/src/main/res/layout/fragment_library_container.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - \ No newline at end of file From 67de02b5028a3bd97912d6aa2d76b3040a2e3901 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 00:56:31 +0900 Subject: [PATCH 49/49] =?UTF-8?q?=E7=94=BB=E9=9D=A2=E6=8E=A8=E7=A7=BB?= =?UTF-8?q?=E3=81=A7=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E6=A6=82=E3=81=AD=E8=A7=A3=E6=B6=88=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/library/LibraryPageFragment.java | 36 +++++++++---------- .../navigation/feature_library_navigation.xml | 12 ++++++- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index 905fafa8..876d62e6 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -8,6 +8,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; +import androidx.navigation.Navigation; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -29,6 +30,7 @@ import org.w3c.dom.Text; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import javax.inject.Inject; @@ -159,10 +161,19 @@ public class LibraryPageFragment extends Fragment { @Override public void onFolderSelected(String folderId, String folderName) { logger.debug("LibraryTopFragment", "Folder selected! folderId: " + folderId + ", folderName: " + folderName); - // 画面遷移 - FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); - // folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親) - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage != null ? libraryItemPage.getParentId() : null), false); +// // 画面遷移 +// FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); +// // folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親) +// fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage != null ? libraryItemPage.getParentId() : null), false); + Bundle bundle = new Bundle(); + bundle.putString("folderId", folderId); + bundle.putString("title", folderName); + bundle.putString("publicPath", libraryItemPage != null ? libraryItemPage.getParentId() : null); + try { + Navigation.findNavController(requireView()).navigate(R.id.action_feature_library_top_fragment_self, bundle); + } catch (IllegalStateException e) { + logger.error("LibraryTopFragment", "IllegalStateException: " + e.getMessage()); + } } @Override @@ -251,7 +262,8 @@ public class LibraryPageFragment extends Fragment { toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); toolbar.setNavigationOnClickListener(v -> { //this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join(); - processBack(); + // Back + Navigation.findNavController(requireView()).popBackStack(); }); } else { toolbar.setNavigationIcon(null); @@ -268,18 +280,4 @@ public class LibraryPageFragment extends Fragment { }); }); } - - /** - * Backボタンが押された時の処理 - */ - private void processBack() { - if (this.parentId != null) { - FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(this.parentId)); - } else { // Root - FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance()); - } - } - } diff --git a/feature/library/src/main/res/navigation/feature_library_navigation.xml b/feature/library/src/main/res/navigation/feature_library_navigation.xml index 136b7b98..3a5dcd14 100644 --- a/feature/library/src/main/res/navigation/feature_library_navigation.xml +++ b/feature/library/src/main/res/navigation/feature_library_navigation.xml @@ -8,5 +8,15 @@ android:id="@+id/feature_library_top_fragment" android:name="one.nem.lacerta.feature.library.LibraryPageFragment" android:label="fragment_library_top" - tools:layout="@layout/fragment_library_top" /> + tools:layout="@layout/fragment_library_top" > + + \ No newline at end of file