mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2026-11-07 19:47:36 +00:00
Compare commits
252
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67de02b502 | ||
|
|
5fafbec247 | ||
|
|
e104b3d8ff | ||
|
|
d8d8a5932b | ||
|
|
113a2fd3d2 | ||
|
|
4714e3d8cb | ||
|
|
14ff9abab9 | ||
|
|
1105c17fca | ||
|
|
37a18704e3 | ||
|
|
d5df291c81 | ||
|
|
3178e9233b | ||
|
|
004bedb45f | ||
|
|
de30eb241c | ||
|
|
c7f2a3eebe | ||
|
|
2a7e329ad7 | ||
|
|
52f41881fd | ||
|
|
68fb0b719b | ||
|
|
da8d4fb4fc | ||
|
|
f7d07b0ec3 | ||
|
|
7f71e818a8 | ||
|
|
fc6cbb9d37 | ||
|
|
df3edbf354 | ||
|
|
d40b188f87 | ||
|
|
253c77d6f5 | ||
|
|
b87b635d2b | ||
|
|
9df033af73 | ||
|
|
58e0686304 | ||
|
|
a0f89de1ac | ||
|
|
fe4999384a | ||
|
|
bc304f8535 | ||
|
|
e77fafc108 | ||
|
|
305cbcd679 | ||
|
|
c06d7e6b15 | ||
|
|
1648e0b7c1 | ||
|
|
04db160548 | ||
|
|
611c5b516d | ||
|
|
734f75b4c7 | ||
|
|
6e0c473c66 | ||
|
|
20828e2f0f | ||
|
|
3b684bec53 | ||
|
|
afef074242 | ||
|
|
1ceb3e29b7 | ||
|
|
a5fa89252c | ||
|
|
106bb93644 | ||
|
|
ab39cd4d00 | ||
|
|
d1a5cd2f23 | ||
|
|
0dc69e1d73 | ||
|
|
3d8ab69742 | ||
|
|
6bc43869c9 | ||
|
|
63dfbc120d | ||
|
|
064c4edfbe | ||
|
|
1a80d00319 | ||
|
|
3f893fc580 | ||
|
|
225058f836 | ||
|
|
c23b92d386 | ||
|
|
41e5ab2349 | ||
|
|
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 | ||
|
|
f392991988 | ||
|
|
556c7d0841 | ||
|
|
d43bcf09b2 | ||
|
|
6120427400 | ||
|
|
2b087a4c45 | ||
|
|
457e58264b | ||
|
|
4d5d02c794 | ||
|
|
b8f3b016b7 | ||
|
|
b6307f67ce | ||
|
|
1e8dec3021 | ||
|
|
86d290b217 | ||
|
|
02d26f864d | ||
|
|
5aa6c975da | ||
|
|
7075fc710d | ||
|
|
ba0cb871a4 | ||
|
|
95a2a44cb1 | ||
|
|
fd65b17921 | ||
|
|
a3f469b466 | ||
|
|
e86129295a | ||
|
|
f4c46fbd5d | ||
|
|
439b76f8bf | ||
|
|
ffd455c6d8 | ||
|
|
29c3fddd14 | ||
|
|
516a55e4e0 | ||
|
|
68e4d0639a | ||
|
|
db26e639e6 | ||
|
|
32cd27997c | ||
|
|
6fb8091754 | ||
|
|
0d7d47ea10 | ||
|
|
3d544fa423 | ||
|
|
487451712e | ||
|
|
e78718ab79 | ||
|
|
35c58e14ad | ||
|
|
4efad853f7 | ||
|
|
6c22050906 | ||
|
|
17dc90162b | ||
|
|
72933fd45b | ||
|
|
c8c0e37052 | ||
|
|
7b6d8e3a18 | ||
|
|
6167c412c7 | ||
|
|
226f09f8bb | ||
|
|
0c4ba99a07 | ||
|
|
097adebd9b | ||
|
|
03a75a5b29 | ||
|
|
0c6e2b1a98 | ||
|
|
a7b92120ba | ||
|
|
3f78dccf3b | ||
|
|
c6ddd6fd03 | ||
|
|
eab00983a8 | ||
|
|
038c526652 | ||
|
|
704c128801 | ||
|
|
209eab0755 | ||
|
|
65d48d03fd | ||
|
|
dcd5f1b650 | ||
|
|
a74eb821f8 | ||
|
|
738d8a055c | ||
|
|
2e5559df88 | ||
|
|
dc1cc429e9 | ||
|
|
339566b243 | ||
|
|
0e1d4703e5 | ||
|
|
bcaa0e5c5c | ||
|
|
cbc1d139af | ||
|
|
ef48223d46 | ||
|
|
81ba96a3d0 | ||
|
|
80104a2285 | ||
|
|
b9973b845f | ||
|
|
a325ace6f3 | ||
|
|
7a2beececc | ||
|
|
4b5ce622fd | ||
|
|
5d8b9f338d | ||
|
|
9d2e5dd217 | ||
|
|
9ad6a6291d | ||
|
|
4235030986 | ||
|
|
c60fedeb87 | ||
|
|
2f18134581 | ||
|
|
4101f75685 |
No files matched your search
Generated
+2
-2
@@ -4,10 +4,10 @@
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<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">
|
||||
<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>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
|
||||
Generated
+1
-1
@@ -4,7 +4,6 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="jbr-17" />
|
||||
<option name="modules">
|
||||
@@ -23,6 +22,7 @@
|
||||
<option value="$PROJECT_DIR$/feature/library" />
|
||||
<option value="$PROJECT_DIR$/feature/scan" />
|
||||
<option value="$PROJECT_DIR$/feature/search" />
|
||||
<option value="$PROJECT_DIR$/feature/setting" />
|
||||
<option value="$PROJECT_DIR$/model" />
|
||||
<option value="$PROJECT_DIR$/processor" />
|
||||
<option value="$PROJECT_DIR$/shared" />
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" 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">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -74,7 +74,12 @@ dependencies {
|
||||
implementation project(':feature:library')
|
||||
implementation project(':feature:scan')
|
||||
implementation project(':feature:debug') // デバッグメニュー
|
||||
implementation project(':feature:setting') // 設定画面
|
||||
|
||||
implementation project(':data')
|
||||
implementation project(':shared:ui')
|
||||
|
||||
implementation project(':model')
|
||||
|
||||
implementation project(':utils')
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package one.nem.lacerta;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
@@ -10,31 +13,47 @@ import androidx.navigation.ui.NavigationUI;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import one.nem.lacerta.model.FragmentNavigation;
|
||||
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
|
||||
import one.nem.lacerta.utils.FeatureSwitch;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
|
||||
|
||||
import java.io.NotActiveException;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.utils.repository.SharedPrefUtils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@AndroidEntryPoint
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
public class MainActivity extends AppCompatActivity implements FragmentNavigation {
|
||||
|
||||
@Inject
|
||||
SharedPrefUtils sharedPrefUtils;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
|
||||
|
||||
// Initialize app
|
||||
if (sharedPrefUtils.getIsFirstLaunch()) initializeApp();
|
||||
|
||||
// Init navigation
|
||||
try {
|
||||
FragmentManager supportFragmentManager = getSupportFragmentManager();
|
||||
NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment);
|
||||
assert navHostFragment != null;
|
||||
NavController navController = navHostFragment.getNavController();
|
||||
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
|
||||
NavigationUI.setupWithNavController(bottomNavigationView, navController);
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -44,7 +63,95 @@ public class MainActivity extends AppCompatActivity {
|
||||
finish(); // Exit app
|
||||
}
|
||||
|
||||
// Apply feature switch
|
||||
applyFeatureSwitch(bottomNavigationView, FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch, one.nem.lacerta.feature.search.R.id.feature_search_navigation);
|
||||
applyFeatureSwitch(bottomNavigationView, FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu, one.nem.lacerta.feature.debug.R.id.feature_debug_navigation);
|
||||
|
||||
|
||||
// Set navigation bar color
|
||||
getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurfaceVariant));
|
||||
getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
|
||||
|
||||
// Set status bar color
|
||||
getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface));
|
||||
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigateToFragment(Fragment fragment) {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.nav_host_fragment, fragment)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigateToFragment(Fragment fragment, boolean addToBackStack) {
|
||||
if (addToBackStack) {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.nav_host_fragment, fragment)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.nav_host_fragment, fragment)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigateToFragment(Fragment fragment, boolean addToBackStack, boolean clearBackStack) {
|
||||
if (clearBackStack) {
|
||||
getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
}
|
||||
if (addToBackStack) {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.nav_host_fragment, fragment)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.nav_host_fragment, fragment)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
|
||||
public void navigateToFragmentAlternate(Fragment fragment, boolean addToBackStack) {
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
|
||||
// get the current fragment
|
||||
Fragment currentFragment = getSupportFragmentManager().getPrimaryNavigationFragment();
|
||||
|
||||
// hide the current fragment
|
||||
if (currentFragment != null) {
|
||||
transaction.hide(currentFragment);
|
||||
}
|
||||
|
||||
// Add the new fragment
|
||||
transaction.add(R.id.nav_host_fragment, fragment);
|
||||
|
||||
// Add the transaction to the back stack if needed
|
||||
if (addToBackStack) {
|
||||
transaction.addToBackStack(null);
|
||||
}
|
||||
|
||||
// Commit the transaction
|
||||
transaction.commit();
|
||||
|
||||
// Update the primary navigation fragment
|
||||
getSupportFragmentManager().beginTransaction().setPrimaryNavigationFragment(fragment).commit();
|
||||
}
|
||||
}
|
||||
@@ -18,15 +18,20 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/main_nav"
|
||||
tools:layout="@layout/fragment_debug_menu_container" />
|
||||
tools:layout="@layout/fragment_home_top" />
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_nav"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorSecondaryContainer"
|
||||
app:itemIconTint="@color/colorOnSecondaryContainer"
|
||||
app:itemTextColor="@color/colorOnSecondaryContainer"
|
||||
app:itemActiveIndicatorStyle="@style/Lacerta.Custom.Indicator"
|
||||
app:labelVisibilityMode="selected"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:menu="@menu/bottom_nav_menu"/>
|
||||
app:menu="@menu/bottom_nav_menu" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -4,21 +4,26 @@
|
||||
<item
|
||||
android:id="@id/feature_home_navigation"
|
||||
android:icon="@drawable/home_24px"
|
||||
android:title="Home"/>
|
||||
android:title="@string/home_title"/>
|
||||
|
||||
<item
|
||||
android:id="@id/feature_search_navigation"
|
||||
android:icon="@drawable/search_24px"
|
||||
android:title="Search"/>
|
||||
android:title="@string/search_title"/>
|
||||
|
||||
<item
|
||||
android:id="@id/feature_library_navigation"
|
||||
android:icon="@drawable/folder_24px"
|
||||
android:title="Library"/>
|
||||
android:title="@string/library_title"/>
|
||||
|
||||
<item
|
||||
android:id="@id/feature_debug_navigation"
|
||||
android:icon="@drawable/developer_mode_24px"
|
||||
android:title="Debug menu"/>
|
||||
android:title="@string/debug_menu_title" />
|
||||
|
||||
<item
|
||||
android:id="@id/feature_setting_navigation"
|
||||
android:icon="@drawable/settings_24px"
|
||||
android:title="@string/setting_title"/>
|
||||
|
||||
</menu>
|
||||
@@ -2,14 +2,17 @@
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/app_main_nav"
|
||||
app:startDestination="@id/feature_debug_navigation">
|
||||
app:startDestination="@id/feature_home_navigation">
|
||||
|
||||
<include app:graph="@navigation/feature_debug_navigation" />
|
||||
|
||||
<include app:graph="@navigation/feature_library_navigation" />
|
||||
|
||||
<include app:graph="@navigation/feature_home_navigation" />
|
||||
|
||||
<include app:graph="@navigation/feature_search_navigation" />
|
||||
|
||||
<include app:graph="@navigation/feature_setting_navigation" />
|
||||
|
||||
|
||||
</navigation>
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.component.common'
|
||||
compileSdk 33
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
@@ -32,4 +32,6 @@ dependencies {
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.androidx.test.ext.junit
|
||||
androidTestImplementation libs.androidx.test.espresso.core
|
||||
|
||||
implementation project(':shared:ui')
|
||||
}
|
||||
@@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.component.scanner'
|
||||
compileSdk 33
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
|
||||
+29
-13
@@ -1,5 +1,6 @@
|
||||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
@@ -22,6 +23,7 @@ import com.websitebeaver.documentscanner.DocumentScanner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -152,21 +154,35 @@ public class ScannerManagerActivity extends AppCompatActivity {
|
||||
|
||||
private void saveNewDocument() {
|
||||
logger.debug(TAG, "saveNewDocument");
|
||||
// Deprecatedだが、中断機能が存在しないので操作をブロックする目的で(意図的に)使用
|
||||
ProgressDialog dialog = new ProgressDialog(this);
|
||||
dialog.setMessage("保存中..."); // TODO-rca: テキストをリソースに移動
|
||||
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする
|
||||
DocumentDetail documentDetail = document.createDocument(documentMeta);
|
||||
Bitmap[] bitmaps = new Bitmap[this.croppedImages.size()];
|
||||
this.croppedImages.toArray(bitmaps);
|
||||
try {
|
||||
documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps);
|
||||
Toast.makeText(this, "Saved.", Toast.LENGTH_SHORT).show();
|
||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit");
|
||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).printLog(); // Debug
|
||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).printRev(); // Debug
|
||||
document.createDocument(documentMeta).thenAccept((documentDetail) -> {
|
||||
Bitmap[] bitmaps = new Bitmap[croppedImages.size()];
|
||||
croppedImages.toArray(bitmaps);
|
||||
logger.debug(TAG, "bitmaps.length: " + bitmaps.length);
|
||||
addPagesToDocumentDetail(documentDetail, bitmaps).join();
|
||||
document.updateDocument(documentDetail).join();
|
||||
dialog.dismiss();
|
||||
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() {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
plugins {
|
||||
alias(libs.plugins.com.android.library)
|
||||
id 'com.google.dagger.hilt.android'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.component.viewer'
|
||||
compileSdk 33
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
@@ -29,7 +30,28 @@ dependencies {
|
||||
|
||||
implementation libs.androidx.appcompat
|
||||
implementation libs.com.google.android.material
|
||||
implementation libs.androidx.activity
|
||||
implementation libs.androidx.constraintlayout
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.androidx.test.ext.junit
|
||||
androidTestImplementation libs.androidx.test.espresso.core
|
||||
|
||||
// Navigation
|
||||
implementation libs.navigation.fragment
|
||||
implementation libs.navigation.ui
|
||||
implementation libs.navigation.dynamic.features.fragment
|
||||
|
||||
// DI
|
||||
implementation libs.com.google.dagger.hilt.android
|
||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||
|
||||
// shared
|
||||
implementation project(':shared:ui')
|
||||
|
||||
implementation project(':utils')
|
||||
|
||||
implementation project(':data')
|
||||
|
||||
implementation project(':model')
|
||||
|
||||
}
|
||||
@@ -1,4 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".ViewerMainActivity"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
+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.util.ArrayList;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import one.nem.lacerta.model.document.DocumentMeta;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
@@ -13,13 +14,13 @@ import one.nem.lacerta.model.document.tag.DocumentTag;
|
||||
*/
|
||||
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,25 +1,29 @@
|
||||
package one.nem.lacerta.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
import one.nem.lacerta.model.ListItemType;
|
||||
|
||||
import one.nem.lacerta.model.LibraryItemPage;
|
||||
import one.nem.lacerta.model.PublicPath;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
|
||||
public interface LacertaLibrary {
|
||||
|
||||
// Get History
|
||||
ArrayList<ListItem> getRecentDocument(int limit);
|
||||
ArrayList<ListItem> getRecentDocument(int limit, int offset);
|
||||
CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit);
|
||||
CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit, int offset);
|
||||
|
||||
// Get Library page
|
||||
LibraryItemPage getLibraryPage(int limit);
|
||||
LibraryItemPage getLibraryPage(int limit, int offset);
|
||||
LibraryItemPage getLibraryPage(String pageId, int limit);
|
||||
LibraryItemPage getLibraryPage(String pageId, int limit, int offset);
|
||||
// Get Library Page
|
||||
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit);
|
||||
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset);
|
||||
|
||||
// Create Folder
|
||||
CompletableFuture<String> createFolder(String parentId, String name);
|
||||
|
||||
// Get Public Path
|
||||
CompletableFuture<PublicPath> getPublicPath(String itemId, ListItemType itemType);
|
||||
|
||||
// GetDocument
|
||||
DocumentDetail getDocumentDetailById(String id); // TODO-rca: Documentに統合する
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
// Hilt
|
||||
import javax.inject.Inject;
|
||||
@@ -16,13 +18,20 @@ import one.nem.lacerta.model.document.DocumentMeta;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
|
||||
// Lacerta/source
|
||||
import one.nem.lacerta.model.document.internal.XmlMetaModel;
|
||||
import one.nem.lacerta.model.document.internal.XmlMetaPageModel;
|
||||
import one.nem.lacerta.model.document.page.Page;
|
||||
import one.nem.lacerta.source.database.LacertaDatabase;
|
||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||
|
||||
// Lacerta/utils
|
||||
import one.nem.lacerta.source.file.FileManager;
|
||||
import one.nem.lacerta.source.file.factory.FileManagerFactory;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
// Lacerta/vcs
|
||||
import one.nem.lacerta.utils.XmlMetaParser;
|
||||
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
|
||||
import one.nem.lacerta.vcs.LacertaVcs;
|
||||
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
||||
|
||||
@@ -40,6 +49,14 @@ public class DocumentImpl implements Document {
|
||||
@Inject
|
||||
LacertaVcsFactory vcsFactory;
|
||||
|
||||
@Inject
|
||||
FileManagerFactory fileManagerFactory;
|
||||
|
||||
@Inject
|
||||
DeviceInfoUtils deviceInfoUtils;
|
||||
|
||||
@Inject
|
||||
XmlMetaParser xmlMetaParser;
|
||||
|
||||
@Inject
|
||||
public DocumentImpl() {
|
||||
@@ -49,35 +66,37 @@ public class DocumentImpl implements Document {
|
||||
|
||||
|
||||
@Override
|
||||
public DocumentDetail createDocument(DocumentMeta meta) {
|
||||
DocumentDetail detail = new DocumentDetail();
|
||||
detail.setMeta(meta);
|
||||
detail.setPages(new ArrayList<>());
|
||||
public CompletableFuture<DocumentDetail> createDocument(DocumentMeta meta) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
DocumentDetail detail = new DocumentDetail();
|
||||
detail.setMeta(meta);
|
||||
detail.setPages(new ArrayList<>());
|
||||
// Create DocumentEntity
|
||||
DocumentEntity documentEntity = new DocumentEntity();
|
||||
documentEntity.id = meta.getId();
|
||||
documentEntity.title = meta.getTitle();
|
||||
documentEntity.author = meta.getAuthor();
|
||||
documentEntity.defaultBranch = meta.getDefaultBranch();
|
||||
documentEntity.updatedAt = meta.getUpdatedAt();
|
||||
documentEntity.createdAt = meta.getCreatedAt();
|
||||
documentEntity.parentId = meta.getParentId();
|
||||
documentEntity.tagIds = meta.getTagIds();
|
||||
|
||||
// TODO-rca: UIスレッドから追い出す
|
||||
database.documentDao().insert(documentEntity);
|
||||
|
||||
// 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();
|
||||
// Vcs
|
||||
LacertaVcs vcs = vcsFactory.create(meta.getId());
|
||||
vcs.createDocument(meta.getId());
|
||||
|
||||
database.documentDao().insert(documentEntity);
|
||||
// XmlMeta
|
||||
updateXmlMeta(detail).join();
|
||||
|
||||
// Vcs
|
||||
LacertaVcs vcs = vcsFactory.create(meta.getId());
|
||||
vcs.createDocument(meta.getId());
|
||||
|
||||
return detail;
|
||||
return detail;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentDetail createDocument() {
|
||||
public CompletableFuture<DocumentDetail> createDocument() {
|
||||
DocumentMeta meta = new DocumentMeta();
|
||||
meta.setId(UUID.randomUUID().toString());
|
||||
meta.setTitle("New Document");
|
||||
@@ -85,23 +104,118 @@ public class DocumentImpl implements Document {
|
||||
meta.setDefaultBranch("master");
|
||||
meta.setUpdatedAt(new Date());
|
||||
meta.setCreatedAt(new Date());
|
||||
meta.setPath(new PublicPath().getRoot()); // TODO-rca: 2回インスタンスを生成していて無駄なのでなんとかする
|
||||
meta.setParentId(null);
|
||||
meta.setTags(new ArrayList<>());
|
||||
return createDocument(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDocument(String documentId) {
|
||||
|
||||
public CompletableFuture<Void> deleteDocument(String documentId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDocument(DocumentMeta meta, DocumentDetail detail) {
|
||||
|
||||
public CompletableFuture<Void> updateDocument(DocumentDetail detail) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
updateXmlMeta(detail).join();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentDetail getDocument(String documentId) {
|
||||
return null;
|
||||
public CompletableFuture<DocumentDetail> getDocument(String documentId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
DocumentEntity documentEntity = database.documentDao().findById(documentId);
|
||||
if (documentEntity == null) {
|
||||
throw new IllegalArgumentException("documentId is not found");
|
||||
}
|
||||
DocumentMeta meta = new DocumentMeta();
|
||||
meta.setId(documentEntity.id);
|
||||
meta.setTitle(documentEntity.title);
|
||||
meta.setAuthor(documentEntity.author);
|
||||
meta.setDefaultBranch(documentEntity.defaultBranch);
|
||||
meta.setUpdatedAt(documentEntity.updatedAt);
|
||||
meta.setCreatedAt(documentEntity.createdAt);
|
||||
meta.setParentId(documentEntity.parentId);
|
||||
meta.setTags(new ArrayList<>()); // TODO-rca: タグを取得する
|
||||
|
||||
DocumentDetail detail = new DocumentDetail();
|
||||
|
||||
getPagesByXmlMeta(documentId).thenCompose(xmlMetaPageModels -> getPagesByXmlMetaPageModel(documentId, xmlMetaPageModels)).thenAccept(pages -> {
|
||||
logger.debug(TAG, "pages: " + pages.size());
|
||||
detail.setMeta(meta);
|
||||
detail.setPages(pages);
|
||||
}).join();
|
||||
|
||||
return detail;
|
||||
});
|
||||
}
|
||||
|
||||
private CompletableFuture<ArrayList<XmlMetaPageModel>> getPagesByXmlMeta(String documentId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
|
||||
try {
|
||||
ArrayList<XmlMetaPageModel> xmlMetaPageModels = xmlMetaParser.deserialize(fileManager.resolve(documentId).loadXml("meta.xml")).getPages();
|
||||
// Debug
|
||||
logger.debug(TAG, "xmlMetaPageModels: " + xmlMetaPageModels.size());
|
||||
for (XmlMetaPageModel xmlMetaPageModel : xmlMetaPageModels) {
|
||||
logger.debug(TAG, "\txmlMetaPageModel: " + xmlMetaPageModel.getFilename());
|
||||
}
|
||||
return xmlMetaPageModels;
|
||||
} catch (IOException e) {
|
||||
logger.error(TAG, "DocumentMeta parse error");
|
||||
logger.trace(TAG, e.getMessage());
|
||||
logger.e_code("db18c04a-1625-4871-9e4e-918d805568ac");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private CompletableFuture<ArrayList<Page>> getPagesByXmlMetaPageModel(String documentId, ArrayList<XmlMetaPageModel> xmlMetaPageModels) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ArrayList<Page> pages = new ArrayList<>();
|
||||
FileManager fileManager;
|
||||
try {
|
||||
fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory()).resolve(documentId);
|
||||
} catch (IOException e) {
|
||||
logger.error(TAG, "FileManager resolve error");
|
||||
logger.trace(TAG, e.getMessage());
|
||||
logger.e_code("2235e8ee-4177-46f8-af6b-084381b202e6");
|
||||
return null;
|
||||
}
|
||||
for (XmlMetaPageModel xmlMetaPageModel : xmlMetaPageModels) {
|
||||
try {
|
||||
pages.add(new Page(xmlMetaPageModel.getFilename(), fileManager.resolve("raw").loadBitmap(xmlMetaPageModel.getFilename())));
|
||||
} catch (IOException e) {
|
||||
logger.error(TAG, "Bitmap decode error");
|
||||
logger.trace(TAG, e.getMessage());
|
||||
logger.e_code("3bba8c8f-90fb-4a24-a726-7ea201929f8b");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return pages;
|
||||
});
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> updateXmlMeta(DocumentDetail documentDetail) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
// TODO-rca: リビジョンIDを検証する, 挿入する
|
||||
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
|
||||
ArrayList<XmlMetaPageModel> xmlMetaPageModels = new ArrayList<>();
|
||||
for (Page page : documentDetail.getPages()) {
|
||||
xmlMetaPageModels.add(new XmlMetaPageModel(page.getFileName()));
|
||||
}
|
||||
try {
|
||||
fileManager.createDirectoryIfNotExist(documentDetail.getMeta().getId()).resolve(documentDetail.getMeta().getId())
|
||||
.createFileIfNotExist("meta.xml").resolve("meta.xml").saveXml(xmlMetaParser.serialize(new XmlMetaModel("revisionId_PLACEHOLDER", xmlMetaPageModels)));
|
||||
} catch (IOException e) {
|
||||
logger.error(TAG, "DocumentMeta serialize error");
|
||||
logger.trace(TAG, e.getMessage());
|
||||
logger.e_code("e3b4d0c9-5b7e-4b7e-9e9a-5b8b8b8b8b8b");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -10,63 +15,186 @@ import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.model.LibraryItemPage;
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
import one.nem.lacerta.model.ListItemType;
|
||||
import one.nem.lacerta.model.PublicPath;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
import one.nem.lacerta.source.database.LacertaDatabase;
|
||||
import one.nem.lacerta.source.database.common.DateTypeConverter;
|
||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||
import one.nem.lacerta.source.database.entity.FolderEntity;
|
||||
import one.nem.lacerta.utils.FeatureSwitch;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
public class LacertaLibraryImpl implements LacertaLibrary {
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
@Inject
|
||||
LacertaDatabase database;
|
||||
|
||||
@Override
|
||||
public ArrayList<ListItem> getRecentDocument(int limit) {
|
||||
List<DocumentEntity> documentEntities = database.documentDao().getRecentDocument(limit);
|
||||
|
||||
ArrayList<ListItem> listItems = new ArrayList<>();
|
||||
for (DocumentEntity documentEntity : documentEntities) {
|
||||
ListItem listItem = new ListItem();
|
||||
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
||||
listItem.setTitle(documentEntity.title);
|
||||
listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt));
|
||||
listItem.setItemId(documentEntity.id);
|
||||
listItems.add(listItem);
|
||||
}
|
||||
return listItems;
|
||||
@Inject
|
||||
public LacertaLibraryImpl(LacertaLogger logger, LacertaDatabase database) {
|
||||
this.logger = logger;
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
@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
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibraryItemPage getLibraryPage(int limit) {
|
||||
return null;
|
||||
public CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||
|
||||
List<FolderEntity> folderEntities;
|
||||
List<DocumentEntity> documentEntities;
|
||||
|
||||
if (pageId == null) { // When root folder
|
||||
libraryItemPage.setPageTitle("ライブラリ");
|
||||
libraryItemPage.setPageId(null);
|
||||
libraryItemPage.setParentId(null);
|
||||
|
||||
folderEntities = database.folderDao().findRootFolders();
|
||||
documentEntities = database.documentDao().findRootDocuments();
|
||||
} else {
|
||||
FolderEntity folderEntity = database.folderDao().findById(pageId);
|
||||
if (folderEntity == null) {
|
||||
logger.warn("LacertaLibraryImpl", pageId + " is not found.");
|
||||
return null;
|
||||
}
|
||||
libraryItemPage.setPageTitle(folderEntity.name);
|
||||
libraryItemPage.setPageId(folderEntity.id);
|
||||
libraryItemPage.setParentId(folderEntity.parentId);
|
||||
|
||||
folderEntities = database.folderDao().findByParentId(pageId);
|
||||
documentEntities = database.documentDao().findByParentId(pageId);
|
||||
}
|
||||
|
||||
ArrayList<ListItem> listItems = new ArrayList<>();
|
||||
for (FolderEntity childFolderEntity : folderEntities) {
|
||||
logger.debug("LacertaLibraryImpl", "childFolderEntity.name: " + childFolderEntity.name);
|
||||
ListItem listItem = new ListItem();
|
||||
listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
|
||||
listItem.setTitle(childFolderEntity.name);
|
||||
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
|
||||
listItem.setItemId(childFolderEntity.id);
|
||||
listItems.add(listItem);
|
||||
}
|
||||
|
||||
for (DocumentEntity documentEntity : documentEntities) {
|
||||
logger.debug("LacertaLibraryImpl", "documentEntity.title: " + documentEntity.title);
|
||||
ListItem listItem = new ListItem();
|
||||
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
||||
listItem.setTitle(documentEntity.title);
|
||||
// listItem.setDescription(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm").format(documentEntity.updatedAt.toInstant()));
|
||||
listItem.setItemId(documentEntity.id);
|
||||
listItems.add(listItem);
|
||||
}
|
||||
|
||||
libraryItemPage.setListItems(listItems);
|
||||
|
||||
logger.debug("LacertaLibraryImpl", "libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||
|
||||
return libraryItemPage;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibraryItemPage getLibraryPage(int limit, int offset) {
|
||||
return null;
|
||||
public CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibraryItemPage getLibraryPage(String pageId, int limit) {
|
||||
return null;
|
||||
public CompletableFuture<String> createFolder(String parentId, String name) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
FolderEntity folderEntity = new FolderEntity();
|
||||
folderEntity.id = UUID.randomUUID().toString();
|
||||
folderEntity.name = name;
|
||||
folderEntity.parentId = parentId;
|
||||
database.folderDao().insert(folderEntity);
|
||||
return folderEntity.id;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibraryItemPage getLibraryPage(String pageId, int limit, int offset) {
|
||||
return null;
|
||||
public CompletableFuture<PublicPath> getPublicPath(String itemId, ListItemType itemType) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
|
||||
DocumentEntity documentEntity = database.documentDao().findById(itemId);
|
||||
if (documentEntity == null) {
|
||||
logger.warn("LacertaLibraryImpl", itemId + " is not found.");
|
||||
return null;
|
||||
}
|
||||
PublicPath publicPath = recursiveResolve(documentEntity.parentId);
|
||||
publicPath.resolve(documentEntity.title);
|
||||
return publicPath;
|
||||
} else if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
|
||||
FolderEntity folderEntity = database.folderDao().findById(itemId);
|
||||
if (folderEntity == null) {
|
||||
return null;
|
||||
}
|
||||
return recursiveResolve(folderEntity.id);
|
||||
} else {
|
||||
logger.warn("LacertaLibraryImpl", "Unknown ListItemType: " + itemType);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentDetail getDocumentDetailById(String id) {
|
||||
return null;
|
||||
/**
|
||||
* 再帰的にパスを解決する
|
||||
*
|
||||
* @param folderId
|
||||
* @return
|
||||
*/
|
||||
private PublicPath recursiveResolve(String folderId) {
|
||||
String current = folderId;
|
||||
boolean continueFlag = true;
|
||||
ArrayList<String> folderNames = new ArrayList<>();
|
||||
while (continueFlag) {
|
||||
FolderEntity folderEntity = database.folderDao().findById(current);
|
||||
if (folderEntity == null) { // 存在しないフォルダIDが指定された場合
|
||||
continueFlag = false;
|
||||
} else {
|
||||
folderNames.add(folderEntity.name);
|
||||
current = folderEntity.parentId;
|
||||
if (current == null) { // ルートフォルダに到達した場合
|
||||
continueFlag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// フォルダ名を逆順にしてListに変換
|
||||
Collections.reverse(folderNames);
|
||||
List<String> folderNamesReversed = new ArrayList<>(folderNames);
|
||||
|
||||
return new PublicPath(folderNamesReversed);
|
||||
}
|
||||
}
|
||||
@@ -1,219 +1,219 @@
|
||||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.model.LibraryItemPage;
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
import one.nem.lacerta.model.ListItemType;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
|
||||
import one.nem.lacerta.model.document.DocumentMeta;
|
||||
import one.nem.lacerta.model.document.path.DocumentPath;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
import com.github.javafaker.DateAndTime;
|
||||
import com.github.javafaker.Faker;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* LacertaLibraryのスタブ実装
|
||||
*/
|
||||
public class LacertaLibraryStubImpl implements LacertaLibrary {
|
||||
|
||||
LacertaLogger logger;
|
||||
|
||||
Faker faker;
|
||||
|
||||
@Inject
|
||||
public LacertaLibraryStubImpl(LacertaLogger logger) {
|
||||
faker = new Faker(); // Init Faker
|
||||
this.logger = logger;
|
||||
logger.debug("LibraryStub", "Initialized");
|
||||
}
|
||||
|
||||
// Internal Methods
|
||||
|
||||
// Generate Stub Data
|
||||
private LibraryItemPage generateStubLibraryItemPage(int limit, String pageId) {
|
||||
logger.debug("LibraryStub", "generateStubLibraryItemPage");
|
||||
ArrayList<ListItem> listItems = new ArrayList<>();
|
||||
int itemTotal = faker.number().numberBetween(1, limit); // 実際に返却するアイテム数を決定
|
||||
int folderTotal;
|
||||
// フォルダ数の抽選
|
||||
if (itemTotal > 4) {
|
||||
folderTotal = faker.number().numberBetween(1, itemTotal - 2);
|
||||
}
|
||||
else {
|
||||
if (itemTotal > 2) {
|
||||
folderTotal = 1;
|
||||
}
|
||||
else { // ドキュメント数がゼロにならないように
|
||||
folderTotal = 0;
|
||||
}
|
||||
}
|
||||
int documentTotal = itemTotal - folderTotal; // ドキュメント数を決定
|
||||
logger.debug("LibraryStub", "itemTotal: " + itemTotal);
|
||||
logger.debug("LibraryStub", "folderTotal: " + folderTotal);
|
||||
logger.debug("LibraryStub", "documentTotal: " + documentTotal);
|
||||
|
||||
// フォルダを生成
|
||||
for (int i = 0; i < folderTotal; i++) {
|
||||
listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_FOLDER));
|
||||
}
|
||||
// ドキュメントを生成
|
||||
for (int i = 0; i < documentTotal; i++) {
|
||||
listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
|
||||
}
|
||||
|
||||
LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||
libraryItemPage.setListItems(listItems);
|
||||
if (pageId == null) {
|
||||
libraryItemPage.setPageId(UUID.randomUUID().toString());
|
||||
} else {
|
||||
libraryItemPage.setPageId(pageId);
|
||||
}
|
||||
libraryItemPage.setPageTitle("FakePage" + faker.number().digits(3));
|
||||
|
||||
return libraryItemPage;
|
||||
}
|
||||
|
||||
private ListItem generateStubListItem(ListItemType itemType) {
|
||||
if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
|
||||
ListItem listItem = new ListItem();
|
||||
listItem.setTitle("FakeFolder" + faker.number().digits(3));
|
||||
listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
|
||||
listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
|
||||
listItem.setItemId(UUID.randomUUID().toString());
|
||||
return listItem;
|
||||
} else if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
|
||||
ListItem listItem = new ListItem();
|
||||
listItem.setTitle("FakeDocument" + faker.book().title());
|
||||
listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
|
||||
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
||||
listItem.setItemId(UUID.randomUUID().toString());
|
||||
return listItem;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private LibraryItemPage getRecentDocumentPage(int limit) {
|
||||
int itemTotal = faker.number().numberBetween(1, limit);
|
||||
ArrayList<ListItem> listItems = new ArrayList<>();
|
||||
for (int i = 0; i < itemTotal; i++) {
|
||||
listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
|
||||
}
|
||||
// DescriptionからDateを抽出して新しい順にソート
|
||||
listItems.sort((a, b) -> {
|
||||
String aDate = a.getDescription().substring(11);
|
||||
String bDate = b.getDescription().substring(11);
|
||||
return bDate.compareTo(aDate);
|
||||
});
|
||||
LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||
libraryItemPage.setListItems(listItems);
|
||||
libraryItemPage.setPageId(UUID.randomUUID().toString());
|
||||
libraryItemPage.setPageTitle("RecentDocument");
|
||||
return libraryItemPage;
|
||||
}
|
||||
|
||||
private DocumentDetail generateStubDocumentDetail(String id) throws IllegalArgumentException {
|
||||
|
||||
if (Objects.isNull(id)) {
|
||||
throw new IllegalArgumentException("id is null");
|
||||
}
|
||||
|
||||
DocumentMeta documentMeta = new DocumentMeta();
|
||||
documentMeta.setId(id);
|
||||
documentMeta.setTitle("FakeDocument" + faker.book().title());
|
||||
documentMeta.setCreatedAt(faker.date().birthday());
|
||||
documentMeta.setUpdatedAt(faker.date().birthday()); // TODO-rca: 更新日のほうが古くなることがあるのでなんとかする?
|
||||
ArrayList<String> tagIds = new ArrayList<>();
|
||||
|
||||
DocumentDetail documentDetail = new DocumentDetail();
|
||||
documentDetail.setMeta(documentMeta);
|
||||
// documentDetail.setPath(null); // TODO-rca: なんとかする
|
||||
// documentDetail.setAuthor(faker.name().fullName());
|
||||
// documentDetail.setRepository(null); // TODO-rca: なんとかする
|
||||
return documentDetail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 履歴ページを取得する
|
||||
* @param limit 取得するアイテム数
|
||||
* @return ページオブジェクト
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<ListItem> getRecentDocument(int limit) {
|
||||
return getRecentDocumentPage(limit).getListItems();
|
||||
}
|
||||
|
||||
/**
|
||||
* 履歴ページを取得する
|
||||
* @param limit 取得するアイテム数
|
||||
* @param offset 取得するアイテムのオフセット
|
||||
* @return ページオブジェクト
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
|
||||
return getRecentDocumentPage(limit).getListItems();
|
||||
}
|
||||
|
||||
/**
|
||||
* ライブラリページを取得する
|
||||
* @param limit 取得するアイテム数
|
||||
* @return ページオブジェクト
|
||||
*/
|
||||
@Override
|
||||
public LibraryItemPage getLibraryPage(int limit) {
|
||||
return generateStubLibraryItemPage(limit, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* ライブラリページを取得する
|
||||
* @param limit 取得するアイテム数
|
||||
* @param offset 取得するアイテムのオフセット
|
||||
* @return ページオブジェクト
|
||||
*/
|
||||
@Override
|
||||
public LibraryItemPage getLibraryPage(int limit, int offset) {
|
||||
return generateStubLibraryItemPage(limit, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* ライブラリページを取得する
|
||||
* @param pageId ページID
|
||||
* @param limit 取得するアイテム数
|
||||
* @return ページオブジェクト
|
||||
*/
|
||||
@Override
|
||||
public LibraryItemPage getLibraryPage(String pageId, int limit) {
|
||||
return generateStubLibraryItemPage(limit, pageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* ライブラリページを取得する
|
||||
* @param pageId ページID
|
||||
* @param limit 取得するアイテム数
|
||||
* @param offset 取得するアイテムのオフセット
|
||||
* @return ページオブジェクト
|
||||
*/
|
||||
@Override
|
||||
public LibraryItemPage getLibraryPage(String pageId, int limit, int offset) {
|
||||
return generateStubLibraryItemPage(limit, pageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* ドキュメント詳細を取得する
|
||||
* @param id ドキュメントID
|
||||
* @return ドキュメント詳細オブジェクト
|
||||
*/
|
||||
@Override
|
||||
public DocumentDetail getDocumentDetailById(String id) throws IllegalArgumentException {
|
||||
return generateStubDocumentDetail(id);
|
||||
}
|
||||
}
|
||||
//package one.nem.lacerta.data.impl;
|
||||
//
|
||||
//import one.nem.lacerta.data.LacertaLibrary;
|
||||
//import one.nem.lacerta.model.LibraryItemPage;
|
||||
//import one.nem.lacerta.model.ListItem;
|
||||
//import one.nem.lacerta.model.ListItemType;
|
||||
//import one.nem.lacerta.model.document.DocumentDetail;
|
||||
//
|
||||
//import one.nem.lacerta.model.document.DocumentMeta;
|
||||
//import one.nem.lacerta.model.document.path.DocumentPath;
|
||||
//import one.nem.lacerta.utils.LacertaLogger;
|
||||
//
|
||||
//import com.github.javafaker.DateAndTime;
|
||||
//import com.github.javafaker.Faker;
|
||||
//
|
||||
//import java.text.DateFormat;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Objects;
|
||||
//import java.util.UUID;
|
||||
//
|
||||
//import javax.inject.Inject;
|
||||
//
|
||||
///**
|
||||
// * LacertaLibraryのスタブ実装
|
||||
// */
|
||||
//public class LacertaLibraryStubImpl implements LacertaLibrary {
|
||||
//
|
||||
// LacertaLogger logger;
|
||||
//
|
||||
// Faker faker;
|
||||
//
|
||||
// @Inject
|
||||
// public LacertaLibraryStubImpl(LacertaLogger logger) {
|
||||
// faker = new Faker(); // Init Faker
|
||||
// this.logger = logger;
|
||||
// logger.debug("LibraryStub", "Initialized");
|
||||
// }
|
||||
//
|
||||
// // Internal Methods
|
||||
//
|
||||
// // Generate Stub Data
|
||||
// private LibraryItemPage generateStubLibraryItemPage(int limit, String pageId) {
|
||||
// logger.debug("LibraryStub", "generateStubLibraryItemPage");
|
||||
// ArrayList<ListItem> listItems = new ArrayList<>();
|
||||
// int itemTotal = faker.number().numberBetween(1, limit); // 実際に返却するアイテム数を決定
|
||||
// int folderTotal;
|
||||
// // フォルダ数の抽選
|
||||
// if (itemTotal > 4) {
|
||||
// folderTotal = faker.number().numberBetween(1, itemTotal - 2);
|
||||
// }
|
||||
// else {
|
||||
// if (itemTotal > 2) {
|
||||
// folderTotal = 1;
|
||||
// }
|
||||
// else { // ドキュメント数がゼロにならないように
|
||||
// folderTotal = 0;
|
||||
// }
|
||||
// }
|
||||
// int documentTotal = itemTotal - folderTotal; // ドキュメント数を決定
|
||||
// logger.debug("LibraryStub", "itemTotal: " + itemTotal);
|
||||
// logger.debug("LibraryStub", "folderTotal: " + folderTotal);
|
||||
// logger.debug("LibraryStub", "documentTotal: " + documentTotal);
|
||||
//
|
||||
// // フォルダを生成
|
||||
// for (int i = 0; i < folderTotal; i++) {
|
||||
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_FOLDER));
|
||||
// }
|
||||
// // ドキュメントを生成
|
||||
// for (int i = 0; i < documentTotal; i++) {
|
||||
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
|
||||
// }
|
||||
//
|
||||
// LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||
// libraryItemPage.setListItems(listItems);
|
||||
// if (pageId == null) {
|
||||
// libraryItemPage.setPageId(UUID.randomUUID().toString());
|
||||
// } else {
|
||||
// libraryItemPage.setPageId(pageId);
|
||||
// }
|
||||
// libraryItemPage.setPageTitle("FakePage" + faker.number().digits(3));
|
||||
//
|
||||
// return libraryItemPage;
|
||||
// }
|
||||
//
|
||||
// private ListItem generateStubListItem(ListItemType itemType) {
|
||||
// if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
|
||||
// ListItem listItem = new ListItem();
|
||||
// listItem.setTitle("FakeFolder" + faker.number().digits(3));
|
||||
// listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
|
||||
// listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
|
||||
// listItem.setItemId(UUID.randomUUID().toString());
|
||||
// return listItem;
|
||||
// } else if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
|
||||
// ListItem listItem = new ListItem();
|
||||
// listItem.setTitle("FakeDocument" + faker.book().title());
|
||||
// listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
|
||||
// listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
||||
// listItem.setItemId(UUID.randomUUID().toString());
|
||||
// return listItem;
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private LibraryItemPage getRecentDocumentPage(int limit) {
|
||||
// int itemTotal = faker.number().numberBetween(1, limit);
|
||||
// ArrayList<ListItem> listItems = new ArrayList<>();
|
||||
// for (int i = 0; i < itemTotal; i++) {
|
||||
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
|
||||
// }
|
||||
// // DescriptionからDateを抽出して新しい順にソート
|
||||
// listItems.sort((a, b) -> {
|
||||
// String aDate = a.getDescription().substring(11);
|
||||
// String bDate = b.getDescription().substring(11);
|
||||
// return bDate.compareTo(aDate);
|
||||
// });
|
||||
// LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||
// libraryItemPage.setListItems(listItems);
|
||||
// libraryItemPage.setPageId(UUID.randomUUID().toString());
|
||||
// libraryItemPage.setPageTitle("RecentDocument");
|
||||
// return libraryItemPage;
|
||||
// }
|
||||
//
|
||||
// private DocumentDetail generateStubDocumentDetail(String id) throws IllegalArgumentException {
|
||||
//
|
||||
// if (Objects.isNull(id)) {
|
||||
// throw new IllegalArgumentException("id is null");
|
||||
// }
|
||||
//
|
||||
// DocumentMeta documentMeta = new DocumentMeta();
|
||||
// documentMeta.setId(id);
|
||||
// documentMeta.setTitle("FakeDocument" + faker.book().title());
|
||||
// documentMeta.setCreatedAt(faker.date().birthday());
|
||||
// documentMeta.setUpdatedAt(faker.date().birthday()); // TODO-rca: 更新日のほうが古くなることがあるのでなんとかする?
|
||||
// ArrayList<String> tagIds = new ArrayList<>();
|
||||
//
|
||||
// DocumentDetail documentDetail = new DocumentDetail();
|
||||
// documentDetail.setMeta(documentMeta);
|
||||
//// documentDetail.setPath(null); // TODO-rca: なんとかする
|
||||
//// documentDetail.setAuthor(faker.name().fullName());
|
||||
//// documentDetail.setRepository(null); // TODO-rca: なんとかする
|
||||
// return documentDetail;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 履歴ページを取得する
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public ArrayList<ListItem> getRecentDocument(int limit) {
|
||||
// return getRecentDocumentPage(limit).getListItems();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 履歴ページを取得する
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @param offset 取得するアイテムのオフセット
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
|
||||
// return getRecentDocumentPage(limit).getListItems();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ライブラリページを取得する
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public LibraryItemPage getLibraryPage(int limit) {
|
||||
// return generateStubLibraryItemPage(limit, null);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ライブラリページを取得する
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @param offset 取得するアイテムのオフセット
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public LibraryItemPage getLibraryPage(int limit, int offset) {
|
||||
// return generateStubLibraryItemPage(limit, null);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ライブラリページを取得する
|
||||
// * @param pageId ページID
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public LibraryItemPage getLibraryPage(String pageId, int limit) {
|
||||
// return generateStubLibraryItemPage(limit, pageId);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ライブラリページを取得する
|
||||
// * @param pageId ページID
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @param offset 取得するアイテムのオフセット
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public LibraryItemPage getLibraryPage(String pageId, int limit, int offset) {
|
||||
// return generateStubLibraryItemPage(limit, pageId);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ドキュメント詳細を取得する
|
||||
// * @param id ドキュメントID
|
||||
// * @return ドキュメント詳細オブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public DocumentDetail getDocumentDetailById(String id) throws IllegalArgumentException {
|
||||
// return generateStubDocumentDetail(id);
|
||||
// }
|
||||
//}
|
||||
@@ -30,9 +30,10 @@ public class LacertaSearchStubImpl implements LacertaSearch {
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<ListItem> autoSearch(String query, int limit) {
|
||||
logger.debug("SearchStub", "autoSearch");
|
||||
logger.debug("SearchStub", "query: " + query);
|
||||
return library.getLibraryPage(limit).getListItems();
|
||||
// logger.debug("SearchStub", "autoSearch");
|
||||
// logger.debug("SearchStub", "query: " + query);
|
||||
// return library.getLibraryPage(limit).getListItems();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,8 +45,9 @@ public class LacertaSearchStubImpl implements LacertaSearch {
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<ListItem> autoSearch(String query, int limit, int offset) {
|
||||
logger.debug("SearchStub", "autoSearch");
|
||||
logger.debug("SearchStub", "query: " + query);
|
||||
return library.getLibraryPage(limit, offset).getListItems();
|
||||
// logger.debug("SearchStub", "autoSearch");
|
||||
// logger.debug("SearchStub", "query: " + query);
|
||||
// return library.getLibraryPage(limit, offset).getListItems();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import dagger.hilt.android.components.FragmentComponent;
|
||||
import dagger.hilt.migration.DisableInstallInCheck;
|
||||
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.data.impl.LacertaLibraryStubImpl;
|
||||
import one.nem.lacerta.data.impl.LacertaLibraryImpl;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
@Module
|
||||
@@ -16,6 +16,6 @@ import one.nem.lacerta.utils.LacertaLogger;
|
||||
abstract public class LacertaLibraryModule {
|
||||
|
||||
@Binds
|
||||
public abstract LacertaLibrary bindLacertaLibrary(LacertaLibraryStubImpl impl);
|
||||
public abstract LacertaLibrary bindLacertaLibrary(LacertaLibraryImpl impl);
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.feature.common'
|
||||
compileSdk 33
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
|
||||
+2
-1
@@ -57,7 +57,8 @@ public class DebugMenuLibraryItemListPageFragment extends Fragment {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_debug_menu_library_item_list_page, container, false);
|
||||
|
||||
ArrayList<ListItem> listItems = lacertaLibrary.getRecentDocument(10);
|
||||
// ArrayList<ListItem> listItems = lacertaLibrary.getRecentDocument(10);
|
||||
ArrayList<ListItem> listItems = new ArrayList<>();
|
||||
for (ListItem listItem : listItems) {
|
||||
System.out.println(listItem.getTitle());
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="Placeholder Title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -19,6 +20,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:text="Placeholder Description"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/debug_menu_item_title" />
|
||||
|
||||
@@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.feature.home'
|
||||
compileSdk 33
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
@@ -55,4 +55,8 @@ dependencies {
|
||||
implementation project(':model')
|
||||
|
||||
implementation "androidx.recyclerview:recyclerview:1.3.2"
|
||||
|
||||
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,21 +1,36 @@
|
||||
package one.nem.lacerta.feature.home;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.component.viewer.ViewerMainActivity;
|
||||
import one.nem.lacerta.data.Document;
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
@@ -34,34 +49,13 @@ public class HomeTopFragment extends Fragment {
|
||||
@Inject
|
||||
LacertaLibrary lacertaLibrary;
|
||||
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public HomeTopFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment HomeTopFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static HomeTopFragment newInstance(String param1, String param2) {
|
||||
public static HomeTopFragment newInstance() {
|
||||
HomeTopFragment fragment = new HomeTopFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
@@ -70,49 +64,46 @@ public class HomeTopFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
|
||||
|
||||
// List<DocumentMeta> metas = document.getAllDocumentMetas(100);
|
||||
setHasOptionsMenu(true);
|
||||
return view;
|
||||
}
|
||||
|
||||
ArrayList<ListItem> listItems = lacertaLibrary.getRecentDocument(100);
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
Log.d("docs", Integer.toString(listItems.size()));
|
||||
RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view);
|
||||
|
||||
RecyclerView recyclerView = view.findViewById(R.id.item_recycler_view);
|
||||
|
||||
ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> {
|
||||
Log.d("HomeTopFragment", "onViewCreated: " + documentId);
|
||||
Intent intent = new Intent(getContext(), ViewerMainActivity.class);
|
||||
intent.putExtra("documentId", documentId);
|
||||
startActivity(intent);
|
||||
});
|
||||
recyclerView.setAdapter(listItemAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
MyAdapter myAdapter = new MyAdapter(listItems);
|
||||
|
||||
recyclerView.setAdapter(myAdapter);
|
||||
|
||||
return view;
|
||||
|
||||
|
||||
}
|
||||
String pageTitle;
|
||||
String pageId;
|
||||
ArrayList listItems;
|
||||
|
||||
String title;
|
||||
String description;
|
||||
|
||||
String itemId;
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package one.nem.lacerta.feature.home;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import one.nem.lacerta.component.viewer.ViewerMainActivity;
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
|
||||
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
|
||||
|
||||
ArrayList<ListItem> listItems;
|
||||
|
||||
DocumentSelectListener listener;
|
||||
|
||||
public ListItemAdapter(DocumentSelectListener listener){
|
||||
this.listItems = new ArrayList<>();
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setListItems(ArrayList<ListItem> listItems) {
|
||||
this.listItems = listItems;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ListItemAdapter.ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
|
||||
return new ListItemViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ListItemAdapter.ListItemViewHolder holder, int position) {
|
||||
ListItem listItem = listItems.get(position);
|
||||
holder.icon.setImageResource(listItem.getItemType().getIconId());
|
||||
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
|
||||
holder.title.setText(listItem.getTitle());
|
||||
holder.description.setText(listItem.getDescription());
|
||||
|
||||
holder.itemView.setOnClickListener( v -> {
|
||||
Intent intent = new Intent(v.getContext(), ViewerMainActivity.class);
|
||||
intent.putExtra("documentId", listItem.getItemId());
|
||||
v.getContext().startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return listItems.size();
|
||||
}
|
||||
|
||||
public static class ListItemViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
ImageView icon;
|
||||
TextView title;
|
||||
TextView description;
|
||||
public ListItemViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
|
||||
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
|
||||
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".HomeTopFragment"
|
||||
tools:ignore="ExtraText">
|
||||
android:background="@color/colorSurface">
|
||||
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/item_recycler_view"
|
||||
<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">
|
||||
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
<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>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/item_placeholder"
|
||||
android:icon="@drawable/developer_mode_24px"
|
||||
android:title="@string/placeholder" />
|
||||
</menu>
|
||||
@@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.feature.library'
|
||||
compileSdk 33
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
@@ -51,5 +51,7 @@ dependencies {
|
||||
|
||||
implementation project(':data')
|
||||
|
||||
implementation project(':utils')
|
||||
|
||||
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package one.nem.lacerta.feature.library;
|
||||
|
||||
public interface DocumentSelectListener {
|
||||
void onFolderSelected(String folderId, String folderName);
|
||||
void onDocumentSelected(String documentId, String documentName);
|
||||
}
|
||||
-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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+283
@@ -0,0 +1,283 @@
|
||||
package one.nem.lacerta.feature.library;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.data.Document;
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.model.FragmentNavigation;
|
||||
import one.nem.lacerta.model.LibraryItemPage;
|
||||
import one.nem.lacerta.model.PublicPath;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link LibraryPageFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
public class LibraryPageFragment extends Fragment {
|
||||
|
||||
// Variables
|
||||
// このインスタンスで表示されているページ
|
||||
LibraryItemPage libraryItemPage;
|
||||
|
||||
// Arguments
|
||||
String folderId;
|
||||
String title;
|
||||
String parentId;
|
||||
|
||||
|
||||
@Inject
|
||||
LacertaLibrary lacertaLibrary;
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
ListItemAdapter listItemAdapter;
|
||||
|
||||
public LibraryPageFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static LibraryPageFragment newInstance(String folderId, String title, String parentId) {
|
||||
LibraryPageFragment fragment = new LibraryPageFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("folderId", folderId);
|
||||
args.putString("title", title);
|
||||
args.putString("publicPath", parentId);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public static LibraryPageFragment newInstance(String folderId) { // Back action
|
||||
LibraryPageFragment fragment = new LibraryPageFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("folderId", folderId);
|
||||
args.putString("title", null);
|
||||
args.putString("publicPath", null);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public static LibraryPageFragment newInstance() {
|
||||
LibraryPageFragment fragment = new LibraryPageFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("folderId", null);
|
||||
args.putString("title", null);
|
||||
args.putString("publicPath", null);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
|
||||
|
||||
// Set status bar color
|
||||
AppBarLayout appBarLayout = view.findViewById(R.id.app_bar_layout);
|
||||
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
|
||||
@Override
|
||||
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
|
||||
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
|
||||
// Collapsed
|
||||
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
|
||||
} else if (verticalOffset == 0) {
|
||||
// Expanded
|
||||
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), one.nem.lacerta.shared.ui.R.color.colorSurface));
|
||||
} else {
|
||||
// Somewhere in between
|
||||
// Here you can add a color transition if you want
|
||||
}
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
if (getArguments() != null) {
|
||||
this.folderId = getArguments().getString("folderId"); // Required
|
||||
if (getArguments().getString("title") == null && getArguments().getString("publicPath") == null) {
|
||||
this.libraryItemPage = new LibraryItemPage();
|
||||
} else {
|
||||
this.title = getArguments().getString("title");
|
||||
this.parentId = getArguments().getString("publicPath");
|
||||
}
|
||||
} else {
|
||||
logger.debug("LibraryTopFragment", "getArguments() is null(maybe root)");
|
||||
this.libraryItemPage = new LibraryItemPage();
|
||||
}
|
||||
|
||||
// Toolbar Setup
|
||||
toolbarSetup(view.findViewById(R.id.library_toolbar), this.folderId != null, this.title != null ? this.title : "ライブラリ");
|
||||
|
||||
// RecyclerView Setup
|
||||
|
||||
RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view);
|
||||
this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() {
|
||||
@Override
|
||||
public void onFolderSelected(String folderId, String folderName) {
|
||||
logger.debug("LibraryTopFragment", "Folder selected! folderId: " + folderId + ", folderName: " + folderName);
|
||||
// // 画面遷移
|
||||
// FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity();
|
||||
// // folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親)
|
||||
// fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage != null ? libraryItemPage.getParentId() : null), false);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("folderId", folderId);
|
||||
bundle.putString("title", folderName);
|
||||
bundle.putString("publicPath", libraryItemPage != null ? libraryItemPage.getParentId() : null);
|
||||
try {
|
||||
Navigation.findNavController(requireView()).navigate(R.id.action_feature_library_top_fragment_self, bundle);
|
||||
} catch (IllegalStateException e) {
|
||||
logger.error("LibraryTopFragment", "IllegalStateException: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDocumentSelected(String documentId, String documentName) {
|
||||
Toast.makeText(getContext(), "Document selected! documentId: " + documentId + ", documentName: " + documentName, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
recyclerView.setAdapter(listItemAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
// Get library page and update RecyclerView items
|
||||
lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> {
|
||||
this.libraryItemPage = libraryItemPage;
|
||||
|
||||
if (this.parentId == null) {
|
||||
this.parentId = libraryItemPage.getParentId();
|
||||
}
|
||||
if (this.title == null) {
|
||||
this.title = libraryItemPage.getPageTitle();
|
||||
// Toolbar init again
|
||||
toolbarSetup(view.findViewById(R.id.library_toolbar), this.folderId != null, this.title != null ? this.title : "ライブラリ");
|
||||
}
|
||||
|
||||
logger.debug("LibraryTopFragment", "Item selected! Total item page: " + this.libraryItemPage.getListItems().size());
|
||||
getActivity().runOnUiThread(() -> { // TODO-rca: 実行条件を考える?
|
||||
listItemAdapter.notifyItemRangeRemoved(0, this.libraryItemPage.getListItems().size() - 1);
|
||||
});
|
||||
listItemAdapter.setLibraryItemPage(this.libraryItemPage);
|
||||
getActivity().runOnUiThread(() -> {
|
||||
listItemAdapter.notifyItemRangeInserted(0, this.libraryItemPage.getListItems().size() - 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Currentにフォルダを作成する
|
||||
*/
|
||||
private void createFolder(String pageId) {
|
||||
// TODO-rca: デザインをMaterial Design 3に合わせたカスタムダイアログにする
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle("フォルダの作成");
|
||||
builder.setMessage("フォルダ名を入力してください");
|
||||
final android.widget.EditText input = new android.widget.EditText(getContext());
|
||||
input.setText("フォルダ名");
|
||||
builder.setView(input);
|
||||
builder.setPositiveButton("作成", (dialog, which) -> {
|
||||
lacertaLibrary.createFolder(pageId, input.getText().toString()).thenAccept(folderId -> {
|
||||
// Refresh
|
||||
updateItem(pageId);
|
||||
});
|
||||
});
|
||||
builder.setNegativeButton("キャンセル", (dialog, which) -> {
|
||||
dialog.cancel();
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* RecyclerViewのアイテムを更新する
|
||||
*/
|
||||
private void updateItem(String pageId) {
|
||||
lacertaLibrary.getLibraryPage(pageId, 10).thenAccept(libraryItemPage -> {
|
||||
this.libraryItemPage = libraryItemPage;
|
||||
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
|
||||
getActivity().runOnUiThread(() -> {
|
||||
listItemAdapter.notifyItemRangeRemoved(0, libraryItemPage.getListItems().size() - 1);
|
||||
});
|
||||
listItemAdapter.setLibraryItemPage(libraryItemPage);
|
||||
getActivity().runOnUiThread(() -> {
|
||||
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ToolbarをInitする
|
||||
*
|
||||
* @param toolbar Toolbar
|
||||
* @param showBackButton 戻るボタンを表示するか
|
||||
* @param title タイトル
|
||||
*/
|
||||
private void toolbarSetup(Toolbar toolbar, boolean showBackButton, String title) {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (showBackButton) {
|
||||
toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px);
|
||||
toolbar.setNavigationOnClickListener(v -> {
|
||||
//this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join();
|
||||
// Back
|
||||
Navigation.findNavController(requireView()).popBackStack();
|
||||
});
|
||||
} else {
|
||||
toolbar.setNavigationIcon(null);
|
||||
}
|
||||
toolbar.setTitle(title);
|
||||
toolbar.inflateMenu(R.menu.dir_menu);
|
||||
toolbar.setOnMenuItemClickListener(item -> {
|
||||
if (item.getItemId() == R.id.menu_item_create_new_folder) {
|
||||
createFolder(this.folderId);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
package one.nem.lacerta.feature.library;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.data.Document;
|
||||
import one.nem.lacerta.model.document.DocumentMeta;
|
||||
import one.nem.lacerta.model.document.tag.DocumentTag;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link LibraryTopFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
public class LibraryTopFragment extends Fragment {
|
||||
|
||||
// @Inject
|
||||
// Document document;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public LibraryTopFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment LibraryTopFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static LibraryTopFragment newInstance(String param1, String param2) {
|
||||
LibraryTopFragment fragment = new LibraryTopFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_library_top, container, false);
|
||||
|
||||
// Use view.findViewById instead of findViewById
|
||||
RecyclerView documentRecyclerView = view.findViewById(R.id.document_list);
|
||||
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
|
||||
documentRecyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
//データを取得
|
||||
|
||||
// List<DocumentMeta> metas = document.getAllDocumentMetas(100);
|
||||
|
||||
// Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
|
||||
|
||||
// Create and set the adapter
|
||||
// DocumentAdapter adapter = new DocumentAdapter(metas);
|
||||
// documentRecyclerView.setAdapter(adapter);
|
||||
|
||||
// Use a LinearLayoutManager to specify the layout
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package one.nem.lacerta.feature.library;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import one.nem.lacerta.model.LibraryItemPage;
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
import one.nem.lacerta.model.ListItemType;
|
||||
|
||||
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
|
||||
|
||||
LibraryItemPage libraryItemPage;
|
||||
|
||||
DocumentSelectListener listener;
|
||||
|
||||
|
||||
public ListItemAdapter(DocumentSelectListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setLibraryItemPage(LibraryItemPage libraryItemPage) {
|
||||
this.libraryItemPage = libraryItemPage;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
|
||||
return new ListItemViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ListItemViewHolder holder, int position) {
|
||||
ListItem listItem = libraryItemPage.getListItems().get(position);
|
||||
holder.icon.setImageResource(listItem.getItemType().getIconId());
|
||||
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
|
||||
holder.title.setText(listItem.getTitle());
|
||||
holder.description.setText(listItem.getDescription());
|
||||
|
||||
holder.itemView.setOnClickListener( v -> {
|
||||
if (listItem.getItemType() == ListItemType.ITEM_TYPE_DOCUMENT) {
|
||||
listener.onDocumentSelected(listItem.getItemId(), listItem.getTitle());
|
||||
}
|
||||
else if (listItem.getItemType() == ListItemType.ITEM_TYPE_FOLDER) {
|
||||
listener.onFolderSelected(listItem.getItemId(), listItem.getTitle());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return this.libraryItemPage == null ? 0
|
||||
: this.libraryItemPage.getListItems() == null ? 0 : this.libraryItemPage.getListItems().size();
|
||||
}
|
||||
|
||||
public static class ListItemViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
ImageView icon;
|
||||
TextView title;
|
||||
TextView description;
|
||||
public ListItemViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
|
||||
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
|
||||
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:theme="@style/Theme.Lacerta"
|
||||
tools:context=".LibraryTopFragment">
|
||||
android:background="@color/colorSurface">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/tool_bar"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
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" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/document_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tool_bar" />
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
app:contentScrim="@color/colorSecondaryContainer"
|
||||
android:background="@color/colorSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:fitsSystemWindows="true"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:collapsedTitleGravity="start|center_vertical"
|
||||
app:expandedTitleGravity="start|bottom"
|
||||
app:expandedTitleMarginBottom="16dp"
|
||||
app:expandedTitleMarginStart="16dp"
|
||||
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/library_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:title="HOGE" />
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/library_item_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -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>
|
||||
@@ -6,7 +6,17 @@
|
||||
app:startDestination="@id/feature_library_top_fragment">
|
||||
<fragment
|
||||
android:id="@+id/feature_library_top_fragment"
|
||||
android:name="one.nem.lacerta.feature.library.LibraryTopFragment"
|
||||
android:name="one.nem.lacerta.feature.library.LibraryPageFragment"
|
||||
android:label="fragment_library_top"
|
||||
tools:layout="@layout/fragment_library_top" />
|
||||
tools:layout="@layout/fragment_library_top" >
|
||||
<action
|
||||
android:id="@+id/action_feature_library_top_fragment_self"
|
||||
app:destination="@id/feature_library_top_fragment"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@anim/nav_default_exit_anim"
|
||||
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||
app:popUpTo="@id/feature_library_top_fragment"
|
||||
app:popUpToInclusive="false"/>
|
||||
</fragment>
|
||||
</navigation>
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.feature.scan'
|
||||
compileSdk 33
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.feature.search'
|
||||
compileSdk 33
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,48 @@
|
||||
plugins {
|
||||
alias(libs.plugins.com.android.library)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.setting'
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation libs.androidx.appcompat
|
||||
implementation libs.com.google.android.material
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.androidx.test.ext.junit
|
||||
androidTestImplementation libs.androidx.test.espresso.core
|
||||
|
||||
// Navigation
|
||||
implementation libs.navigation.fragment
|
||||
implementation libs.navigation.ui
|
||||
implementation libs.navigation.dynamic.features.fragment
|
||||
|
||||
// DI
|
||||
implementation libs.com.google.dagger.hilt.android
|
||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||
|
||||
// shared
|
||||
implementation project(':shared:ui')
|
||||
|
||||
}
|
||||
Whitespace-only changes.
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package one.nem.lacerta.setting;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("one.nem.lacerta.setting.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,63 @@
|
||||
package one.nem.lacerta.setting;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import one.nem.lacerta.setting.model.SettingListItem;
|
||||
|
||||
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
|
||||
|
||||
ArrayList<SettingListItem> listItems;
|
||||
|
||||
public ListItemAdapter(ArrayList<SettingListItem> listItems){
|
||||
this.listItems = listItems;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ListItemAdapter.ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
|
||||
return new ListItemViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ListItemAdapter.ListItemViewHolder holder, int position) {
|
||||
SettingListItem listItem = listItems.get(position);
|
||||
holder.icon.setImageDrawable(listItem.getIcon());
|
||||
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
|
||||
holder.title.setText(listItem.getTitle());
|
||||
holder.description.setText(listItem.getDescription());
|
||||
|
||||
holder.itemView.setOnClickListener( v -> {
|
||||
Navigation.findNavController(v).navigate(listItem.getDestination());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return listItems.size();
|
||||
}
|
||||
|
||||
public static class ListItemViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
ImageView icon;
|
||||
TextView title;
|
||||
TextView description;
|
||||
public ListItemViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
|
||||
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
|
||||
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package one.nem.lacerta.setting;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link SettingAboutPageFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class SettingAboutPageFragment extends Fragment {
|
||||
|
||||
public SettingAboutPageFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static SettingAboutPageFragment newInstance() {
|
||||
SettingAboutPageFragment fragment = new SettingAboutPageFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_setting_about_page, container, false);
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package one.nem.lacerta.setting;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link SettingDataPageFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class SettingDataPageFragment extends Fragment {
|
||||
|
||||
public SettingDataPageFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static SettingDataPageFragment newInstance() {
|
||||
SettingDataPageFragment fragment = new SettingDataPageFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_setting_data_page, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package one.nem.lacerta.setting;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link SettingDisplayPageFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class SettingDisplayPageFragment extends Fragment {
|
||||
|
||||
public SettingDisplayPageFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static SettingDisplayPageFragment newInstance() {
|
||||
SettingDisplayPageFragment fragment = new SettingDisplayPageFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_setting_display_page, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package one.nem.lacerta.setting;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link SettingScanPageFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class SettingScanPageFragment extends Fragment {
|
||||
|
||||
public SettingScanPageFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static SettingScanPageFragment newInstance() {
|
||||
SettingScanPageFragment fragment = new SettingScanPageFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_setting_scan_page, container, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package one.nem.lacerta.setting;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import one.nem.lacerta.setting.model.SettingListItem;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link SettingTopFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class SettingTopFragment extends Fragment {
|
||||
|
||||
public SettingTopFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static SettingTopFragment newInstance() {
|
||||
SettingTopFragment fragment = new SettingTopFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_setting_top, container, false);
|
||||
|
||||
// Setting items
|
||||
ArrayList<SettingListItem> settingListItems = new ArrayList<>();
|
||||
settingListItems.add(
|
||||
new SettingListItem(
|
||||
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_display_title),
|
||||
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_display_description),
|
||||
ContextCompat.getDrawable(getContext(), one.nem.lacerta.shared.ui.R.drawable.palette_24px),
|
||||
R.id.action_settingTopFragment_to_settingDisplayPageFragment
|
||||
)
|
||||
);
|
||||
|
||||
settingListItems.add(
|
||||
new SettingListItem(
|
||||
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_data_title),
|
||||
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_data_description),
|
||||
ContextCompat.getDrawable(getContext(), one.nem.lacerta.shared.ui.R.drawable.settings_backup_restore_24px),
|
||||
R.id.action_settingTopFragment_to_settingDataPageFragment
|
||||
)
|
||||
);
|
||||
|
||||
settingListItems.add(
|
||||
new SettingListItem(
|
||||
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_scan_title),
|
||||
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_scan_description),
|
||||
ContextCompat.getDrawable(getContext(), one.nem.lacerta.shared.ui.R.drawable.document_scanner_24px),
|
||||
R.id.action_settingTopFragment_to_settingScanPageFragment
|
||||
)
|
||||
);
|
||||
|
||||
settingListItems.add(
|
||||
new SettingListItem(
|
||||
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_about_title),
|
||||
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_about_description),
|
||||
ContextCompat.getDrawable(getContext(), one.nem.lacerta.shared.ui.R.drawable.info_24px),
|
||||
R.id.action_settingTopFragment_to_settingAboutPageFragment
|
||||
)
|
||||
);
|
||||
|
||||
// Init RecyclerView
|
||||
RecyclerView recyclerView = view.findViewById(R.id.setting_item_recycler_view);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerView.setAdapter(new ListItemAdapter(settingListItems));
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package one.nem.lacerta.setting.model;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class SettingListItem {
|
||||
|
||||
String title;
|
||||
String description;
|
||||
Drawable icon;
|
||||
int destination;
|
||||
|
||||
public SettingListItem(String title, String description, Drawable icon, int destination) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.icon = icon;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Drawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public int getDestination() {
|
||||
return destination;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SettingAboutPageFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SettingDataPageFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SettingDisplayPageFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SettingScanPageFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,50 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/colorSurface">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
app:contentScrim="@color/colorSecondaryContainer"
|
||||
android:background="@color/colorSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:fitsSystemWindows="true"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:collapsedTitleGravity="start|center_vertical"
|
||||
app:expandedTitleGravity="start|bottom"
|
||||
app:expandedTitleMarginBottom="16dp"
|
||||
app:expandedTitleMarginStart="16dp"
|
||||
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:title="@string/setting_title" />
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/setting_item_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/feature_setting_navigation"
|
||||
app:startDestination="@id/settingTopFragment">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/settingTopFragment"
|
||||
android:name="one.nem.lacerta.setting.SettingTopFragment"
|
||||
android:label="SettingTopFragment" >
|
||||
<action
|
||||
android:id="@+id/action_settingTopFragment_to_settingAboutPageFragment"
|
||||
app:destination="@id/settingAboutPageFragment"
|
||||
app:enterAnim="@anim/slide_from_right"
|
||||
app:exitAnim="@anim/slide_to_left"
|
||||
app:popEnterAnim="@anim/slide_from_left"
|
||||
app:popExitAnim="@anim/slide_to_right" />
|
||||
<action
|
||||
android:id="@+id/action_settingTopFragment_to_settingDisplayPageFragment"
|
||||
app:destination="@id/settingDisplayPageFragment"
|
||||
app:enterAnim="@anim/slide_from_right"
|
||||
app:exitAnim="@anim/slide_to_left"
|
||||
app:popEnterAnim="@anim/slide_from_left"
|
||||
app:popExitAnim="@anim/slide_to_right" />
|
||||
<action
|
||||
android:id="@+id/action_settingTopFragment_to_settingDataPageFragment"
|
||||
app:destination="@id/settingDataPageFragment"
|
||||
app:enterAnim="@anim/slide_from_right"
|
||||
app:exitAnim="@anim/slide_to_left"
|
||||
app:popEnterAnim="@anim/slide_from_left"
|
||||
app:popExitAnim="@anim/slide_to_right" />
|
||||
<action
|
||||
android:id="@+id/action_settingTopFragment_to_settingScanPageFragment"
|
||||
app:destination="@id/settingScanPageFragment"
|
||||
app:enterAnim="@anim/slide_from_right"
|
||||
app:exitAnim="@anim/slide_to_left"
|
||||
app:popEnterAnim="@anim/slide_from_left"
|
||||
app:popExitAnim="@anim/slide_to_right" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/settingAboutPageFragment"
|
||||
android:name="one.nem.lacerta.setting.SettingAboutPageFragment"
|
||||
android:label="fragment_setting_about_page"
|
||||
tools:layout="@layout/fragment_setting_about_page" />
|
||||
<fragment
|
||||
android:id="@+id/settingDataPageFragment"
|
||||
android:name="one.nem.lacerta.setting.SettingDataPageFragment"
|
||||
android:label="fragment_setting_data_page"
|
||||
tools:layout="@layout/fragment_setting_data_page" />
|
||||
<fragment
|
||||
android:id="@+id/settingDisplayPageFragment"
|
||||
android:name="one.nem.lacerta.setting.SettingDisplayPageFragment"
|
||||
android:label="fragment_setting_display_page"
|
||||
tools:layout="@layout/fragment_setting_display_page" />
|
||||
<fragment
|
||||
android:id="@+id/settingScanPageFragment"
|
||||
android:name="one.nem.lacerta.setting.SettingScanPageFragment"
|
||||
android:label="fragment_setting_scan_page"
|
||||
tools:layout="@layout/fragment_setting_scan_page" />
|
||||
</navigation>
|
||||
@@ -0,0 +1,4 @@
|
||||
<resources>
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
package one.nem.lacerta.setting;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package one.nem.lacerta.model;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public interface FragmentNavigation {
|
||||
void navigateToFragment(Fragment fragment);
|
||||
|
||||
void navigateToFragment(Fragment fragment, boolean addToBackStack);
|
||||
|
||||
void navigateToFragment(Fragment fragment, boolean addToBackStack, boolean clearBackStack);
|
||||
|
||||
void navigateToFragmentAlternate(Fragment fragment, boolean addToBackStack);
|
||||
}
|
||||
@@ -6,10 +6,18 @@ public class LibraryItemPage {
|
||||
|
||||
String pageTitle;
|
||||
String pageId;
|
||||
String parentId;
|
||||
ArrayList<ListItem> listItems;
|
||||
|
||||
// Constructor
|
||||
|
||||
public LibraryItemPage(String pageTitle, String pageId, ArrayList<ListItem> listItems, String parentId) {
|
||||
this.pageTitle = pageTitle;
|
||||
this.pageId = pageId;
|
||||
this.listItems = listItems;
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public LibraryItemPage(String pageTitle, String pageId, ArrayList<ListItem> listItems) {
|
||||
this.pageTitle = pageTitle;
|
||||
this.pageId = pageId;
|
||||
@@ -30,6 +38,10 @@ public class LibraryItemPage {
|
||||
return pageId;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public ArrayList<ListItem> getListItems() {
|
||||
return listItems;
|
||||
}
|
||||
@@ -44,6 +56,10 @@ public class LibraryItemPage {
|
||||
this.pageId = pageId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public void setListItems(ArrayList<ListItem> listItems) {
|
||||
this.listItems = listItems;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package one.nem.lacerta.model;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,11 +31,31 @@ public class PublicPath {
|
||||
private void resolveInternal(String path) {
|
||||
if (path.equals("..")) {
|
||||
this.path.remove(this.path.size() - 1);
|
||||
} else if (path.equals(".")) {
|
||||
// do nothing
|
||||
} else {
|
||||
add(path);
|
||||
this.path.add(path);
|
||||
}
|
||||
}
|
||||
|
||||
public PublicPath parse(String path) {
|
||||
if (path == null) {
|
||||
this.path.clear();
|
||||
this.path.add("/");
|
||||
} else {
|
||||
if (path.startsWith("/")) {
|
||||
this.path.clear();
|
||||
path = path.substring(1);
|
||||
}
|
||||
String[] pathArray = path.split("/");
|
||||
for (String p : pathArray) {
|
||||
Log.d("PublicPath", "parse: " + p);
|
||||
resolveInternal(p);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public PublicPath resolve(String path) {
|
||||
resolveInternal(path);
|
||||
return this;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
||||
*/
|
||||
List<DocumentTag> tags;
|
||||
|
||||
PublicPath path;
|
||||
String parentId;
|
||||
|
||||
String author;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
||||
this.tags = new ArrayList<>();
|
||||
this.author = ""; // TODO-rca: 作者のデフォルト値を設定できるようにする
|
||||
this.defaultBranch = "main"; // TODO-rca: デフォルトブランチのデフォルト値を設定できるようにする
|
||||
this.path = new PublicPath().getRoot();
|
||||
this.parentId = null;
|
||||
this.updatedAt = new Date();
|
||||
this.createdAt = new Date();
|
||||
}
|
||||
@@ -85,13 +85,13 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
||||
this.defaultBranch = defaultBranch;
|
||||
}
|
||||
|
||||
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, List<DocumentTag> tags, PublicPath path, String author, String defaultBranch) {
|
||||
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, List<DocumentTag> tags, String parentId, String author, String defaultBranch) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.updatedAt = updatedAt;
|
||||
this.createdAt = createdAt;
|
||||
this.tags = tags;
|
||||
this.path = path;
|
||||
this.parentId = parentId;
|
||||
this.author = author;
|
||||
this.defaultBranch = defaultBranch;
|
||||
}
|
||||
@@ -145,10 +145,10 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
||||
}
|
||||
|
||||
/**
|
||||
* PublicPathを取得する
|
||||
* ドキュメントの親フォルダのID(String)を取得する
|
||||
*/
|
||||
public PublicPath getPath() {
|
||||
return path;
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,11 +208,11 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
|
||||
}
|
||||
|
||||
/**
|
||||
* PublicPathを設定する
|
||||
* @param path PublicPath
|
||||
* ドキュメントの親フォルダのID(String)を設定する
|
||||
* @param parentId ドキュメントの親フォルダのID
|
||||
*/
|
||||
public void setPath(PublicPath path) {
|
||||
this.path = path;
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 {
|
||||
|
||||
// ページ操作
|
||||
void addNewPageToLast(Bitmap bitmap) throws Exception;
|
||||
void addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
|
||||
void insertPageAtIndex(Bitmap bitmap, int index) throws Exception;
|
||||
void removePageAtIndex(int index) throws Exception;
|
||||
DocumentProcessor addNewPageToLast(Bitmap bitmap) throws Exception;
|
||||
DocumentProcessor addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
|
||||
DocumentProcessor insertPageAtIndex(Bitmap bitmap, int index) throws Exception;
|
||||
DocumentProcessor removePageAtIndex(int index) throws Exception;
|
||||
|
||||
// 更新
|
||||
void updatePageAtIndex(Bitmap bitmap, int index);
|
||||
DocumentProcessor updatePageAtIndex(Bitmap bitmap, int index);
|
||||
|
||||
// ページ取得
|
||||
Bitmap getPageAtIndex(int index);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class DocumentProcessorImpl implements DocumentProcessor{
|
||||
|
||||
|
||||
@Override
|
||||
public void addNewPageToLast(Bitmap bitmap) throws Exception{
|
||||
public DocumentProcessor addNewPageToLast(Bitmap bitmap) throws Exception{
|
||||
logger.debug("addNewPageToLast", "called");
|
||||
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
|
||||
|
||||
@@ -85,19 +85,23 @@ public class DocumentProcessorImpl implements DocumentProcessor{
|
||||
|
||||
logger.info("addNewPageToLast", "finished");
|
||||
logger.info("addNewPageToLast", "filename: " + filename);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewPagesToLast(Bitmap[] bitmaps) throws Exception{
|
||||
public DocumentProcessor addNewPagesToLast(Bitmap[] bitmaps) throws Exception{
|
||||
logger.debug("addNewPagesToLast", "called");
|
||||
|
||||
for (Bitmap bitmap : bitmaps) {
|
||||
addNewPageToLast(bitmap);
|
||||
} // TODO-rca: 効率悪いので改善する
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertPageAtIndex(Bitmap bitmap, int index) throws Exception {
|
||||
public DocumentProcessor insertPageAtIndex(Bitmap bitmap, int index) throws Exception {
|
||||
logger.debug("addNewPageAfterIndex", "called");
|
||||
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
|
||||
|
||||
@@ -109,16 +113,18 @@ public class DocumentProcessorImpl implements DocumentProcessor{
|
||||
this.documentDetail.getPages().add(index, page);
|
||||
|
||||
lacertaVcs.insertPage(index, filename);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePageAtIndex(int index) {
|
||||
|
||||
public DocumentProcessor removePageAtIndex(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePageAtIndex(Bitmap bitmap, int index) {
|
||||
|
||||
public DocumentProcessor updatePageAtIndex(Bitmap bitmap, int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,3 +31,4 @@ include ':model'
|
||||
include ':processor'
|
||||
include ':shared:ui'
|
||||
include ':vcs'
|
||||
include ':feature:setting'
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate android:fromXDelta="-100%p" android:toXDelta="0"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
android:duration="120" />
|
||||
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
android:duration="120" />
|
||||
</set>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate android:fromXDelta="100%p" android:toXDelta="0"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
android:duration="120" />
|
||||
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
android:duration="120" />
|
||||
</set>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate android:fromXDelta="0" android:toXDelta="-100%p"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
android:duration="120" />
|
||||
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
android:duration="120" />
|
||||
</set>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate android:fromXDelta="0" android:toXDelta="100%p"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
android:duration="120" />
|
||||
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
android:duration="120" />
|
||||
</set>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@color/colorOnBackground"
|
||||
android:pathData="M90,230L90,50L270,50L270,110L150,110L150,230L90,230ZM810,230L810,110L690,110L690,50L870,50L870,230L810,230ZM90,910L90,730L150,730L150,850L270,850L270,910L90,910ZM690,910L690,850L810,850L810,730L870,730L870,910L690,910ZM270,717.69Q270,722.31 273.85,726.15Q277.69,730 282.31,730L677.69,730Q682.31,730 686.15,726.15Q690,722.31 690,717.69L690,242.31Q690,237.69 686.15,233.85Q682.31,230 677.69,230L282.31,230Q277.69,230 273.85,233.85Q270,237.69 270,242.31L270,717.69ZM282.31,790Q252,790 231,769Q210,748 210,717.69L210,242.31Q210,212 231,191Q252,170 282.31,170L677.69,170Q708,170 729,191Q750,212 750,242.31L750,717.69Q750,748 729,769Q708,790 677.69,790L282.31,790ZM370,390L590,390L590,330L370,330L370,390ZM370,510L590,510L590,450L370,450L370,510ZM370,630L590,630L590,570L370,570L370,630ZM270,717.69L270,242.31Q270,237.69 270,233.85Q270,230 270,230L270,230Q270,230 270,233.85Q270,237.69 270,242.31L270,717.69Q270,722.31 270,726.15Q270,730 270,730L270,730Q270,730 270,726.15Q270,722.31 270,717.69Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@color/colorOnBackground"
|
||||
android:pathData="M450,670L510,670L510,440L450,440L450,670ZM480,371.54Q493.73,371.54 503.02,362.25Q512.31,352.96 512.31,339.23Q512.31,325.5 503.02,316.21Q493.73,306.92 480,306.92Q466.27,306.92 456.98,316.21Q447.69,325.5 447.69,339.23Q447.69,352.96 456.98,362.25Q466.27,371.54 480,371.54ZM480.07,860Q401.23,860 331.86,830.08Q262.49,800.16 211.18,748.87Q159.87,697.58 129.93,628.24Q100,558.9 100,480.07Q100,401.23 129.92,331.86Q159.84,262.49 211.13,211.18Q262.42,159.87 331.76,129.93Q401.1,100 479.93,100Q558.77,100 628.14,129.92Q697.51,159.84 748.82,211.13Q800.13,262.42 830.07,331.76Q860,401.1 860,479.93Q860,558.77 830.08,628.14Q800.16,697.51 748.87,748.82Q697.58,800.13 628.24,830.07Q558.9,860 480.07,860ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@color/colorOnBackground"
|
||||
android:pathData="M479.23,860Q401.46,860 332.31,830.04Q263.15,800.08 211.54,748.46Q159.92,696.84 129.96,627.5Q100,558.15 100,480Q100,400.85 130.77,331.5Q161.54,262.16 214.35,210.85Q267.15,159.54 337.89,129.77Q408.62,100 488.77,100Q563.77,100 630.92,125.58Q698.08,151.16 748.88,196.39Q799.69,241.62 829.84,303.89Q860,366.15 860,438.92Q860,542.77 798.27,601.38Q736.54,660 640,660L567.54,660Q550.46,660 540.23,671.15Q530,682.31 530,697.54Q530,716.08 545,736.08Q560,756.08 560,782Q560,821.61 538.08,840.81Q516.15,860 479.23,860ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480ZM260,510Q281.38,510 295.69,495.69Q310,481.38 310,460Q310,438.62 295.69,424.31Q281.38,410 260,410Q238.62,410 224.31,424.31Q210,438.62 210,460Q210,481.38 224.31,495.69Q238.62,510 260,510ZM380,350Q401.38,350 415.69,335.69Q430,321.38 430,300Q430,278.62 415.69,264.31Q401.38,250 380,250Q358.62,250 344.31,264.31Q330,278.62 330,300Q330,321.38 344.31,335.69Q358.62,350 380,350ZM580,350Q601.38,350 615.69,335.69Q630,321.38 630,300Q630,278.62 615.69,264.31Q601.38,250 580,250Q558.62,250 544.31,264.31Q530,278.62 530,300Q530,321.38 544.31,335.69Q558.62,350 580,350ZM700,510Q721.38,510 735.69,495.69Q750,481.38 750,460Q750,438.62 735.69,424.31Q721.38,410 700,410Q678.62,410 664.31,424.31Q650,438.62 650,460Q650,481.38 664.31,495.69Q678.62,510 700,510ZM479.23,800Q489,800 494.5,795.19Q500,790.39 500,782Q500,768 485,750.54Q470,733.08 470,695.85Q470,653.08 499,626.54Q528,600 570,600L640,600Q710.62,600 755.31,558.61Q800,517.23 800,438.92Q800,317.54 706.92,238.77Q613.85,160 488.77,160Q351.61,160 255.81,253Q160,346 160,480Q160,613 253.5,706.5Q347,800 479.23,800Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@color/colorOnBackground"
|
||||
android:pathData="M479.23,540Q454.69,540 436.96,522.27Q419.23,504.54 419.23,480Q419.23,455.46 436.96,437.73Q454.69,420 479.23,420Q503.77,420 521.5,437.73Q539.23,455.46 539.23,480Q539.23,504.54 521.5,522.27Q503.77,540 479.23,540ZM479.23,820Q348.69,820 252.46,734.27Q156.23,648.54 141.62,520L202.85,520Q218,623.61 296.27,691.81Q374.54,760 479.23,760Q596.23,760 677.73,678.5Q759.23,597 759.23,480Q759.23,363 677.73,281.5Q596.23,200 479.23,200Q413.69,200 356.39,229.11Q299.08,258.23 257.69,309.23L362.31,309.23L362.31,369.23L159.23,369.23L159.23,166.15L219.23,166.15L219.23,260.92Q267.92,203.46 335.85,171.73Q403.77,140 479.23,140Q550.03,140 611.86,166.77Q673.69,193.54 719.69,239.54Q765.69,285.54 792.46,347.36Q819.23,409.19 819.23,479.98Q819.23,550.77 792.46,612.61Q765.69,674.46 719.69,720.46Q673.69,766.46 611.86,793.23Q550.03,820 479.23,820Z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="24dp"
|
||||
android:paddingVertical="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/item_icon"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/item_text_container"
|
||||
app:srcCompat="@drawable/description_24px"
|
||||
android:contentDescription="icon" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/item_text_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/item_icon"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="Placeholder Title"
|
||||
android:textColor="@color/colorOnSurface"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:text="Placeholder Description"
|
||||
android:textColor="@color/colorOnSurfaceSecondary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/item_title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
</resources>
|
||||
@@ -30,6 +30,7 @@
|
||||
<item name="colorOnBackground">@color/colorOnBackground</item>
|
||||
|
||||
<item name="android:windowLightNavigationBar">false</item>
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
|
||||
</style>
|
||||
</resources>
|
||||
@@ -25,4 +25,8 @@
|
||||
<color name="colorSurfaceVariant">@color/material_dynamic_neutral_variant90</color>
|
||||
<color name="colorOnSurfaceVariant">@color/material_dynamic_neutral_variant30</color>
|
||||
<color name="colorSurfaceInverse">@color/material_dynamic_neutral20</color>
|
||||
|
||||
<!-- indicator icon background -->
|
||||
<color name="colorIndicator">@color/material_dynamic_secondary70</color>
|
||||
<color name="colorOnSurfaceSecondary">@color/material_dynamic_neutral_variant30</color>
|
||||
</resources>
|
||||
@@ -25,4 +25,8 @@
|
||||
<color name="colorSurfaceInverse">#313033</color>
|
||||
<color name="colorOnSurfaceInverse">#F4EFF4</color>
|
||||
<color name="colorPrimaryInverse">#D0BCFF</color>
|
||||
|
||||
<!-- indicator icon background -->
|
||||
<color name="colorIndicator">#d2d4bc</color>
|
||||
<color name="colorOnSurfaceSecondary">#49454F</color>
|
||||
</resources>
|
||||
@@ -24,4 +24,8 @@
|
||||
<color name="colorSurfaceVariant">@color/material_dynamic_neutral_variant90</color>
|
||||
<color name="colorOnSurfaceVariant">@color/material_dynamic_neutral_variant30</color>
|
||||
<color name="colorSurfaceInverse">@color/material_dynamic_neutral20</color>
|
||||
|
||||
<!-- indicator icon background -->
|
||||
<color name="colorIndicator">@color/material_dynamic_secondary80</color>
|
||||
<color name="colorOnSurfaceSecondary">@color/material_dynamic_neutral_variant30</color>
|
||||
</resources>
|
||||
@@ -30,6 +30,6 @@
|
||||
<item name="colorOnBackground">@color/colorOnBackground</item>
|
||||
|
||||
<item name="android:windowLightNavigationBar">true</item>
|
||||
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -25,4 +25,7 @@
|
||||
<color name="colorSurfaceInverse">#31312B</color>
|
||||
<color name="colorOnSurfaceInverse">#F3F1E8</color>
|
||||
<color name="colorPrimaryInverse">#B8D321</color>
|
||||
<!-- indicator icon background -->
|
||||
<color name="colorIndicator">#d2d4bc</color>
|
||||
<color name="colorOnSurfaceSecondary">#46483B</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Lacerta.Custom.Indicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator">
|
||||
<item name="android:color">@color/colorIndicator</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- home -->
|
||||
<string name="home_title">ホーム</string>
|
||||
|
||||
<!-- search -->
|
||||
<string name="search_title">検索</string>
|
||||
|
||||
<!-- library -->
|
||||
<string name="library_title">ライブラリ</string>
|
||||
|
||||
<!-- debug -->
|
||||
<string name="debug_menu_title">デバッグメニュー</string>
|
||||
|
||||
<!-- setting -->
|
||||
<string name="setting_title">設定</string>
|
||||
|
||||
<string name="setting_top_scan_title">スキャン</string>
|
||||
<string name="setting_top_scan_description">画質, 保存先</string>
|
||||
|
||||
<string name="setting_top_display_title">表示</string>
|
||||
<string name="setting_top_display_description">テーマ, フォントサイズ</string>
|
||||
|
||||
<string name="setting_top_data_title">データ</string>
|
||||
<string name="setting_top_data_description">バックアップ, リストア</string>
|
||||
|
||||
<string name="setting_top_about_title">このアプリについて</string>
|
||||
<string name="setting_top_about_description">バージョン情報</string>
|
||||
|
||||
<!-- common -->
|
||||
|
||||
<string name="placeholder">Placeholder(TODO: Replace)</string>
|
||||
</resources>
|
||||
@@ -28,8 +28,6 @@
|
||||
<item name="colorOutline">@color/colorOutline</item>
|
||||
<item name="colorOnBackground">@color/colorOnBackground</item>
|
||||
|
||||
<item name="android:windowLightNavigationBar">true</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Lacerta" parent="Base.Theme.Lacerta" >
|
||||
|
||||
@@ -19,7 +19,7 @@ import one.nem.lacerta.source.database.dao.LibraryDao;
|
||||
import one.nem.lacerta.source.database.dao.VcsRevDao;
|
||||
import one.nem.lacerta.source.database.dao.VcsLogDao;
|
||||
|
||||
@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class}, version = 4)
|
||||
@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class}, version = 5)
|
||||
public abstract class LacertaDatabase extends RoomDatabase {
|
||||
public abstract TagDao tagDao();
|
||||
public abstract DocumentDao documentDao();
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||
@@ -28,8 +29,11 @@ public interface DocumentDao {
|
||||
@Query("SELECT * FROM Document WHERE id IN (:ids)")
|
||||
List<DocumentEntity> findByIds(List<String> ids);
|
||||
|
||||
@Query("SELECT * FROM Document WHERE public_path = :publicPath LIMIT :limit")
|
||||
List<DocumentEntity> findByPublicPathWithLimit(String publicPath, int limit);
|
||||
@Query("SELECT * FROM Document WHERE parent_id = :parentId")
|
||||
List<DocumentEntity> findByParentId(String parentId);
|
||||
|
||||
@Query("SELECT * FROM Document WHERE parent_id IS NULL")
|
||||
List<DocumentEntity> findRootDocuments();
|
||||
|
||||
@Query("SELECT * FROM Document ORDER BY created_at DESC LIMIT :limit")
|
||||
List<DocumentEntity> getRecentDocument(int limit);
|
||||
|
||||
Loaded 100 of 109 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user