Compare commits

..
Author SHA1 Message Date
r-ca 3a979b7dab WIP 2024-01-19 17:18:34 +09:00
r-ca f1d8a3341e padding追加 2024-01-19 16:59:12 +09:00
r-ca 462495b173 radius変更 2024-01-19 16:53:36 +09:00
r-ca 74d1011412 fix 2024-01-19 16:53:15 +09:00
r-ca 52d2a244a0 WIP 2024-01-19 16:36:44 +09:00
r-ca 1b050f5d3c リソースファイル追加tuika 2024-01-19 16:19:17 +09:00
r-ca 2cec483288 MaterialToolBarへ変更 2024-01-19 16:16:49 +09:00
r-ca 10019cb86b タイトルを中央へ WIP 2024-01-19 16:12:41 +09:00
r-ca 83806e0d90 仮置きアイテム追加 2024-01-19 16:08:50 +09:00
r-ca 30661e1a2b 実装テスト 2024-01-19 16:08:41 +09:00
r-ca 26326024e0 仮置き用リソース追加 2024-01-19 16:06:44 +09:00
r-ca b0bd74af5a 全体のUIを修正 WIP 2024-01-19 16:04:10 +09:00
110 changed files with 707 additions and 2722 deletions

No files matched your search

+2 -2
View File
@@ -4,10 +4,10 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-01-20T07:15:21.179573376Z">
<DropdownSelection timestamp="2023-12-18T03:36:14.973846Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="LocalEmulator" identifier="path=/home/rca/.android/avd/Pixel_3a_API_34_extension_level_7_x86_64.avd" />
<DeviceId pluginId="PhysicalDevice" identifier="serial=ZY22H7V3G7" />
</handle>
</Target>
</DropdownSelection>
+1 -1
View File
@@ -4,6 +4,7 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
@@ -22,7 +23,6 @@
<option value="$PROJECT_DIR$/feature/library" />
<option value="$PROJECT_DIR$/feature/scan" />
<option value="$PROJECT_DIR$/feature/search" />
<option value="$PROJECT_DIR$/feature/setting" />
<option value="$PROJECT_DIR$/model" />
<option value="$PROJECT_DIR$/processor" />
<option value="$PROJECT_DIR$/shared" />
+1 -1
View File
@@ -1,6 +1,6 @@
<project version="4">
<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" />
</component>
<component name="ProjectType">
-5
View File
@@ -74,12 +74,7 @@ dependencies {
implementation project(':feature:library')
implementation project(':feature:scan')
implementation project(':feature:debug') // デバッグメニュー
implementation project(':feature:setting') // 設定画面
implementation project(':data')
implementation project(':shared:ui')
implementation project(':model')
implementation project(':utils')
}
@@ -1,11 +1,11 @@
package one.nem.lacerta;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.NavigationUI;
@@ -13,47 +13,34 @@ import androidx.navigation.ui.NavigationUI;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Gravity;
import android.widget.TextView;
import android.widget.Toast;
import one.nem.lacerta.model.FragmentNavigation;
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
import one.nem.lacerta.utils.FeatureSwitch;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.shape.CornerFamily;
import com.google.android.material.shape.MaterialShapeDrawable;
import com.google.android.material.shape.ShapeAppearanceModel;
import java.io.NotActiveException;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.utils.repository.SharedPrefUtils;
import javax.inject.Inject;
@AndroidEntryPoint
public class MainActivity extends AppCompatActivity implements FragmentNavigation {
@Inject
SharedPrefUtils sharedPrefUtils;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
// Initialize app
if (sharedPrefUtils.getIsFirstLaunch()) initializeApp();
// Init navigation
try {
FragmentManager supportFragmentManager = getSupportFragmentManager();
NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment);
assert navHostFragment != null;
NavController navController = navHostFragment.getNavController();
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
NavigationUI.setupWithNavController(bottomNavigationView, navController);
}
catch (Exception e) {
@@ -63,95 +50,40 @@ public class MainActivity extends AppCompatActivity implements FragmentNavigatio
finish(); // Exit app
}
// Apply feature switch
applyFeatureSwitch(bottomNavigationView, FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch, one.nem.lacerta.feature.search.R.id.feature_search_navigation);
applyFeatureSwitch(bottomNavigationView, FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu, one.nem.lacerta.feature.debug.R.id.feature_debug_navigation);
// Set navigation bar color
getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurfaceVariant));
// Set status bar color
getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface));
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
private void initializeApp() {
Log.d("Init", "Initializing app");
// Set feature switch override to default value
sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch);
sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu);
// // Create a new TextView
// TextView toolbarTitle = new TextView(this);
// // Set the text and center it in the TextView
// toolbarTitle.setText("App Name");
// toolbarTitle.setTextColor(Color.WHITE);
// toolbarTitle.setTextSize(20);
// toolbarTitle.setLayoutParams(new Toolbar.LayoutParams(Toolbar.LayoutParams.WRAP_CONTENT,
// Toolbar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
//
// // Set the TextView as the title
// toolbar.addView(toolbarTitle);
// Set isFirstLaunch to false
sharedPrefUtils.setIsFirstLaunch(false);
}
float radius = getResources().getDimension(one.nem.lacerta.shared.ui.R.dimen.toolbar_corner_radius);
private void applyFeatureSwitch(BottomNavigationView bottomNavigationView, FeatureSwitchOverride featureSwitchOverride, boolean defaultValue, int menuId) {
boolean isEnabled = FeatureSwitch.Meta.canOverrideSwitch ? sharedPrefUtils.getFeatureSwitchOverride(featureSwitchOverride) : defaultValue;
if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId);
}
MaterialShapeDrawable materialShapeDrawable = (MaterialShapeDrawable)toolbar.getBackground();
materialShapeDrawable.setShapeAppearanceModel(materialShapeDrawable.getShapeAppearanceModel()
.toBuilder()
.setAllCorners(CornerFamily.ROUNDED,radius)
.build());
// Set the MaterialShapeDrawable as the background of the Toolbar
@Override
public void navigateToFragment(Fragment fragment) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
.addToBackStack(null)
.commit();
}
DrawerLayout drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, one.nem.lacerta.shared.ui.R.string.placeholder, one.nem.lacerta.shared.ui.R.string.placeholder);
drawer.addDrawerListener(toggle);
toggle.syncState();
@Override
public void navigateToFragment(Fragment fragment, boolean addToBackStack) {
if (addToBackStack) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
.addToBackStack(null)
.commit();
} else {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
.commit();
}
}
@Override
public void navigateToFragment(Fragment fragment, boolean addToBackStack, boolean clearBackStack) {
if (clearBackStack) {
getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
if (addToBackStack) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
.addToBackStack(null)
.commit();
} else {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
.commit();
}
}
public void navigateToFragmentAlternate(Fragment fragment, boolean addToBackStack) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// get the current fragment
Fragment currentFragment = getSupportFragmentManager().getPrimaryNavigationFragment();
// hide the current fragment
if (currentFragment != null) {
transaction.hide(currentFragment);
}
// Add the new fragment
transaction.add(R.id.nav_host_fragment, fragment);
// Add the transaction to the back stack if needed
if (addToBackStack) {
transaction.addToBackStack(null);
}
// Commit the transaction
transaction.commit();
// Update the primary navigation fragment
getSupportFragmentManager().beginTransaction().setPrimaryNavigationFragment(fragment).commit();
// Set the app name in the middle of the toolbar
getSupportActionBar().setTitle("App Name");
}
}
+54 -27
View File
@@ -1,37 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Theme.Lacerta"
tools:context=".MainActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@+id/bottom_nav"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/main_nav"
tools:layout="@layout/fragment_home_top" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorSecondaryContainer"
app:itemIconTint="@color/colorOnSecondaryContainer"
app:itemTextColor="@color/colorOnSecondaryContainer"
app:itemActiveIndicatorStyle="@style/Lacerta.Custom.Indicator"
app:labelVisibilityMode="selected"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_nav_menu" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent">
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?attr/colorSecondaryContainer"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_margin="8dp"
app:titleCentered="true" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@+id/bottom_nav"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/app_bar_layout"
app:navGraph="@navigation/main_nav"
tools:layout="@layout/fragment_debug_menu_container" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_nav_menu"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- NavigationView for the navigation drawer -->
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/drawer_menu" />
</androidx.drawerlayout.widget.DrawerLayout>
+1 -6
View File
@@ -19,11 +19,6 @@
<item
android:id="@id/feature_debug_navigation"
android:icon="@drawable/developer_mode_24px"
android:title="@string/debug_menu_title" />
<item
android:id="@id/feature_setting_navigation"
android:icon="@drawable/settings_24px"
android:title="@string/setting_title"/>
android:title="@string/debug_menu_title"/>
</menu>
@@ -2,7 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/item_placeholder"
android:id="@+id/nav_home"
android:icon="@drawable/developer_mode_24px"
android:title="@string/placeholder" />
</menu>
+1 -4
View File
@@ -2,17 +2,14 @@
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/app_main_nav"
app:startDestination="@id/feature_home_navigation">
app:startDestination="@id/feature_debug_navigation">
<include app:graph="@navigation/feature_debug_navigation" />
<include app:graph="@navigation/feature_library_navigation" />
<include app:graph="@navigation/feature_home_navigation" />
<include app:graph="@navigation/feature_search_navigation" />
<include app:graph="@navigation/feature_setting_navigation" />
</navigation>
+1 -3
View File
@@ -4,7 +4,7 @@ plugins {
android {
namespace 'one.nem.lacerta.component.common'
compileSdk 34
compileSdk 33
defaultConfig {
minSdk 26
@@ -32,6 +32,4 @@ dependencies {
testImplementation libs.junit
androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.espresso.core
implementation project(':shared:ui')
}
+1 -1
View File
@@ -5,7 +5,7 @@ plugins {
android {
namespace 'one.nem.lacerta.component.scanner'
compileSdk 34
compileSdk 33
defaultConfig {
minSdk 26
@@ -1,6 +1,5 @@
package one.nem.lacerta.component.scanner;
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
@@ -23,7 +22,6 @@ import com.websitebeaver.documentscanner.DocumentScanner;
import java.util.ArrayList;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import javax.inject.Inject;
@@ -154,35 +152,21 @@ public class ScannerManagerActivity extends AppCompatActivity {
private void saveNewDocument() {
logger.debug(TAG, "saveNewDocument");
// Deprecatedだが、中断機能が存在しないので操作をブロックする目的で(意図的に)使用
ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("保存中..."); // TODO-rca: テキストをリソースに移動
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
dialog.show();
DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする
document.createDocument(documentMeta).thenAccept((documentDetail) -> {
Bitmap[] bitmaps = new Bitmap[croppedImages.size()];
croppedImages.toArray(bitmaps);
logger.debug(TAG, "bitmaps.length: " + bitmaps.length);
addPagesToDocumentDetail(documentDetail, bitmaps).join();
document.updateDocument(documentDetail).join();
dialog.dismiss();
DocumentDetail documentDetail = document.createDocument(documentMeta);
Bitmap[] bitmaps = new Bitmap[this.croppedImages.size()];
this.croppedImages.toArray(bitmaps);
try {
documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps);
Toast.makeText(this, "Saved.", Toast.LENGTH_SHORT).show();
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit");
lacertaVcsFactory.create(documentDetail.getMeta().getId()).printLog(); // Debug
lacertaVcsFactory.create(documentDetail.getMeta().getId()).printRev(); // Debug
finish();
});
}
private CompletableFuture<Void> addPagesToDocumentDetail(DocumentDetail documentDetail, Bitmap[] bitmaps) {
return CompletableFuture.runAsync(() -> {
try {
document.updateDocument(documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps).getDocumentDetail()).join();
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit");
} catch (Exception e) {
logger.error(TAG, "Error: " + e.getMessage());
logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a");
}
});
} catch (Exception e) {
logger.error(TAG, "Error: " + e.getMessage());
logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a");
}
}
private void insertToExistDocument() {
+1 -23
View File
@@ -1,11 +1,10 @@
plugins {
alias(libs.plugins.com.android.library)
id 'com.google.dagger.hilt.android'
}
android {
namespace 'one.nem.lacerta.component.viewer'
compileSdk 34
compileSdk 33
defaultConfig {
minSdk 26
@@ -30,28 +29,7 @@ dependencies {
implementation libs.androidx.appcompat
implementation libs.com.google.android.material
implementation libs.androidx.activity
implementation libs.androidx.constraintlayout
testImplementation libs.junit
androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.espresso.core
// Navigation
implementation libs.navigation.fragment
implementation libs.navigation.ui
implementation libs.navigation.dynamic.features.fragment
// DI
implementation libs.com.google.dagger.hilt.android
annotationProcessor libs.com.google.dagger.hilt.compiler
// shared
implementation project(':shared:ui')
implementation project(':utils')
implementation project(':data')
implementation project(':model')
}
@@ -1,10 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity
android:name=".ViewerMainActivity"
android:exported="false" />
</application>
</manifest>
@@ -1,88 +0,0 @@
package one.nem.lacerta.component.viewer;
import android.graphics.Bitmap;
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 java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.page.Page;
import one.nem.lacerta.utils.LacertaLogger;
/**
* A simple {@link Fragment} subclass.
* Use the {@link ComponentViewerTopFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class ComponentViewerTopFragment extends Fragment {
@Inject
Document document;
@Inject
LacertaLogger logger;
private static final String TAG = "ComponentViewerTopFragment";
private String documentId;
public ComponentViewerTopFragment() {
// Required empty public constructor
}
public static ComponentViewerTopFragment newInstance(String documentId) {
ComponentViewerTopFragment fragment = new ComponentViewerTopFragment();
Bundle args = new Bundle();
args.putString("documentId", documentId);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
documentId = getArguments().getString("documentId");
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_component_viewer_top, container, false);
RecyclerView recyclerView = view.findViewById(R.id.body_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(fileName -> {
Toast.makeText(getContext(), fileName, Toast.LENGTH_SHORT).show();
});
recyclerView.setAdapter(viewerBodyAdapter);
document.getDocument(documentId).thenAccept(documentDetail -> {
ArrayList<Page> pages = documentDetail.getPages();
logger.debug(TAG, "pages.size(): " + pages.size());
viewerBodyAdapter.setPages(pages);
getActivity().runOnUiThread(() -> {
viewerBodyAdapter.notifyItemRangeChanged(0, pages.size());
});
});
return view;
}
}
@@ -1,5 +0,0 @@
package one.nem.lacerta.component.viewer;
public interface ItemClickListener {
void onItemClick(String fileName); // DEBUG
}
@@ -1,66 +0,0 @@
package one.nem.lacerta.component.viewer;
import android.graphics.Bitmap;
import android.media.Image;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import one.nem.lacerta.model.document.page.Page;
public class ViewerBodyAdapter extends RecyclerView.Adapter<ViewerBodyAdapter.ViewHolder>{
ArrayList<Page> pages;
ItemClickListener listener;
public ViewerBodyAdapter(ArrayList<Page> pages, ItemClickListener listener){
this.pages = pages;
this.listener = listener;
}
public ViewerBodyAdapter(ItemClickListener listener){
this.pages = new ArrayList<>();
this.listener = listener;
}
public void setPages(ArrayList<Page> pages){
this.pages = pages;
}
@NonNull
@Override
public ViewerBodyAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = View.inflate(parent.getContext(), R.layout.viewer_body_list_item, null);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewerBodyAdapter.ViewHolder holder, int position) {
Bitmap bitmap = pages.get(position).getBitmap();
holder.image.setImageBitmap(bitmap);
holder.itemView.setOnClickListener(v -> {
});
}
@Override
public int getItemCount() {
return pages.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
ImageView image;
public ViewHolder(@NonNull View itemView) {
super(itemView);
image = itemView.findViewById(R.id.imageView);
}
}
}
@@ -1,65 +0,0 @@
package one.nem.lacerta.component.viewer;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.FragmentManager;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.NavigationUI;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.utils.LacertaLogger;
@AndroidEntryPoint
public class ViewerMainActivity extends AppCompatActivity {
@Inject
LacertaLogger logger;
@Inject
public ViewerMainActivity() {
}
// Variables
private static final String TAG = "ViewerMainActivity";
String documentId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_viewer_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
Intent intent = getIntent();
try {
documentId = intent.getStringExtra("documentId");
}
catch (Exception e) {
logger.error(TAG, "Failed to get documentId from intent");
logger.error(TAG, "Searchable Error code: " + "f64c21a2-391f-4c40-92f6-183da459de21");
Toast.makeText(this, "Failed to get documentId from intent", Toast.LENGTH_LONG).show();
finish();
}
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, ComponentViewerTopFragment.newInstance(documentId))
.commitNow();
}
}
@@ -1,20 +0,0 @@
package one.nem.lacerta.component.viewer.model;
import android.graphics.Bitmap;
public class ViewerBodyListItem {
Bitmap image;
public ViewerBodyListItem(Bitmap image) {
this.image = image;
}
public Bitmap getImage() {
return image;
}
public void setImage(Bitmap image) {
this.image = image;
}
}
@@ -1,21 +0,0 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ViewerMainActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="one.nem.lacerta.component.viewer.ComponentViewerTopFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -1,51 +0,0 @@
<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.CollapsingToolbarLayout
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.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/body_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</FrameLayout>
@@ -1,19 +0,0 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="8dp"
android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/backgrounds/scenic" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/component_viewer_navigation"
app:startDestination="@id/componentViewerTopFragment">
<fragment
android:id="@+id/componentViewerTopFragment"
android:name="one.nem.lacerta.component.viewer.ComponentViewerTopFragment"
android:label="ComponentViewerTopFragment" />
</navigation>
@@ -1,4 +0,0 @@
<resources>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
@@ -2,7 +2,6 @@ package one.nem.lacerta.data;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.DocumentDetail;
@@ -14,13 +13,13 @@ import one.nem.lacerta.model.document.tag.DocumentTag;
*/
public interface Document {
CompletableFuture<DocumentDetail> createDocument(DocumentMeta meta);
DocumentDetail createDocument(DocumentMeta meta);
CompletableFuture<DocumentDetail> createDocument();
DocumentDetail createDocument();
CompletableFuture<Void> deleteDocument(String documentId);
void deleteDocument(String documentId);
CompletableFuture<Void> updateDocument(DocumentDetail detail);
void updateDocument(DocumentMeta meta, DocumentDetail detail);
CompletableFuture<DocumentDetail> getDocument(String documentId);
DocumentDetail getDocument(String documentId);
}
@@ -1,29 +1,25 @@
package one.nem.lacerta.data;
import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.PublicPath;
import one.nem.lacerta.model.document.DocumentDetail;
public interface LacertaLibrary {
// Get History
CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit);
CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit, int offset);
ArrayList<ListItem> getRecentDocument(int limit);
ArrayList<ListItem> getRecentDocument(int limit, int offset);
// Get Library Page
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit);
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset);
// Create Folder
CompletableFuture<String> createFolder(String parentId, String name);
// Get Public Path
CompletableFuture<PublicPath> getPublicPath(String itemId, ListItemType itemType);
// Get Library page
LibraryItemPage getLibraryPage(int limit);
LibraryItemPage getLibraryPage(int limit, int offset);
LibraryItemPage getLibraryPage(String pageId, int limit);
LibraryItemPage getLibraryPage(String pageId, int limit, int offset);
// GetDocument
DocumentDetail getDocumentDetailById(String id); // TODO-rca: Documentに統合する
}
@@ -1,10 +1,8 @@
package one.nem.lacerta.data.impl;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
// Hilt
import javax.inject.Inject;
@@ -18,20 +16,13 @@ import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.DocumentDetail;
// Lacerta/source
import one.nem.lacerta.model.document.internal.XmlMetaModel;
import one.nem.lacerta.model.document.internal.XmlMetaPageModel;
import one.nem.lacerta.model.document.page.Page;
import one.nem.lacerta.source.database.LacertaDatabase;
import one.nem.lacerta.source.database.entity.DocumentEntity;
// Lacerta/utils
import one.nem.lacerta.source.file.FileManager;
import one.nem.lacerta.source.file.factory.FileManagerFactory;
import one.nem.lacerta.utils.LacertaLogger;
// Lacerta/vcs
import one.nem.lacerta.utils.XmlMetaParser;
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
import one.nem.lacerta.vcs.LacertaVcs;
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
@@ -49,14 +40,6 @@ public class DocumentImpl implements Document {
@Inject
LacertaVcsFactory vcsFactory;
@Inject
FileManagerFactory fileManagerFactory;
@Inject
DeviceInfoUtils deviceInfoUtils;
@Inject
XmlMetaParser xmlMetaParser;
@Inject
public DocumentImpl() {
@@ -66,37 +49,35 @@ public class DocumentImpl implements Document {
@Override
public CompletableFuture<DocumentDetail> createDocument(DocumentMeta meta) {
return CompletableFuture.supplyAsync(() -> {
DocumentDetail detail = new DocumentDetail();
detail.setMeta(meta);
detail.setPages(new ArrayList<>());
// Create DocumentEntity
DocumentEntity documentEntity = new DocumentEntity();
documentEntity.id = meta.getId();
documentEntity.title = meta.getTitle();
documentEntity.author = meta.getAuthor();
documentEntity.defaultBranch = meta.getDefaultBranch();
documentEntity.updatedAt = meta.getUpdatedAt();
documentEntity.createdAt = meta.getCreatedAt();
documentEntity.parentId = meta.getParentId();
documentEntity.tagIds = meta.getTagIds();
public DocumentDetail createDocument(DocumentMeta meta) {
DocumentDetail detail = new DocumentDetail();
detail.setMeta(meta);
detail.setPages(new ArrayList<>());
database.documentDao().insert(documentEntity);
// TODO-rca: UIスレッドから追い出す
// Vcs
LacertaVcs vcs = vcsFactory.create(meta.getId());
vcs.createDocument(meta.getId());
// Create DocumentEntity
DocumentEntity documentEntity = new DocumentEntity();
documentEntity.id = meta.getId();
documentEntity.title = meta.getTitle();
documentEntity.author = meta.getAuthor();
documentEntity.defaultBranch = meta.getDefaultBranch();
documentEntity.updatedAt = meta.getUpdatedAt();
documentEntity.createdAt = meta.getCreatedAt();
documentEntity.publicPath = meta.getPath().getStringPath();
documentEntity.tagIds = meta.getTagIds();
// XmlMeta
updateXmlMeta(detail).join();
database.documentDao().insert(documentEntity);
return detail;
});
// Vcs
LacertaVcs vcs = vcsFactory.create(meta.getId());
vcs.createDocument(meta.getId());
return detail;
}
@Override
public CompletableFuture<DocumentDetail> createDocument() {
public DocumentDetail createDocument() {
DocumentMeta meta = new DocumentMeta();
meta.setId(UUID.randomUUID().toString());
meta.setTitle("New Document");
@@ -104,118 +85,23 @@ public class DocumentImpl implements Document {
meta.setDefaultBranch("master");
meta.setUpdatedAt(new Date());
meta.setCreatedAt(new Date());
meta.setParentId(null);
meta.setPath(new PublicPath().getRoot()); // TODO-rca: 2回インスタンスを生成していて無駄なのでなんとかする
meta.setTags(new ArrayList<>());
return createDocument(meta);
}
@Override
public CompletableFuture<Void> deleteDocument(String documentId) {
return CompletableFuture.supplyAsync(() -> {
return null;
});
public void deleteDocument(String documentId) {
}
@Override
public CompletableFuture<Void> updateDocument(DocumentDetail detail) {
return CompletableFuture.supplyAsync(() -> {
updateXmlMeta(detail).join();
return null;
});
public void updateDocument(DocumentMeta meta, DocumentDetail detail) {
}
@Override
public CompletableFuture<DocumentDetail> getDocument(String documentId) {
return CompletableFuture.supplyAsync(() -> {
DocumentEntity documentEntity = database.documentDao().findById(documentId);
if (documentEntity == null) {
throw new IllegalArgumentException("documentId is not found");
}
DocumentMeta meta = new DocumentMeta();
meta.setId(documentEntity.id);
meta.setTitle(documentEntity.title);
meta.setAuthor(documentEntity.author);
meta.setDefaultBranch(documentEntity.defaultBranch);
meta.setUpdatedAt(documentEntity.updatedAt);
meta.setCreatedAt(documentEntity.createdAt);
meta.setParentId(documentEntity.parentId);
meta.setTags(new ArrayList<>()); // TODO-rca: タグを取得する
DocumentDetail detail = new DocumentDetail();
getPagesByXmlMeta(documentId).thenCompose(xmlMetaPageModels -> getPagesByXmlMetaPageModel(documentId, xmlMetaPageModels)).thenAccept(pages -> {
logger.debug(TAG, "pages: " + pages.size());
detail.setMeta(meta);
detail.setPages(pages);
}).join();
return detail;
});
}
private CompletableFuture<ArrayList<XmlMetaPageModel>> getPagesByXmlMeta(String documentId) {
return CompletableFuture.supplyAsync(() -> {
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
try {
ArrayList<XmlMetaPageModel> xmlMetaPageModels = xmlMetaParser.deserialize(fileManager.resolve(documentId).loadXml("meta.xml")).getPages();
// Debug
logger.debug(TAG, "xmlMetaPageModels: " + xmlMetaPageModels.size());
for (XmlMetaPageModel xmlMetaPageModel : xmlMetaPageModels) {
logger.debug(TAG, "\txmlMetaPageModel: " + xmlMetaPageModel.getFilename());
}
return xmlMetaPageModels;
} catch (IOException e) {
logger.error(TAG, "DocumentMeta parse error");
logger.trace(TAG, e.getMessage());
logger.e_code("db18c04a-1625-4871-9e4e-918d805568ac");
}
return null;
});
}
private CompletableFuture<ArrayList<Page>> getPagesByXmlMetaPageModel(String documentId, ArrayList<XmlMetaPageModel> xmlMetaPageModels) {
return CompletableFuture.supplyAsync(() -> {
ArrayList<Page> pages = new ArrayList<>();
FileManager fileManager;
try {
fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory()).resolve(documentId);
} catch (IOException e) {
logger.error(TAG, "FileManager resolve error");
logger.trace(TAG, e.getMessage());
logger.e_code("2235e8ee-4177-46f8-af6b-084381b202e6");
return null;
}
for (XmlMetaPageModel xmlMetaPageModel : xmlMetaPageModels) {
try {
pages.add(new Page(xmlMetaPageModel.getFilename(), fileManager.resolve("raw").loadBitmap(xmlMetaPageModel.getFilename())));
} catch (IOException e) {
logger.error(TAG, "Bitmap decode error");
logger.trace(TAG, e.getMessage());
logger.e_code("3bba8c8f-90fb-4a24-a726-7ea201929f8b");
return null;
}
}
return pages;
});
}
private CompletableFuture<Void> updateXmlMeta(DocumentDetail documentDetail) {
return CompletableFuture.supplyAsync(() -> {
// TODO-rca: リビジョンIDを検証する, 挿入する
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
ArrayList<XmlMetaPageModel> xmlMetaPageModels = new ArrayList<>();
for (Page page : documentDetail.getPages()) {
xmlMetaPageModels.add(new XmlMetaPageModel(page.getFileName()));
}
try {
fileManager.createDirectoryIfNotExist(documentDetail.getMeta().getId()).resolve(documentDetail.getMeta().getId())
.createFileIfNotExist("meta.xml").resolve("meta.xml").saveXml(xmlMetaParser.serialize(new XmlMetaModel("revisionId_PLACEHOLDER", xmlMetaPageModels)));
} catch (IOException e) {
logger.error(TAG, "DocumentMeta serialize error");
logger.trace(TAG, e.getMessage());
logger.e_code("e3b4d0c9-5b7e-4b7e-9e9a-5b8b8b8b8b8b");
}
return null;
});
public DocumentDetail getDocument(String documentId) {
return null;
}
}
@@ -1,13 +1,8 @@
package one.nem.lacerta.data.impl;
import java.text.DateFormat;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import javax.inject.Inject;
@@ -15,186 +10,63 @@ import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.PublicPath;
import one.nem.lacerta.model.document.DocumentDetail;
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.utils.FeatureSwitch;
import one.nem.lacerta.utils.LacertaLogger;
public class LacertaLibraryImpl implements LacertaLibrary {
@Inject
LacertaLogger logger;
LacertaDatabase database;
@Inject
public LacertaLibraryImpl(LacertaLogger logger, LacertaDatabase database) {
this.logger = logger;
this.database = database;
LacertaDatabase database;
@Override
public ArrayList<ListItem> getRecentDocument(int limit) {
List<DocumentEntity> documentEntities = database.documentDao().getRecentDocument(limit);
ArrayList<ListItem> listItems = new ArrayList<>();
for (DocumentEntity documentEntity : documentEntities) {
ListItem listItem = new ListItem();
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
listItem.setTitle(documentEntity.title);
listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt));
listItem.setItemId(documentEntity.id);
listItems.add(listItem);
}
return listItems;
}
@Override
public CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit) {
return CompletableFuture.supplyAsync(() -> {
// 5秒フリーズさせる
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
List<DocumentEntity> documentEntities = database.documentDao().getRecentDocument(limit);
ArrayList<ListItem> listItems = new ArrayList<>();
for (DocumentEntity documentEntity : documentEntities) {
ListItem listItem = new ListItem();
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
listItem.setTitle(documentEntity.title);
listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt));
listItem.setItemId(documentEntity.id);
listItems.add(listItem);
}
return listItems;
});
}
@Override
public CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit, int offset) {
public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
return null; // TODO-rca: Implement
}
@Override
public CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit) {
return CompletableFuture.supplyAsync(() -> {
LibraryItemPage libraryItemPage = new LibraryItemPage();
List<FolderEntity> folderEntities;
List<DocumentEntity> documentEntities;
if (pageId == null) { // When root folder
libraryItemPage.setPageTitle("ライブラリ");
libraryItemPage.setPageId(null);
libraryItemPage.setParentId(null);
folderEntities = database.folderDao().findRootFolders();
documentEntities = database.documentDao().findRootDocuments();
} else {
FolderEntity folderEntity = database.folderDao().findById(pageId);
if (folderEntity == null) {
logger.warn("LacertaLibraryImpl", pageId + " is not found.");
return null;
}
libraryItemPage.setPageTitle(folderEntity.name);
libraryItemPage.setPageId(folderEntity.id);
libraryItemPage.setParentId(folderEntity.parentId);
folderEntities = database.folderDao().findByParentId(pageId);
documentEntities = database.documentDao().findByParentId(pageId);
}
ArrayList<ListItem> listItems = new ArrayList<>();
for (FolderEntity childFolderEntity : folderEntities) {
logger.debug("LacertaLibraryImpl", "childFolderEntity.name: " + childFolderEntity.name);
ListItem listItem = new ListItem();
listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
listItem.setTitle(childFolderEntity.name);
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
listItem.setItemId(childFolderEntity.id);
listItems.add(listItem);
}
for (DocumentEntity documentEntity : documentEntities) {
logger.debug("LacertaLibraryImpl", "documentEntity.title: " + documentEntity.title);
ListItem listItem = new ListItem();
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
listItem.setTitle(documentEntity.title);
// listItem.setDescription(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm").format(documentEntity.updatedAt.toInstant()));
listItem.setItemId(documentEntity.id);
listItems.add(listItem);
}
libraryItemPage.setListItems(listItems);
logger.debug("LacertaLibraryImpl", "libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
return libraryItemPage;
});
public LibraryItemPage getLibraryPage(int limit) {
return null;
}
@Override
public CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset) {
return CompletableFuture.supplyAsync(() -> {
return null;
});
public LibraryItemPage getLibraryPage(int limit, int offset) {
return null;
}
@Override
public CompletableFuture<String> createFolder(String parentId, String name) {
return CompletableFuture.supplyAsync(() -> {
FolderEntity folderEntity = new FolderEntity();
folderEntity.id = UUID.randomUUID().toString();
folderEntity.name = name;
folderEntity.parentId = parentId;
database.folderDao().insert(folderEntity);
return folderEntity.id;
});
public LibraryItemPage getLibraryPage(String pageId, int limit) {
return null;
}
@Override
public CompletableFuture<PublicPath> getPublicPath(String itemId, ListItemType itemType) {
return CompletableFuture.supplyAsync(() -> {
if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
DocumentEntity documentEntity = database.documentDao().findById(itemId);
if (documentEntity == null) {
logger.warn("LacertaLibraryImpl", itemId + " is not found.");
return null;
}
PublicPath publicPath = recursiveResolve(documentEntity.parentId);
publicPath.resolve(documentEntity.title);
return publicPath;
} else if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
FolderEntity folderEntity = database.folderDao().findById(itemId);
if (folderEntity == null) {
return null;
}
return recursiveResolve(folderEntity.id);
} else {
logger.warn("LacertaLibraryImpl", "Unknown ListItemType: " + itemType);
return null;
}
});
public LibraryItemPage getLibraryPage(String pageId, int limit, int offset) {
return null;
}
/**
* 再帰的にパスを解決する
*
* @param folderId
* @return
*/
private PublicPath recursiveResolve(String folderId) {
String current = folderId;
boolean continueFlag = true;
ArrayList<String> folderNames = new ArrayList<>();
while (continueFlag) {
FolderEntity folderEntity = database.folderDao().findById(current);
if (folderEntity == null) { // 存在しないフォルダIDが指定された場合
continueFlag = false;
} else {
folderNames.add(folderEntity.name);
current = folderEntity.parentId;
if (current == null) { // ルートフォルダに到達した場合
continueFlag = false;
}
}
}
// フォルダ名を逆順にしてListに変換
Collections.reverse(folderNames);
List<String> folderNamesReversed = new ArrayList<>(folderNames);
return new PublicPath(folderNamesReversed);
@Override
public DocumentDetail getDocumentDetailById(String id) {
return null;
}
}
@@ -1,219 +1,219 @@
//package one.nem.lacerta.data.impl;
//
//import one.nem.lacerta.data.LacertaLibrary;
//import one.nem.lacerta.model.LibraryItemPage;
//import one.nem.lacerta.model.ListItem;
//import one.nem.lacerta.model.ListItemType;
//import one.nem.lacerta.model.document.DocumentDetail;
//
//import one.nem.lacerta.model.document.DocumentMeta;
//import one.nem.lacerta.model.document.path.DocumentPath;
//import one.nem.lacerta.utils.LacertaLogger;
//
//import com.github.javafaker.DateAndTime;
//import com.github.javafaker.Faker;
//
//import java.text.DateFormat;
//import java.util.ArrayList;
//import java.util.Objects;
//import java.util.UUID;
//
//import javax.inject.Inject;
//
///**
// * LacertaLibraryのスタブ実装
// */
//public class LacertaLibraryStubImpl implements LacertaLibrary {
//
// LacertaLogger logger;
//
// Faker faker;
//
// @Inject
// public LacertaLibraryStubImpl(LacertaLogger logger) {
// faker = new Faker(); // Init Faker
// this.logger = logger;
// logger.debug("LibraryStub", "Initialized");
// }
//
// // Internal Methods
//
// // Generate Stub Data
// private LibraryItemPage generateStubLibraryItemPage(int limit, String pageId) {
// logger.debug("LibraryStub", "generateStubLibraryItemPage");
// ArrayList<ListItem> listItems = new ArrayList<>();
// int itemTotal = faker.number().numberBetween(1, limit); // 実際に返却するアイテム数を決定
// int folderTotal;
// // フォルダ数の抽選
// if (itemTotal > 4) {
// folderTotal = faker.number().numberBetween(1, itemTotal - 2);
// }
// else {
// if (itemTotal > 2) {
// folderTotal = 1;
// }
// else { // ドキュメント数がゼロにならないように
// folderTotal = 0;
// }
// }
// int documentTotal = itemTotal - folderTotal; // ドキュメント数を決定
// logger.debug("LibraryStub", "itemTotal: " + itemTotal);
// logger.debug("LibraryStub", "folderTotal: " + folderTotal);
// logger.debug("LibraryStub", "documentTotal: " + documentTotal);
//
// // フォルダを生成
// for (int i = 0; i < folderTotal; i++) {
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_FOLDER));
// }
// // ドキュメントを生成
// for (int i = 0; i < documentTotal; i++) {
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
// }
//
// LibraryItemPage libraryItemPage = new LibraryItemPage();
// libraryItemPage.setListItems(listItems);
// if (pageId == null) {
// libraryItemPage.setPageId(UUID.randomUUID().toString());
// } else {
// libraryItemPage.setPageId(pageId);
// }
// libraryItemPage.setPageTitle("FakePage" + faker.number().digits(3));
//
// return libraryItemPage;
// }
//
// private ListItem generateStubListItem(ListItemType itemType) {
// if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
// ListItem listItem = new ListItem();
// listItem.setTitle("FakeFolder" + faker.number().digits(3));
// listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
// listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
// listItem.setItemId(UUID.randomUUID().toString());
// return listItem;
// } else if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
// ListItem listItem = new ListItem();
// listItem.setTitle("FakeDocument" + faker.book().title());
// listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
// listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
// listItem.setItemId(UUID.randomUUID().toString());
// return listItem;
// } else {
// return null;
// }
// }
//
// private LibraryItemPage getRecentDocumentPage(int limit) {
// int itemTotal = faker.number().numberBetween(1, limit);
// ArrayList<ListItem> listItems = new ArrayList<>();
// for (int i = 0; i < itemTotal; i++) {
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
// }
// // DescriptionからDateを抽出して新しい順にソート
// listItems.sort((a, b) -> {
// String aDate = a.getDescription().substring(11);
// String bDate = b.getDescription().substring(11);
// return bDate.compareTo(aDate);
// });
// LibraryItemPage libraryItemPage = new LibraryItemPage();
// libraryItemPage.setListItems(listItems);
// libraryItemPage.setPageId(UUID.randomUUID().toString());
// libraryItemPage.setPageTitle("RecentDocument");
// return libraryItemPage;
// }
//
// private DocumentDetail generateStubDocumentDetail(String id) throws IllegalArgumentException {
//
// if (Objects.isNull(id)) {
// throw new IllegalArgumentException("id is null");
// }
//
// DocumentMeta documentMeta = new DocumentMeta();
// documentMeta.setId(id);
// documentMeta.setTitle("FakeDocument" + faker.book().title());
// documentMeta.setCreatedAt(faker.date().birthday());
// documentMeta.setUpdatedAt(faker.date().birthday()); // TODO-rca: 更新日のほうが古くなることがあるのでなんとかする?
// ArrayList<String> tagIds = new ArrayList<>();
//
// DocumentDetail documentDetail = new DocumentDetail();
// documentDetail.setMeta(documentMeta);
//// documentDetail.setPath(null); // TODO-rca: なんとかする
//// documentDetail.setAuthor(faker.name().fullName());
//// documentDetail.setRepository(null); // TODO-rca: なんとかする
// return documentDetail;
// }
//
// /**
// * 履歴ページを取得する
// * @param limit 取得するアイテム数
// * @return ページオブジェクト
// */
// @Override
// public ArrayList<ListItem> getRecentDocument(int limit) {
// return getRecentDocumentPage(limit).getListItems();
// }
//
// /**
// * 履歴ページを取得する
// * @param limit 取得するアイテム数
// * @param offset 取得するアイテムのオフセット
// * @return ページオブジェクト
// */
// @Override
// public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
// return getRecentDocumentPage(limit).getListItems();
// }
//
// /**
// * ライブラリページを取得する
// * @param limit 取得するアイテム数
// * @return ページオブジェクト
// */
// @Override
// public LibraryItemPage getLibraryPage(int limit) {
// return generateStubLibraryItemPage(limit, null);
// }
//
// /**
// * ライブラリページを取得する
// * @param limit 取得するアイテム数
// * @param offset 取得するアイテムのオフセット
// * @return ページオブジェクト
// */
// @Override
// public LibraryItemPage getLibraryPage(int limit, int offset) {
// return generateStubLibraryItemPage(limit, null);
// }
//
// /**
// * ライブラリページを取得する
// * @param pageId ページID
// * @param limit 取得するアイテム数
// * @return ページオブジェクト
// */
// @Override
// public LibraryItemPage getLibraryPage(String pageId, int limit) {
// return generateStubLibraryItemPage(limit, pageId);
// }
//
// /**
// * ライブラリページを取得する
// * @param pageId ページID
// * @param limit 取得するアイテム数
// * @param offset 取得するアイテムのオフセット
// * @return ページオブジェクト
// */
// @Override
// public LibraryItemPage getLibraryPage(String pageId, int limit, int offset) {
// return generateStubLibraryItemPage(limit, pageId);
// }
//
// /**
// * ドキュメント詳細を取得する
// * @param id ドキュメントID
// * @return ドキュメント詳細オブジェクト
// */
// @Override
// public DocumentDetail getDocumentDetailById(String id) throws IllegalArgumentException {
// return generateStubDocumentDetail(id);
// }
//}
package one.nem.lacerta.data.impl;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.path.DocumentPath;
import one.nem.lacerta.utils.LacertaLogger;
import com.github.javafaker.DateAndTime;
import com.github.javafaker.Faker;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Objects;
import java.util.UUID;
import javax.inject.Inject;
/**
* LacertaLibraryのスタブ実装
*/
public class LacertaLibraryStubImpl implements LacertaLibrary {
LacertaLogger logger;
Faker faker;
@Inject
public LacertaLibraryStubImpl(LacertaLogger logger) {
faker = new Faker(); // Init Faker
this.logger = logger;
logger.debug("LibraryStub", "Initialized");
}
// Internal Methods
// Generate Stub Data
private LibraryItemPage generateStubLibraryItemPage(int limit, String pageId) {
logger.debug("LibraryStub", "generateStubLibraryItemPage");
ArrayList<ListItem> listItems = new ArrayList<>();
int itemTotal = faker.number().numberBetween(1, limit); // 実際に返却するアイテム数を決定
int folderTotal;
// フォルダ数の抽選
if (itemTotal > 4) {
folderTotal = faker.number().numberBetween(1, itemTotal - 2);
}
else {
if (itemTotal > 2) {
folderTotal = 1;
}
else { // ドキュメント数がゼロにならないように
folderTotal = 0;
}
}
int documentTotal = itemTotal - folderTotal; // ドキュメント数を決定
logger.debug("LibraryStub", "itemTotal: " + itemTotal);
logger.debug("LibraryStub", "folderTotal: " + folderTotal);
logger.debug("LibraryStub", "documentTotal: " + documentTotal);
// フォルダを生成
for (int i = 0; i < folderTotal; i++) {
listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_FOLDER));
}
// ドキュメントを生成
for (int i = 0; i < documentTotal; i++) {
listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
}
LibraryItemPage libraryItemPage = new LibraryItemPage();
libraryItemPage.setListItems(listItems);
if (pageId == null) {
libraryItemPage.setPageId(UUID.randomUUID().toString());
} else {
libraryItemPage.setPageId(pageId);
}
libraryItemPage.setPageTitle("FakePage" + faker.number().digits(3));
return libraryItemPage;
}
private ListItem generateStubListItem(ListItemType itemType) {
if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
ListItem listItem = new ListItem();
listItem.setTitle("FakeFolder" + faker.number().digits(3));
listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
listItem.setItemId(UUID.randomUUID().toString());
return listItem;
} else if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
ListItem listItem = new ListItem();
listItem.setTitle("FakeDocument" + faker.book().title());
listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
listItem.setItemId(UUID.randomUUID().toString());
return listItem;
} else {
return null;
}
}
private LibraryItemPage getRecentDocumentPage(int limit) {
int itemTotal = faker.number().numberBetween(1, limit);
ArrayList<ListItem> listItems = new ArrayList<>();
for (int i = 0; i < itemTotal; i++) {
listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
}
// DescriptionからDateを抽出して新しい順にソート
listItems.sort((a, b) -> {
String aDate = a.getDescription().substring(11);
String bDate = b.getDescription().substring(11);
return bDate.compareTo(aDate);
});
LibraryItemPage libraryItemPage = new LibraryItemPage();
libraryItemPage.setListItems(listItems);
libraryItemPage.setPageId(UUID.randomUUID().toString());
libraryItemPage.setPageTitle("RecentDocument");
return libraryItemPage;
}
private DocumentDetail generateStubDocumentDetail(String id) throws IllegalArgumentException {
if (Objects.isNull(id)) {
throw new IllegalArgumentException("id is null");
}
DocumentMeta documentMeta = new DocumentMeta();
documentMeta.setId(id);
documentMeta.setTitle("FakeDocument" + faker.book().title());
documentMeta.setCreatedAt(faker.date().birthday());
documentMeta.setUpdatedAt(faker.date().birthday()); // TODO-rca: 更新日のほうが古くなることがあるのでなんとかする?
ArrayList<String> tagIds = new ArrayList<>();
DocumentDetail documentDetail = new DocumentDetail();
documentDetail.setMeta(documentMeta);
// documentDetail.setPath(null); // TODO-rca: なんとかする
// documentDetail.setAuthor(faker.name().fullName());
// documentDetail.setRepository(null); // TODO-rca: なんとかする
return documentDetail;
}
/**
* 履歴ページを取得する
* @param limit 取得するアイテム数
* @return ページオブジェクト
*/
@Override
public ArrayList<ListItem> getRecentDocument(int limit) {
return getRecentDocumentPage(limit).getListItems();
}
/**
* 履歴ページを取得する
* @param limit 取得するアイテム数
* @param offset 取得するアイテムのオフセット
* @return ページオブジェクト
*/
@Override
public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
return getRecentDocumentPage(limit).getListItems();
}
/**
* ライブラリページを取得する
* @param limit 取得するアイテム数
* @return ページオブジェクト
*/
@Override
public LibraryItemPage getLibraryPage(int limit) {
return generateStubLibraryItemPage(limit, null);
}
/**
* ライブラリページを取得する
* @param limit 取得するアイテム数
* @param offset 取得するアイテムのオフセット
* @return ページオブジェクト
*/
@Override
public LibraryItemPage getLibraryPage(int limit, int offset) {
return generateStubLibraryItemPage(limit, null);
}
/**
* ライブラリページを取得する
* @param pageId ページID
* @param limit 取得するアイテム数
* @return ページオブジェクト
*/
@Override
public LibraryItemPage getLibraryPage(String pageId, int limit) {
return generateStubLibraryItemPage(limit, pageId);
}
/**
* ライブラリページを取得する
* @param pageId ページID
* @param limit 取得するアイテム数
* @param offset 取得するアイテムのオフセット
* @return ページオブジェクト
*/
@Override
public LibraryItemPage getLibraryPage(String pageId, int limit, int offset) {
return generateStubLibraryItemPage(limit, pageId);
}
/**
* ドキュメント詳細を取得する
* @param id ドキュメントID
* @return ドキュメント詳細オブジェクト
*/
@Override
public DocumentDetail getDocumentDetailById(String id) throws IllegalArgumentException {
return generateStubDocumentDetail(id);
}
}
@@ -30,10 +30,9 @@ public class LacertaSearchStubImpl implements LacertaSearch {
*/
@Override
public ArrayList<ListItem> autoSearch(String query, int limit) {
// logger.debug("SearchStub", "autoSearch");
// logger.debug("SearchStub", "query: " + query);
// return library.getLibraryPage(limit).getListItems();
return null;
logger.debug("SearchStub", "autoSearch");
logger.debug("SearchStub", "query: " + query);
return library.getLibraryPage(limit).getListItems();
}
/**
@@ -45,9 +44,8 @@ public class LacertaSearchStubImpl implements LacertaSearch {
*/
@Override
public ArrayList<ListItem> autoSearch(String query, int limit, int offset) {
// logger.debug("SearchStub", "autoSearch");
// logger.debug("SearchStub", "query: " + query);
// return library.getLibraryPage(limit, offset).getListItems();
return null;
logger.debug("SearchStub", "autoSearch");
logger.debug("SearchStub", "query: " + query);
return library.getLibraryPage(limit, offset).getListItems();
}
}
@@ -7,7 +7,7 @@ import dagger.hilt.android.components.FragmentComponent;
import dagger.hilt.migration.DisableInstallInCheck;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.data.impl.LacertaLibraryImpl;
import one.nem.lacerta.data.impl.LacertaLibraryStubImpl;
import one.nem.lacerta.utils.LacertaLogger;
@Module
@@ -16,6 +16,6 @@ import one.nem.lacerta.utils.LacertaLogger;
abstract public class LacertaLibraryModule {
@Binds
public abstract LacertaLibrary bindLacertaLibrary(LacertaLibraryImpl impl);
public abstract LacertaLibrary bindLacertaLibrary(LacertaLibraryStubImpl impl);
}
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
android {
namespace 'one.nem.lacerta.feature.common'
compileSdk 34
compileSdk 33
defaultConfig {
minSdk 26
@@ -57,8 +57,7 @@ public class DebugMenuLibraryItemListPageFragment extends Fragment {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_debug_menu_library_item_list_page, container, false);
// ArrayList<ListItem> listItems = lacertaLibrary.getRecentDocument(10);
ArrayList<ListItem> listItems = new ArrayList<>();
ArrayList<ListItem> listItems = lacertaLibrary.getRecentDocument(10);
for (ListItem listItem : listItems) {
System.out.println(listItem.getTitle());
}
@@ -11,7 +11,6 @@
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginEnd="8dp"
android:text="Placeholder Title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -20,7 +19,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="Placeholder Description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" />
+1 -5
View File
@@ -5,7 +5,7 @@ plugins {
android {
namespace 'one.nem.lacerta.feature.home'
compileSdk 34
compileSdk 33
defaultConfig {
minSdk 26
@@ -55,8 +55,4 @@ dependencies {
implementation project(':model')
implementation "androidx.recyclerview:recyclerview:1.3.2"
implementation project(':component:common')
implementation project(':component:viewer')
}
@@ -1,5 +0,0 @@
package one.nem.lacerta.feature.home;
public interface DocumentSelectListener {
void onDocumentSelect(String documentId);
}
@@ -1,36 +1,21 @@
package one.nem.lacerta.feature.home;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.component.viewer.ViewerMainActivity;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.ListItem;
@@ -49,13 +34,34 @@ public class HomeTopFragment extends Fragment {
@Inject
LacertaLibrary lacertaLibrary;
// 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 HomeTopFragment() {
// Required empty public constructor
}
public static HomeTopFragment newInstance() {
/**
* 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 HomeTopFragment.
*/
// TODO: Rename and change types and number of parameters
public static HomeTopFragment newInstance(String param1, String param2) {
HomeTopFragment fragment = new HomeTopFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@@ -64,46 +70,49 @@ public class HomeTopFragment 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
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
setHasOptionsMenu(true);
return view;
}
// List<DocumentMeta> metas = document.getAllDocumentMetas(100);
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ArrayList<ListItem> listItems = lacertaLibrary.getRecentDocument(100);
RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view);
Log.d("docs", Integer.toString(listItems.size()));
RecyclerView recyclerView = view.findViewById(R.id.item_recycler_view);
ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> {
Log.d("HomeTopFragment", "onViewCreated: " + documentId);
Intent intent = new Intent(getContext(), ViewerMainActivity.class);
intent.putExtra("documentId", documentId);
startActivity(intent);
});
recyclerView.setAdapter(listItemAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> {
listItemAdapter.setListItems(listItems);
getActivity().runOnUiThread(() -> {
listItemAdapter.notifyItemRangeInserted(0, listItems.size());
});
});
}
MyAdapter myAdapter = new MyAdapter(listItems);
recyclerView.setAdapter(myAdapter);
return view;
}
String pageTitle;
String pageId;
ArrayList listItems;
String title;
String description;
String itemId;
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.drawer_menu, menu);
super.onCreateOptionsMenu(menu, inflater);
}
}
@@ -1,73 +0,0 @@
package one.nem.lacerta.feature.home;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import one.nem.lacerta.component.viewer.ViewerMainActivity;
import one.nem.lacerta.model.ListItem;
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
ArrayList<ListItem> listItems;
DocumentSelectListener listener;
public ListItemAdapter(DocumentSelectListener listener){
this.listItems = new ArrayList<>();
this.listener = listener;
}
public void setListItems(ArrayList<ListItem> listItems) {
this.listItems = listItems;
}
@NonNull
@Override
public ListItemAdapter.ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
return new ListItemViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ListItemAdapter.ListItemViewHolder holder, int position) {
ListItem listItem = listItems.get(position);
holder.icon.setImageResource(listItem.getItemType().getIconId());
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
holder.title.setText(listItem.getTitle());
holder.description.setText(listItem.getDescription());
holder.itemView.setOnClickListener( v -> {
Intent intent = new Intent(v.getContext(), ViewerMainActivity.class);
intent.putExtra("documentId", listItem.getItemId());
v.getContext().startActivity(intent);
});
}
@Override
public int getItemCount() {
return listItems.size();
}
public static class ListItemViewHolder extends RecyclerView.ViewHolder{
ImageView icon;
TextView title;
TextView description;
public ListItemViewHolder(@NonNull View itemView) {
super(itemView);
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
}
}
}
@@ -1,50 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeTopFragment"
tools:ignore="ExtraText"
android:background="@color/colorSurface">
<androidx.coordinatorlayout.widget.CoordinatorLayout
<!-- TODO: Update blank fragment layout -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/item_recycler_view"
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.CollapsingToolbarLayout
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="HOGE" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_item_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.recyclerview.widget.RecyclerView>
</FrameLayout>
+1 -3
View File
@@ -5,7 +5,7 @@ plugins {
android {
namespace 'one.nem.lacerta.feature.library'
compileSdk 34
compileSdk 33
defaultConfig {
minSdk 26
@@ -51,7 +51,5 @@ dependencies {
implementation project(':data')
implementation project(':utils')
}
@@ -1,6 +0,0 @@
package one.nem.lacerta.feature.library;
public interface DocumentSelectListener {
void onFolderSelected(String folderId, String folderName);
void onDocumentSelected(String documentId, String documentName);
}
@@ -0,0 +1,38 @@
package one.nem.lacerta.feature.library;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
// LibraryArchiveFragment.java
//画面変移用のコード
//Fragmentへのデータの受け渡し機能
public class LibraryArchiveFragment extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_library_top);
// ここに入力された内容を表示する機能
TextView textView = findViewById(R.id.document_list);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 文字をタップしたときの処理
// 移動先のアクティビティを指定
Intent intent = new Intent(LibraryArchiveFragment.this, LibraryDocFragment.class);
// データを付加する
intent.putExtra("key_name", "value_data");
startActivity(intent);
}
});
}
}
@@ -1,283 +0,0 @@
package one.nem.lacerta.feature.library;
import android.app.AlertDialog;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import org.w3c.dom.Text;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
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.FragmentNavigation;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.PublicPath;
import one.nem.lacerta.utils.LacertaLogger;
/**
* A simple {@link Fragment} subclass.
* Use the {@link LibraryPageFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class LibraryPageFragment extends Fragment {
// Variables
// このインスタンスで表示されているページ
LibraryItemPage libraryItemPage;
// Arguments
String folderId;
String title;
String parentId;
@Inject
LacertaLibrary lacertaLibrary;
@Inject
LacertaLogger logger;
ListItemAdapter listItemAdapter;
public LibraryPageFragment() {
// Required empty public constructor
}
public static LibraryPageFragment newInstance(String folderId, String title, String parentId) {
LibraryPageFragment fragment = new LibraryPageFragment();
Bundle args = new Bundle();
args.putString("folderId", folderId);
args.putString("title", title);
args.putString("publicPath", parentId);
fragment.setArguments(args);
return fragment;
}
public static LibraryPageFragment newInstance(String folderId) { // Back action
LibraryPageFragment fragment = new LibraryPageFragment();
Bundle args = new Bundle();
args.putString("folderId", folderId);
args.putString("title", null);
args.putString("publicPath", null);
fragment.setArguments(args);
return fragment;
}
public static LibraryPageFragment newInstance() {
LibraryPageFragment fragment = new LibraryPageFragment();
Bundle args = new Bundle();
args.putString("folderId", null);
args.putString("title", null);
args.putString("publicPath", null);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
// Set status bar color
AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
// Collapsed
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
} else if (verticalOffset == 0) {
// Expanded
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSurface));
} else {
// Somewhere in between
// Here you can add a color transition if you want
}
}
});
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (getArguments() != null) {
this.folderId = getArguments().getString("folderId"); // Required
if (getArguments().getString("title") == null && getArguments().getString("publicPath") == null) {
this.libraryItemPage = new LibraryItemPage();
} else {
this.title = getArguments().getString("title");
this.parentId = getArguments().getString("publicPath");
}
} else {
logger.debug("LibraryTopFragment", "getArguments() is null(maybe root)");
this.libraryItemPage = new LibraryItemPage();
}
// Toolbar Setup
toolbarSetup(view.findViewById(R.id.library_toolbar), this.folderId != null, this.title != null ? this.title : "ライブラリ");
// RecyclerView Setup
RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view);
this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() {
@Override
public void onFolderSelected(String folderId, String folderName) {
logger.debug("LibraryTopFragment", "Folder selected! folderId: " + folderId + ", folderName: " + folderName);
// // 画面遷移
// FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity();
// // folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親)
// fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage != null ? libraryItemPage.getParentId() : null), false);
Bundle bundle = new Bundle();
bundle.putString("folderId", folderId);
bundle.putString("title", folderName);
bundle.putString("publicPath", libraryItemPage != null ? libraryItemPage.getParentId() : null);
try {
Navigation.findNavController(requireView()).navigate(R.id.action_feature_library_top_fragment_self, bundle);
} catch (IllegalStateException e) {
logger.error("LibraryTopFragment", "IllegalStateException: " + e.getMessage());
}
}
@Override
public void onDocumentSelected(String documentId, String documentName) {
Toast.makeText(getContext(), "Document selected! documentId: " + documentId + ", documentName: " + documentName, Toast.LENGTH_SHORT).show();
}
});
recyclerView.setAdapter(listItemAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// Get library page and update RecyclerView items
lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> {
this.libraryItemPage = libraryItemPage;
if (this.parentId == null) {
this.parentId = libraryItemPage.getParentId();
}
if (this.title == null) {
this.title = libraryItemPage.getPageTitle();
// Toolbar init again
toolbarSetup(view.findViewById(R.id.library_toolbar), this.folderId != null, this.title != null ? this.title : "ライブラリ");
}
logger.debug("LibraryTopFragment", "Item selected! Total item page: " + this.libraryItemPage.getListItems().size());
getActivity().runOnUiThread(() -> { // TODO-rca: 実行条件を考える?
listItemAdapter.notifyItemRangeRemoved(0, this.libraryItemPage.getListItems().size() - 1);
});
listItemAdapter.setLibraryItemPage(this.libraryItemPage);
getActivity().runOnUiThread(() -> {
listItemAdapter.notifyItemRangeInserted(0, this.libraryItemPage.getListItems().size() - 1);
});
});
}
/**
* Currentにフォルダを作成する
*/
private void createFolder(String pageId) {
// TODO-rca: デザインをMaterial Design 3に合わせたカスタムダイアログにする
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle("フォルダの作成");
builder.setMessage("フォルダ名を入力してください");
final android.widget.EditText input = new android.widget.EditText(getContext());
input.setText("フォルダ名");
builder.setView(input);
builder.setPositiveButton("作成", (dialog, which) -> {
lacertaLibrary.createFolder(pageId, input.getText().toString()).thenAccept(folderId -> {
// Refresh
updateItem(pageId);
});
});
builder.setNegativeButton("キャンセル", (dialog, which) -> {
dialog.cancel();
});
builder.show();
}
/**
* RecyclerViewのアイテムを更新する
*/
private void updateItem(String pageId) {
lacertaLibrary.getLibraryPage(pageId, 10).thenAccept(libraryItemPage -> {
this.libraryItemPage = libraryItemPage;
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
getActivity().runOnUiThread(() -> {
listItemAdapter.notifyItemRangeRemoved(0, libraryItemPage.getListItems().size() - 1);
});
listItemAdapter.setLibraryItemPage(libraryItemPage);
getActivity().runOnUiThread(() -> {
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
});
});
}
/**
* 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.dir_menu);
toolbar.setOnMenuItemClickListener(item -> {
if (item.getItemId() == R.id.menu_item_create_new_folder) {
createFolder(this.folderId);
return true;
} else {
return false;
}
});
});
}
}
@@ -0,0 +1,106 @@
package one.nem.lacerta.feature.library;
import android.os.Bundle;
import androidx.annotation.NonNull;
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.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
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.model.document.DocumentMeta;
import one.nem.lacerta.model.document.tag.DocumentTag;
/**
* A simple {@link Fragment} subclass.
* Use the {@link LibraryTopFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class LibraryTopFragment extends Fragment {
// @Inject
// Document document;
// 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 LibraryTopFragment() {
// 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 LibraryTopFragment.
*/
// TODO: Rename and change types and number of parameters
public static LibraryTopFragment newInstance(String param1, String param2) {
LibraryTopFragment fragment = new LibraryTopFragment();
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
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
// Use view.findViewById instead of findViewById
RecyclerView documentRecyclerView = view.findViewById(R.id.document_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
documentRecyclerView.setLayoutManager(layoutManager);
//データを取得
// List<DocumentMeta> metas = document.getAllDocumentMetas(100);
// Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
// Create and set the adapter
// DocumentAdapter adapter = new DocumentAdapter(metas);
// documentRecyclerView.setAdapter(adapter);
// Use a LinearLayoutManager to specify the layout
return view;
}
}
@@ -1,78 +0,0 @@
package one.nem.lacerta.feature.library;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
LibraryItemPage libraryItemPage;
DocumentSelectListener listener;
public ListItemAdapter(DocumentSelectListener listener) {
this.listener = listener;
}
public void setLibraryItemPage(LibraryItemPage libraryItemPage) {
this.libraryItemPage = libraryItemPage;
}
@NonNull
@Override
public ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
return new ListItemViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ListItemViewHolder holder, int position) {
ListItem listItem = libraryItemPage.getListItems().get(position);
holder.icon.setImageResource(listItem.getItemType().getIconId());
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
holder.title.setText(listItem.getTitle());
holder.description.setText(listItem.getDescription());
holder.itemView.setOnClickListener( v -> {
if (listItem.getItemType() == ListItemType.ITEM_TYPE_DOCUMENT) {
listener.onDocumentSelected(listItem.getItemId(), listItem.getTitle());
}
else if (listItem.getItemType() == ListItemType.ITEM_TYPE_FOLDER) {
listener.onFolderSelected(listItem.getItemId(), listItem.getTitle());
}
});
}
@Override
public int getItemCount() {
return this.libraryItemPage == null ? 0
: this.libraryItemPage.getListItems() == null ? 0 : this.libraryItemPage.getListItems().size();
}
public static class ListItemViewHolder extends RecyclerView.ViewHolder{
ImageView icon;
TextView title;
TextView description;
public ListItemViewHolder(@NonNull View itemView) {
super(itemView);
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
}
}
}
@@ -1,50 +1,32 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorSurface">
android:theme="@style/Theme.Lacerta"
tools:context=".LibraryTopFragment">
<androidx.coordinatorlayout.widget.CoordinatorLayout
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:background="@color/colorPrimaryContainer"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="Library"
app:titleTextColor="@color/colorOnPrimaryContainer" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/document_list"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tool_bar" />
<com.google.android.material.appbar.CollapsingToolbarLayout
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/library_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:title="HOGE" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/library_item_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_item_create_new_folder"
android:icon="@drawable/developer_mode_24px"
android:title="@string/app_name"
app:showAsAction="ifRoom"/> <!-- TODO-rca: change this -->
</menu>
@@ -6,17 +6,7 @@
app:startDestination="@id/feature_library_top_fragment">
<fragment
android:id="@+id/feature_library_top_fragment"
android:name="one.nem.lacerta.feature.library.LibraryPageFragment"
android:name="one.nem.lacerta.feature.library.LibraryTopFragment"
android:label="fragment_library_top"
tools:layout="@layout/fragment_library_top" >
<action
android:id="@+id/action_feature_library_top_fragment_self"
app:destination="@id/feature_library_top_fragment"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim"
app:popUpTo="@id/feature_library_top_fragment"
app:popUpToInclusive="false"/>
</fragment>
tools:layout="@layout/fragment_library_top" />
</navigation>
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
android {
namespace 'one.nem.lacerta.feature.scan'
compileSdk 34
compileSdk 33
defaultConfig {
minSdk 26
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
android {
namespace 'one.nem.lacerta.feature.search'
compileSdk 34
compileSdk 33
defaultConfig {
minSdk 26
-1
View File
@@ -1 +0,0 @@
/build
-48
View File
@@ -1,48 +0,0 @@
plugins {
alias(libs.plugins.com.android.library)
}
android {
namespace 'one.nem.lacerta.setting'
compileSdk 34
defaultConfig {
minSdk 26
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation libs.androidx.appcompat
implementation libs.com.google.android.material
testImplementation libs.junit
androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.espresso.core
// Navigation
implementation libs.navigation.fragment
implementation libs.navigation.ui
implementation libs.navigation.dynamic.features.fragment
// DI
implementation libs.com.google.dagger.hilt.android
annotationProcessor libs.com.google.dagger.hilt.compiler
// shared
implementation project(':shared:ui')
}
View File
Whitespace-only changes.
-21
View File
@@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -1,26 +0,0 @@
package one.nem.lacerta.setting;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("one.nem.lacerta.setting.test", appContext.getPackageName());
}
}
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
@@ -1,63 +0,0 @@
package one.nem.lacerta.setting;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import one.nem.lacerta.setting.model.SettingListItem;
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
ArrayList<SettingListItem> listItems;
public ListItemAdapter(ArrayList<SettingListItem> listItems){
this.listItems = listItems;
}
@NonNull
@Override
public ListItemAdapter.ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
return new ListItemViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ListItemAdapter.ListItemViewHolder holder, int position) {
SettingListItem listItem = listItems.get(position);
holder.icon.setImageDrawable(listItem.getIcon());
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
holder.title.setText(listItem.getTitle());
holder.description.setText(listItem.getDescription());
holder.itemView.setOnClickListener( v -> {
Navigation.findNavController(v).navigate(listItem.getDestination());
});
}
@Override
public int getItemCount() {
return listItems.size();
}
public static class ListItemViewHolder extends RecyclerView.ViewHolder{
ImageView icon;
TextView title;
TextView description;
public ListItemViewHolder(@NonNull View itemView) {
super(itemView);
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
}
}
}
@@ -1,43 +0,0 @@
package one.nem.lacerta.setting;
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 SettingAboutPageFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class SettingAboutPageFragment extends Fragment {
public SettingAboutPageFragment() {
// Required empty public constructor
}
public static SettingAboutPageFragment newInstance() {
SettingAboutPageFragment fragment = new SettingAboutPageFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_setting_about_page, container, false);
return view;
}
}
@@ -1,40 +0,0 @@
package one.nem.lacerta.setting;
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 SettingDataPageFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class SettingDataPageFragment extends Fragment {
public SettingDataPageFragment() {
// Required empty public constructor
}
public static SettingDataPageFragment newInstance() {
SettingDataPageFragment fragment = new SettingDataPageFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_setting_data_page, container, false);
}
}
@@ -1,40 +0,0 @@
package one.nem.lacerta.setting;
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 SettingDisplayPageFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class SettingDisplayPageFragment extends Fragment {
public SettingDisplayPageFragment() {
// Required empty public constructor
}
public static SettingDisplayPageFragment newInstance() {
SettingDisplayPageFragment fragment = new SettingDisplayPageFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_setting_display_page, container, false);
}
}
@@ -1,41 +0,0 @@
package one.nem.lacerta.setting;
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 SettingScanPageFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class SettingScanPageFragment extends Fragment {
public SettingScanPageFragment() {
// Required empty public constructor
}
public static SettingScanPageFragment newInstance() {
SettingScanPageFragment fragment = new SettingScanPageFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_setting_scan_page, container, false);
}
}
@@ -1,92 +0,0 @@
package one.nem.lacerta.setting;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
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 java.util.ArrayList;
import one.nem.lacerta.setting.model.SettingListItem;
/**
* A simple {@link Fragment} subclass.
* Use the {@link SettingTopFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class SettingTopFragment extends Fragment {
public SettingTopFragment() {
// Required empty public constructor
}
public static SettingTopFragment newInstance() {
SettingTopFragment fragment = new SettingTopFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_setting_top, container, false);
// Setting items
ArrayList<SettingListItem> settingListItems = new ArrayList<>();
settingListItems.add(
new SettingListItem(
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_display_title),
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_display_description),
ContextCompat.getDrawable(getContext(), one.nem.lacerta.shared.ui.R.drawable.palette_24px),
R.id.action_settingTopFragment_to_settingDisplayPageFragment
)
);
settingListItems.add(
new SettingListItem(
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_data_title),
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_data_description),
ContextCompat.getDrawable(getContext(), one.nem.lacerta.shared.ui.R.drawable.settings_backup_restore_24px),
R.id.action_settingTopFragment_to_settingDataPageFragment
)
);
settingListItems.add(
new SettingListItem(
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_scan_title),
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_scan_description),
ContextCompat.getDrawable(getContext(), one.nem.lacerta.shared.ui.R.drawable.document_scanner_24px),
R.id.action_settingTopFragment_to_settingScanPageFragment
)
);
settingListItems.add(
new SettingListItem(
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_about_title),
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_about_description),
ContextCompat.getDrawable(getContext(), one.nem.lacerta.shared.ui.R.drawable.info_24px),
R.id.action_settingTopFragment_to_settingAboutPageFragment
)
);
// Init RecyclerView
RecyclerView recyclerView = view.findViewById(R.id.setting_item_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(new ListItemAdapter(settingListItems));
return view;
}
}
@@ -1,34 +0,0 @@
package one.nem.lacerta.setting.model;
import android.graphics.drawable.Drawable;
public class SettingListItem {
String title;
String description;
Drawable icon;
int destination;
public SettingListItem(String title, String description, Drawable icon, int destination) {
this.title = title;
this.description = description;
this.icon = icon;
this.destination = destination;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public Drawable getIcon() {
return icon;
}
public int getDestination() {
return destination;
}
}
@@ -1,14 +0,0 @@
<?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"
tools:context=".SettingAboutPageFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
@@ -1,14 +0,0 @@
<?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"
tools:context=".SettingDataPageFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
@@ -1,14 +0,0 @@
<?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"
tools:context=".SettingDisplayPageFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
@@ -1,14 +0,0 @@
<?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"
tools:context=".SettingScanPageFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
@@ -1,50 +0,0 @@
<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.CollapsingToolbarLayout
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="@string/setting_title" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/setting_item_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</FrameLayout>
@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/feature_setting_navigation"
app:startDestination="@id/settingTopFragment">
<fragment
android:id="@+id/settingTopFragment"
android:name="one.nem.lacerta.setting.SettingTopFragment"
android:label="SettingTopFragment" >
<action
android:id="@+id/action_settingTopFragment_to_settingAboutPageFragment"
app:destination="@id/settingAboutPageFragment"
app:enterAnim="@anim/slide_from_right"
app:exitAnim="@anim/slide_to_left"
app:popEnterAnim="@anim/slide_from_left"
app:popExitAnim="@anim/slide_to_right" />
<action
android:id="@+id/action_settingTopFragment_to_settingDisplayPageFragment"
app:destination="@id/settingDisplayPageFragment"
app:enterAnim="@anim/slide_from_right"
app:exitAnim="@anim/slide_to_left"
app:popEnterAnim="@anim/slide_from_left"
app:popExitAnim="@anim/slide_to_right" />
<action
android:id="@+id/action_settingTopFragment_to_settingDataPageFragment"
app:destination="@id/settingDataPageFragment"
app:enterAnim="@anim/slide_from_right"
app:exitAnim="@anim/slide_to_left"
app:popEnterAnim="@anim/slide_from_left"
app:popExitAnim="@anim/slide_to_right" />
<action
android:id="@+id/action_settingTopFragment_to_settingScanPageFragment"
app:destination="@id/settingScanPageFragment"
app:enterAnim="@anim/slide_from_right"
app:exitAnim="@anim/slide_to_left"
app:popEnterAnim="@anim/slide_from_left"
app:popExitAnim="@anim/slide_to_right" />
</fragment>
<fragment
android:id="@+id/settingAboutPageFragment"
android:name="one.nem.lacerta.setting.SettingAboutPageFragment"
android:label="fragment_setting_about_page"
tools:layout="@layout/fragment_setting_about_page" />
<fragment
android:id="@+id/settingDataPageFragment"
android:name="one.nem.lacerta.setting.SettingDataPageFragment"
android:label="fragment_setting_data_page"
tools:layout="@layout/fragment_setting_data_page" />
<fragment
android:id="@+id/settingDisplayPageFragment"
android:name="one.nem.lacerta.setting.SettingDisplayPageFragment"
android:label="fragment_setting_display_page"
tools:layout="@layout/fragment_setting_display_page" />
<fragment
android:id="@+id/settingScanPageFragment"
android:name="one.nem.lacerta.setting.SettingScanPageFragment"
android:label="fragment_setting_scan_page"
tools:layout="@layout/fragment_setting_scan_page" />
</navigation>
@@ -1,4 +0,0 @@
<resources>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
@@ -1,17 +0,0 @@
package one.nem.lacerta.setting;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
@@ -1,13 +0,0 @@
package one.nem.lacerta.model;
import androidx.fragment.app.Fragment;
public interface FragmentNavigation {
void navigateToFragment(Fragment fragment);
void navigateToFragment(Fragment fragment, boolean addToBackStack);
void navigateToFragment(Fragment fragment, boolean addToBackStack, boolean clearBackStack);
void navigateToFragmentAlternate(Fragment fragment, boolean addToBackStack);
}
@@ -6,18 +6,10 @@ public class LibraryItemPage {
String pageTitle;
String pageId;
String parentId;
ArrayList<ListItem> listItems;
// Constructor
public LibraryItemPage(String pageTitle, String pageId, ArrayList<ListItem> listItems, String parentId) {
this.pageTitle = pageTitle;
this.pageId = pageId;
this.listItems = listItems;
this.parentId = parentId;
}
public LibraryItemPage(String pageTitle, String pageId, ArrayList<ListItem> listItems) {
this.pageTitle = pageTitle;
this.pageId = pageId;
@@ -38,10 +30,6 @@ public class LibraryItemPage {
return pageId;
}
public String getParentId() {
return parentId;
}
public ArrayList<ListItem> getListItems() {
return listItems;
}
@@ -56,10 +44,6 @@ public class LibraryItemPage {
this.pageId = pageId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public void setListItems(ArrayList<ListItem> listItems) {
this.listItems = listItems;
}
@@ -1,7 +1,5 @@
package one.nem.lacerta.model;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
@@ -31,31 +29,11 @@ public class PublicPath {
private void resolveInternal(String path) {
if (path.equals("..")) {
this.path.remove(this.path.size() - 1);
} else if (path.equals(".")) {
// do nothing
} else {
this.path.add(path);
add(path);
}
}
public PublicPath parse(String path) {
if (path == null) {
this.path.clear();
this.path.add("/");
} else {
if (path.startsWith("/")) {
this.path.clear();
path = path.substring(1);
}
String[] pathArray = path.split("/");
for (String p : pathArray) {
Log.d("PublicPath", "parse: " + p);
resolveInternal(p);
}
}
return this;
}
public PublicPath resolve(String path) {
resolveInternal(path);
return this;
@@ -37,7 +37,7 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
*/
List<DocumentTag> tags;
String parentId;
PublicPath path;
String author;
@@ -54,7 +54,7 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
this.tags = new ArrayList<>();
this.author = ""; // TODO-rca: 作者のデフォルト値を設定できるようにする
this.defaultBranch = "main"; // TODO-rca: デフォルトブランチのデフォルト値を設定できるようにする
this.parentId = null;
this.path = new PublicPath().getRoot();
this.updatedAt = new Date();
this.createdAt = new Date();
}
@@ -85,13 +85,13 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
this.defaultBranch = defaultBranch;
}
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, List<DocumentTag> tags, String parentId, String author, String defaultBranch) {
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, List<DocumentTag> tags, PublicPath path, String author, String defaultBranch) {
this.id = id;
this.title = title;
this.updatedAt = updatedAt;
this.createdAt = createdAt;
this.tags = tags;
this.parentId = parentId;
this.path = path;
this.author = author;
this.defaultBranch = defaultBranch;
}
@@ -145,10 +145,10 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
}
/**
* ドキュメントの親フォルダのID(String)を取得する
* PublicPathを取得する
*/
public String getParentId() {
return parentId;
public PublicPath getPath() {
return path;
}
/**
@@ -208,11 +208,11 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
}
/**
* ドキュメントの親フォルダのID(String)を設定する
* @param parentId ドキュメントの親フォルダのID
* PublicPathを設定する
* @param path PublicPath
*/
public void setParentId(String parentId) {
this.parentId = parentId;
public void setPath(PublicPath path) {
this.path = path;
}
/**
@@ -1,30 +0,0 @@
package one.nem.lacerta.model.pref;
public enum FeatureSwitchOverride {
ENABLE_DEBUG_MENU("enableDebugMenu"),
ENABLE_SEARCH("enableSearch"),
SHOW_DISPLAY_MENU("showDisplayMenu"),
SHOW_DATA_MENU("showDataMenu"),
SHOW_SCAN_MENU("showScanMenu");
private final String key;
FeatureSwitchOverride(String key) {
this.key = key;
}
public String getKey() {
return key;
}
public static FeatureSwitchOverride fromKey(String key) {
for (FeatureSwitchOverride value : values()) {
if (value.getKey().equals(key)) {
return value;
}
}
return null;
}
}
@@ -7,13 +7,13 @@ import one.nem.lacerta.model.document.DocumentDetail;
public interface DocumentProcessor {
// ページ操作
DocumentProcessor addNewPageToLast(Bitmap bitmap) throws Exception;
DocumentProcessor addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
DocumentProcessor insertPageAtIndex(Bitmap bitmap, int index) throws Exception;
DocumentProcessor removePageAtIndex(int index) throws Exception;
void addNewPageToLast(Bitmap bitmap) throws Exception;
void addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
void insertPageAtIndex(Bitmap bitmap, int index) throws Exception;
void removePageAtIndex(int index) throws Exception;
// 更新
DocumentProcessor updatePageAtIndex(Bitmap bitmap, int index);
void updatePageAtIndex(Bitmap bitmap, int index);
// ページ取得
Bitmap getPageAtIndex(int index);
@@ -70,7 +70,7 @@ public class DocumentProcessorImpl implements DocumentProcessor{
@Override
public DocumentProcessor addNewPageToLast(Bitmap bitmap) throws Exception{
public void addNewPageToLast(Bitmap bitmap) throws Exception{
logger.debug("addNewPageToLast", "called");
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
@@ -85,23 +85,19 @@ public class DocumentProcessorImpl implements DocumentProcessor{
logger.info("addNewPageToLast", "finished");
logger.info("addNewPageToLast", "filename: " + filename);
return this;
}
@Override
public DocumentProcessor addNewPagesToLast(Bitmap[] bitmaps) throws Exception{
public void addNewPagesToLast(Bitmap[] bitmaps) throws Exception{
logger.debug("addNewPagesToLast", "called");
for (Bitmap bitmap : bitmaps) {
addNewPageToLast(bitmap);
} // TODO-rca: 効率悪いので改善する
return this;
}
@Override
public DocumentProcessor insertPageAtIndex(Bitmap bitmap, int index) throws Exception {
public void insertPageAtIndex(Bitmap bitmap, int index) throws Exception {
logger.debug("addNewPageAfterIndex", "called");
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
@@ -113,18 +109,16 @@ public class DocumentProcessorImpl implements DocumentProcessor{
this.documentDetail.getPages().add(index, page);
lacertaVcs.insertPage(index, filename);
return this;
}
@Override
public DocumentProcessor removePageAtIndex(int index) {
return null;
public void removePageAtIndex(int index) {
}
@Override
public DocumentProcessor updatePageAtIndex(Bitmap bitmap, int index) {
return null;
public void updatePageAtIndex(Bitmap bitmap, int index) {
}
@Override
-1
View File
@@ -31,4 +31,3 @@ include ':model'
include ':processor'
include ':shared:ui'
include ':vcs'
include ':feature:setting'
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-100%p" android:toXDelta="0"
android:duration="120" />
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="120" />
android:duration="@android:integer/config_mediumAnimTime" />
</set>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0"
android:duration="120" />
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="120" />
android:duration="@android:integer/config_mediumAnimTime" />
</set>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="-100%p"
android:duration="120" />
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="120" />
android:duration="@android:integer/config_mediumAnimTime" />
</set>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="100%p"
android:duration="120" />
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="120" />
android:duration="@android:integer/config_mediumAnimTime" />
</set>
@@ -1,10 +0,0 @@
<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/colorOnBackground"
android:pathData="M90,230L90,50L270,50L270,110L150,110L150,230L90,230ZM810,230L810,110L690,110L690,50L870,50L870,230L810,230ZM90,910L90,730L150,730L150,850L270,850L270,910L90,910ZM690,910L690,850L810,850L810,730L870,730L870,910L690,910ZM270,717.69Q270,722.31 273.85,726.15Q277.69,730 282.31,730L677.69,730Q682.31,730 686.15,726.15Q690,722.31 690,717.69L690,242.31Q690,237.69 686.15,233.85Q682.31,230 677.69,230L282.31,230Q277.69,230 273.85,233.85Q270,237.69 270,242.31L270,717.69ZM282.31,790Q252,790 231,769Q210,748 210,717.69L210,242.31Q210,212 231,191Q252,170 282.31,170L677.69,170Q708,170 729,191Q750,212 750,242.31L750,717.69Q750,748 729,769Q708,790 677.69,790L282.31,790ZM370,390L590,390L590,330L370,330L370,390ZM370,510L590,510L590,450L370,450L370,510ZM370,630L590,630L590,570L370,570L370,630ZM270,717.69L270,242.31Q270,237.69 270,233.85Q270,230 270,230L270,230Q270,230 270,233.85Q270,237.69 270,242.31L270,717.69Q270,722.31 270,726.15Q270,730 270,730L270,730Q270,730 270,726.15Q270,722.31 270,717.69Z"/>
</vector>
@@ -1,10 +0,0 @@
<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/colorOnBackground"
android:pathData="M450,670L510,670L510,440L450,440L450,670ZM480,371.54Q493.73,371.54 503.02,362.25Q512.31,352.96 512.31,339.23Q512.31,325.5 503.02,316.21Q493.73,306.92 480,306.92Q466.27,306.92 456.98,316.21Q447.69,325.5 447.69,339.23Q447.69,352.96 456.98,362.25Q466.27,371.54 480,371.54ZM480.07,860Q401.23,860 331.86,830.08Q262.49,800.16 211.18,748.87Q159.87,697.58 129.93,628.24Q100,558.9 100,480.07Q100,401.23 129.92,331.86Q159.84,262.49 211.13,211.18Q262.42,159.87 331.76,129.93Q401.1,100 479.93,100Q558.77,100 628.14,129.92Q697.51,159.84 748.82,211.13Q800.13,262.42 830.07,331.76Q860,401.1 860,479.93Q860,558.77 830.08,628.14Q800.16,697.51 748.87,748.82Q697.58,800.13 628.24,830.07Q558.9,860 480.07,860ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
</vector>
@@ -1,10 +0,0 @@
<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/colorOnBackground"
android:pathData="M479.23,860Q401.46,860 332.31,830.04Q263.15,800.08 211.54,748.46Q159.92,696.84 129.96,627.5Q100,558.15 100,480Q100,400.85 130.77,331.5Q161.54,262.16 214.35,210.85Q267.15,159.54 337.89,129.77Q408.62,100 488.77,100Q563.77,100 630.92,125.58Q698.08,151.16 748.88,196.39Q799.69,241.62 829.84,303.89Q860,366.15 860,438.92Q860,542.77 798.27,601.38Q736.54,660 640,660L567.54,660Q550.46,660 540.23,671.15Q530,682.31 530,697.54Q530,716.08 545,736.08Q560,756.08 560,782Q560,821.61 538.08,840.81Q516.15,860 479.23,860ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480ZM260,510Q281.38,510 295.69,495.69Q310,481.38 310,460Q310,438.62 295.69,424.31Q281.38,410 260,410Q238.62,410 224.31,424.31Q210,438.62 210,460Q210,481.38 224.31,495.69Q238.62,510 260,510ZM380,350Q401.38,350 415.69,335.69Q430,321.38 430,300Q430,278.62 415.69,264.31Q401.38,250 380,250Q358.62,250 344.31,264.31Q330,278.62 330,300Q330,321.38 344.31,335.69Q358.62,350 380,350ZM580,350Q601.38,350 615.69,335.69Q630,321.38 630,300Q630,278.62 615.69,264.31Q601.38,250 580,250Q558.62,250 544.31,264.31Q530,278.62 530,300Q530,321.38 544.31,335.69Q558.62,350 580,350ZM700,510Q721.38,510 735.69,495.69Q750,481.38 750,460Q750,438.62 735.69,424.31Q721.38,410 700,410Q678.62,410 664.31,424.31Q650,438.62 650,460Q650,481.38 664.31,495.69Q678.62,510 700,510ZM479.23,800Q489,800 494.5,795.19Q500,790.39 500,782Q500,768 485,750.54Q470,733.08 470,695.85Q470,653.08 499,626.54Q528,600 570,600L640,600Q710.62,600 755.31,558.61Q800,517.23 800,438.92Q800,317.54 706.92,238.77Q613.85,160 488.77,160Q351.61,160 255.81,253Q160,346 160,480Q160,613 253.5,706.5Q347,800 479.23,800Z"/>
</vector>
@@ -1,10 +0,0 @@
<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/colorOnBackground"
android:pathData="M479.23,540Q454.69,540 436.96,522.27Q419.23,504.54 419.23,480Q419.23,455.46 436.96,437.73Q454.69,420 479.23,420Q503.77,420 521.5,437.73Q539.23,455.46 539.23,480Q539.23,504.54 521.5,522.27Q503.77,540 479.23,540ZM479.23,820Q348.69,820 252.46,734.27Q156.23,648.54 141.62,520L202.85,520Q218,623.61 296.27,691.81Q374.54,760 479.23,760Q596.23,760 677.73,678.5Q759.23,597 759.23,480Q759.23,363 677.73,281.5Q596.23,200 479.23,200Q413.69,200 356.39,229.11Q299.08,258.23 257.69,309.23L362.31,309.23L362.31,369.23L159.23,369.23L159.23,166.15L219.23,166.15L219.23,260.92Q267.92,203.46 335.85,171.73Q403.77,140 479.23,140Q550.03,140 611.86,166.77Q673.69,193.54 719.69,239.54Q765.69,285.54 792.46,347.36Q819.23,409.19 819.23,479.98Q819.23,550.77 792.46,612.61Q765.69,674.46 719.69,720.46Q673.69,766.46 611.86,793.23Q550.03,820 479.23,820Z"/>
</vector>
@@ -1,56 +0,0 @@
<?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:paddingHorizontal="24dp"
android:paddingVertical="16dp">
<ImageView
android:id="@+id/item_icon"
android:layout_width="32dp"
android:layout_height="0dp"
android:layout_marginEnd="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/item_text_container"
app:srcCompat="@drawable/description_24px"
android:contentDescription="icon" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/item_text_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/item_icon"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/item_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginEnd="8dp"
android:text="Placeholder Title"
android:textColor="@color/colorOnSurface"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/item_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="Placeholder Description"
android:textColor="@color/colorOnSurfaceSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/item_title" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -30,7 +30,6 @@
<item name="colorOnBackground">@color/colorOnBackground</item>
<item name="android:windowLightNavigationBar">false</item>
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>
@@ -25,8 +25,4 @@
<color name="colorSurfaceVariant">@color/material_dynamic_neutral_variant90</color>
<color name="colorOnSurfaceVariant">@color/material_dynamic_neutral_variant30</color>
<color name="colorSurfaceInverse">@color/material_dynamic_neutral20</color>
<!-- indicator icon background -->
<color name="colorIndicator">@color/material_dynamic_secondary70</color>
<color name="colorOnSurfaceSecondary">@color/material_dynamic_neutral_variant30</color>
</resources>
@@ -25,8 +25,4 @@
<color name="colorSurfaceInverse">#313033</color>
<color name="colorOnSurfaceInverse">#F4EFF4</color>
<color name="colorPrimaryInverse">#D0BCFF</color>
<!-- indicator icon background -->
<color name="colorIndicator">#d2d4bc</color>
<color name="colorOnSurfaceSecondary">#49454F</color>
</resources>
@@ -24,8 +24,4 @@
<color name="colorSurfaceVariant">@color/material_dynamic_neutral_variant90</color>
<color name="colorOnSurfaceVariant">@color/material_dynamic_neutral_variant30</color>
<color name="colorSurfaceInverse">@color/material_dynamic_neutral20</color>
<!-- indicator icon background -->
<color name="colorIndicator">@color/material_dynamic_secondary80</color>
<color name="colorOnSurfaceSecondary">@color/material_dynamic_neutral_variant30</color>
</resources>
+1 -1
View File
@@ -30,6 +30,6 @@
<item name="colorOnBackground">@color/colorOnBackground</item>
<item name="android:windowLightNavigationBar">true</item>
<item name="android:windowLightStatusBar">true</item>
</style>
</resources>
-3
View File
@@ -25,7 +25,4 @@
<color name="colorSurfaceInverse">#31312B</color>
<color name="colorOnSurfaceInverse">#F3F1E8</color>
<color name="colorPrimaryInverse">#B8D321</color>
<!-- indicator icon background -->
<color name="colorIndicator">#d2d4bc</color>
<color name="colorOnSurfaceSecondary">#46483B</color>
</resources>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="toolbar_corner_radius">32dp</dimen>
</resources>
-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Lacerta.Custom.Indicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator">
<item name="android:color">@color/colorIndicator</item>
</style>
</resources>
+1 -15
View File
@@ -13,22 +13,8 @@
<!-- debug -->
<string name="debug_menu_title">デバッグメニュー</string>
<!-- setting -->
<string name="setting_title">設定</string>
<string name="setting_top_scan_title">スキャン</string>
<string name="setting_top_scan_description">画質, 保存先</string>
<string name="setting_top_display_title">表示</string>
<string name="setting_top_display_description">テーマ, フォントサイズ</string>
<string name="setting_top_data_title">データ</string>
<string name="setting_top_data_description">バックアップ, リストア</string>
<string name="setting_top_about_title">このアプリについて</string>
<string name="setting_top_about_description">バージョン情報</string>
<!-- common -->
<!-- for placeholder -->
<string name="placeholder">Placeholder(TODO: Replace)</string>
</resources>
+2
View File
@@ -28,6 +28,8 @@
<item name="colorOutline">@color/colorOutline</item>
<item name="colorOnBackground">@color/colorOnBackground</item>
<item name="android:windowLightNavigationBar">true</item>
</style>
<style name="Theme.Lacerta" parent="Base.Theme.Lacerta" >
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
@@ -19,7 +19,7 @@ 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}, version = 5)
@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class}, version = 4)
public abstract class LacertaDatabase extends RoomDatabase {
public abstract TagDao tagDao();
public abstract DocumentDao documentDao();
Loaded 100 of 110 files, more files were not shown because too many files have changed in this diff. Show more