mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 09:43:15 +00:00
iroiro, コミット履歴を表示できるように
This commit is contained in:
parent
af8935cd7f
commit
b820f42007
|
@ -3,7 +3,9 @@ package one.nem.lacerta.component.viewer;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.navigation.Navigation;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
@ -67,6 +69,10 @@ public class ComponentViewerTopFragment extends Fragment {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_component_viewer_top, container, false);
|
View view = inflater.inflate(R.layout.fragment_component_viewer_top, container, false);
|
||||||
|
|
||||||
|
// Toolbar
|
||||||
|
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
||||||
|
toolbarSetup(toolbar, true, "Revision List");
|
||||||
|
|
||||||
RecyclerView recyclerView = view.findViewById(R.id.body_recycler_view);
|
RecyclerView recyclerView = view.findViewById(R.id.body_recycler_view);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(fileName -> {
|
ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(fileName -> {
|
||||||
|
@ -85,4 +91,39 @@ public class ComponentViewerTopFragment extends Fragment {
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ToolbarをInitする
|
||||||
|
*
|
||||||
|
* @param toolbar Toolbar
|
||||||
|
* @param showBackButton 戻るボタンを表示するか
|
||||||
|
* @param title タイトル
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
toolbar.setNavigationOnClickListener(v -> {
|
||||||
|
//this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join();
|
||||||
|
// Back
|
||||||
|
Navigation.findNavController(requireView()).popBackStack();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
toolbar.setNavigationIcon(null);
|
||||||
|
}
|
||||||
|
toolbar.setTitle(title);
|
||||||
|
toolbar.inflateMenu(R.menu.viewer_menu);
|
||||||
|
toolbar.setOnMenuItemClickListener(item -> {
|
||||||
|
if (item.getItemId() == R.id.action_open_vcs_rev_list) {
|
||||||
|
// Open vcs rev list
|
||||||
|
getParentFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.nav_host_fragment, ViewerVcsRevListFragment.newInstance(documentId))
|
||||||
|
.commit();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,18 @@
|
||||||
package one.nem.lacerta.component.viewer;
|
package one.nem.lacerta.component.viewer;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import one.nem.lacerta.model.VcsRevModel;
|
import one.nem.lacerta.model.VcsRevModel;
|
||||||
|
import one.nem.lacerta.utils.FeatureSwitch;
|
||||||
|
|
||||||
public class RevAdapter extends RecyclerView.Adapter<RevAdapter.RevViewHolder>{
|
public class RevAdapter extends RecyclerView.Adapter<RevAdapter.RevViewHolder>{
|
||||||
|
|
||||||
|
@ -29,23 +33,48 @@ public class RevAdapter extends RecyclerView.Adapter<RevAdapter.RevViewHolder>{
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RevAdapter.RevViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public RevAdapter.RevViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
return null;
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.viewer_rev_list_item, parent, false);
|
||||||
|
return new RevAdapter.RevViewHolder(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RevAdapter.RevViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RevAdapter.RevViewHolder holder, int position) {
|
||||||
|
VcsRevModel revModel = revModels.get(position);
|
||||||
|
holder.title.setText(revModel.getCommitMessage());
|
||||||
|
if (FeatureSwitch.Vcs.disableBranchDisplay) {
|
||||||
|
// holder.detail.setText(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(revModel.getCreatedAt().toInstant()));
|
||||||
|
holder.detail.setText("DateTimePlaceholder");
|
||||||
|
} else {
|
||||||
|
// holder.detail.setText(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(revModel.getCreatedAt().toInstant()) + " " + revModel.getBranchName());
|
||||||
|
holder.detail.setText("DateTimePlaceholder" + " " + revModel.getBranchName());
|
||||||
|
}
|
||||||
|
holder.revId.setText("RevID: " + revModel.getId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
|
if (revModels == null) {
|
||||||
return 0;
|
return 0;
|
||||||
|
} else {
|
||||||
|
return revModels.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RevViewHolder extends RecyclerView.ViewHolder {
|
class RevViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
TextView title;
|
||||||
|
|
||||||
|
TextView detail;
|
||||||
|
|
||||||
|
TextView revId;
|
||||||
|
|
||||||
public RevViewHolder(@NonNull View itemView) {
|
public RevViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
|
title = itemView.findViewById(R.id.rev_item_title);
|
||||||
|
detail = itemView.findViewById(R.id.rev_item_detail);
|
||||||
|
revId = itemView.findViewById(R.id.rev_item_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,8 +58,9 @@ public class ViewerMainActivity extends AppCompatActivity {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Navigation
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.replace(R.id.nav_host_fragment, ComponentViewerTopFragment.newInstance(documentId))
|
.replace(R.id.nav_host_fragment, ComponentViewerTopFragment.newInstance(documentId))
|
||||||
.commitNow();
|
.commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,45 +3,46 @@ package one.nem.lacerta.component.viewer;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
import one.nem.lacerta.vcs.LacertaVcs;
|
||||||
|
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
* Use the {@link ViewerVcsRevListFragment#newInstance} factory method to
|
* Use the {@link ViewerVcsRevListFragment#newInstance} factory method to
|
||||||
* create an instance of this fragment.
|
* create an instance of this fragment.
|
||||||
*/
|
*/
|
||||||
|
@AndroidEntryPoint
|
||||||
public class ViewerVcsRevListFragment extends Fragment {
|
public class ViewerVcsRevListFragment extends Fragment {
|
||||||
|
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
@Inject
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
LacertaVcsFactory lacertaVcsFactory;
|
||||||
private static final String ARG_PARAM1 = "param1";
|
|
||||||
private static final String ARG_PARAM2 = "param2";
|
|
||||||
|
|
||||||
// TODO: Rename and change types of parameters
|
@Inject
|
||||||
private String mParam1;
|
LacertaLogger logger;
|
||||||
private String mParam2;
|
|
||||||
|
LacertaVcs lacertaVcs;
|
||||||
|
|
||||||
|
private String documentId;
|
||||||
|
|
||||||
public ViewerVcsRevListFragment() {
|
public ViewerVcsRevListFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static ViewerVcsRevListFragment newInstance(String documentId) {
|
||||||
* 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 ViewerVcsRevListFragment.
|
|
||||||
*/
|
|
||||||
// TODO: Rename and change types and number of parameters
|
|
||||||
public static ViewerVcsRevListFragment newInstance(String param1, String param2) {
|
|
||||||
ViewerVcsRevListFragment fragment = new ViewerVcsRevListFragment();
|
ViewerVcsRevListFragment fragment = new ViewerVcsRevListFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(ARG_PARAM1, param1);
|
args.putString("documentId", documentId);
|
||||||
args.putString(ARG_PARAM2, param2);
|
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
@ -49,10 +50,6 @@ public class ViewerVcsRevListFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (getArguments() != null) {
|
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,4 +58,38 @@ public class ViewerVcsRevListFragment extends Fragment {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
return inflater.inflate(R.layout.fragment_viewer_vcs_rev_list, container, false);
|
return inflater.inflate(R.layout.fragment_viewer_vcs_rev_list, container, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
// Init arg
|
||||||
|
if (getArguments() != null) {
|
||||||
|
this.documentId = getArguments().getString("documentId");
|
||||||
|
logger.debug("ViewerVcsRevListFragment", "documentId: " + documentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init vcs
|
||||||
|
lacertaVcs = lacertaVcsFactory.create(documentId);
|
||||||
|
|
||||||
|
// Init view
|
||||||
|
RecyclerView recyclerView = view.findViewById(R.id.rev_list);
|
||||||
|
|
||||||
|
// Init adapter
|
||||||
|
RevAdapter revAdapter = new RevAdapter();
|
||||||
|
|
||||||
|
// Set adapter
|
||||||
|
recyclerView.setAdapter(revAdapter);
|
||||||
|
|
||||||
|
// Set layout manager
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
|
lacertaVcs.getRevisionHistory().thenAccept(revModels -> {
|
||||||
|
logger.debug("ViewerVcsRevListFragment", "revModels.size(): " + revModels.size());
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
revAdapter.setRevModels(revModels);
|
||||||
|
revAdapter.notifyDataSetChanged();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -5,10 +5,8 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ViewerVcsRevListFragment">
|
tools:context=".ViewerVcsRevListFragment">
|
||||||
|
|
||||||
<!-- TODO: Update blank fragment layout -->
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
<TextView
|
android:id="@+id/rev_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
android:text="@string/hello_blank_fragment" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
|
@ -15,7 +15,7 @@
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/item_title"
|
android:id="@+id/rev_item_title"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/item_detail"
|
android:id="@+id/rev_item_detail"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
|
@ -34,10 +34,10 @@
|
||||||
android:textColor="@color/colorOnSurfaceSecondary"
|
android:textColor="@color/colorOnSurfaceSecondary"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/item_title" />
|
app:layout_constraintTop_toBottomOf="@+id/rev_item_title" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/item_rev_id"
|
android:id="@+id/rev_item_id"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
android:textColor="@color/colorOnSurfaceSecondary"
|
android:textColor="@color/colorOnSurfaceSecondary"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/item_detail" />
|
app:layout_constraintTop_toBottomOf="@+id/rev_item_detail" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
7
component/viewer/src/main/res/menu/viewer_menu.xml
Normal file
7
component/viewer/src/main/res/menu/viewer_menu.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_open_vcs_rev_list"
|
||||||
|
android:title="Open VCS Rev List" />
|
||||||
|
|
||||||
|
</menu>
|
|
@ -1,11 +1,21 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/component_viewer_navigation"
|
android:id="@+id/component_viewer_navigation"
|
||||||
app:startDestination="@id/componentViewerTopFragment">
|
app:startDestination="@id/componentViewerTopFragment">
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/componentViewerTopFragment"
|
android:id="@+id/componentViewerTopFragment"
|
||||||
android:name="one.nem.lacerta.component.viewer.ComponentViewerTopFragment"
|
android:name="one.nem.lacerta.component.viewer.ComponentViewerTopFragment"
|
||||||
android:label="ComponentViewerTopFragment" />
|
android:label="ComponentViewerTopFragment" >
|
||||||
|
<action
|
||||||
|
android:id="@+id/action_componentViewerTopFragment_to_viewerVcsRevListFragment"
|
||||||
|
app:destination="@id/viewerVcsRevListFragment" />
|
||||||
|
</fragment>
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/viewerVcsRevListFragment"
|
||||||
|
android:name="one.nem.lacerta.component.viewer.ViewerVcsRevListFragment"
|
||||||
|
android:label="fragment_viewer_vcs_rev_list"
|
||||||
|
tools:layout="@layout/fragment_viewer_vcs_rev_list" />
|
||||||
</navigation>
|
</navigation>
|
|
@ -11,6 +11,10 @@ public class FeatureSwitch {
|
||||||
public static boolean enableDebugMenu = false;
|
public static boolean enableDebugMenu = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Vcs {
|
||||||
|
public static boolean disableBranchDisplay = true;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Setting {
|
public static class Setting {
|
||||||
public static boolean showDisplayMenu = false;
|
public static boolean showDisplayMenu = false;
|
||||||
public static boolean showDataMenu = false;
|
public static boolean showDataMenu = false;
|
||||||
|
|
|
@ -133,6 +133,7 @@ public class LacertaVcsImpl implements LacertaVcs {
|
||||||
List<VcsRevEntity> vcsRevEntities = database.vcsRevDao().findByDocumentId(this.documentId);
|
List<VcsRevEntity> vcsRevEntities = database.vcsRevDao().findByDocumentId(this.documentId);
|
||||||
vcsRevEntities.forEach(vcsRevEntity -> {
|
vcsRevEntities.forEach(vcsRevEntity -> {
|
||||||
VcsRevModel vcsRevModel = new VcsRevModel();
|
VcsRevModel vcsRevModel = new VcsRevModel();
|
||||||
|
vcsRevModel.setId(vcsRevEntity.id);
|
||||||
vcsRevModel.setDocumentId(vcsRevEntity.documentId);
|
vcsRevModel.setDocumentId(vcsRevEntity.documentId);
|
||||||
vcsRevModel.setBranchName(vcsRevEntity.branchName);
|
vcsRevModel.setBranchName(vcsRevEntity.branchName);
|
||||||
vcsRevModel.setCommitMessage(vcsRevEntity.commitMessage);
|
vcsRevModel.setCommitMessage(vcsRevEntity.commitMessage);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user