From dbef7b45d1648060776283a3b99bfd189c0803a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 18:16:00 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AE?= =?UTF-8?q?=E3=83=91=E3=82=B9=E3=82=92=E3=82=B5=E3=83=96=E3=82=BF=E3=82=A4?= =?UTF-8?q?=E3=83=88=E3=83=AB=E3=81=A8=E3=81=97=E3=81=A6=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerListFragment.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java index 7a35379a..51e94931 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java @@ -22,6 +22,8 @@ import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.component.common.LacertaSelectDirDialog; import one.nem.lacerta.component.common.LacertaSelectDirDialogListener; import one.nem.lacerta.data.Document; +import one.nem.lacerta.data.LacertaLibrary; +import one.nem.lacerta.model.ListItemType; import one.nem.lacerta.model.document.page.Page; import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; @@ -39,6 +41,9 @@ public class ViewerListFragment extends Fragment { @Inject Document document; + @Inject + LacertaLibrary lacertaLibrary; + @Inject LacertaLogger logger; @@ -92,7 +97,7 @@ public class ViewerListFragment extends Fragment { // Toolbar Toolbar toolbar = view.findViewById(R.id.toolbar); - toolbarSetup(toolbar, true, this.documentName == null ? "Document" : this.documentName); + toolbarSetup(toolbar, true, this.documentName == null ? "Document" : this.documentName, null); RecyclerView recyclerView = view.findViewById(R.id.body_recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); @@ -112,6 +117,8 @@ public class ViewerListFragment extends Fragment { viewerBodyAdapter.notifyItemRangeChanged(0, pages.size()); if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.GONE); }); + }).thenCompose(aVoid -> lacertaLibrary.getPublicPath(documentId, ListItemType.ITEM_TYPE_DOCUMENT)).thenAccept(publicPath -> { + updateToolbarSubtitle(toolbar, "/" + publicPath.parent().getStringPath()); }); } else { logger.debug(TAG, "revisionId: " + revisionId); @@ -127,12 +134,24 @@ public class ViewerListFragment extends Fragment { if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.GONE); }); }); + }).thenCompose(aVoid -> lacertaLibrary.getPublicPath(documentId, ListItemType.ITEM_TYPE_DOCUMENT)).thenAccept(publicPath -> { + updateToolbarSubtitle(toolbar, "/" + publicPath.parent().getStringPath()); // TODO-rca: リビジョンの場合はリビジョン名を表示する? }); } return view; } + /** + * Toolbarのサブタイトルを更新 + * @param subtitle サブタイトル + */ + private void updateToolbarSubtitle(Toolbar toolbar, String subtitle) { + getActivity().runOnUiThread(() -> { + toolbar.setSubtitle(subtitle); + }); + } + /** * ToolbarをInitする * @@ -140,7 +159,7 @@ public class ViewerListFragment extends Fragment { * @param showBackButton 戻るボタンを表示するか * @param title タイトル */ - private void toolbarSetup(Toolbar toolbar, boolean showBackButton, String title) { + 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); @@ -152,6 +171,7 @@ public class ViewerListFragment extends Fragment { toolbar.setNavigationIcon(null); } toolbar.setTitle(title); + if (Subtitle != null) toolbar.setSubtitle(Subtitle); toolbar.inflateMenu(R.menu.viewer_menu); toolbar.setOnMenuItemClickListener(item -> { if (item.getItemId() == R.id.action_open_vcs_rev_list) {