ファイルのパスをサブタイトルとして表示するように

This commit is contained in:
ろむねこ 2024-01-26 18:16:00 +09:00
parent 3c079ffc23
commit dbef7b45d1
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -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) {