mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
commit
23489e20c6
|
@ -61,4 +61,6 @@ dependencies {
|
|||
// TODO-rca: バージョンカタログに切り出す
|
||||
implementation "com.hendraanggrian.material:collapsingtoolbarlayout-subtitle:1.5.0"
|
||||
|
||||
// ViewPager2
|
||||
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package one.nem.lacerta.component.viewer;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
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.Document;
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
import one.nem.lacerta.vcs.LacertaVcs;
|
||||
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link ViewerBodyFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
public class ViewerBodyFragment extends Fragment {
|
||||
|
||||
@Inject
|
||||
Document document;
|
||||
|
||||
@Inject
|
||||
LacertaLibrary lacertaLibrary;
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
@Inject
|
||||
LacertaVcsFactory lacertaVcsFactory;
|
||||
|
||||
// Variables
|
||||
private String documentId;
|
||||
private String documentName;
|
||||
private String revisionId;
|
||||
|
||||
public ViewerBodyFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static ViewerBodyFragment newInstance(String documentId, String documentName) {
|
||||
ViewerBodyFragment fragment = new ViewerBodyFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("documentId", documentId);
|
||||
args.putString("documentName", documentName);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public static ViewerBodyFragment newInstance(String documentId, String documentName, String revisionId) {
|
||||
ViewerBodyFragment fragment = new ViewerBodyFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("documentId", documentId);
|
||||
args.putString("documentName", documentName);
|
||||
args.putString("revisionId", revisionId);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
documentId = getArguments().getString("documentId");
|
||||
documentName = getArguments().getString("documentName");
|
||||
revisionId = getArguments().getString("revisionId");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_viewer_body, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
logger.debug("ViewerBodyFragment", "ViewerBodyFragment.onViewCreated");
|
||||
|
||||
RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(fileName -> {
|
||||
Toast.makeText(getContext(), fileName, Toast.LENGTH_SHORT).show();
|
||||
// TODO-rca: なにか処理をもたせる
|
||||
});
|
||||
recyclerView.setAdapter(viewerBodyAdapter);
|
||||
|
||||
loadDocument(viewerBodyAdapter, documentId, revisionId);
|
||||
}
|
||||
|
||||
private void loadDocument(ViewerBodyAdapter adapter, String documentId, String revisionId) {
|
||||
if (revisionId == null) { // load latest revision
|
||||
document.getDocument(documentId).thenAccept(document -> {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
adapter.setPages(document.getPages());
|
||||
adapter.notifyDataSetChanged();
|
||||
});
|
||||
});
|
||||
} else { // load specified revision
|
||||
LacertaVcs vcs = lacertaVcsFactory.create(documentId);
|
||||
document.getDocumentPageListByFileNameList(documentId, vcs.getDocumentPagePathListRev(revisionId).join()).thenAccept(documentPageList -> {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
adapter.setPages(documentPageList);
|
||||
adapter.notifyDataSetChanged();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
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.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.component.common.picker.LacertaFilePickerDialog;
|
||||
import one.nem.lacerta.data.Document;
|
||||
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;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link ViewerContainerFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
public class ViewerContainerFragment extends Fragment {
|
||||
|
||||
// Inject
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
@Inject
|
||||
LacertaLibrary lacertaLibrary;
|
||||
|
||||
@Inject
|
||||
Document document;
|
||||
|
||||
// Variables
|
||||
private String documentId;
|
||||
private String documentName;
|
||||
private boolean hasCombined = false;
|
||||
|
||||
public ViewerContainerFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static ViewerContainerFragment newInstance(String documentId, String documentName, boolean hasCombined) {
|
||||
ViewerContainerFragment fragment = new ViewerContainerFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
args.putString("documentId", documentId);
|
||||
args.putString("documentName", documentName);
|
||||
args.putBoolean("hasCombined", hasCombined);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public static ViewerContainerFragment newInstance(String documentId, String documentName) {
|
||||
ViewerContainerFragment fragment = new ViewerContainerFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
args.putString("documentId", documentId);
|
||||
args.putString("documentName", documentName);
|
||||
args.putBoolean("hasCombined", false);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null){
|
||||
documentId = getArguments().getString("documentId");
|
||||
documentName = getArguments().getString("documentName");
|
||||
hasCombined = getArguments().getBoolean("hasCombined");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_viewer_container, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
// Init view pager
|
||||
ViewPager2 viewPager = view.findViewById(R.id.view_pager);
|
||||
|
||||
// Init view pager adapter
|
||||
ViewerViewPagerAdapter viewerViewPagerAdapter = new ViewerViewPagerAdapter(requireActivity());
|
||||
viewPager.setAdapter(viewerViewPagerAdapter);
|
||||
|
||||
// Init tab layout
|
||||
TabLayout tabLayout = view.findViewById(R.id.tab_layout);
|
||||
|
||||
// Init toolbar
|
||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
||||
initToolbar(toolbar, true, documentName);
|
||||
|
||||
if (this.hasCombined) {
|
||||
logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined);
|
||||
lacertaLibrary.getCombinedDocumentToxiList(documentId).thenAccept(combinedDocumentToxiList -> {
|
||||
logger.debug("ViewerContainerFragment", "combinedDocumentToxiList: " + combinedDocumentToxiList.size());
|
||||
for (ToxiDocumentModel toxiDocumentModel : combinedDocumentToxiList) {
|
||||
logger.debug("ViewerContainerFragment", "titleCache: " + toxiDocumentModel.getTitleCache());
|
||||
viewerViewPagerAdapter
|
||||
.addFragment(ViewerBodyFragment.newInstance(toxiDocumentModel.getChildDocumentId(), toxiDocumentModel.getTitleCache()),
|
||||
toxiDocumentModel.getTitleCache());
|
||||
}
|
||||
viewerViewPagerAdapter.notifyItemRangeChanged(0, combinedDocumentToxiList.size());
|
||||
});
|
||||
} else {
|
||||
logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined);
|
||||
tabLayout.setVisibility(View.GONE);
|
||||
viewerViewPagerAdapter.addFragment(ViewerBodyFragment.newInstance(documentId, documentName), documentName);
|
||||
viewerViewPagerAdapter.notifyItemRangeChanged(0, 1);
|
||||
}
|
||||
|
||||
// Attach tab layout to view pager
|
||||
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
|
||||
View customView = LayoutInflater.from(getContext()).inflate(R.layout.viewer_custom_tab, null);
|
||||
|
||||
TextView textView = customView.findViewById(R.id.tab_title);
|
||||
textView.setText(viewerViewPagerAdapter.getTabTitle(position));
|
||||
|
||||
ImageButton imageButton = customView.findViewById(R.id.tab_modify);
|
||||
imageButton.setOnClickListener(v -> {
|
||||
Toast.makeText(getContext(), "Working!, Index:" + position, Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
tab.setCustomView(customView);
|
||||
}).attach();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
renameDocument();
|
||||
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 if (item.getItemId() == R.id.action_combine) {
|
||||
combineDocument();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void combineDocument() {
|
||||
LacertaFilePickerDialog lacertaFilePickerDialog = new LacertaFilePickerDialog();
|
||||
lacertaFilePickerDialog.setListener((fileName, selectedId) -> {
|
||||
lacertaLibrary.combineDocument(documentId, selectedId).thenAccept(aVoid -> {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
Toast.makeText(getContext(), "結合しました", Toast.LENGTH_SHORT).show();
|
||||
getActivity().finish(); // TODO-rca: 終了させずにUIを更新したい
|
||||
});
|
||||
});
|
||||
});
|
||||
lacertaFilePickerDialog
|
||||
.setTitle("ファイルの結合")
|
||||
.setMessage("結合するファイルを選択してください")
|
||||
.setNegativeButtonText("キャンセル")
|
||||
.show(getChildFragmentManager(), "LacertaFilePickerDialog");
|
||||
}
|
||||
|
||||
/**
|
||||
* ドキュメント名を変更する
|
||||
*/
|
||||
private void renameDocument() {
|
||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext());
|
||||
builder.setTitle("ファイル名の変更");
|
||||
builder.setMessage("ファイル名を入力してください");
|
||||
|
||||
View view = LayoutInflater.from(getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.lacerta_dialog_edit_text_layout, null);
|
||||
TextInputEditText textInputEditText = view.findViewById(one.nem.lacerta.shared.ui.R.id.custom_edit_text);
|
||||
TextInputLayout textInputLayout = view.findViewById(one.nem.lacerta.shared.ui.R.id.custom_text_input_layout);
|
||||
textInputEditText.setText(documentName);
|
||||
textInputLayout.setHint("ファイル名");
|
||||
builder.setView(view);
|
||||
|
||||
builder.setPositiveButton("変更", (dialog, which) -> {
|
||||
document.renameDocument(documentId, textInputEditText.getText().toString()).thenAccept(aVoid -> {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
this.documentName = textInputEditText.getText().toString();
|
||||
// TODO-rca: Toolbarのタイトルも変更する
|
||||
});
|
||||
});
|
||||
});
|
||||
builder.setNegativeButton("キャンセル", (dialog, which) -> {
|
||||
dialog.cancel();
|
||||
});
|
||||
|
||||
builder.show();
|
||||
}
|
||||
}
|
|
@ -24,6 +24,8 @@ import one.nem.lacerta.component.common.LacertaSelectDirDialogListener;
|
|||
import one.nem.lacerta.component.common.LacertaSelectRevDialog;
|
||||
import one.nem.lacerta.component.common.LacertaSelectRevDialogListener;
|
||||
import one.nem.lacerta.component.common.picker.LacertaDirPickerDialog;
|
||||
import one.nem.lacerta.component.common.picker.LacertaFilePickerAdapter;
|
||||
import one.nem.lacerta.component.common.picker.LacertaFilePickerDialog;
|
||||
import one.nem.lacerta.data.Document;
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.model.ListItemType;
|
||||
|
@ -256,6 +258,21 @@ public class ViewerListFragment extends Fragment {
|
|||
.setNegativeButtonText("キャンセル");
|
||||
lacertaDirPickerDialog.show(getParentFragmentManager(), "select_dir_dialog");
|
||||
return true;
|
||||
} else if(item.getItemId() == R.id.action_combine) {
|
||||
LacertaFilePickerDialog lacertaFilePickerDialog = new LacertaFilePickerDialog();
|
||||
lacertaFilePickerDialog.setListener((name, fileId) -> {
|
||||
lacertaLibrary.combineDocument(documentId, fileId).thenAccept(aVoid -> {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
// Stop Activity
|
||||
getActivity().finish(); // TODO-rca: 終了せずにUIを更新したい
|
||||
});
|
||||
});
|
||||
});
|
||||
lacertaFilePickerDialog.setTitle("ファイルの結合")
|
||||
.setMessage("結合するファイルを選択してください。")
|
||||
.setNegativeButtonText("キャンセル");
|
||||
lacertaFilePickerDialog.show(getParentFragmentManager(), "select_file_dialog");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public class ViewerMainActivity extends AppCompatActivity {
|
|||
private static final String TAG = "ViewerMainActivity";
|
||||
String documentId;
|
||||
String documentName;
|
||||
boolean hasCombined = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -49,6 +50,7 @@ public class ViewerMainActivity extends AppCompatActivity {
|
|||
try {
|
||||
documentId = intent.getStringExtra("documentId");
|
||||
documentName = intent.getStringExtra("documentName");
|
||||
hasCombined = intent.getBooleanExtra("hasCombined", false);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error(TAG, "Failed to get documentId from intent");
|
||||
|
@ -58,9 +60,18 @@ public class ViewerMainActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
// Navigation
|
||||
// getSupportFragmentManager().beginTransaction()
|
||||
// .replace(R.id.nav_host_fragment, ViewerListFragment.newInstance(documentId, documentName))
|
||||
// .commit();
|
||||
if (hasCombined) {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.nav_host_fragment, ViewerListFragment.newInstance(documentId, documentName))
|
||||
.replace(R.id.nav_host_fragment, ViewerContainerFragment.newInstance(documentId, documentName, hasCombined))
|
||||
.commit();
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.nav_host_fragment, ViewerContainerFragment.newInstance(documentId, documentName))
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package one.nem.lacerta.component.viewer;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ViewerViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
// Variables
|
||||
private ArrayList<Fragment> fragmentArrayList = new ArrayList<>();
|
||||
private ArrayList<String> fragmentTitleList = new ArrayList<>();
|
||||
|
||||
// Setter
|
||||
public void addFragment(Fragment fragment, String title){
|
||||
fragmentArrayList.add(fragment);
|
||||
fragmentTitleList.add(title);
|
||||
}
|
||||
|
||||
public ViewerViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
|
||||
super(fragmentActivity);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
return fragmentArrayList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fragmentArrayList == null ? 0 : fragmentArrayList.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getTabTitle(int position) {
|
||||
return fragmentTitleList.get(position);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:context=".ViewerBodyFragment">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</FrameLayout>
|
|
@ -0,0 +1,66 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/colorSurface">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.SubtitleCollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
app:contentScrim="@color/colorSecondaryContainer"
|
||||
android:background="@color/colorSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:fitsSystemWindows="true"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:collapsedTitleGravity="start|center_vertical"
|
||||
app:expandedTitleGravity="start|bottom"
|
||||
app:expandedTitleMarginBottom="16dp"
|
||||
app:expandedTitleMarginStart="16dp"
|
||||
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:title="Title" />
|
||||
|
||||
</com.google.android.material.appbar.SubtitleCollapsingToolbarLayout>
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabMode="scrollable"
|
||||
/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading_progress_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"
|
||||
android:background="@color/colorSurface"
|
||||
android:visibility="gone" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/view_pager"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</FrameLayout>
|
25
component/viewer/src/main/res/layout/viewer_custom_tab.xml
Normal file
25
component/viewer/src/main/res/layout/viewer_custom_tab.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tab_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TAB TITLE"
|
||||
android:textSize="16sp"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/tab_modify"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="16dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:src="@drawable/more_vert_24px"
|
||||
android:layout_gravity="center_vertical" />
|
||||
</LinearLayout>
|
|
@ -16,4 +16,8 @@
|
|||
android:id="@+id/action_move"
|
||||
android:title="移動" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_combine"
|
||||
android:title="結合" />
|
||||
|
||||
</menu>
|
|
@ -10,6 +10,7 @@ import one.nem.lacerta.model.LibraryItemPage;
|
|||
import one.nem.lacerta.model.PublicPath;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
import one.nem.lacerta.model.document.tag.DocumentTag;
|
||||
import one.nem.lacerta.model.pref.ToxiDocumentModel;
|
||||
|
||||
public interface LacertaLibrary {
|
||||
|
||||
|
@ -43,4 +44,16 @@ public interface LacertaLibrary {
|
|||
CompletableFuture<Void> addTagToDocument(String documentId, String tagId);
|
||||
|
||||
CompletableFuture<Void> removeTagFromDocument(String documentId, String tagId);
|
||||
|
||||
// Combined Document
|
||||
|
||||
CompletableFuture<Void> combineDocument(String parentId, String childId);
|
||||
|
||||
CompletableFuture<Void> uncombineDocument(String parentId, String childId);
|
||||
|
||||
// CompletableFuture<Void> combineDocument(String parentId, ArrayList<String> childIdList);
|
||||
//
|
||||
// CompletableFuture<Void> uncombineDocument(String parentId, ArrayList<String> childIdList);
|
||||
|
||||
CompletableFuture<ArrayList<ToxiDocumentModel>> getCombinedDocumentToxiList(String parentId);
|
||||
}
|
||||
|
|
|
@ -81,6 +81,8 @@ public class DocumentImpl implements Document {
|
|||
documentEntity.updatedAt = meta.getUpdatedAt();
|
||||
documentEntity.createdAt = meta.getCreatedAt();
|
||||
documentEntity.parentId = meta.getParentId();
|
||||
documentEntity.isCombineChild = meta.getIsCombineChild();
|
||||
documentEntity.isCombineParent = meta.getIsCombineParent();
|
||||
|
||||
database.documentDao().insert(documentEntity);
|
||||
|
||||
|
@ -104,6 +106,8 @@ public class DocumentImpl implements Document {
|
|||
meta.setUpdatedAt(new Date());
|
||||
meta.setCreatedAt(new Date());
|
||||
meta.setParentId(null);
|
||||
meta.setIsCombineChild(false);
|
||||
meta.setIsCombineParent(false);
|
||||
return createDocument(meta);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
@ -22,11 +23,13 @@ import one.nem.lacerta.model.ListItemType;
|
|||
import one.nem.lacerta.model.PublicPath;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
import one.nem.lacerta.model.document.tag.DocumentTag;
|
||||
import one.nem.lacerta.model.pref.ToxiDocumentModel;
|
||||
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.source.database.entity.TagEntity;
|
||||
import one.nem.lacerta.source.database.entity.ToxiDocumentEntity;
|
||||
import one.nem.lacerta.source.database.entity.ToxiDocumentTagEntity;
|
||||
import one.nem.lacerta.utils.FeatureSwitch;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
@ -54,6 +57,7 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||
listItem.setTitle(documentEntity.title);
|
||||
listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt));
|
||||
listItem.setItemId(documentEntity.id);
|
||||
listItem.setHasCombined(documentEntity.isCombineParent);
|
||||
listItems.add(listItem);
|
||||
}
|
||||
|
||||
|
@ -103,6 +107,7 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||
listItem.setTitle(childFolderEntity.name);
|
||||
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
|
||||
listItem.setItemId(childFolderEntity.id);
|
||||
listItem.setHasCombined(false);
|
||||
listItems.add(listItem);
|
||||
}
|
||||
|
||||
|
@ -115,6 +120,7 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||
listItem.setTitle(documentEntity.title);
|
||||
listItem.setDescription(simpleDateFormat.format(documentEntity.updatedAt));
|
||||
listItem.setItemId(documentEntity.id);
|
||||
listItem.setHasCombined(documentEntity.isCombineParent);
|
||||
listItems.add(listItem);
|
||||
}
|
||||
|
||||
|
@ -164,6 +170,7 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||
listItem.setTitle(childFolderEntity.name);
|
||||
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
|
||||
listItem.setItemId(childFolderEntity.id);
|
||||
listItem.setHasCombined(false);
|
||||
listItems.add(listItem);
|
||||
}
|
||||
|
||||
|
@ -294,6 +301,90 @@ public class LacertaLibraryImpl implements LacertaLibrary {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> combineDocument(String targetId1, String tagetId2) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
DocumentEntity target1DocumentEntity = database.documentDao().findById(targetId1);
|
||||
DocumentEntity target2DocumentEntity = database.documentDao().findById(tagetId2);
|
||||
if (target1DocumentEntity == null || target2DocumentEntity == null) {
|
||||
logger.warn("LacertaLibraryImpl", "DocumentEntity is not found.");
|
||||
return null;
|
||||
}
|
||||
target1DocumentEntity.isCombineChild = true;
|
||||
target2DocumentEntity.isCombineChild = true;
|
||||
database.documentDao().update(target1DocumentEntity);
|
||||
database.documentDao().update(target2DocumentEntity);
|
||||
logger.debug("LacertaLibraryImpl", "Database Query: Updated DocumentEntity");
|
||||
|
||||
DocumentEntity parentDocumentEntity = new DocumentEntity();
|
||||
parentDocumentEntity.id = UUID.randomUUID().toString();
|
||||
parentDocumentEntity.title = target1DocumentEntity.title + "(Combined)";
|
||||
parentDocumentEntity.parentId = target1DocumentEntity.parentId;
|
||||
parentDocumentEntity.author = target1DocumentEntity.author; // TODO-rca: Target1とTarget2の作者が異なる場合の処理
|
||||
// CombinedなDocumentはいま作成された と考える
|
||||
parentDocumentEntity.createdAt = new Date();
|
||||
parentDocumentEntity.updatedAt = new Date();
|
||||
parentDocumentEntity.isCombineParent = true;
|
||||
parentDocumentEntity.isCombineChild = false;
|
||||
database.documentDao().insert(parentDocumentEntity);
|
||||
logger.debug("LacertaLibraryImpl", "Database Query: Inserted DocumentEntity");
|
||||
|
||||
insertCombineDocumentToxi(parentDocumentEntity.id, target1DocumentEntity.id, target1DocumentEntity.title);
|
||||
insertCombineDocumentToxi(parentDocumentEntity.id, target2DocumentEntity.id, target2DocumentEntity.title);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private void insertCombineDocumentToxi(String parentId, String childId, String titleCache) {
|
||||
ToxiDocumentEntity toxiDocumentEntity = new ToxiDocumentEntity();
|
||||
toxiDocumentEntity.parentDocumentId = parentId;
|
||||
toxiDocumentEntity.childDocumentId = childId;
|
||||
toxiDocumentEntity.order = 0; // TODO-rca: 並び順の概念をもたせる
|
||||
toxiDocumentEntity.isActive = true; // TODO-rca: タブから非表示にできるようにする
|
||||
toxiDocumentEntity.titleCache = titleCache;
|
||||
database.toxiDocumentDao().insert(toxiDocumentEntity);
|
||||
logger.debug("LacertaLibraryImpl", "Database Query: Inserted ToxiDocumentEntity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> uncombineDocument(String parentId, String childId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
DocumentEntity parentDocumentEntity = database.documentDao().findById(parentId);
|
||||
DocumentEntity childDocumentEntity = database.documentDao().findById(childId);
|
||||
if (parentDocumentEntity == null || childDocumentEntity == null) {
|
||||
logger.warn("LacertaLibraryImpl", "DocumentEntity is not found.");
|
||||
return null;
|
||||
}
|
||||
parentDocumentEntity.isCombineParent = false;
|
||||
childDocumentEntity.isCombineChild = false;
|
||||
database.documentDao().update(parentDocumentEntity);
|
||||
database.documentDao().update(childDocumentEntity);
|
||||
logger.debug("LacertaLibraryImpl", "Database Query: Updated DocumentEntity");
|
||||
|
||||
database.toxiDocumentDao().deleteByParentIdAndChildId(parentId, childId);
|
||||
logger.debug("LacertaLibraryImpl", "Database Query: Deleted ToxiDocumentEntity");
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<ArrayList<ToxiDocumentModel>> getCombinedDocumentToxiList(String parentId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
List<ToxiDocumentEntity> toxiDocumentEntities = database.toxiDocumentDao().findByParentId(parentId);
|
||||
ArrayList<ToxiDocumentModel> toxiDocumentModels = new ArrayList<>();
|
||||
for (ToxiDocumentEntity toxiDocumentEntity : toxiDocumentEntities) {
|
||||
ToxiDocumentModel toxiDocumentModel = new ToxiDocumentModel();
|
||||
toxiDocumentModel.setParentDocumentId(toxiDocumentEntity.parentDocumentId);
|
||||
toxiDocumentModel.setChildDocumentId(toxiDocumentEntity.childDocumentId);
|
||||
toxiDocumentModel.setOrder(toxiDocumentEntity.order);
|
||||
toxiDocumentModel.setActive(toxiDocumentEntity.isActive);
|
||||
toxiDocumentModel.setTitleCache(toxiDocumentEntity.titleCache);
|
||||
toxiDocumentModels.add(toxiDocumentModel);
|
||||
}
|
||||
return toxiDocumentModels;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 再帰的にパスを解決する
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package one.nem.lacerta.feature.home;
|
||||
|
||||
public interface DocumentSelectListener {
|
||||
void onDocumentSelect(String documentId, String documentName);
|
||||
void onDocumentSelect(String documentId, String documentName, boolean hasCombined);
|
||||
}
|
||||
|
|
|
@ -85,11 +85,12 @@ public class HomeTopFragment extends Fragment {
|
|||
|
||||
this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() {
|
||||
@Override
|
||||
public void onDocumentSelect(String documentId, String documentName) {
|
||||
public void onDocumentSelect(String documentId, String documentName, boolean hasCombined) {
|
||||
Intent intent = new Intent(getContext(), ViewerMainActivity.class);
|
||||
Log.d("HomeTopFragment", "onDocumentSelect: " + documentId + " " + documentName);
|
||||
intent.putExtra("documentId", documentId);
|
||||
intent.putExtra("documentName", documentName);
|
||||
intent.putExtra("hasCombined", hasCombined);
|
||||
startActivity(intent, ActivityOptions.makeCustomAnimation(getContext(), one.nem.lacerta.shared.ui.R.anim.nav_up_enter_anim, one.nem.lacerta.shared.ui.R.anim.nav_up_exit_anim).toBundle());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
|
|||
holder.description.setText(listItem.getDescription());
|
||||
|
||||
holder.itemView.setOnClickListener( v -> {
|
||||
listener.onDocumentSelect(listItem.getItemId(), listItem.getTitle());
|
||||
listener.onDocumentSelect(listItem.getItemId(), listItem.getTitle(), listItem.getHasCombined());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -2,5 +2,5 @@ package one.nem.lacerta.feature.library;
|
|||
|
||||
public interface DocumentSelectListener {
|
||||
void onFolderSelected(String folderId, String folderName);
|
||||
void onDocumentSelected(String documentId, String documentName);
|
||||
void onDocumentSelected(String documentId, String documentName, boolean hasCombined);
|
||||
}
|
||||
|
|
|
@ -164,11 +164,12 @@ public class LibraryPageFragment extends Fragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDocumentSelected(String documentId, String documentName) {
|
||||
public void onDocumentSelected(String documentId, String documentName, boolean hasCombined) {
|
||||
Intent intent = new Intent(getContext(), ViewerMainActivity.class);
|
||||
logger.debug("LibraryTopFragment", "Document selected! documentId: " + documentId + ", documentName: " + documentName);
|
||||
intent.putExtra("documentId", documentId);
|
||||
intent.putExtra("documentName", documentName);
|
||||
intent.putExtra("hasCombined", hasCombined);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
|
|||
|
||||
holder.itemView.setOnClickListener( v -> {
|
||||
if (listItem.getItemType() == ListItemType.ITEM_TYPE_DOCUMENT) {
|
||||
listener.onDocumentSelected(listItem.getItemId(), listItem.getTitle());
|
||||
listener.onDocumentSelected(listItem.getItemId(), listItem.getTitle(), listItem.getHasCombined());
|
||||
}
|
||||
else if (listItem.getItemType() == ListItemType.ITEM_TYPE_FOLDER) {
|
||||
listener.onFolderSelected(listItem.getItemId(), listItem.getTitle());
|
||||
|
|
|
@ -10,6 +10,7 @@ public class ListItem {
|
|||
String description;
|
||||
ListItemType itemType;
|
||||
String itemId;
|
||||
boolean hasCombined;
|
||||
|
||||
// Constructor
|
||||
|
||||
|
@ -20,6 +21,14 @@ public class ListItem {
|
|||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public ListItem(String title, String description, ListItemType itemType, String itemId, boolean hasCombined) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.itemType = itemType;
|
||||
this.itemId = itemId;
|
||||
this.hasCombined = hasCombined;
|
||||
}
|
||||
|
||||
public ListItem() {
|
||||
// Empty constructor
|
||||
}
|
||||
|
@ -42,6 +51,10 @@ public class ListItem {
|
|||
return itemId;
|
||||
}
|
||||
|
||||
public boolean getHasCombined() {
|
||||
return hasCombined;
|
||||
}
|
||||
|
||||
// Setter
|
||||
|
||||
public void setTitle(String title) {
|
||||
|
@ -60,4 +73,8 @@ public class ListItem {
|
|||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public void setHasCombined(boolean hasCombined) {
|
||||
this.hasCombined = hasCombined;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
|||
|
||||
String author;
|
||||
|
||||
boolean isCombineChild;
|
||||
|
||||
boolean isCombineParent;
|
||||
|
||||
// Constructor
|
||||
|
||||
public DocumentMeta() {
|
||||
|
@ -48,12 +52,16 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
|||
this.parentId = null;
|
||||
this.updatedAt = new Date();
|
||||
this.createdAt = new Date();
|
||||
this.isCombineChild = false;
|
||||
this.isCombineParent = false;
|
||||
}
|
||||
|
||||
public DocumentMeta(String title, String author) {
|
||||
this.id = UUID.randomUUID().toString();
|
||||
this.title = title;
|
||||
this.author = author;
|
||||
this.isCombineChild = false;
|
||||
this.isCombineParent = false;
|
||||
}
|
||||
|
||||
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, String author) {
|
||||
|
@ -62,6 +70,8 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
|||
this.updatedAt = updatedAt;
|
||||
this.createdAt = createdAt;
|
||||
this.author = author;
|
||||
this.isCombineChild = false;
|
||||
this.isCombineParent = false;
|
||||
}
|
||||
|
||||
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, String parentId, String author) {
|
||||
|
@ -71,6 +81,19 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
|||
this.createdAt = createdAt;
|
||||
this.parentId = parentId;
|
||||
this.author = author;
|
||||
this.isCombineChild = false;
|
||||
this.isCombineParent = false;
|
||||
}
|
||||
|
||||
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, String parentId, String author, boolean isCombineChild, boolean isCombineParent) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.updatedAt = updatedAt;
|
||||
this.createdAt = createdAt;
|
||||
this.parentId = parentId;
|
||||
this.author = author;
|
||||
this.isCombineChild = isCombineChild;
|
||||
this.isCombineParent = isCombineParent;
|
||||
}
|
||||
|
||||
// Getter
|
||||
|
@ -117,6 +140,20 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
|||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* ドキュメントの結合子フラグ(boolean)を取得する
|
||||
*/
|
||||
public boolean getIsCombineChild() {
|
||||
return isCombineChild;
|
||||
}
|
||||
|
||||
/**
|
||||
* ドキュメントの結合親フラグ(boolean)を取得する
|
||||
*/
|
||||
public boolean getIsCombineParent() {
|
||||
return isCombineParent;
|
||||
}
|
||||
|
||||
// Setter
|
||||
|
||||
/**
|
||||
|
@ -167,6 +204,22 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
|||
this.author = author;
|
||||
}
|
||||
|
||||
/**
|
||||
* ドキュメントの結合子フラグ(boolean)を設定する
|
||||
* @param isCombineChild ドキュメントの結合子フラグ
|
||||
*/
|
||||
public void setIsCombineChild(boolean isCombineChild) {
|
||||
this.isCombineChild = isCombineChild;
|
||||
}
|
||||
|
||||
/**
|
||||
* ドキュメントの結合親フラグ(boolean)を設定する
|
||||
* @param isCombineParent ドキュメントの結合親フラグ
|
||||
*/
|
||||
public void setIsCombineParent(boolean isCombineParent) {
|
||||
this.isCombineParent = isCombineParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* updatedAtを現在時刻に設定する
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package one.nem.lacerta.model.pref;
|
||||
|
||||
public class ToxiDocumentModel {
|
||||
|
||||
// Field
|
||||
public String parentDocumentId;
|
||||
|
||||
public String childDocumentId;
|
||||
|
||||
public int order;
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
public String titleCache;
|
||||
|
||||
// Constructor
|
||||
public ToxiDocumentModel() {
|
||||
}
|
||||
|
||||
public ToxiDocumentModel(String parentDocumentId, String childDocumentId, int order, boolean isActive, String titleCache) {
|
||||
this.parentDocumentId = parentDocumentId;
|
||||
this.childDocumentId = childDocumentId;
|
||||
this.order = order;
|
||||
this.isActive = isActive;
|
||||
this.titleCache = titleCache;
|
||||
}
|
||||
|
||||
// Getter / Setter
|
||||
public String getParentDocumentId() {
|
||||
return parentDocumentId;
|
||||
}
|
||||
|
||||
public void setParentDocumentId(String parentDocumentId) {
|
||||
this.parentDocumentId = parentDocumentId;
|
||||
}
|
||||
|
||||
public String getChildDocumentId() {
|
||||
return childDocumentId;
|
||||
}
|
||||
|
||||
public void setChildDocumentId(String childDocumentId) {
|
||||
this.childDocumentId = childDocumentId;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
isActive = active;
|
||||
}
|
||||
|
||||
public String getTitleCache() {
|
||||
return titleCache;
|
||||
}
|
||||
|
||||
public void setTitleCache(String titleCache) {
|
||||
this.titleCache = titleCache;
|
||||
}
|
||||
}
|
10
shared/ui/src/main/res/drawable/more_vert_24px.xml
Normal file
10
shared/ui/src/main/res/drawable/more_vert_24px.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@color/colorOnSurface"
|
||||
android:pathData="M480,770.77Q455.25,770.77 437.63,753.14Q420,735.52 420,710.77Q420,686.02 437.63,668.4Q455.25,650.77 480,650.77Q504.75,650.77 522.37,668.4Q540,686.02 540,710.77Q540,735.52 522.37,753.14Q504.75,770.77 480,770.77ZM480,540Q455.25,540 437.63,522.37Q420,504.75 420,480Q420,455.25 437.63,437.63Q455.25,420 480,420Q504.75,420 522.37,437.63Q540,455.25 540,480Q540,504.75 522.37,522.37Q504.75,540 480,540ZM480,309.23Q455.25,309.23 437.63,291.6Q420,273.98 420,249.23Q420,224.48 437.63,206.86Q455.25,189.23 480,189.23Q504.75,189.23 522.37,206.86Q540,224.48 540,249.23Q540,273.98 522.37,291.6Q504.75,309.23 480,309.23Z"/>
|
||||
</vector>
|
|
@ -5,11 +5,13 @@ import androidx.room.RoomDatabase;
|
|||
|
||||
// Entities
|
||||
import one.nem.lacerta.source.database.dao.FolderDao;
|
||||
import one.nem.lacerta.source.database.dao.ToxiDocumentDao;
|
||||
import one.nem.lacerta.source.database.dao.ToxiDocumentTagDao;
|
||||
import one.nem.lacerta.source.database.entity.FolderEntity;
|
||||
import one.nem.lacerta.source.database.entity.TagEntity;
|
||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||
import one.nem.lacerta.source.database.entity.LibraryEntity;
|
||||
import one.nem.lacerta.source.database.entity.ToxiDocumentEntity;
|
||||
import one.nem.lacerta.source.database.entity.ToxiDocumentTagEntity;
|
||||
import one.nem.lacerta.source.database.entity.VcsRevEntity;
|
||||
import one.nem.lacerta.source.database.entity.VcsLogEntity;
|
||||
|
@ -21,11 +23,12 @@ 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, ToxiDocumentTagEntity.class}, version = 6)
|
||||
@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class, ToxiDocumentTagEntity.class, ToxiDocumentEntity.class}, version = 8)
|
||||
public abstract class LacertaDatabase extends RoomDatabase {
|
||||
public abstract TagDao tagDao();
|
||||
public abstract DocumentDao documentDao();
|
||||
public abstract ToxiDocumentTagDao toxiDocumentTagDao();
|
||||
public abstract ToxiDocumentDao toxiDocumentDao();
|
||||
public abstract LibraryDao libraryDao();
|
||||
public abstract VcsRevDao vcsRevDao();
|
||||
public abstract VcsLogDao vcsLogDao();
|
||||
|
|
|
@ -29,13 +29,13 @@ public interface DocumentDao {
|
|||
@Query("SELECT * FROM Document WHERE id IN (:ids)")
|
||||
List<DocumentEntity> findByIds(List<String> ids);
|
||||
|
||||
@Query("SELECT * FROM Document WHERE parent_id = :parentId")
|
||||
@Query("SELECT * FROM Document WHERE parent_id = :parentId AND is_combine_child = 0 ORDER BY created_at DESC")
|
||||
List<DocumentEntity> findByParentId(String parentId);
|
||||
|
||||
@Query("SELECT * FROM Document WHERE parent_id IS NULL")
|
||||
@Query("SELECT * FROM Document WHERE parent_id IS NULL AND is_combine_child = 0 ORDER BY created_at DESC")
|
||||
List<DocumentEntity> findRootDocuments();
|
||||
|
||||
@Query("SELECT * FROM Document ORDER BY created_at DESC LIMIT :limit")
|
||||
@Query("SELECT * FROM Document WHERE is_combine_child = 0 ORDER BY created_at DESC LIMIT :limit")
|
||||
List<DocumentEntity> getRecentDocument(int limit);
|
||||
|
||||
// Insert
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package one.nem.lacerta.source.database.dao;
|
||||
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import one.nem.lacerta.source.database.entity.ToxiDocumentEntity;
|
||||
|
||||
@Dao
|
||||
public interface ToxiDocumentDao {
|
||||
|
||||
@Query("SELECT * FROM toxi_document WHERE parent_document_id = :parentId AND is_active = 1 ORDER BY `order` ASC")
|
||||
List<ToxiDocumentEntity> findByParentId(String parentId);
|
||||
|
||||
@Insert
|
||||
void insert(ToxiDocumentEntity toxiDocument);
|
||||
|
||||
@Insert
|
||||
void insertAll(ToxiDocumentEntity... toxiDocuments);
|
||||
|
||||
@Update
|
||||
void update(ToxiDocumentEntity toxiDocument);
|
||||
|
||||
@Update
|
||||
void updateAll(ToxiDocumentEntity... toxiDocuments);
|
||||
|
||||
@Query("DELETE FROM toxi_document WHERE parent_document_id = :parentId")
|
||||
void deleteByParentId(String parentId);
|
||||
|
||||
@Query("DELETE FROM toxi_document WHERE parent_document_id = :parentId AND child_document_id = :childId")
|
||||
void deleteByParentIdAndChildId(String parentId, String childId);
|
||||
}
|
|
@ -36,4 +36,10 @@ public class DocumentEntity {
|
|||
|
||||
@ColumnInfo(name = "parent_id")
|
||||
public String parentId; // 親フォルダID
|
||||
|
||||
@ColumnInfo(name = "is_combine_child")
|
||||
public boolean isCombineChild; // 結合されたドキュメントの子かどうか
|
||||
|
||||
@ColumnInfo(name = "is_combine_parent")
|
||||
public boolean isCombineParent; // 結合されたドキュメントの親かどうか
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package one.nem.lacerta.source.database.entity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
|
||||
@Entity(primaryKeys = {"parent_document_id", "child_document_id"}, tableName = "toxi_document")
|
||||
public class ToxiDocumentEntity {
|
||||
|
||||
@ColumnInfo(name = "parent_document_id")
|
||||
@NonNull
|
||||
public String parentDocumentId;
|
||||
|
||||
@ColumnInfo(name = "child_document_id")
|
||||
@NonNull
|
||||
public String childDocumentId;
|
||||
|
||||
@ColumnInfo(name = "order")
|
||||
public int order;
|
||||
|
||||
@ColumnInfo(name = "is_active")
|
||||
public boolean isActive;
|
||||
|
||||
@ColumnInfo(name = "title_cache")
|
||||
public String titleCache;
|
||||
}
|
Loading…
Reference in New Issue
Block a user