From b852e9b7ee2f989591f954dc9ec88bc36eaf2347 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 01:05:45 +0900 Subject: [PATCH 1/9] =?UTF-8?q?RevListFragment=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../viewer/ViewerVcsRevListFragment.java | 64 +++++++++++++++++++ .../layout/fragment_viewer_vcs_rev_list.xml | 14 ++++ 2 files changed, 78 insertions(+) create mode 100644 component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java create mode 100644 component/viewer/src/main/res/layout/fragment_viewer_vcs_rev_list.xml diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java new file mode 100644 index 00000000..f859747e --- /dev/null +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java @@ -0,0 +1,64 @@ +package one.nem.lacerta.component.viewer; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * A simple {@link Fragment} subclass. + * Use the {@link ViewerVcsRevListFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class ViewerVcsRevListFragment extends Fragment { + + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; + + public ViewerVcsRevListFragment() { + // Required empty public constructor + } + + /** + * 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(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_viewer_vcs_rev_list, container, false); + } +} \ No newline at end of file diff --git a/component/viewer/src/main/res/layout/fragment_viewer_vcs_rev_list.xml b/component/viewer/src/main/res/layout/fragment_viewer_vcs_rev_list.xml new file mode 100644 index 00000000..019260c9 --- /dev/null +++ b/component/viewer/src/main/res/layout/fragment_viewer_vcs_rev_list.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file From f0ed4327ca4b0663d1daa792dc8f200efc7b8713 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 01:13:00 +0900 Subject: [PATCH 2/9] =?UTF-8?q?Model=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/model/VcsRevModel.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 model/src/main/java/one/nem/lacerta/model/VcsRevModel.java diff --git a/model/src/main/java/one/nem/lacerta/model/VcsRevModel.java b/model/src/main/java/one/nem/lacerta/model/VcsRevModel.java new file mode 100644 index 00000000..a819179c --- /dev/null +++ b/model/src/main/java/one/nem/lacerta/model/VcsRevModel.java @@ -0,0 +1,80 @@ +package one.nem.lacerta.model; + +import java.util.ArrayList; +import java.util.Date; + +public class VcsRevModel { + + String id; + + String documentId; + + String branchName; + + String commitMessage; + + Date createdAt; + + ArrayList logIds; + + public VcsRevModel(String id, String documentId, String branchName, String commitMessage, Date createdAt, ArrayList logIds) { + this.id = id; + this.documentId = documentId; + this.branchName = branchName; + this.commitMessage = commitMessage; + this.createdAt = createdAt; + this.logIds = logIds; + } + + // Empty constructor + public VcsRevModel() { + } + + public String getId() { + return id; + } + + public String getDocumentId() { + return documentId; + } + + public String getBranchName() { + return branchName; + } + + public String getCommitMessage() { + return commitMessage; + } + + public Date getCreatedAt() { + return createdAt; + } + + public ArrayList getLogIds() { + return logIds; + } + + public void setId(String id) { + this.id = id; + } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public void setBranchName(String branchName) { + this.branchName = branchName; + } + + public void setCommitMessage(String commitMessage) { + this.commitMessage = commitMessage; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public void setLogIds(ArrayList logIds) { + this.logIds = logIds; + } +} From b13f048c7e8dea21b8e6b1a5aabf44d580c519e8 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 01:15:46 +0900 Subject: [PATCH 3/9] =?UTF-8?q?Adapter=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/feature/library/RevAdapter.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 feature/library/src/main/java/one/nem/lacerta/feature/library/RevAdapter.java diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/RevAdapter.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/RevAdapter.java new file mode 100644 index 00000000..589c157c --- /dev/null +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/RevAdapter.java @@ -0,0 +1,51 @@ +package one.nem.lacerta.feature.library; + +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; + +import one.nem.lacerta.model.VcsRevModel; + +public class RevAdapter extends RecyclerView.Adapter{ + + private ArrayList revModels; + + public RevAdapter(ArrayList revModels) { + this.revModels = revModels; + } + + public RevAdapter() { + } + + public void setRevModels(ArrayList revModels) { + this.revModels = revModels; + } + + + @NonNull + @Override + public RevAdapter.RevViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return null; + } + + @Override + public void onBindViewHolder(@NonNull RevAdapter.RevViewHolder holder, int position) { + + } + + @Override + public int getItemCount() { + return 0; + } + + class RevViewHolder extends RecyclerView.ViewHolder { + + public RevViewHolder(@NonNull View itemView) { + super(itemView); + } + } +} From 07e14eb90c4701b8c9c4f4d24b98366037e9af4a Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 01:27:11 +0900 Subject: [PATCH 4/9] =?UTF-8?q?getRevisionHistoryByDocumentId=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/vcs/LacertaVcs.java | 7 ++++++ .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java index 1f5d31ea..4874bd7b 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -1,5 +1,10 @@ package one.nem.lacerta.vcs; +import java.util.ArrayList; +import java.util.concurrent.CompletableFuture; + +import one.nem.lacerta.model.VcsRevModel; + public interface LacertaVcs { // Actions @@ -13,6 +18,8 @@ public interface LacertaVcs { public void generateRevisionAtCurrent(String message); + public CompletableFuture> getRevisionHistoryByDocumentId(String documentId); + // debug public void printLog(); diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java index 89cd8d2d..347c138a 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java @@ -3,11 +3,13 @@ package one.nem.lacerta.vcs.impl; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.concurrent.CompletableFuture; import javax.inject.Inject; import dagger.assisted.Assisted; import dagger.assisted.AssistedInject; +import one.nem.lacerta.model.VcsRevModel; import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.entity.VcsLogEntity; import one.nem.lacerta.source.database.entity.VcsRevEntity; @@ -122,6 +124,26 @@ public class LacertaVcsImpl implements LacertaVcs { logger.debug(TAG, "New revision inserted: " + vcsRevEntity.id); } + @Override + public CompletableFuture> getRevisionHistoryByDocumentId(String documentId) { + return CompletableFuture.supplyAsync(() -> { + logger.debug(TAG, "getRevisionHistoryByDocumentId"); + ArrayList vcsRevModels = new ArrayList<>(); + + List vcsRevEntities = database.vcsRevDao().findByDocumentId(documentId); + vcsRevEntities.forEach(vcsRevEntity -> { + VcsRevModel vcsRevModel = new VcsRevModel(); + vcsRevModel.setDocumentId(vcsRevEntity.documentId); + vcsRevModel.setBranchName(vcsRevEntity.branchName); + vcsRevModel.setCommitMessage(vcsRevEntity.commitMessage); + vcsRevModel.setLogIds(vcsRevEntity.logIds); + vcsRevModels.add(vcsRevModel); + }); + + return vcsRevModels; + }); + } + @Override public void printLog() { logger.debug(TAG, "printLog"); From 15d4a369d8c5d04f58a6e5a59278a687251e06fe Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 01:27:20 +0900 Subject: [PATCH 5/9] =?UTF-8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/component/viewer}/RevAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {feature/library/src/main/java/one/nem/lacerta/feature/library => component/viewer/src/main/java/one/nem/lacerta/component/viewer}/RevAdapter.java (96%) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/RevAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java similarity index 96% rename from feature/library/src/main/java/one/nem/lacerta/feature/library/RevAdapter.java rename to component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java index 589c157c..74736547 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/RevAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java @@ -1,4 +1,4 @@ -package one.nem.lacerta.feature.library; +package one.nem.lacerta.component.viewer; import android.view.View; import android.view.ViewGroup; From 791084b7375cf9e604ac25e51009497a880330ce Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 01:28:22 +0900 Subject: [PATCH 6/9] =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/viewer/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/component/viewer/build.gradle b/component/viewer/build.gradle index cf2bb069..93006a1e 100644 --- a/component/viewer/build.gradle +++ b/component/viewer/build.gradle @@ -54,4 +54,6 @@ dependencies { implementation project(':model') + implementation project(':vcs') + } \ No newline at end of file From 6c50675938d31efee4e48e7f448f98ff0b7ec5d9 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 01:29:30 +0900 Subject: [PATCH 7/9] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java | 2 +- .../main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java index 4874bd7b..664c45e1 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -18,7 +18,7 @@ public interface LacertaVcs { public void generateRevisionAtCurrent(String message); - public CompletableFuture> getRevisionHistoryByDocumentId(String documentId); + public CompletableFuture> getRevisionHistory(); // debug diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java index 347c138a..e04c7e49 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java @@ -125,12 +125,12 @@ public class LacertaVcsImpl implements LacertaVcs { } @Override - public CompletableFuture> getRevisionHistoryByDocumentId(String documentId) { + public CompletableFuture> getRevisionHistory() { return CompletableFuture.supplyAsync(() -> { logger.debug(TAG, "getRevisionHistoryByDocumentId"); ArrayList vcsRevModels = new ArrayList<>(); - List vcsRevEntities = database.vcsRevDao().findByDocumentId(documentId); + List vcsRevEntities = database.vcsRevDao().findByDocumentId(this.documentId); vcsRevEntities.forEach(vcsRevEntity -> { VcsRevModel vcsRevModel = new VcsRevModel(); vcsRevModel.setDocumentId(vcsRevEntity.documentId); From af8935cd7f6dd89ae8f21f9ccb9723a1735e863c Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 01:46:47 +0900 Subject: [PATCH 8/9] =?UTF-8?q?=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0?= =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6=E3=83=88=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/layout/viewer_rev_list_item.xml | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 component/viewer/src/main/res/layout/viewer_rev_list_item.xml diff --git a/component/viewer/src/main/res/layout/viewer_rev_list_item.xml b/component/viewer/src/main/res/layout/viewer_rev_list_item.xml new file mode 100644 index 00000000..c3e56be3 --- /dev/null +++ b/component/viewer/src/main/res/layout/viewer_rev_list_item.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file From b820f4200705388b5b877a8e8b24ab206ba7feea Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 02:04:25 +0900 Subject: [PATCH 9/9] =?UTF-8?q?iroiro,=20=E3=82=B3=E3=83=9F=E3=83=83?= =?UTF-8?q?=E3=83=88=E5=B1=A5=E6=AD=B4=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=A7?= =?UTF-8?q?=E3=81=8D=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 --- .../viewer/ComponentViewerTopFragment.java | 41 ++++++++++ .../lacerta/component/viewer/RevAdapter.java | 35 ++++++++- .../component/viewer/ViewerMainActivity.java | 3 +- .../viewer/ViewerVcsRevListFragment.java | 77 +++++++++++++------ .../layout/fragment_viewer_vcs_rev_list.xml | 8 +- .../main/res/layout/viewer_rev_list_item.xml | 10 +-- .../viewer/src/main/res/menu/viewer_menu.xml | 7 ++ .../component_viewer_navigation.xml | 12 ++- .../one/nem/lacerta/utils/FeatureSwitch.java | 4 + .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 1 + 10 files changed, 160 insertions(+), 38 deletions(-) create mode 100644 component/viewer/src/main/res/menu/viewer_menu.xml diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java index 89ba6954..e3f71bb7 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java @@ -3,7 +3,9 @@ package one.nem.lacerta.component.viewer; import android.graphics.Bitmap; import android.os.Bundle; +import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; +import androidx.navigation.Navigation; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -67,6 +69,10 @@ public class ComponentViewerTopFragment extends Fragment { // Inflate the layout for this fragment 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.setLayoutManager(new LinearLayoutManager(getContext())); ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(fileName -> { @@ -85,4 +91,39 @@ public class ComponentViewerTopFragment extends Fragment { 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; + } + }); + }); + } } \ No newline at end of file diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java index 74736547..bee4308d 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java @@ -1,14 +1,18 @@ package one.nem.lacerta.component.viewer; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import one.nem.lacerta.model.VcsRevModel; +import one.nem.lacerta.utils.FeatureSwitch; public class RevAdapter extends RecyclerView.Adapter{ @@ -29,23 +33,48 @@ public class RevAdapter extends RecyclerView.Adapter{ @NonNull @Override 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 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 public int getItemCount() { - return 0; + if (revModels == null) { + return 0; + } else { + return revModels.size(); + } } class RevViewHolder extends RecyclerView.ViewHolder { + TextView title; + + TextView detail; + + TextView revId; + public RevViewHolder(@NonNull View 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); } } -} +} \ No newline at end of file diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java index e6fcdb43..6ef85637 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java @@ -58,8 +58,9 @@ public class ViewerMainActivity extends AppCompatActivity { finish(); } + // Navigation getSupportFragmentManager().beginTransaction() .replace(R.id.nav_host_fragment, ComponentViewerTopFragment.newInstance(documentId)) - .commitNow(); + .commit(); } } \ No newline at end of file diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java index f859747e..237c1564 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java @@ -3,45 +3,46 @@ 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 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. * Use the {@link ViewerVcsRevListFragment#newInstance} factory method to * create an instance of this fragment. */ +@AndroidEntryPoint public class ViewerVcsRevListFragment extends Fragment { - // TODO: Rename parameter arguments, choose names that match - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER - private static final String ARG_PARAM1 = "param1"; - private static final String ARG_PARAM2 = "param2"; + @Inject + LacertaVcsFactory lacertaVcsFactory; - // TODO: Rename and change types of parameters - private String mParam1; - private String mParam2; + @Inject + LacertaLogger logger; + + LacertaVcs lacertaVcs; + + private String documentId; public ViewerVcsRevListFragment() { // Required empty public constructor } - /** - * 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) { + public static ViewerVcsRevListFragment newInstance(String documentId) { ViewerVcsRevListFragment fragment = new ViewerVcsRevListFragment(); Bundle args = new Bundle(); - args.putString(ARG_PARAM1, param1); - args.putString(ARG_PARAM2, param2); + args.putString("documentId", documentId); fragment.setArguments(args); return fragment; } @@ -49,10 +50,6 @@ public class ViewerVcsRevListFragment extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (getArguments() != null) { - mParam1 = getArguments().getString(ARG_PARAM1); - mParam2 = getArguments().getString(ARG_PARAM2); - } } @Override @@ -61,4 +58,38 @@ public class ViewerVcsRevListFragment extends Fragment { // Inflate the layout for this fragment 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(); + }); + }); + } } \ No newline at end of file diff --git a/component/viewer/src/main/res/layout/fragment_viewer_vcs_rev_list.xml b/component/viewer/src/main/res/layout/fragment_viewer_vcs_rev_list.xml index 019260c9..c6de6685 100644 --- a/component/viewer/src/main/res/layout/fragment_viewer_vcs_rev_list.xml +++ b/component/viewer/src/main/res/layout/fragment_viewer_vcs_rev_list.xml @@ -5,10 +5,8 @@ android:layout_height="match_parent" tools:context=".ViewerVcsRevListFragment"> - - - + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/component/viewer/src/main/res/layout/viewer_rev_list_item.xml b/component/viewer/src/main/res/layout/viewer_rev_list_item.xml index c3e56be3..bd938d79 100644 --- a/component/viewer/src/main/res/layout/viewer_rev_list_item.xml +++ b/component/viewer/src/main/res/layout/viewer_rev_list_item.xml @@ -15,7 +15,7 @@ app:layout_constraintTop_toTopOf="parent"> + app:layout_constraintTop_toBottomOf="@+id/rev_item_title" /> + app:layout_constraintTop_toBottomOf="@+id/rev_item_detail" /> diff --git a/component/viewer/src/main/res/menu/viewer_menu.xml b/component/viewer/src/main/res/menu/viewer_menu.xml new file mode 100644 index 00000000..cc8a206d --- /dev/null +++ b/component/viewer/src/main/res/menu/viewer_menu.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/component/viewer/src/main/res/navigation/component_viewer_navigation.xml b/component/viewer/src/main/res/navigation/component_viewer_navigation.xml index 0c821755..a8cd6b96 100644 --- a/component/viewer/src/main/res/navigation/component_viewer_navigation.xml +++ b/component/viewer/src/main/res/navigation/component_viewer_navigation.xml @@ -1,11 +1,21 @@ + android:label="ComponentViewerTopFragment" > + + + \ No newline at end of file diff --git a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java index 5d8dbc57..718c1aa8 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java +++ b/utils/src/main/java/one/nem/lacerta/utils/FeatureSwitch.java @@ -11,6 +11,10 @@ public class FeatureSwitch { public static boolean enableDebugMenu = false; } + public static class Vcs { + public static boolean disableBranchDisplay = true; + } + public static class Setting { public static boolean showDisplayMenu = false; public static boolean showDataMenu = false; diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java index e04c7e49..63da3858 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java @@ -133,6 +133,7 @@ public class LacertaVcsImpl implements LacertaVcs { List vcsRevEntities = database.vcsRevDao().findByDocumentId(this.documentId); vcsRevEntities.forEach(vcsRevEntity -> { VcsRevModel vcsRevModel = new VcsRevModel(); + vcsRevModel.setId(vcsRevEntity.id); vcsRevModel.setDocumentId(vcsRevEntity.documentId); vcsRevModel.setBranchName(vcsRevEntity.branchName); vcsRevModel.setCommitMessage(vcsRevEntity.commitMessage);