From 8038b7e1989386000e0c6762d42e4baa64958678 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 13:23:16 +0900 Subject: [PATCH] =?UTF-8?q?Toolbar=E3=82=92=E5=87=A6=E7=90=86=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=AE=9F=E8=A3=85?= =?UTF-8?q?=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../viewer/ViewerContainerFragment.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java index a5beea08..d51a015e 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerContainerFragment.java @@ -2,17 +2,20 @@ package one.nem.lacerta.component.viewer; import android.os.Bundle; +import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.viewpager2.widget.ViewPager2; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.data.LacertaLibrary; +import one.nem.lacerta.model.document.page.Page; import one.nem.lacerta.model.pref.ToxiDocumentModel; import one.nem.lacerta.utils.LacertaLogger; @@ -100,4 +103,48 @@ public class ViewerContainerFragment extends Fragment { viewerViewPagerAdapter.addFragment(ViewerBodyFragment.newInstance(documentId, documentName), documentName); } } + + /** + * Toolbarをinitする + * + * @param toolbar Toolbar + * @param showCloseButton Closeボタンを表示するかどうか + * @param title タイトル + */ + private void initToolbar(Toolbar toolbar, boolean showCloseButton, String title) { + getActivity().runOnUiThread(() -> { + // Close button + if (showCloseButton) { + toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.close_24px); + toolbar.setNavigationOnClickListener(v -> { + getActivity().finish(); + }); + } else { + toolbar.setNavigationIcon(null); + } + + // Title + toolbar.setTitle(title); + + // Menu + toolbar.inflateMenu(R.menu.viewer_menu); + toolbar.setOnMenuItemClickListener(item -> { + if (item.getItemId() == R.id.action_open_vcs_rev_list) { + Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show(); + return true; + } else if (item.getItemId() == R.id.action_rename) { + Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show(); + return true; + } else if (item.getItemId() == R.id.action_delete) { + Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show(); + return true; + } else if (item.getItemId() == R.id.action_move) { + Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show(); + return true; + } else { + return false; + } + }); + }); + } } \ No newline at end of file