Merge pull request #78 from lacerta-doc/feature/home/add_document_history

ドキュメント履歴をホームに追加
This commit is contained in:
ろむねこ 2024-01-18 18:19:49 +09:00 committed by GitHub
commit 3d2cc5ac05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 222 additions and 13 deletions

View File

@ -4,6 +4,7 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="jbr-17" /> <option name="gradleJvm" value="jbr-17" />
<option name="modules"> <option name="modules">

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -14,5 +14,7 @@ public class LacertaApplication extends Application {
// DynamicColorを有効化 // DynamicColorを有効化
DynamicColors.applyToActivitiesIfAvailable(this); DynamicColors.applyToActivitiesIfAvailable(this);
} }
} }

View File

@ -35,6 +35,8 @@ public class MainActivity extends AppCompatActivity {
NavigationUI.setupWithNavController(bottomNavigationView, navController); NavigationUI.setupWithNavController(bottomNavigationView, navController);
Toast.makeText(this, "testMessage", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "testMessage", Toast.LENGTH_SHORT).show();
} }
} }

View File

@ -23,4 +23,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" /> app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,4 +1,5 @@
plugins { plugins {
id 'com.google.dagger.hilt.android'
id 'com.android.library' id 'com.android.library'
} }
@ -29,6 +30,8 @@ dependencies {
implementation libs.androidx.appcompat implementation libs.androidx.appcompat
implementation libs.com.google.android.material implementation libs.com.google.android.material
implementation project(path: ':feature:debug')
implementation project(path: ':utils')
testImplementation libs.junit testImplementation libs.junit
androidTestImplementation libs.androidx.test.ext.junit androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.espresso.core androidTestImplementation libs.androidx.test.espresso.core
@ -38,6 +41,18 @@ dependencies {
implementation libs.navigation.ui implementation libs.navigation.ui
implementation libs.navigation.dynamic.features.fragment implementation libs.navigation.dynamic.features.fragment
// DI
implementation libs.com.google.dagger.hilt.android
annotationProcessor libs.com.google.dagger.hilt.compiler
// shared // shared
implementation project(':shared:ui') implementation project(':shared:ui')
// DI
implementation project(':data')
//model
implementation project(':model')
implementation "androidx.recyclerview:recyclerview:1.3.2"
} }

View File

@ -22,5 +22,7 @@ public class ExampleInstrumentedTest {
// Context of the app under test. // Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("one.nem.lacerta.feature.home.test", appContext.getPackageName()); assertEquals("one.nem.lacerta.feature.home.test", appContext.getPackageName());
} }
} }

View File

@ -1,20 +1,40 @@
package one.nem.lacerta.feature.home; package one.nem.lacerta.feature.home;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import androidx.fragment.app.Fragment;
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 androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
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.model.ListItem;
import one.nem.lacerta.model.document.DocumentMeta;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
* Use the {@link HomeTopFragment#newInstance} factory method to * Use the {@link HomeTopFragment#newInstance} factory method to
* create an instance of this fragment. * create an instance of this fragment.
*/ */
@AndroidEntryPoint
public class HomeTopFragment extends Fragment { public class HomeTopFragment extends Fragment {
@Inject
LacertaLibrary lacertaLibrary;
// TODO: Rename parameter arguments, choose names that match // TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM1 = "param1";
@ -46,12 +66,15 @@ public class HomeTopFragment extends Fragment {
return fragment; return fragment;
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (getArguments() != null) { if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1); mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2); mParam2 = getArguments().getString(ARG_PARAM2);
} }
} }
@ -59,6 +82,42 @@ public class HomeTopFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_home_top, container, false); View view = inflater.inflate(R.layout.fragment_home_top, container, false);
}
} // List<DocumentMeta> metas = document.getAllDocumentMetas(100);
List<ListItem> listItem = lacertaLibrary.getRecentDocument(100).getListItems();
Log.d("docs", Integer.toString(listItem.size()));
RecyclerView recyclerView = view.findViewById(R.id.item_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
MyAdapter myAdapter = new MyAdapter(listItems);
recyclerView.setAdapter(myAdapter);
return view;
}
String pageTitle;
String pageId;
ArrayList listItems;
String title;
String description;
String itemId;
}

View File

@ -0,0 +1,70 @@
package one.nem.lacerta.feature.home;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.document.DocumentMeta;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyAdapterViewHolder> {
ArrayList<ListItem> listItems;
public MyAdapter(ArrayList<ListItem> ListItem) {
// this.listItem = listItem;
}
@NonNull
@Override
public MyAdapterViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_home_document, parent, false);
return new MyAdapterViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull MyAdapterViewHolder holder, int position) {
holder.title.setText(listItems.get(position).getTitle());
holder.description.setText(listItems.get(position).getDescription());
}
@Override
public int getItemCount() {
return listItems.size();
}
public class MyAdapterViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView description;
public MyAdapterViewHolder(@NonNull View itemView) {
super(itemView);
title = itemView.findViewById(R.id.debug_menu_item_title);
description = itemView.findViewById(R.id.debug_menu_item_description);
}
}
}

View File

@ -3,12 +3,19 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".HomeTopFragment"> tools:context=".HomeTopFragment"
tools:ignore="ExtraText">
<!-- TODO: Update blank fragment layout --> <!-- TODO: Update blank fragment layout -->
<TextView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/item_recycler_view"
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" />
</androidx.recyclerview.widget.RecyclerView>
</FrameLayout> </FrameLayout>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content"
android:padding="16dp">
<TextView
android:id="@+id/debug_menu_item_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginEnd="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/debug_menu_item_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" />
<TextView
android:id="@+id/debug_menu_item_updated_at_home"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="Updated at: aaaaaaaaaa"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="my_recycler_view" type="id" />
<item name="TITLE" type="id" />
<item name="textView" type="id" />
</resources>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View File

@ -1,4 +1,5 @@
<resources> <resources>
<!-- TODO: Remove or change this placeholder text --> <!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string> <string name="hello_blank_fragment">Hello blank fragment</string>
<string name="textview">TextView</string>
</resources> </resources>

View File

@ -25,6 +25,8 @@ import one.nem.lacerta.data.Document;
import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.tag.DocumentTag; import one.nem.lacerta.model.document.tag.DocumentTag;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
* Use the {@link LibraryTopFragment#newInstance} factory method to * Use the {@link LibraryTopFragment#newInstance} factory method to

View File

@ -73,4 +73,6 @@ public class DocumentDetail {
this.pages = pages; this.pages = pages;
} }
}
}