mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2026-11-07 19:47:36 +00:00
Compare commits
120
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
580e79b03a | ||
|
|
301fab8024 | ||
|
|
281238a38e | ||
|
|
81fa259985 | ||
|
|
b2c6085933 | ||
|
|
caf3a0dd34 | ||
|
|
c4e10b9487 | ||
|
|
b05ee22c29 | ||
|
|
839433dbb1 | ||
|
|
153242ef66 | ||
|
|
05997eafe1 | ||
|
|
d6f4885b4a | ||
|
|
0b33c60a5a | ||
|
|
ad3a600e8c | ||
|
|
50dfb9be8b | ||
|
|
fafb996453 | ||
|
|
e1129bc009 | ||
|
|
5752e3285b | ||
|
|
a2ed78dfb8 | ||
|
|
0eadc3c3d5 | ||
|
|
6d0b24eb70 | ||
|
|
9da41e73aa | ||
|
|
01f28ecd4d | ||
|
|
2f3a331527 | ||
|
|
9496c3efbb | ||
|
|
93b833f7a9 | ||
|
|
3130be88be | ||
|
|
bb7b628d2f | ||
|
|
5f9ea732cf | ||
|
|
42f6bc17d3 | ||
|
|
1c6878c3fd | ||
|
|
b5beb7cc15 | ||
|
|
c6fb06ffe2 | ||
|
|
95d808dc75 | ||
|
|
b4135f9ec0 | ||
|
|
a62d748c72 | ||
|
|
ea0b1a7665 | ||
|
|
4cfc87a40b | ||
|
|
40a0d08a1f | ||
|
|
fd850651b3 | ||
|
|
ec633a7238 | ||
|
|
e10207959b | ||
|
|
c46ec70d97 | ||
|
|
871dfad6c4 | ||
|
|
676a0e2772 | ||
|
|
d9d22198d5 | ||
|
|
2dc3407217 | ||
|
|
d40f61928c | ||
|
|
19ff824591 | ||
|
|
ec7adbe331 | ||
|
|
af626f4dc0 | ||
|
|
acea8ba27d | ||
|
|
8f1849591d | ||
|
|
882207682f | ||
|
|
0be12e73a8 | ||
|
|
f0b4cc556e | ||
|
|
8c71dedd85 | ||
|
|
c1151b778c | ||
|
|
10e3093c53 | ||
|
|
9ef49e0226 | ||
|
|
a8ce70e6d9 | ||
|
|
2f9777f1f4 | ||
|
|
0a867051f2 | ||
|
|
673918771c | ||
|
|
df14850df1 | ||
|
|
28cae3fa19 | ||
|
|
c167d83940 | ||
|
|
722a3d8c7b | ||
|
|
d7f22c8e36 | ||
|
|
0da5e8a961 | ||
|
|
c45847ecd2 | ||
|
|
d6faf8ec16 | ||
|
|
3e21b0ea1c | ||
|
|
a8e15d8e18 | ||
|
|
50eeaa03bf | ||
|
|
f5b94e0f6a | ||
|
|
e9145d491c | ||
|
|
cb662fe1ff | ||
|
|
8ad3150f33 | ||
|
|
5cc718e35d | ||
|
|
0accd4fa79 | ||
|
|
5840c0126e | ||
|
|
017a2413b6 | ||
|
|
c53c4ed9a1 | ||
|
|
12ba9234a4 | ||
|
|
aaff0be438 | ||
|
|
11e32572ef | ||
|
|
ce3f9ebfd7 | ||
|
|
1b70b444f2 | ||
|
|
7214da80fa | ||
|
|
4e5aab276a | ||
|
|
4ab13508c4 | ||
|
|
df22a754b7 | ||
|
|
9efecab4b6 | ||
|
|
9aea4bb90e | ||
|
|
5c17f96d3d | ||
|
|
d47c6d0cc8 | ||
|
|
176160cd8f | ||
|
|
e6a4393b6d | ||
|
|
acc5b166d5 | ||
|
|
1d2f3345df | ||
|
|
b63e9a6747 | ||
|
|
1f8b56bc78 | ||
|
|
dc9a6bfd9b | ||
|
|
a825ad6a36 | ||
|
|
dd1be73904 | ||
|
|
7156bc417c | ||
|
|
d9c46898ab | ||
|
|
19ce9cbd7e | ||
|
|
584556faca | ||
|
|
028ca6303a | ||
|
|
76734de987 | ||
|
|
646a97e77b | ||
|
|
1aa41eb638 | ||
|
|
2a34100bf2 | ||
|
|
5d33d188bd | ||
|
|
8343ba9c2d | ||
|
|
95cbfdf42c | ||
|
|
7e72cbef54 | ||
|
|
a7642795ca |
No files matched your search
Generated
+2
-2
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2023-12-18T03:36:14.973846Z">
|
<DropdownSelection timestamp="2024-01-20T07:15:21.179573376Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=ZY22H7V3G7" />
|
<DeviceId pluginId="LocalEmulator" identifier="path=/home/rca/.android/avd/Pixel_3a_API_34_extension_level_7_x86_64.avd" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
Generated
-1
@@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
|
|||||||
@@ -78,4 +78,8 @@ dependencies {
|
|||||||
|
|
||||||
implementation project(':data')
|
implementation project(':data')
|
||||||
implementation project(':shared:ui')
|
implementation project(':shared:ui')
|
||||||
|
|
||||||
|
implementation project(':model')
|
||||||
|
|
||||||
|
implementation project(':utils')
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package one.nem.lacerta;
|
package one.nem.lacerta;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.navigation.NavController;
|
import androidx.navigation.NavController;
|
||||||
@@ -10,31 +11,46 @@ import androidx.navigation.ui.NavigationUI;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
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.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.NotActiveException;
|
||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
import one.nem.lacerta.utils.repository.SharedPrefUtils;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
SharedPrefUtils sharedPrefUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
|
||||||
|
|
||||||
|
// Initialize app
|
||||||
|
if (sharedPrefUtils.getIsFirstLaunch()) initializeApp();
|
||||||
|
|
||||||
// Init navigation
|
// Init navigation
|
||||||
try {
|
try {
|
||||||
FragmentManager supportFragmentManager = getSupportFragmentManager();
|
FragmentManager supportFragmentManager = getSupportFragmentManager();
|
||||||
NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment);
|
NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment);
|
||||||
assert navHostFragment != null;
|
assert navHostFragment != null;
|
||||||
NavController navController = navHostFragment.getNavController();
|
NavController navController = navHostFragment.getNavController();
|
||||||
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
|
|
||||||
NavigationUI.setupWithNavController(bottomNavigationView, navController);
|
NavigationUI.setupWithNavController(bottomNavigationView, navController);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@@ -44,10 +60,64 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
finish(); // Exit app
|
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
|
// 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.colorSecondaryContainer));
|
||||||
|
|
||||||
// Set status bar color
|
// Set status bar color
|
||||||
getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface));
|
getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface));
|
||||||
|
|
||||||
|
// Set app bar color
|
||||||
|
AppBarLayout appBarLayout = 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
|
||||||
|
getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
|
||||||
|
} else if (verticalOffset == 0) {
|
||||||
|
// Expanded
|
||||||
|
getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), one.nem.lacerta.shared.ui.R.color.colorSurface));
|
||||||
|
} else {
|
||||||
|
// Somewhere in between
|
||||||
|
// Here you can add a color transition if you want
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Public
|
||||||
|
public void setActionBarTitle(String title) {
|
||||||
|
getSupportActionBar().setTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActionBarBackButton(boolean isEnabled) {
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(isEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActionBarMenuItem(int itemId, boolean isEnabled) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Set isFirstLaunch to false
|
||||||
|
sharedPrefUtils.setIsFirstLaunch(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,61 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:theme="@style/Theme.Lacerta"
|
android:background="@color/colorSurface">
|
||||||
tools:context=".MainActivity">
|
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
android:id="@+id/nav_host_fragment"
|
|
||||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:defaultNavHost="true"
|
app:layout_constraintBottom_toTopOf="@id/bottom_nav"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/bottom_nav"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
app:navGraph="@navigation/main_nav"
|
|
||||||
tools:layout="@layout/fragment_debug_menu_container" />
|
<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"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="160dp"
|
||||||
|
android:background="@color/colorSurface"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
|
app:collapsedTitleGravity="start|center_vertical"
|
||||||
|
app:contentScrim="@color/colorSecondaryContainer"
|
||||||
|
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.fragment.app.FragmentContainerView
|
||||||
|
|
||||||
|
android:id="@+id/nav_host_fragment"
|
||||||
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:defaultNavHost="true"
|
||||||
|
app:navGraph="@navigation/main_nav"
|
||||||
|
tools:layout="@layout/fragment_home_top"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
android:id="@+id/bottom_nav"
|
android:id="@+id/bottom_nav"
|
||||||
@@ -32,6 +69,6 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:menu="@menu/bottom_nav_menu"/>
|
app:menu="@menu/bottom_nav_menu" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@id/feature_debug_navigation"
|
android:id="@id/feature_debug_navigation"
|
||||||
android:icon="@drawable/developer_mode_24px"
|
android:icon="@drawable/developer_mode_24px"
|
||||||
android:title="@string/debug_menu_title"/>
|
android:title="@string/debug_menu_title" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@id/feature_setting_navigation"
|
android:id="@id/feature_setting_navigation"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/app_main_nav"
|
android:id="@+id/app_main_nav"
|
||||||
app:startDestination="@id/feature_debug_navigation">
|
app:startDestination="@id/feature_home_navigation">
|
||||||
|
|
||||||
<include app:graph="@navigation/feature_debug_navigation" />
|
<include app:graph="@navigation/feature_debug_navigation" />
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ plugins {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'one.nem.lacerta.component.common'
|
namespace 'one.nem.lacerta.component.common'
|
||||||
compileSdk 33
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk 26
|
minSdk 26
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ plugins {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'one.nem.lacerta.component.scanner'
|
namespace 'one.nem.lacerta.component.scanner'
|
||||||
compileSdk 33
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk 26
|
minSdk 26
|
||||||
|
|||||||
+29
-13
@@ -1,5 +1,6 @@
|
|||||||
package one.nem.lacerta.component.scanner;
|
package one.nem.lacerta.component.scanner;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
@@ -22,6 +23,7 @@ import com.websitebeaver.documentscanner.DocumentScanner;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -152,21 +154,35 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void saveNewDocument() {
|
private void saveNewDocument() {
|
||||||
logger.debug(TAG, "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: デフォルトタイトルを指定できるようにする
|
DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする
|
||||||
DocumentDetail documentDetail = document.createDocument(documentMeta);
|
document.createDocument(documentMeta).thenAccept((documentDetail) -> {
|
||||||
Bitmap[] bitmaps = new Bitmap[this.croppedImages.size()];
|
Bitmap[] bitmaps = new Bitmap[croppedImages.size()];
|
||||||
this.croppedImages.toArray(bitmaps);
|
croppedImages.toArray(bitmaps);
|
||||||
try {
|
logger.debug(TAG, "bitmaps.length: " + bitmaps.length);
|
||||||
documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps);
|
addPagesToDocumentDetail(documentDetail, bitmaps).join();
|
||||||
Toast.makeText(this, "Saved.", Toast.LENGTH_SHORT).show();
|
document.updateDocument(documentDetail).join();
|
||||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit");
|
dialog.dismiss();
|
||||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).printLog(); // Debug
|
|
||||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).printRev(); // Debug
|
|
||||||
finish();
|
finish();
|
||||||
} catch (Exception e) {
|
});
|
||||||
logger.error(TAG, "Error: " + e.getMessage());
|
|
||||||
logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a");
|
}
|
||||||
}
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertToExistDocument() {
|
private void insertToExistDocument() {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.com.android.library)
|
alias(libs.plugins.com.android.library)
|
||||||
|
id 'com.google.dagger.hilt.android'
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'one.nem.lacerta.component.viewer'
|
namespace 'one.nem.lacerta.component.viewer'
|
||||||
compileSdk 33
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk 26
|
minSdk 26
|
||||||
@@ -29,7 +30,28 @@ dependencies {
|
|||||||
|
|
||||||
implementation libs.androidx.appcompat
|
implementation libs.androidx.appcompat
|
||||||
implementation libs.com.google.android.material
|
implementation libs.com.google.android.material
|
||||||
|
implementation libs.androidx.activity
|
||||||
|
implementation libs.androidx.constraintlayout
|
||||||
testImplementation libs.junit
|
testImplementation libs.junit
|
||||||
androidTestImplementation libs.androidx.test.ext.junit
|
androidTestImplementation libs.androidx.test.ext.junit
|
||||||
androidTestImplementation libs.androidx.test.espresso.core
|
androidTestImplementation libs.androidx.test.espresso.core
|
||||||
|
|
||||||
|
// 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,4 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<application>
|
||||||
|
<activity
|
||||||
|
android:name=".ViewerMainActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
+88
@@ -0,0 +1,88 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package one.nem.lacerta.component.viewer;
|
||||||
|
|
||||||
|
public interface ItemClickListener {
|
||||||
|
void onItemClick(String fileName); // DEBUG
|
||||||
|
}
|
||||||
+66
@@ -0,0 +1,66 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?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>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<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>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?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>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?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>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<resources>
|
||||||
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
|
</resources>
|
||||||
@@ -2,6 +2,7 @@ package one.nem.lacerta.data;
|
|||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import one.nem.lacerta.model.document.DocumentMeta;
|
import one.nem.lacerta.model.document.DocumentMeta;
|
||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
import one.nem.lacerta.model.document.DocumentDetail;
|
||||||
@@ -13,13 +14,13 @@ import one.nem.lacerta.model.document.tag.DocumentTag;
|
|||||||
*/
|
*/
|
||||||
public interface Document {
|
public interface Document {
|
||||||
|
|
||||||
DocumentDetail createDocument(DocumentMeta meta);
|
CompletableFuture<DocumentDetail> createDocument(DocumentMeta meta);
|
||||||
|
|
||||||
DocumentDetail createDocument();
|
CompletableFuture<DocumentDetail> createDocument();
|
||||||
|
|
||||||
void deleteDocument(String documentId);
|
CompletableFuture<Void> deleteDocument(String documentId);
|
||||||
|
|
||||||
void updateDocument(DocumentMeta meta, DocumentDetail detail);
|
CompletableFuture<Void> updateDocument(DocumentDetail detail);
|
||||||
|
|
||||||
DocumentDetail getDocument(String documentId);
|
CompletableFuture<DocumentDetail> getDocument(String documentId);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package one.nem.lacerta.data;
|
package one.nem.lacerta.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import one.nem.lacerta.model.ListItem;
|
import one.nem.lacerta.model.ListItem;
|
||||||
import one.nem.lacerta.model.ListItemType;
|
import one.nem.lacerta.model.ListItemType;
|
||||||
@@ -11,15 +12,16 @@ import one.nem.lacerta.model.document.DocumentDetail;
|
|||||||
public interface LacertaLibrary {
|
public interface LacertaLibrary {
|
||||||
|
|
||||||
// Get History
|
// Get History
|
||||||
ArrayList<ListItem> getRecentDocument(int limit);
|
CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit);
|
||||||
ArrayList<ListItem> getRecentDocument(int limit, int offset);
|
CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit, int offset);
|
||||||
|
|
||||||
// Get Library page
|
// Get Library page
|
||||||
LibraryItemPage getLibraryPage(int limit);
|
CompletableFuture<LibraryItemPage> getLibraryPage(int limit);
|
||||||
LibraryItemPage getLibraryPage(int limit, int offset);
|
CompletableFuture<LibraryItemPage> getLibraryPage(int limit, int offset);
|
||||||
LibraryItemPage getLibraryPage(String pageId, int limit);
|
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit);
|
||||||
LibraryItemPage getLibraryPage(String pageId, int limit, int offset);
|
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset);
|
||||||
|
|
||||||
|
// Create Folder
|
||||||
|
CompletableFuture<String> createFolder(String path, String name);
|
||||||
|
|
||||||
// GetDocument
|
|
||||||
DocumentDetail getDocumentDetailById(String id); // TODO-rca: Documentに統合する
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package one.nem.lacerta.data.impl;
|
package one.nem.lacerta.data.impl;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
// Hilt
|
// Hilt
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -16,13 +18,20 @@ import one.nem.lacerta.model.document.DocumentMeta;
|
|||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
import one.nem.lacerta.model.document.DocumentDetail;
|
||||||
|
|
||||||
// Lacerta/source
|
// 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.LacertaDatabase;
|
||||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||||
|
|
||||||
// Lacerta/utils
|
// Lacerta/utils
|
||||||
|
import one.nem.lacerta.source.file.FileManager;
|
||||||
|
import one.nem.lacerta.source.file.factory.FileManagerFactory;
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
|
||||||
// Lacerta/vcs
|
// 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.LacertaVcs;
|
||||||
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
||||||
|
|
||||||
@@ -40,6 +49,14 @@ public class DocumentImpl implements Document {
|
|||||||
@Inject
|
@Inject
|
||||||
LacertaVcsFactory vcsFactory;
|
LacertaVcsFactory vcsFactory;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
FileManagerFactory fileManagerFactory;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
DeviceInfoUtils deviceInfoUtils;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
XmlMetaParser xmlMetaParser;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DocumentImpl() {
|
public DocumentImpl() {
|
||||||
@@ -49,35 +66,37 @@ public class DocumentImpl implements Document {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DocumentDetail createDocument(DocumentMeta meta) {
|
public CompletableFuture<DocumentDetail> createDocument(DocumentMeta meta) {
|
||||||
DocumentDetail detail = new DocumentDetail();
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
detail.setMeta(meta);
|
DocumentDetail detail = new DocumentDetail();
|
||||||
detail.setPages(new ArrayList<>());
|
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.publicPath = meta.getPath().getStringPath();
|
||||||
|
documentEntity.tagIds = meta.getTagIds();
|
||||||
|
|
||||||
// TODO-rca: UIスレッドから追い出す
|
database.documentDao().insert(documentEntity);
|
||||||
|
|
||||||
// Create DocumentEntity
|
// Vcs
|
||||||
DocumentEntity documentEntity = new DocumentEntity();
|
LacertaVcs vcs = vcsFactory.create(meta.getId());
|
||||||
documentEntity.id = meta.getId();
|
vcs.createDocument(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();
|
|
||||||
|
|
||||||
database.documentDao().insert(documentEntity);
|
// XmlMeta
|
||||||
|
updateXmlMeta(detail).join();
|
||||||
|
|
||||||
// Vcs
|
return detail;
|
||||||
LacertaVcs vcs = vcsFactory.create(meta.getId());
|
});
|
||||||
vcs.createDocument(meta.getId());
|
|
||||||
|
|
||||||
return detail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DocumentDetail createDocument() {
|
public CompletableFuture<DocumentDetail> createDocument() {
|
||||||
DocumentMeta meta = new DocumentMeta();
|
DocumentMeta meta = new DocumentMeta();
|
||||||
meta.setId(UUID.randomUUID().toString());
|
meta.setId(UUID.randomUUID().toString());
|
||||||
meta.setTitle("New Document");
|
meta.setTitle("New Document");
|
||||||
@@ -91,17 +110,112 @@ public class DocumentImpl implements Document {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteDocument(String documentId) {
|
public CompletableFuture<Void> deleteDocument(String documentId) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDocument(DocumentMeta meta, DocumentDetail detail) {
|
public CompletableFuture<Void> updateDocument(DocumentDetail detail) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
updateXmlMeta(detail).join();
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DocumentDetail getDocument(String documentId) {
|
public CompletableFuture<DocumentDetail> getDocument(String documentId) {
|
||||||
return null;
|
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.setPath(new PublicPath().resolve(documentEntity.publicPath));
|
||||||
|
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;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
package one.nem.lacerta.data.impl;
|
package one.nem.lacerta.data.impl;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -10,63 +14,156 @@ import one.nem.lacerta.data.LacertaLibrary;
|
|||||||
import one.nem.lacerta.model.LibraryItemPage;
|
import one.nem.lacerta.model.LibraryItemPage;
|
||||||
import one.nem.lacerta.model.ListItem;
|
import one.nem.lacerta.model.ListItem;
|
||||||
import one.nem.lacerta.model.ListItemType;
|
import one.nem.lacerta.model.ListItemType;
|
||||||
|
import one.nem.lacerta.model.PublicPath;
|
||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
import one.nem.lacerta.model.document.DocumentDetail;
|
||||||
import one.nem.lacerta.source.database.LacertaDatabase;
|
import one.nem.lacerta.source.database.LacertaDatabase;
|
||||||
import one.nem.lacerta.source.database.common.DateTypeConverter;
|
import one.nem.lacerta.source.database.common.DateTypeConverter;
|
||||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||||
|
import one.nem.lacerta.source.database.entity.FolderEntity;
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
|
||||||
public class LacertaLibraryImpl implements LacertaLibrary {
|
public class LacertaLibraryImpl implements LacertaLibrary {
|
||||||
|
|
||||||
@Inject
|
|
||||||
LacertaLogger logger;
|
LacertaLogger logger;
|
||||||
|
|
||||||
@Inject
|
|
||||||
LacertaDatabase database;
|
LacertaDatabase database;
|
||||||
|
|
||||||
@Override
|
@Inject
|
||||||
public ArrayList<ListItem> getRecentDocument(int limit) {
|
public LacertaLibraryImpl(LacertaLogger logger, LacertaDatabase database) {
|
||||||
List<DocumentEntity> documentEntities = database.documentDao().getRecentDocument(limit);
|
this.logger = logger;
|
||||||
|
this.database = database;
|
||||||
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
|
@Override
|
||||||
public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
|
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) {
|
||||||
return null; // TODO-rca: Implement
|
return null; // TODO-rca: Implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// Internal
|
||||||
public LibraryItemPage getLibraryPage(int limit) {
|
private CompletableFuture<List<FolderEntity>> getFolderEntitiesByPublicPath(String publicPath) {
|
||||||
return null;
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
return database.folderDao().findByPublicPathWithLimit(publicPath, 10); // TODO-rca: ハードコーディングやめる
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private CompletableFuture<List<DocumentEntity>> getDocumentEntitiesByPublicPath(String publicPath) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
return database.documentDao().findByPublicPathWithLimit(publicPath, 10); // TODO-rca: ハードコーディングやめる
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LibraryItemPage getLibraryPage(int limit, int offset) {
|
public CompletableFuture<LibraryItemPage> getLibraryPage(int limit) {
|
||||||
return null;
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
|
||||||
|
// 5秒フリーズさせる
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||||
|
|
||||||
|
List<FolderEntity> folderEntities = getFolderEntitiesByPublicPath("/").join();
|
||||||
|
logger.debug("LacertaLibraryImpl", "folderEntities.size(): " + folderEntities.size());
|
||||||
|
List<DocumentEntity> documentEntities = getDocumentEntitiesByPublicPath("/").join();
|
||||||
|
logger.debug("LacertaLibraryImpl", "documentEntities.size(): " + documentEntities.size());
|
||||||
|
|
||||||
|
ArrayList<ListItem> listItems = new ArrayList<>();
|
||||||
|
for (FolderEntity folderEntity : folderEntities) {
|
||||||
|
logger.debug("LacertaLibraryImpl", "folderEntity.name: " + folderEntity.name);
|
||||||
|
ListItem listItem = new ListItem();
|
||||||
|
listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
|
||||||
|
listItem.setTitle(folderEntity.name);
|
||||||
|
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
|
||||||
|
listItem.setItemId(folderEntity.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.setPageTitle("/");
|
||||||
|
libraryItemPage.setPageId("root");
|
||||||
|
libraryItemPage.setListItems(listItems);
|
||||||
|
|
||||||
|
logger.debug("LacertaLibraryImpl", "libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
|
|
||||||
|
return libraryItemPage;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LibraryItemPage getLibraryPage(String pageId, int limit) {
|
public CompletableFuture<LibraryItemPage> getLibraryPage(int limit, int offset) {
|
||||||
return null;
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LibraryItemPage getLibraryPage(String pageId, int limit, int offset) {
|
public CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit) {
|
||||||
return null;
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DocumentDetail getDocumentDetailById(String id) {
|
public CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset) {
|
||||||
return null;
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<String> createFolder(String parentId, String name) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
|
||||||
|
FolderEntity parentFolderEntity = database.folderDao().findById(parentId);
|
||||||
|
PublicPath publicPath;
|
||||||
|
if (parentFolderEntity == null) {
|
||||||
|
publicPath = new PublicPath().resolve("/");
|
||||||
|
} else {
|
||||||
|
publicPath = new PublicPath().resolve(parentFolderEntity.publicPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
FolderEntity folderEntity = new FolderEntity();
|
||||||
|
folderEntity.id = UUID.randomUUID().toString();
|
||||||
|
folderEntity.name = name;
|
||||||
|
folderEntity.publicPath = publicPath.getStringPath();
|
||||||
|
database.folderDao().insert(folderEntity);
|
||||||
|
return folderEntity.id;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,219 +1,219 @@
|
|||||||
package one.nem.lacerta.data.impl;
|
//package one.nem.lacerta.data.impl;
|
||||||
|
//
|
||||||
import one.nem.lacerta.data.LacertaLibrary;
|
//import one.nem.lacerta.data.LacertaLibrary;
|
||||||
import one.nem.lacerta.model.LibraryItemPage;
|
//import one.nem.lacerta.model.LibraryItemPage;
|
||||||
import one.nem.lacerta.model.ListItem;
|
//import one.nem.lacerta.model.ListItem;
|
||||||
import one.nem.lacerta.model.ListItemType;
|
//import one.nem.lacerta.model.ListItemType;
|
||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
//import one.nem.lacerta.model.document.DocumentDetail;
|
||||||
|
//
|
||||||
import one.nem.lacerta.model.document.DocumentMeta;
|
//import one.nem.lacerta.model.document.DocumentMeta;
|
||||||
import one.nem.lacerta.model.document.path.DocumentPath;
|
//import one.nem.lacerta.model.document.path.DocumentPath;
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
//import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
//
|
||||||
import com.github.javafaker.DateAndTime;
|
//import com.github.javafaker.DateAndTime;
|
||||||
import com.github.javafaker.Faker;
|
//import com.github.javafaker.Faker;
|
||||||
|
//
|
||||||
import java.text.DateFormat;
|
//import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
//import java.util.Objects;
|
||||||
import java.util.UUID;
|
//import java.util.UUID;
|
||||||
|
//
|
||||||
import javax.inject.Inject;
|
//import javax.inject.Inject;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* LacertaLibraryのスタブ実装
|
// * LacertaLibraryのスタブ実装
|
||||||
*/
|
// */
|
||||||
public class LacertaLibraryStubImpl implements LacertaLibrary {
|
//public class LacertaLibraryStubImpl implements LacertaLibrary {
|
||||||
|
//
|
||||||
LacertaLogger logger;
|
// LacertaLogger logger;
|
||||||
|
//
|
||||||
Faker faker;
|
// Faker faker;
|
||||||
|
//
|
||||||
@Inject
|
// @Inject
|
||||||
public LacertaLibraryStubImpl(LacertaLogger logger) {
|
// public LacertaLibraryStubImpl(LacertaLogger logger) {
|
||||||
faker = new Faker(); // Init Faker
|
// faker = new Faker(); // Init Faker
|
||||||
this.logger = logger;
|
// this.logger = logger;
|
||||||
logger.debug("LibraryStub", "Initialized");
|
// logger.debug("LibraryStub", "Initialized");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Internal Methods
|
// // Internal Methods
|
||||||
|
//
|
||||||
// Generate Stub Data
|
// // Generate Stub Data
|
||||||
private LibraryItemPage generateStubLibraryItemPage(int limit, String pageId) {
|
// private LibraryItemPage generateStubLibraryItemPage(int limit, String pageId) {
|
||||||
logger.debug("LibraryStub", "generateStubLibraryItemPage");
|
// logger.debug("LibraryStub", "generateStubLibraryItemPage");
|
||||||
ArrayList<ListItem> listItems = new ArrayList<>();
|
// ArrayList<ListItem> listItems = new ArrayList<>();
|
||||||
int itemTotal = faker.number().numberBetween(1, limit); // 実際に返却するアイテム数を決定
|
// int itemTotal = faker.number().numberBetween(1, limit); // 実際に返却するアイテム数を決定
|
||||||
int folderTotal;
|
// int folderTotal;
|
||||||
// フォルダ数の抽選
|
// // フォルダ数の抽選
|
||||||
if (itemTotal > 4) {
|
// if (itemTotal > 4) {
|
||||||
folderTotal = faker.number().numberBetween(1, itemTotal - 2);
|
// folderTotal = faker.number().numberBetween(1, itemTotal - 2);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
if (itemTotal > 2) {
|
// if (itemTotal > 2) {
|
||||||
folderTotal = 1;
|
// folderTotal = 1;
|
||||||
}
|
// }
|
||||||
else { // ドキュメント数がゼロにならないように
|
// else { // ドキュメント数がゼロにならないように
|
||||||
folderTotal = 0;
|
// folderTotal = 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
int documentTotal = itemTotal - folderTotal; // ドキュメント数を決定
|
// int documentTotal = itemTotal - folderTotal; // ドキュメント数を決定
|
||||||
logger.debug("LibraryStub", "itemTotal: " + itemTotal);
|
// logger.debug("LibraryStub", "itemTotal: " + itemTotal);
|
||||||
logger.debug("LibraryStub", "folderTotal: " + folderTotal);
|
// logger.debug("LibraryStub", "folderTotal: " + folderTotal);
|
||||||
logger.debug("LibraryStub", "documentTotal: " + documentTotal);
|
// logger.debug("LibraryStub", "documentTotal: " + documentTotal);
|
||||||
|
//
|
||||||
// フォルダを生成
|
// // フォルダを生成
|
||||||
for (int i = 0; i < folderTotal; i++) {
|
// for (int i = 0; i < folderTotal; i++) {
|
||||||
listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_FOLDER));
|
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_FOLDER));
|
||||||
}
|
// }
|
||||||
// ドキュメントを生成
|
// // ドキュメントを生成
|
||||||
for (int i = 0; i < documentTotal; i++) {
|
// for (int i = 0; i < documentTotal; i++) {
|
||||||
listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
|
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
LibraryItemPage libraryItemPage = new LibraryItemPage();
|
// LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||||
libraryItemPage.setListItems(listItems);
|
// libraryItemPage.setListItems(listItems);
|
||||||
if (pageId == null) {
|
// if (pageId == null) {
|
||||||
libraryItemPage.setPageId(UUID.randomUUID().toString());
|
// libraryItemPage.setPageId(UUID.randomUUID().toString());
|
||||||
} else {
|
// } else {
|
||||||
libraryItemPage.setPageId(pageId);
|
// libraryItemPage.setPageId(pageId);
|
||||||
}
|
// }
|
||||||
libraryItemPage.setPageTitle("FakePage" + faker.number().digits(3));
|
// libraryItemPage.setPageTitle("FakePage" + faker.number().digits(3));
|
||||||
|
//
|
||||||
return libraryItemPage;
|
// return libraryItemPage;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private ListItem generateStubListItem(ListItemType itemType) {
|
// private ListItem generateStubListItem(ListItemType itemType) {
|
||||||
if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
|
// if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
|
||||||
ListItem listItem = new ListItem();
|
// ListItem listItem = new ListItem();
|
||||||
listItem.setTitle("FakeFolder" + faker.number().digits(3));
|
// listItem.setTitle("FakeFolder" + faker.number().digits(3));
|
||||||
listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
|
// listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
|
||||||
listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
|
// listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
|
||||||
listItem.setItemId(UUID.randomUUID().toString());
|
// listItem.setItemId(UUID.randomUUID().toString());
|
||||||
return listItem;
|
// return listItem;
|
||||||
} else if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
|
// } else if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
|
||||||
ListItem listItem = new ListItem();
|
// ListItem listItem = new ListItem();
|
||||||
listItem.setTitle("FakeDocument" + faker.book().title());
|
// listItem.setTitle("FakeDocument" + faker.book().title());
|
||||||
listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
|
// listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
|
||||||
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
// listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
||||||
listItem.setItemId(UUID.randomUUID().toString());
|
// listItem.setItemId(UUID.randomUUID().toString());
|
||||||
return listItem;
|
// return listItem;
|
||||||
} else {
|
// } else {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private LibraryItemPage getRecentDocumentPage(int limit) {
|
// private LibraryItemPage getRecentDocumentPage(int limit) {
|
||||||
int itemTotal = faker.number().numberBetween(1, limit);
|
// int itemTotal = faker.number().numberBetween(1, limit);
|
||||||
ArrayList<ListItem> listItems = new ArrayList<>();
|
// ArrayList<ListItem> listItems = new ArrayList<>();
|
||||||
for (int i = 0; i < itemTotal; i++) {
|
// for (int i = 0; i < itemTotal; i++) {
|
||||||
listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
|
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
|
||||||
}
|
// }
|
||||||
// DescriptionからDateを抽出して新しい順にソート
|
// // DescriptionからDateを抽出して新しい順にソート
|
||||||
listItems.sort((a, b) -> {
|
// listItems.sort((a, b) -> {
|
||||||
String aDate = a.getDescription().substring(11);
|
// String aDate = a.getDescription().substring(11);
|
||||||
String bDate = b.getDescription().substring(11);
|
// String bDate = b.getDescription().substring(11);
|
||||||
return bDate.compareTo(aDate);
|
// return bDate.compareTo(aDate);
|
||||||
});
|
// });
|
||||||
LibraryItemPage libraryItemPage = new LibraryItemPage();
|
// LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||||
libraryItemPage.setListItems(listItems);
|
// libraryItemPage.setListItems(listItems);
|
||||||
libraryItemPage.setPageId(UUID.randomUUID().toString());
|
// libraryItemPage.setPageId(UUID.randomUUID().toString());
|
||||||
libraryItemPage.setPageTitle("RecentDocument");
|
// libraryItemPage.setPageTitle("RecentDocument");
|
||||||
return libraryItemPage;
|
// return libraryItemPage;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private DocumentDetail generateStubDocumentDetail(String id) throws IllegalArgumentException {
|
// private DocumentDetail generateStubDocumentDetail(String id) throws IllegalArgumentException {
|
||||||
|
//
|
||||||
if (Objects.isNull(id)) {
|
// if (Objects.isNull(id)) {
|
||||||
throw new IllegalArgumentException("id is null");
|
// throw new IllegalArgumentException("id is null");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
DocumentMeta documentMeta = new DocumentMeta();
|
// DocumentMeta documentMeta = new DocumentMeta();
|
||||||
documentMeta.setId(id);
|
// documentMeta.setId(id);
|
||||||
documentMeta.setTitle("FakeDocument" + faker.book().title());
|
// documentMeta.setTitle("FakeDocument" + faker.book().title());
|
||||||
documentMeta.setCreatedAt(faker.date().birthday());
|
// documentMeta.setCreatedAt(faker.date().birthday());
|
||||||
documentMeta.setUpdatedAt(faker.date().birthday()); // TODO-rca: 更新日のほうが古くなることがあるのでなんとかする?
|
// documentMeta.setUpdatedAt(faker.date().birthday()); // TODO-rca: 更新日のほうが古くなることがあるのでなんとかする?
|
||||||
ArrayList<String> tagIds = new ArrayList<>();
|
// ArrayList<String> tagIds = new ArrayList<>();
|
||||||
|
//
|
||||||
DocumentDetail documentDetail = new DocumentDetail();
|
// DocumentDetail documentDetail = new DocumentDetail();
|
||||||
documentDetail.setMeta(documentMeta);
|
// documentDetail.setMeta(documentMeta);
|
||||||
// documentDetail.setPath(null); // TODO-rca: なんとかする
|
//// documentDetail.setPath(null); // TODO-rca: なんとかする
|
||||||
// documentDetail.setAuthor(faker.name().fullName());
|
//// documentDetail.setAuthor(faker.name().fullName());
|
||||||
// documentDetail.setRepository(null); // TODO-rca: なんとかする
|
//// documentDetail.setRepository(null); // TODO-rca: なんとかする
|
||||||
return documentDetail;
|
// return documentDetail;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 履歴ページを取得する
|
// * 履歴ページを取得する
|
||||||
* @param limit 取得するアイテム数
|
// * @param limit 取得するアイテム数
|
||||||
* @return ページオブジェクト
|
// * @return ページオブジェクト
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public ArrayList<ListItem> getRecentDocument(int limit) {
|
// public ArrayList<ListItem> getRecentDocument(int limit) {
|
||||||
return getRecentDocumentPage(limit).getListItems();
|
// return getRecentDocumentPage(limit).getListItems();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 履歴ページを取得する
|
// * 履歴ページを取得する
|
||||||
* @param limit 取得するアイテム数
|
// * @param limit 取得するアイテム数
|
||||||
* @param offset 取得するアイテムのオフセット
|
// * @param offset 取得するアイテムのオフセット
|
||||||
* @return ページオブジェクト
|
// * @return ページオブジェクト
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
|
// public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
|
||||||
return getRecentDocumentPage(limit).getListItems();
|
// return getRecentDocumentPage(limit).getListItems();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* ライブラリページを取得する
|
// * ライブラリページを取得する
|
||||||
* @param limit 取得するアイテム数
|
// * @param limit 取得するアイテム数
|
||||||
* @return ページオブジェクト
|
// * @return ページオブジェクト
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public LibraryItemPage getLibraryPage(int limit) {
|
// public LibraryItemPage getLibraryPage(int limit) {
|
||||||
return generateStubLibraryItemPage(limit, null);
|
// return generateStubLibraryItemPage(limit, null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* ライブラリページを取得する
|
// * ライブラリページを取得する
|
||||||
* @param limit 取得するアイテム数
|
// * @param limit 取得するアイテム数
|
||||||
* @param offset 取得するアイテムのオフセット
|
// * @param offset 取得するアイテムのオフセット
|
||||||
* @return ページオブジェクト
|
// * @return ページオブジェクト
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public LibraryItemPage getLibraryPage(int limit, int offset) {
|
// public LibraryItemPage getLibraryPage(int limit, int offset) {
|
||||||
return generateStubLibraryItemPage(limit, null);
|
// return generateStubLibraryItemPage(limit, null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* ライブラリページを取得する
|
// * ライブラリページを取得する
|
||||||
* @param pageId ページID
|
// * @param pageId ページID
|
||||||
* @param limit 取得するアイテム数
|
// * @param limit 取得するアイテム数
|
||||||
* @return ページオブジェクト
|
// * @return ページオブジェクト
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public LibraryItemPage getLibraryPage(String pageId, int limit) {
|
// public LibraryItemPage getLibraryPage(String pageId, int limit) {
|
||||||
return generateStubLibraryItemPage(limit, pageId);
|
// return generateStubLibraryItemPage(limit, pageId);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* ライブラリページを取得する
|
// * ライブラリページを取得する
|
||||||
* @param pageId ページID
|
// * @param pageId ページID
|
||||||
* @param limit 取得するアイテム数
|
// * @param limit 取得するアイテム数
|
||||||
* @param offset 取得するアイテムのオフセット
|
// * @param offset 取得するアイテムのオフセット
|
||||||
* @return ページオブジェクト
|
// * @return ページオブジェクト
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public LibraryItemPage getLibraryPage(String pageId, int limit, int offset) {
|
// public LibraryItemPage getLibraryPage(String pageId, int limit, int offset) {
|
||||||
return generateStubLibraryItemPage(limit, pageId);
|
// return generateStubLibraryItemPage(limit, pageId);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* ドキュメント詳細を取得する
|
// * ドキュメント詳細を取得する
|
||||||
* @param id ドキュメントID
|
// * @param id ドキュメントID
|
||||||
* @return ドキュメント詳細オブジェクト
|
// * @return ドキュメント詳細オブジェクト
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public DocumentDetail getDocumentDetailById(String id) throws IllegalArgumentException {
|
// public DocumentDetail getDocumentDetailById(String id) throws IllegalArgumentException {
|
||||||
return generateStubDocumentDetail(id);
|
// return generateStubDocumentDetail(id);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
@@ -30,9 +30,10 @@ public class LacertaSearchStubImpl implements LacertaSearch {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<ListItem> autoSearch(String query, int limit) {
|
public ArrayList<ListItem> autoSearch(String query, int limit) {
|
||||||
logger.debug("SearchStub", "autoSearch");
|
// logger.debug("SearchStub", "autoSearch");
|
||||||
logger.debug("SearchStub", "query: " + query);
|
// logger.debug("SearchStub", "query: " + query);
|
||||||
return library.getLibraryPage(limit).getListItems();
|
// return library.getLibraryPage(limit).getListItems();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,8 +45,9 @@ public class LacertaSearchStubImpl implements LacertaSearch {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<ListItem> autoSearch(String query, int limit, int offset) {
|
public ArrayList<ListItem> autoSearch(String query, int limit, int offset) {
|
||||||
logger.debug("SearchStub", "autoSearch");
|
// logger.debug("SearchStub", "autoSearch");
|
||||||
logger.debug("SearchStub", "query: " + query);
|
// logger.debug("SearchStub", "query: " + query);
|
||||||
return library.getLibraryPage(limit, offset).getListItems();
|
// return library.getLibraryPage(limit, offset).getListItems();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import dagger.hilt.android.components.FragmentComponent;
|
|||||||
import dagger.hilt.migration.DisableInstallInCheck;
|
import dagger.hilt.migration.DisableInstallInCheck;
|
||||||
|
|
||||||
import one.nem.lacerta.data.LacertaLibrary;
|
import one.nem.lacerta.data.LacertaLibrary;
|
||||||
import one.nem.lacerta.data.impl.LacertaLibraryStubImpl;
|
import one.nem.lacerta.data.impl.LacertaLibraryImpl;
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@@ -16,6 +16,6 @@ import one.nem.lacerta.utils.LacertaLogger;
|
|||||||
abstract public class LacertaLibraryModule {
|
abstract public class LacertaLibraryModule {
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
public abstract LacertaLibrary bindLacertaLibrary(LacertaLibraryStubImpl impl);
|
public abstract LacertaLibrary bindLacertaLibrary(LacertaLibraryImpl impl);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ plugins {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'one.nem.lacerta.feature.common'
|
namespace 'one.nem.lacerta.feature.common'
|
||||||
compileSdk 33
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk 26
|
minSdk 26
|
||||||
|
|||||||
+2
-1
@@ -57,7 +57,8 @@ public class DebugMenuLibraryItemListPageFragment extends Fragment {
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_debug_menu_library_item_list_page, container, false);
|
View view = inflater.inflate(R.layout.fragment_debug_menu_library_item_list_page, container, false);
|
||||||
|
|
||||||
ArrayList<ListItem> listItems = lacertaLibrary.getRecentDocument(10);
|
// ArrayList<ListItem> listItems = lacertaLibrary.getRecentDocument(10);
|
||||||
|
ArrayList<ListItem> listItems = new ArrayList<>();
|
||||||
for (ListItem listItem : listItems) {
|
for (ListItem listItem : listItems) {
|
||||||
System.out.println(listItem.getTitle());
|
System.out.println(listItem.getTitle());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ plugins {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'one.nem.lacerta.feature.home'
|
namespace 'one.nem.lacerta.feature.home'
|
||||||
compileSdk 33
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk 26
|
minSdk 26
|
||||||
@@ -57,4 +57,6 @@ dependencies {
|
|||||||
implementation "androidx.recyclerview:recyclerview:1.3.2"
|
implementation "androidx.recyclerview:recyclerview:1.3.2"
|
||||||
|
|
||||||
implementation project(':component:common')
|
implementation project(':component:common')
|
||||||
|
|
||||||
|
implementation project(':component:viewer')
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package one.nem.lacerta.feature.home;
|
||||||
|
|
||||||
|
public interface DocumentSelectListener {
|
||||||
|
void onDocumentSelect(String documentId);
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package one.nem.lacerta.feature.home;
|
package one.nem.lacerta.feature.home;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -9,6 +10,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
@@ -23,10 +25,12 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
import one.nem.lacerta.component.viewer.ViewerMainActivity;
|
||||||
import one.nem.lacerta.data.Document;
|
import one.nem.lacerta.data.Document;
|
||||||
import one.nem.lacerta.data.LacertaLibrary;
|
import one.nem.lacerta.data.LacertaLibrary;
|
||||||
import one.nem.lacerta.model.ListItem;
|
import one.nem.lacerta.model.ListItem;
|
||||||
@@ -67,18 +71,7 @@ public class HomeTopFragment extends Fragment {
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
|
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
|
||||||
|
|
||||||
ArrayList<ListItem> recentDocument = lacertaLibrary.getRecentDocument(10);
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
Log.d("docs", Integer.toString(recentDocument.size()));
|
|
||||||
|
|
||||||
RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view);
|
|
||||||
|
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
||||||
|
|
||||||
ListItemAdapter listItemAdapter = new ListItemAdapter(recentDocument);
|
|
||||||
|
|
||||||
recyclerView.setAdapter(listItemAdapter);
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,31 +79,30 @@ public class HomeTopFragment extends Fragment {
|
|||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
|
RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view);
|
||||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
|
||||||
|
|
||||||
// Set the Toolbar
|
|
||||||
((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
// Set the title of the CollapsingToolbarLayout
|
ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> {
|
||||||
collapsingToolbarLayout.setTitle("Lacerta");
|
Log.d("HomeTopFragment", "onViewCreated: " + documentId);
|
||||||
|
Intent intent = new Intent(getContext(), ViewerMainActivity.class);
|
||||||
AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout);
|
intent.putExtra("documentId", documentId);
|
||||||
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
startActivity(intent);
|
||||||
@Override
|
|
||||||
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
|
||||||
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
|
|
||||||
// Collapsed
|
|
||||||
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getActivity(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
|
|
||||||
} else if (verticalOffset == 0) {
|
|
||||||
// Expanded
|
|
||||||
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getActivity(), one.nem.lacerta.shared.ui.R.color.colorSurface));
|
|
||||||
} else {
|
|
||||||
// Somewhere in between
|
|
||||||
// Here you can add a color transition if you want
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
recyclerView.setAdapter(listItemAdapter);
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
|
lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> {
|
||||||
|
listItemAdapter.setListItems(listItems);
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
listItemAdapter.notifyItemRangeInserted(0, listItems.size());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.drawer_menu, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package one.nem.lacerta.feature.home;
|
package one.nem.lacerta.feature.home;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -11,13 +12,21 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import one.nem.lacerta.component.viewer.ViewerMainActivity;
|
||||||
import one.nem.lacerta.model.ListItem;
|
import one.nem.lacerta.model.ListItem;
|
||||||
|
|
||||||
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
|
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
|
||||||
|
|
||||||
ArrayList<ListItem> listItems;
|
ArrayList<ListItem> listItems;
|
||||||
|
|
||||||
public ListItemAdapter(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;
|
this.listItems = listItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +44,12 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
|
|||||||
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
|
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
|
||||||
holder.title.setText(listItem.getTitle());
|
holder.title.setText(listItem.getTitle());
|
||||||
holder.description.setText(listItem.getDescription());
|
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
|
@Override
|
||||||
|
|||||||
@@ -1,50 +1,11 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="@color/colorSurface">
|
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/home_item_recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
@@ -5,7 +5,7 @@ plugins {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'one.nem.lacerta.feature.library'
|
namespace 'one.nem.lacerta.feature.library'
|
||||||
compileSdk 33
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk 26
|
minSdk 26
|
||||||
@@ -51,5 +51,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation project(':data')
|
implementation project(':data')
|
||||||
|
|
||||||
|
implementation project(':utils')
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package one.nem.lacerta.feature.library;
|
||||||
|
|
||||||
|
public interface DocumentSelectListener {
|
||||||
|
void onDocumentSelect(String documentId);
|
||||||
|
}
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+93
-43
@@ -1,13 +1,20 @@
|
|||||||
package one.nem.lacerta.feature.library;
|
package one.nem.lacerta.feature.library;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
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.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
@@ -15,6 +22,11 @@ import android.widget.ListView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -22,9 +34,11 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
import one.nem.lacerta.data.Document;
|
import one.nem.lacerta.data.Document;
|
||||||
|
import one.nem.lacerta.data.LacertaLibrary;
|
||||||
import one.nem.lacerta.model.document.DocumentMeta;
|
import one.nem.lacerta.model.document.DocumentMeta;
|
||||||
import one.nem.lacerta.model.document.tag.DocumentTag;
|
import one.nem.lacerta.model.document.tag.DocumentTag;
|
||||||
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
import one.nem.lacerta.utils.TextInputDialog;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,36 +49,22 @@ import one.nem.lacerta.model.document.tag.DocumentTag;
|
|||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
public class LibraryTopFragment extends Fragment {
|
public class LibraryTopFragment extends Fragment {
|
||||||
|
|
||||||
// @Inject
|
@Inject
|
||||||
// Document document;
|
LacertaLibrary lacertaLibrary;
|
||||||
|
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
@Inject
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
LacertaLogger logger;
|
||||||
private static final String ARG_PARAM1 = "param1";
|
|
||||||
private static final String ARG_PARAM2 = "param2";
|
|
||||||
|
|
||||||
// TODO: Rename and change types of parameters
|
ListItemAdapter listItemAdapter;
|
||||||
private String mParam1;
|
|
||||||
private String mParam2;
|
int currentTotalItemCount = 0;
|
||||||
|
|
||||||
public LibraryTopFragment() {
|
public LibraryTopFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
public static LibraryTopFragment 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 LibraryTopFragment.
|
|
||||||
*/
|
|
||||||
// TODO: Rename and change types and number of parameters
|
|
||||||
public static LibraryTopFragment newInstance(String param1, String param2) {
|
|
||||||
LibraryTopFragment fragment = new LibraryTopFragment();
|
LibraryTopFragment fragment = new LibraryTopFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(ARG_PARAM1, param1);
|
|
||||||
args.putString(ARG_PARAM2, param2);
|
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
@@ -72,10 +72,6 @@ public class LibraryTopFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (getArguments() != null) {
|
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -84,23 +80,77 @@ public class LibraryTopFragment extends Fragment {
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
|
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
|
||||||
|
|
||||||
// Use view.findViewById instead of findViewById
|
setHasOptionsMenu(true);
|
||||||
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;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view);
|
||||||
|
|
||||||
|
this.listItemAdapter = new ListItemAdapter(documentId -> {
|
||||||
|
Toast.makeText(getContext(), documentId, Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
recyclerView.setAdapter(listItemAdapter);
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
|
||||||
|
lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> {
|
||||||
|
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
|
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
||||||
|
this.currentTotalItemCount = libraryItemPage.getListItems().size();
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
listItemAdapter.notifyItemRangeInserted(0, this.currentTotalItemCount - 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.dir_menu, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Selected
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == R.id.menu_item_create_new_folder) {
|
||||||
|
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(null, input.getText().toString()).thenAccept(folderId -> {
|
||||||
|
logger.debug("LibraryTopFragment", "folderId: " + folderId);
|
||||||
|
});
|
||||||
|
// Refresh
|
||||||
|
updateItem();
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("キャンセル", (dialog, which) -> {
|
||||||
|
dialog.cancel();
|
||||||
|
});
|
||||||
|
builder.show();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateItem() {
|
||||||
|
lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> {
|
||||||
|
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
listItemAdapter.notifyItemRangeRemoved(0, this.currentTotalItemCount - 1);
|
||||||
|
});
|
||||||
|
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
|
||||||
|
});
|
||||||
|
this.currentTotalItemCount = libraryItemPage.getListItems().size();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
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 -> {
|
||||||
|
// Intent intent = new Intent(v.getContext(), ViewerMainActivity.class);
|
||||||
|
// intent.putExtra("documentId", listItem.getItemId());
|
||||||
|
// v.getContext().startActivity(intent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@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,32 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:theme="@style/Theme.Lacerta"
|
|
||||||
tools:context=".LibraryTopFragment">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
|
||||||
android:id="@+id/tool_bar"
|
|
||||||
android:layout_width="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" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/document_list"
|
android:id="@+id/library_item_recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent" />
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tool_bar" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</FrameLayout>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?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>
|
||||||
@@ -4,7 +4,7 @@ plugins {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'one.nem.lacerta.feature.scan'
|
namespace 'one.nem.lacerta.feature.scan'
|
||||||
compileSdk 33
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk 26
|
minSdk 26
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ plugins {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'one.nem.lacerta.feature.search'
|
namespace 'one.nem.lacerta.feature.search'
|
||||||
compileSdk 33
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk 26
|
minSdk 26
|
||||||
|
|||||||
@@ -1,50 +1,11 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="@color/colorSurface">
|
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/setting_item_recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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>
|
</FrameLayout>
|
||||||
@@ -27,13 +27,28 @@ public class PublicPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void resolveInternal(String path) {
|
private void resolveInternal(String path) {
|
||||||
if (path.equals("..")) {
|
if (path.startsWith("/")) {
|
||||||
this.path.remove(this.path.size() - 1);
|
this.path.clear();
|
||||||
|
this.path.add("/");
|
||||||
} else {
|
} else {
|
||||||
add(path);
|
if (path.equals("..")) {
|
||||||
|
this.path.remove(this.path.size() - 1);
|
||||||
|
} else if (path.equals(".")) {
|
||||||
|
// do nothing
|
||||||
|
} else {
|
||||||
|
this.path.add(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PublicPath parse(String path) {
|
||||||
|
String[] pathArray = path.split("/");
|
||||||
|
for (String p : pathArray) {
|
||||||
|
resolveInternal(p);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public PublicPath resolve(String path) {
|
public PublicPath resolve(String path) {
|
||||||
resolveInternal(path);
|
resolveInternal(path);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
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 {
|
public interface DocumentProcessor {
|
||||||
|
|
||||||
// ページ操作
|
// ページ操作
|
||||||
void addNewPageToLast(Bitmap bitmap) throws Exception;
|
DocumentProcessor addNewPageToLast(Bitmap bitmap) throws Exception;
|
||||||
void addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
|
DocumentProcessor addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
|
||||||
void insertPageAtIndex(Bitmap bitmap, int index) throws Exception;
|
DocumentProcessor insertPageAtIndex(Bitmap bitmap, int index) throws Exception;
|
||||||
void removePageAtIndex(int index) throws Exception;
|
DocumentProcessor removePageAtIndex(int index) throws Exception;
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
void updatePageAtIndex(Bitmap bitmap, int index);
|
DocumentProcessor updatePageAtIndex(Bitmap bitmap, int index);
|
||||||
|
|
||||||
// ページ取得
|
// ページ取得
|
||||||
Bitmap getPageAtIndex(int index);
|
Bitmap getPageAtIndex(int index);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class DocumentProcessorImpl implements DocumentProcessor{
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNewPageToLast(Bitmap bitmap) throws Exception{
|
public DocumentProcessor addNewPageToLast(Bitmap bitmap) throws Exception{
|
||||||
logger.debug("addNewPageToLast", "called");
|
logger.debug("addNewPageToLast", "called");
|
||||||
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
|
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
|
||||||
|
|
||||||
@@ -85,19 +85,23 @@ public class DocumentProcessorImpl implements DocumentProcessor{
|
|||||||
|
|
||||||
logger.info("addNewPageToLast", "finished");
|
logger.info("addNewPageToLast", "finished");
|
||||||
logger.info("addNewPageToLast", "filename: " + filename);
|
logger.info("addNewPageToLast", "filename: " + filename);
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNewPagesToLast(Bitmap[] bitmaps) throws Exception{
|
public DocumentProcessor addNewPagesToLast(Bitmap[] bitmaps) throws Exception{
|
||||||
logger.debug("addNewPagesToLast", "called");
|
logger.debug("addNewPagesToLast", "called");
|
||||||
|
|
||||||
for (Bitmap bitmap : bitmaps) {
|
for (Bitmap bitmap : bitmaps) {
|
||||||
addNewPageToLast(bitmap);
|
addNewPageToLast(bitmap);
|
||||||
} // TODO-rca: 効率悪いので改善する
|
} // TODO-rca: 効率悪いので改善する
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertPageAtIndex(Bitmap bitmap, int index) throws Exception {
|
public DocumentProcessor insertPageAtIndex(Bitmap bitmap, int index) throws Exception {
|
||||||
logger.debug("addNewPageAfterIndex", "called");
|
logger.debug("addNewPageAfterIndex", "called");
|
||||||
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
|
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
|
||||||
|
|
||||||
@@ -109,16 +113,18 @@ public class DocumentProcessorImpl implements DocumentProcessor{
|
|||||||
this.documentDetail.getPages().add(index, page);
|
this.documentDetail.getPages().add(index, page);
|
||||||
|
|
||||||
lacertaVcs.insertPage(index, filename);
|
lacertaVcs.insertPage(index, filename);
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePageAtIndex(int index) {
|
public DocumentProcessor removePageAtIndex(int index) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePageAtIndex(Bitmap bitmap, int index) {
|
public DocumentProcessor updatePageAtIndex(Bitmap bitmap, int index) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import androidx.room.Insert;
|
|||||||
import androidx.room.Query;
|
import androidx.room.Query;
|
||||||
import androidx.room.Update;
|
import androidx.room.Update;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import androidx.room.Dao;
|
|||||||
import androidx.room.Insert;
|
import androidx.room.Insert;
|
||||||
import androidx.room.Query;
|
import androidx.room.Query;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import one.nem.lacerta.source.database.entity.FolderEntity;
|
import one.nem.lacerta.source.database.entity.FolderEntity;
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
@@ -15,6 +18,9 @@ public interface FolderDao {
|
|||||||
@Query("SELECT * FROM Folder WHERE public_path = :publicPath")
|
@Query("SELECT * FROM Folder WHERE public_path = :publicPath")
|
||||||
FolderEntity findByPublicPath(String publicPath);
|
FolderEntity findByPublicPath(String publicPath);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM Folder WHERE public_path = :publicPath LIMIT :limit")
|
||||||
|
List<FolderEntity> findByPublicPathWithLimit(String publicPath, int limit);
|
||||||
|
|
||||||
@Insert
|
@Insert
|
||||||
void insert(FolderEntity folderEntity);
|
void insert(FolderEntity folderEntity);
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ public class FileManagerImpl implements FileManager {
|
|||||||
@AssistedInject
|
@AssistedInject
|
||||||
public FileManagerImpl(LacertaLogger logger, @Assisted Path rootDir) {
|
public FileManagerImpl(LacertaLogger logger, @Assisted Path rootDir) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
if (rootDir == null) {
|
||||||
|
throw new IllegalArgumentException("rootDir must not be null");
|
||||||
|
}
|
||||||
this.rootDir = rootDir;
|
this.rootDir = rootDir;
|
||||||
|
this.path = rootDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for generate new instance
|
// for generate new instance
|
||||||
@@ -62,6 +66,10 @@ public class FileManagerImpl implements FileManager {
|
|||||||
try {
|
try {
|
||||||
resolvedPath = resolvedPath.resolve(pathPart);
|
resolvedPath = resolvedPath.resolve(pathPart);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logger.error("resolveStringPath", e.getMessage());
|
||||||
|
logger.debug("resolveStringPath", "this.path: " + this.path);
|
||||||
|
logger.debug("resolveStringPath", "pathPart: " + pathPart);
|
||||||
|
logger.debug("resolveStringPath", "resolvedPath: " + resolvedPath);
|
||||||
throw new IOException("Invalid path: " + path);
|
throw new IOException("Invalid path: " + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package one.nem.lacerta.utils;
|
||||||
|
|
||||||
|
public class FeatureSwitch {
|
||||||
|
|
||||||
|
public static class Meta {
|
||||||
|
public static boolean canOverrideSwitch = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FeatureMaster {
|
||||||
|
public static boolean enableSearch = true;
|
||||||
|
public static boolean enableDebugMenu = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Setting {
|
||||||
|
public static boolean showDisplayMenu = false;
|
||||||
|
public static boolean showDataMenu = false;
|
||||||
|
public static boolean showScanMenu = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,9 @@ public class DeviceInfoUtilsImpl implements DeviceInfoUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getExternalStorageDirectory() {
|
public Path getExternalStorageDirectory() {
|
||||||
// TODO-rca: 結果がnullだった場合の処理を追加する?
|
if (applicationContext.getExternalFilesDir(null) == null) {
|
||||||
|
throw new RuntimeException("applicationContext.getExternalFilesDir(null) is null");
|
||||||
|
}
|
||||||
return Objects.requireNonNull(applicationContext.getExternalFilesDir(null)).toPath();
|
return Objects.requireNonNull(applicationContext.getExternalFilesDir(null)).toPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +33,9 @@ public class DeviceInfoUtilsImpl implements DeviceInfoUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getExternalStorageDirectory(String type) {
|
public Path getExternalStorageDirectory(String type) {
|
||||||
// TODO-rca: 結果がnullだった場合の処理を追加する?
|
if(applicationContext.getExternalFilesDir(type) == null) {
|
||||||
|
throw new RuntimeException("applicationContext.getExternalFilesDir(" + type + ") is null");
|
||||||
|
}
|
||||||
return Objects.requireNonNull(applicationContext.getExternalFilesDir(type)).toPath();
|
return Objects.requireNonNull(applicationContext.getExternalFilesDir(type)).toPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,17 @@ package one.nem.lacerta.utils.impl;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext;
|
import dagger.hilt.android.qualifiers.ApplicationContext;
|
||||||
|
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
|
||||||
import one.nem.lacerta.utils.repository.SharedPrefUtils;
|
import one.nem.lacerta.utils.repository.SharedPrefUtils;
|
||||||
|
|
||||||
public class SharedPrefUtilsImpl implements SharedPrefUtils{
|
public class SharedPrefUtilsImpl implements SharedPrefUtils{
|
||||||
|
|
||||||
private final Context applicationContext;
|
private final Context applicationContext;
|
||||||
|
|
||||||
|
@Inject
|
||||||
public SharedPrefUtilsImpl(@ApplicationContext Context applicationContext) {
|
public SharedPrefUtilsImpl(@ApplicationContext Context applicationContext) {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
}
|
}
|
||||||
@@ -26,4 +30,34 @@ public class SharedPrefUtilsImpl implements SharedPrefUtils{
|
|||||||
// Editorの取得
|
// Editorの取得
|
||||||
return applicationContext.getSharedPreferences(name, Context.MODE_PRIVATE).edit();
|
return applicationContext.getSharedPreferences(name, Context.MODE_PRIVATE).edit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SharedPreferences getSharedPreferences(String name) {
|
||||||
|
return applicationContext.getSharedPreferences(name, Context.MODE_PRIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SharedPreferences getSharedPreferences() {
|
||||||
|
return applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE); // TODO-rca: 決め打ちやめる?
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride) {
|
||||||
|
return getSharedPreferences().getBoolean(featureSwitchOverride.getKey(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride, boolean value) {
|
||||||
|
getEditor().putBoolean(featureSwitchOverride.getKey(), value).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getIsFirstLaunch() {
|
||||||
|
return getSharedPreferences().getBoolean("isFirstLaunch", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsFirstLaunch(boolean value) {
|
||||||
|
getEditor().putBoolean("isFirstLaunch", value).apply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,8 @@ import one.nem.lacerta.utils.LacertaLogger;
|
|||||||
|
|
||||||
public class XmlMetaParserImpl implements XmlMetaParser{
|
public class XmlMetaParserImpl implements XmlMetaParser{
|
||||||
|
|
||||||
|
String TAG = getClass().getSimpleName();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
LacertaLogger logger;
|
LacertaLogger logger;
|
||||||
|
|
||||||
@@ -35,13 +37,18 @@ public class XmlMetaParserImpl implements XmlMetaParser{
|
|||||||
meta.setRevisionId(rootElement.getElementsByTagName("revisionId").item(0).getTextContent());
|
meta.setRevisionId(rootElement.getElementsByTagName("revisionId").item(0).getTextContent());
|
||||||
|
|
||||||
ArrayList<XmlMetaPageModel> pages = new ArrayList<>();
|
ArrayList<XmlMetaPageModel> pages = new ArrayList<>();
|
||||||
for(int i = 0; i < rootElement.getElementsByTagName("pages").getLength(); i++) {
|
for (int i = 0; i < rootElement.getElementsByTagName("page").getLength(); i++) {
|
||||||
Element pageElement = (Element) rootElement.getElementsByTagName("page").item(i);
|
Element pageElement = (Element) rootElement.getElementsByTagName("page").item(i);
|
||||||
XmlMetaPageModel page = new XmlMetaPageModel();
|
XmlMetaPageModel page = new XmlMetaPageModel();
|
||||||
page.setFilename(pageElement.getElementsByTagName("filename").item(0).getTextContent());
|
page.setFilename(pageElement.getElementsByTagName("filename").item(0).getTextContent());
|
||||||
pages.add(page);
|
pages.add(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug(TAG, "Parsed Meta: " + meta.getRevisionId() + " " + pages.size() + " pages.");
|
||||||
|
for (XmlMetaPageModel page : pages) {
|
||||||
|
logger.debug(TAG, "\tPage: " + page.getFilename());
|
||||||
|
}
|
||||||
|
|
||||||
meta.setPages(pages);
|
meta.setPages(pages);
|
||||||
|
|
||||||
return meta;
|
return meta;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package one.nem.lacerta.utils.repository;
|
|||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
|
||||||
|
|
||||||
public interface SharedPrefUtils {
|
public interface SharedPrefUtils {
|
||||||
|
|
||||||
// Shared preferences editorの取得
|
// Shared preferences editorの取得
|
||||||
@@ -10,4 +12,15 @@ public interface SharedPrefUtils {
|
|||||||
// TODO-rca: 名称をenumで管理する?
|
// TODO-rca: 名称をenumで管理する?
|
||||||
SharedPreferences.Editor getEditor(String name);
|
SharedPreferences.Editor getEditor(String name);
|
||||||
|
|
||||||
|
SharedPreferences getSharedPreferences(String name);
|
||||||
|
|
||||||
|
SharedPreferences getSharedPreferences();
|
||||||
|
|
||||||
|
boolean getFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride);
|
||||||
|
|
||||||
|
void setFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride, boolean value);
|
||||||
|
|
||||||
|
boolean getIsFirstLaunch();
|
||||||
|
|
||||||
|
void setIsFirstLaunch(boolean value);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user