Compare commits

...
91 Commits
Author SHA1 Message Date
r-ca 153242ef66 WIP 2024-01-22 11:27:56 +09:00
r-ca 05997eafe1 フラグメントからToolBarのアイテムを制御できるようにした 2024-01-22 11:26:11 +09:00
r-ca d6f4885b4a iroiro 2024-01-22 11:08:48 +09:00
r-ca 0b33c60a5a ToolBar削除 2024-01-22 11:04:21 +09:00
r-ca ad3a600e8c ToolBar削除 2024-01-22 11:03:44 +09:00
r-ca 50dfb9be8b ToolBar削除 2024-01-22 11:03:14 +09:00
r-ca fafb996453 ToolBar削除 2024-01-22 11:02:08 +09:00
r-ca e1129bc009 ToolBar削除 2024-01-22 11:02:01 +09:00
r-ca 5752e3285b ToolBar削除 2024-01-22 11:01:57 +09:00
r-ca a2ed78dfb8 プロパティ追加 2024-01-22 10:58:52 +09:00
r-ca 0eadc3c3d5 レイアウト移植 2024-01-22 10:56:19 +09:00
r-ca 6d0b24eb70 レイアウト移植 WIP 2024-01-22 10:54:51 +09:00
ろむねこ 9da41e73aa Merge pull request #90 from lacerta-doc/feature/library/add
Feature/library/add
2024-01-22 10:32:47 +09:00
r-ca 01f28ecd4d ドキュメントを正常に取得できるように 2024-01-22 10:31:26 +09:00
r-ca 2f3a331527 FeatureSwitch切り替え 2024-01-22 10:31:09 +09:00
r-ca 9496c3efbb 依存関係追加 2024-01-22 10:23:08 +09:00
r-ca 93b833f7a9 nullの場合は0を返すように 2024-01-22 10:20:38 +09:00
r-ca 3130be88be getLibraryPage実装WIP 2024-01-22 10:12:21 +09:00
r-ca bb7b628d2f 壊れた実装を削除 2024-01-22 10:00:17 +09:00
r-ca 5f9ea732cf 実装 WIP 2024-01-22 01:24:55 +09:00
r-ca 42f6bc17d3 レイアウトコピー 2024-01-22 01:21:10 +09:00
r-ca 1c6878c3fd コピー 2024-01-22 01:21:00 +09:00
r-ca b5beb7cc15 Adapter修正 2024-01-22 01:20:55 +09:00
r-ca c6fb06ffe2 レイアウトコピー 2024-01-22 01:17:57 +09:00
ろむねこ 95d808dc75 Merge pull request #89 from lacerta-doc/feature/switch
Feature/switch
2024-01-22 01:12:16 +09:00
r-ca b4135f9ec0 リファクタリング 2024-01-21 20:37:04 +09:00
r-ca a62d748c72 ログ追加 2024-01-21 20:35:20 +09:00
r-ca ea0b1a7665 初回起動の場合に初期化処理としてデフォルト値を書き込むように 2024-01-21 20:34:47 +09:00
r-ca 4cfc87a40b 初回起動フラグ追加 2024-01-21 20:32:29 +09:00
r-ca 40a0d08a1f デバッグメニューを無効に 2024-01-21 20:28:56 +09:00
r-ca fd850651b3 実装を単純にした 2024-01-21 20:28:33 +09:00
r-ca ec633a7238 FeatureSwitch実装仮 2024-01-21 20:16:38 +09:00
r-ca e10207959b Merge branch 'develop' into feature/switch 2024-01-21 19:53:55 +09:00
ろむねこ c46ec70d97 Merge pull request #88 from lacerta-doc/fix_versions
compileSDKバージョンを34にアップデート
2024-01-21 19:53:25 +09:00
r-ca 871dfad6c4 compileSDKバージョンを34にアップデート 2024-01-21 19:48:30 +09:00
r-ca 676a0e2772 WIP 2024-01-21 19:45:02 +09:00
r-ca d9d22198d5 FeatureSwitch実装WIP 2024-01-21 19:18:43 +09:00
r-ca 2dc3407217 FeatureSwitchのOverrideができるように 2024-01-21 19:11:25 +09:00
r-ca d40f61928c 依存関係追加 2024-01-21 19:10:03 +09:00
r-ca 19ff824591 Enum追加 2024-01-21 19:09:37 +09:00
r-ca ec7adbe331 SharedPrefUtilsメソッド追加 2024-01-21 19:07:33 +09:00
r-ca af626f4dc0 依存関係追加 2024-01-21 19:04:01 +09:00
r-ca acea8ba27d Revert "依存関係追加"
This reverts commit 8f1849591d.
2024-01-21 19:03:45 +09:00
r-ca 8f1849591d 依存関係追加 2024-01-21 19:02:33 +09:00
r-ca 882207682f FeatureSwitchクラス作成 WIP 2024-01-21 18:56:15 +09:00
ろむねこ 0be12e73a8 Merge pull request #87 from lacerta-doc/component/viewer/1
ビューワー実装 WIP
2024-01-21 18:49:50 +09:00
r-ca f0b4cc556e 正常に画像を取得できるように 2024-01-21 18:45:51 +09:00
r-ca 8c71dedd85 XmlMetaのパース処理を修正 2024-01-21 18:44:26 +09:00
r-ca c1151b778c 画像の表示時にアニメーションするように 2024-01-21 17:56:52 +09:00
r-ca 10e3093c53 レイアウト調整 2024-01-21 17:56:07 +09:00
r-ca 9ef49e0226 レイアウト調整 2024-01-21 17:55:51 +09:00
r-ca a8ce70e6d9 レイアウト調整 2024-01-21 17:54:52 +09:00
r-ca 2f9777f1f4 adjustViewBounds 2024-01-21 17:53:56 +09:00
r-ca 0a867051f2 パス修正 2024-01-21 16:43:51 +09:00
r-ca 673918771c XmlMetaを正常に更新できるようにした 2024-01-21 16:36:52 +09:00
r-ca df14850df1 メソッドチェーン対応 2024-01-21 16:34:07 +09:00
r-ca 28cae3fa19 メソッドチェーン対応WIP 2024-01-21 16:33:26 +09:00
r-ca c167d83940 引数変更 2024-01-21 16:28:06 +09:00
r-ca 722a3d8c7b Xmlを保存できるようにした 2024-01-21 16:26:56 +09:00
r-ca d7f22c8e36 nullをキャッチするようにした 2024-01-21 16:15:11 +09:00
r-ca 0da5e8a961 WIP 2024-01-21 15:43:09 +09:00
r-ca c45847ecd2 NavigationComponent廃止 2024-01-21 15:31:06 +09:00
r-ca d6faf8ec16 ナビゲーショングラフに追加 2024-01-21 15:23:51 +09:00
r-ca 3e21b0ea1c Hiltをプラグインとして追加 2024-01-21 15:18:21 +09:00
r-ca a8e15d8e18 リスナに対応するイベントを実装 2024-01-21 15:17:43 +09:00
r-ca 50eeaa03bf 不要な実装を削除 2024-01-21 15:16:29 +09:00
r-ca f5b94e0f6a コンストラクタに追加 2024-01-21 15:16:18 +09:00
r-ca e9145d491c インターフェース作成 2024-01-21 15:15:35 +09:00
r-ca cb662fe1ff WIP 2024-01-21 15:13:53 +09:00
r-ca 8ad3150f33 コールバックインターフェース作成 2024-01-21 15:10:52 +09:00
r-ca 5cc718e35d Setter, コンストラクタ追加 2024-01-21 15:06:48 +09:00
r-ca 0accd4fa79 Merge branch 'develop' into component/viewer/1 2024-01-21 15:04:37 +09:00
ろむねこ 5840c0126e Merge pull request #86 from lacerta-doc/fix/async
非同期化
2024-01-21 15:03:21 +09:00
r-ca b63e9a6747 テスト 2024-01-20 17:46:23 +09:00
r-ca 1f8b56bc78 依存関係追加 2024-01-20 17:45:42 +09:00
r-ca dc9a6bfd9b iroiro 2024-01-20 17:43:23 +09:00
r-ca a825ad6a36 アダプタ実装 2024-01-20 17:39:21 +09:00
r-ca dd1be73904 アダプタ作成 WIP 2024-01-20 17:37:26 +09:00
r-ca 7156bc417c モデル作成 2024-01-20 17:35:57 +09:00
r-ca d9c46898ab 依存関係追加 2024-01-20 17:29:24 +09:00
r-ca 19ce9cbd7e レイアウト修正 WIP 2024-01-20 17:27:28 +09:00
r-ca 584556faca レイアウトコピー 2024-01-20 17:26:59 +09:00
r-ca 028ca6303a 引数追加 2024-01-20 17:25:44 +09:00
r-ca 76734de987 引数削除 2024-01-20 17:24:32 +09:00
r-ca 646a97e77b Arg取得 WIP 2024-01-20 17:21:48 +09:00
r-ca 1aa41eb638 依存関係追加 2024-01-20 17:19:50 +09:00
r-ca 2a34100bf2 NavHost追加 2024-01-20 17:15:39 +09:00
r-ca 5d33d188bd ComponentViewerTopFragment作成 2024-01-20 17:13:27 +09:00
r-ca 8343ba9c2d 依存関係追加 2024-01-20 17:11:44 +09:00
r-ca 95cbfdf42c ナビゲーショングラフ作成 2024-01-20 17:10:30 +09:00
r-ca 7e72cbef54 アクティビティ作成 2024-01-20 17:06:28 +09:00
52 changed files with 943 additions and 279 deletions

No files matched your search

+2 -2
View File
@@ -4,10 +4,10 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2023-12-18T03:36:14.973846Z"> <DropdownSelection timestamp="2024-01-20T07:15:21.179573376Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=ZY22H7V3G7" /> <DeviceId pluginId="LocalEmulator" identifier="path=/home/rca/.android/avd/Pixel_3a_API_34_extension_level_7_x86_64.avd" />
</handle> </handle>
</Target> </Target>
</DropdownSelection> </DropdownSelection>
-1
View File
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
+4
View File
@@ -78,4 +78,8 @@ dependencies {
implementation project(':data') implementation project(':data')
implementation project(':shared:ui') implementation project(':shared:ui')
implementation project(':model')
implementation project(':utils')
} }
@@ -1,6 +1,7 @@
package one.nem.lacerta; package one.nem.lacerta;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.navigation.NavController; import androidx.navigation.NavController;
@@ -10,31 +11,46 @@ import androidx.navigation.ui.NavigationUI;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast; import android.widget.Toast;
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
import one.nem.lacerta.utils.FeatureSwitch;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView;
import java.io.NotActiveException;
import dagger.hilt.android.AndroidEntryPoint; import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.utils.repository.SharedPrefUtils;
import javax.inject.Inject; import javax.inject.Inject;
@AndroidEntryPoint @AndroidEntryPoint
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
@Inject
SharedPrefUtils sharedPrefUtils;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
// Initialize app
if (sharedPrefUtils.getIsFirstLaunch()) initializeApp();
// Init navigation // Init navigation
try { try {
FragmentManager supportFragmentManager = getSupportFragmentManager(); FragmentManager supportFragmentManager = getSupportFragmentManager();
NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment); NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment);
assert navHostFragment != null; assert navHostFragment != null;
NavController navController = navHostFragment.getNavController(); NavController navController = navHostFragment.getNavController();
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
NavigationUI.setupWithNavController(bottomNavigationView, navController); NavigationUI.setupWithNavController(bottomNavigationView, navController);
} }
catch (Exception e) { catch (Exception e) {
@@ -44,10 +60,64 @@ public class MainActivity extends AppCompatActivity {
finish(); // Exit app finish(); // Exit app
} }
// Apply feature switch
applyFeatureSwitch(bottomNavigationView, FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch, one.nem.lacerta.feature.search.R.id.feature_search_navigation);
applyFeatureSwitch(bottomNavigationView, FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu, one.nem.lacerta.feature.debug.R.id.feature_debug_navigation);
// Set navigation bar color // Set navigation bar color
getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer)); getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
// Set status bar color // Set status bar color
getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface)); getWindow().setStatusBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurface));
// Set app bar color
AppBarLayout appBarLayout = findViewById(R.id.app_bar_layout);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) {
// Collapsed
getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
} else if (verticalOffset == 0) {
// Expanded
getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), one.nem.lacerta.shared.ui.R.color.colorSurface));
} else {
// Somewhere in between
// Here you can add a color transition if you want
}
}
});
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
// Public
public void setActionBarTitle(String title) {
getSupportActionBar().setTitle(title);
}
public void setActionBarBackButton(boolean isEnabled) {
getSupportActionBar().setDisplayHomeAsUpEnabled(isEnabled);
}
public void setActionBarMenuItem(int itemId, boolean isEnabled) {
}
private void initializeApp() {
Log.d("Init", "Initializing app");
// Set feature switch override to default value
sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch);
sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu);
// Set isFirstLaunch to false
sharedPrefUtils.setIsFirstLaunch(false);
}
private void applyFeatureSwitch(BottomNavigationView bottomNavigationView, FeatureSwitchOverride featureSwitchOverride, boolean defaultValue, int menuId) {
boolean isEnabled = FeatureSwitch.Meta.canOverrideSwitch ? sharedPrefUtils.getFeatureSwitchOverride(featureSwitchOverride) : defaultValue;
if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId);
} }
} }
+49 -12
View File
@@ -1,24 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:theme="@style/Theme.Lacerta" android:background="@color/colorSurface">
tools:context=".MainActivity">
<androidx.fragment.app.FragmentContainerView <androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:defaultNavHost="true" app:layout_constraintBottom_toTopOf="@id/bottom_nav"
app:layout_constraintBottom_toTopOf="@+id/bottom_nav"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent">
app:navGraph="@navigation/main_nav"
tools:layout="@layout/fragment_debug_menu_container" /> <com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="@color/colorSurface"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:collapsedTitleGravity="start|center_vertical"
app:contentScrim="@color/colorSecondaryContainer"
app:expandedTitleGravity="start|bottom"
app:expandedTitleMarginBottom="16dp"
app:expandedTitleMarginStart="16dp"
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:title="HOGE" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/main_nav"
tools:layout="@layout/fragment_home_top"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView <com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav" android:id="@+id/bottom_nav"
@@ -32,6 +69,6 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_nav_menu"/> app:menu="@menu/bottom_nav_menu" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
+1 -1
View File
@@ -19,7 +19,7 @@
<item <item
android:id="@id/feature_debug_navigation" android:id="@id/feature_debug_navigation"
android:icon="@drawable/developer_mode_24px" android:icon="@drawable/developer_mode_24px"
android:title="@string/debug_menu_title"/> android:title="@string/debug_menu_title" />
<item <item
android:id="@id/feature_setting_navigation" android:id="@id/feature_setting_navigation"
+1 -1
View File
@@ -2,7 +2,7 @@
<navigation xmlns:android="http://schemas.android.com/apk/res/android" <navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/app_main_nav" android:id="@+id/app_main_nav"
app:startDestination="@id/feature_debug_navigation"> app:startDestination="@id/feature_home_navigation">
<include app:graph="@navigation/feature_debug_navigation" /> <include app:graph="@navigation/feature_debug_navigation" />
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
android { android {
namespace 'one.nem.lacerta.component.common' namespace 'one.nem.lacerta.component.common'
compileSdk 33 compileSdk 34
defaultConfig { defaultConfig {
minSdk 26 minSdk 26
+1 -1
View File
@@ -5,7 +5,7 @@ plugins {
android { android {
namespace 'one.nem.lacerta.component.scanner' namespace 'one.nem.lacerta.component.scanner'
compileSdk 33 compileSdk 34
defaultConfig { defaultConfig {
minSdk 26 minSdk 26
@@ -161,13 +161,14 @@ public class ScannerManagerActivity extends AppCompatActivity {
dialog.setCancelable(false); dialog.setCancelable(false);
dialog.show(); dialog.show();
DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする
document.createDocument(documentMeta).thenAccept((documentDetail1) -> { document.createDocument(documentMeta).thenAccept((documentDetail) -> {
Bitmap[] bitmaps = new Bitmap[this.croppedImages.size()]; Bitmap[] bitmaps = new Bitmap[croppedImages.size()];
this.croppedImages.toArray(bitmaps); croppedImages.toArray(bitmaps);
addPagesToDocumentDetail(documentDetail1, bitmaps).thenRun(() -> { logger.debug(TAG, "bitmaps.length: " + bitmaps.length);
dialog.dismiss(); addPagesToDocumentDetail(documentDetail, bitmaps).join();
finish(); document.updateDocument(documentDetail).join();
}); dialog.dismiss();
finish();
}); });
} }
@@ -175,7 +176,7 @@ public class ScannerManagerActivity extends AppCompatActivity {
private CompletableFuture<Void> addPagesToDocumentDetail(DocumentDetail documentDetail, Bitmap[] bitmaps) { private CompletableFuture<Void> addPagesToDocumentDetail(DocumentDetail documentDetail, Bitmap[] bitmaps) {
return CompletableFuture.runAsync(() -> { return CompletableFuture.runAsync(() -> {
try { try {
documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps); document.updateDocument(documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps).getDocumentDetail()).join();
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit"); lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit");
} catch (Exception e) { } catch (Exception e) {
logger.error(TAG, "Error: " + e.getMessage()); logger.error(TAG, "Error: " + e.getMessage());
+23 -1
View File
@@ -1,10 +1,11 @@
plugins { plugins {
alias(libs.plugins.com.android.library) alias(libs.plugins.com.android.library)
id 'com.google.dagger.hilt.android'
} }
android { android {
namespace 'one.nem.lacerta.component.viewer' namespace 'one.nem.lacerta.component.viewer'
compileSdk 33 compileSdk 34
defaultConfig { defaultConfig {
minSdk 26 minSdk 26
@@ -29,7 +30,28 @@ dependencies {
implementation libs.androidx.appcompat implementation libs.androidx.appcompat
implementation libs.com.google.android.material implementation libs.com.google.android.material
implementation libs.androidx.activity
implementation libs.androidx.constraintlayout
testImplementation libs.junit testImplementation libs.junit
androidTestImplementation libs.androidx.test.ext.junit androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.espresso.core androidTestImplementation libs.androidx.test.espresso.core
// Navigation
implementation libs.navigation.fragment
implementation libs.navigation.ui
implementation libs.navigation.dynamic.features.fragment
// DI
implementation libs.com.google.dagger.hilt.android
annotationProcessor libs.com.google.dagger.hilt.compiler
// shared
implementation project(':shared:ui')
implementation project(':utils')
implementation project(':data')
implementation project(':model')
} }
@@ -1,4 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity
android:name=".ViewerMainActivity"
android:exported="false" />
</application>
</manifest> </manifest>
@@ -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
}
@@ -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);
}
}
}
@@ -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();
}
}
@@ -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>
@@ -20,7 +20,7 @@ public interface Document {
CompletableFuture<Void> deleteDocument(String documentId); CompletableFuture<Void> deleteDocument(String documentId);
CompletableFuture<Void> updateDocument(DocumentMeta meta, DocumentDetail detail); CompletableFuture<Void> updateDocument(DocumentDetail detail);
CompletableFuture<DocumentDetail> getDocument(String documentId); CompletableFuture<DocumentDetail> getDocument(String documentId);
} }
@@ -18,6 +18,7 @@ import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.model.document.DocumentDetail;
// Lacerta/source // Lacerta/source
import one.nem.lacerta.model.document.internal.XmlMetaModel;
import one.nem.lacerta.model.document.internal.XmlMetaPageModel; import one.nem.lacerta.model.document.internal.XmlMetaPageModel;
import one.nem.lacerta.model.document.page.Page; import one.nem.lacerta.model.document.page.Page;
import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.LacertaDatabase;
@@ -87,6 +88,9 @@ public class DocumentImpl implements Document {
LacertaVcs vcs = vcsFactory.create(meta.getId()); LacertaVcs vcs = vcsFactory.create(meta.getId());
vcs.createDocument(meta.getId()); vcs.createDocument(meta.getId());
// XmlMeta
updateXmlMeta(detail).join();
return detail; return detail;
}); });
} }
@@ -113,8 +117,9 @@ public class DocumentImpl implements Document {
} }
@Override @Override
public CompletableFuture<Void> updateDocument(DocumentMeta meta, DocumentDetail detail) { public CompletableFuture<Void> updateDocument(DocumentDetail detail) {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
updateXmlMeta(detail).join();
return null; return null;
}); });
} }
@@ -139,9 +144,11 @@ public class DocumentImpl implements Document {
DocumentDetail detail = new DocumentDetail(); DocumentDetail detail = new DocumentDetail();
getPagesByXmlMeta(documentId).thenCompose(xmlMetaPageModels -> getPagesByXmlMetaPageModel(documentId, xmlMetaPageModels)).thenAccept(pages -> { getPagesByXmlMeta(documentId).thenCompose(xmlMetaPageModels -> getPagesByXmlMetaPageModel(documentId, xmlMetaPageModels)).thenAccept(pages -> {
logger.debug(TAG, "pages: " + pages.size());
detail.setMeta(meta); detail.setMeta(meta);
detail.setPages(pages); detail.setPages(pages);
}); }).join();
return detail; return detail;
}); });
} }
@@ -150,7 +157,13 @@ public class DocumentImpl implements Document {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory()); FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
try { try {
return xmlMetaParser.deserialize(fileManager.resolve(documentId).loadXml("meta.xml")).getPages(); 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) { } catch (IOException e) {
logger.error(TAG, "DocumentMeta parse error"); logger.error(TAG, "DocumentMeta parse error");
logger.trace(TAG, e.getMessage()); logger.trace(TAG, e.getMessage());
@@ -174,7 +187,7 @@ public class DocumentImpl implements Document {
} }
for (XmlMetaPageModel xmlMetaPageModel : xmlMetaPageModels) { for (XmlMetaPageModel xmlMetaPageModel : xmlMetaPageModels) {
try { try {
pages.add(new Page(xmlMetaPageModel.getFilename(), fileManager.loadBitmap(xmlMetaPageModel.getFilename()))); pages.add(new Page(xmlMetaPageModel.getFilename(), fileManager.resolve("raw").loadBitmap(xmlMetaPageModel.getFilename())));
} catch (IOException e) { } catch (IOException e) {
logger.error(TAG, "Bitmap decode error"); logger.error(TAG, "Bitmap decode error");
logger.trace(TAG, e.getMessage()); logger.trace(TAG, e.getMessage());
@@ -185,4 +198,24 @@ public class DocumentImpl implements Document {
return pages; 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,6 +1,7 @@
package one.nem.lacerta.data.impl; package one.nem.lacerta.data.impl;
import java.text.DateFormat; import java.text.DateFormat;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -16,6 +17,7 @@ import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.LacertaDatabase;
import one.nem.lacerta.source.database.common.DateTypeConverter; import one.nem.lacerta.source.database.common.DateTypeConverter;
import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.source.database.entity.DocumentEntity;
import one.nem.lacerta.source.database.entity.FolderEntity;
import one.nem.lacerta.utils.LacertaLogger; import one.nem.lacerta.utils.LacertaLogger;
public class LacertaLibraryImpl implements LacertaLibrary { public class LacertaLibraryImpl implements LacertaLibrary {
@@ -60,10 +62,64 @@ public class LacertaLibraryImpl implements LacertaLibrary {
return null; // TODO-rca: Implement return null; // TODO-rca: Implement
} }
// Internal
private CompletableFuture<List<FolderEntity>> getFolderEntitiesByPublicPath(String publicPath) {
return CompletableFuture.supplyAsync(() -> {
return database.folderDao().findByPublicPathWithLimit(publicPath, 10); // TODO-rca: ハードコーディングやめる
});
}
private CompletableFuture<List<DocumentEntity>> getDocumentEntitiesByPublicPath(String publicPath) {
return CompletableFuture.supplyAsync(() -> {
return database.documentDao().findByPublicPathWithLimit(publicPath, 10); // TODO-rca: ハードコーディングやめる
});
}
@Override @Override
public CompletableFuture<LibraryItemPage> getLibraryPage(int limit) { public CompletableFuture<LibraryItemPage> getLibraryPage(int limit) {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
return null;
// 5秒フリーズさせる
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
LibraryItemPage libraryItemPage = new LibraryItemPage();
List<FolderEntity> folderEntities = getFolderEntitiesByPublicPath("/").join();
logger.debug("LacertaLibraryImpl", "folderEntities.size(): " + folderEntities.size());
List<DocumentEntity> documentEntities = getDocumentEntitiesByPublicPath("/").join();
logger.debug("LacertaLibraryImpl", "documentEntities.size(): " + documentEntities.size());
ArrayList<ListItem> listItems = new ArrayList<>();
for (FolderEntity folderEntity : folderEntities) {
logger.debug("LacertaLibraryImpl", "folderEntity.name: " + folderEntity.name);
ListItem listItem = new ListItem();
listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
listItem.setTitle(folderEntity.name);
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
listItem.setItemId(folderEntity.id);
listItems.add(listItem);
}
for (DocumentEntity documentEntity : documentEntities) {
logger.debug("LacertaLibraryImpl", "documentEntity.title: " + documentEntity.title);
ListItem listItem = new ListItem();
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
listItem.setTitle(documentEntity.title);
// listItem.setDescription(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm").format(documentEntity.updatedAt.toInstant()));
listItem.setItemId(documentEntity.id);
listItems.add(listItem);
}
libraryItemPage.setPageTitle("/");
libraryItemPage.setPageId("root");
libraryItemPage.setListItems(listItems);
logger.debug("LacertaLibraryImpl", "libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
return libraryItemPage;
}); });
} }
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
android { android {
namespace 'one.nem.lacerta.feature.common' namespace 'one.nem.lacerta.feature.common'
compileSdk 33 compileSdk 34
defaultConfig { defaultConfig {
minSdk 26 minSdk 26
+3 -1
View File
@@ -5,7 +5,7 @@ plugins {
android { android {
namespace 'one.nem.lacerta.feature.home' namespace 'one.nem.lacerta.feature.home'
compileSdk 33 compileSdk 34
defaultConfig { defaultConfig {
minSdk 26 minSdk 26
@@ -57,4 +57,6 @@ dependencies {
implementation "androidx.recyclerview:recyclerview:1.3.2" implementation "androidx.recyclerview:recyclerview:1.3.2"
implementation project(':component:common') implementation project(':component:common')
implementation project(':component:viewer')
} }
@@ -0,0 +1,5 @@
package one.nem.lacerta.feature.home;
public interface DocumentSelectListener {
void onDocumentSelect(String documentId);
}
@@ -1,5 +1,6 @@
package one.nem.lacerta.feature.home; package one.nem.lacerta.feature.home;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@@ -9,6 +10,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
@@ -28,6 +30,7 @@ import java.util.concurrent.CompletableFuture;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint; import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.component.viewer.ViewerMainActivity;
import one.nem.lacerta.data.Document; import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.ListItem; import one.nem.lacerta.model.ListItem;
@@ -68,6 +71,7 @@ public class HomeTopFragment extends Fragment {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_home_top, container, false); View view = inflater.inflate(R.layout.fragment_home_top, container, false);
setHasOptionsMenu(true);
return view; return view;
} }
@@ -78,7 +82,12 @@ public class HomeTopFragment extends Fragment {
RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view); RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view);
ListItemAdapter listItemAdapter = new ListItemAdapter(); 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.setAdapter(listItemAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
@@ -88,32 +97,12 @@ public class HomeTopFragment extends Fragment {
listItemAdapter.notifyItemRangeInserted(0, listItems.size()); listItemAdapter.notifyItemRangeInserted(0, listItems.size());
}); });
}); });
}
CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar); @Override
Toolbar toolbar = view.findViewById(R.id.toolbar); public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.drawer_menu, menu);
// Set the Toolbar super.onCreateOptionsMenu(menu, inflater);
((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
// Set the title of the CollapsingToolbarLayout
collapsingToolbarLayout.setTitle("Lacerta");
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(getActivity(), one.nem.lacerta.shared.ui.R.color.colorSecondaryContainer));
} else if (verticalOffset == 0) {
// Expanded
getActivity().getWindow().setStatusBarColor(ContextCompat.getColor(getActivity(), one.nem.lacerta.shared.ui.R.color.colorSurface));
} else {
// Somewhere in between
// Here you can add a color transition if you want
}
}
});
} }
} }
@@ -1,5 +1,6 @@
package one.nem.lacerta.feature.home; package one.nem.lacerta.feature.home;
import android.content.Intent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -11,18 +12,18 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList; import java.util.ArrayList;
import one.nem.lacerta.component.viewer.ViewerMainActivity;
import one.nem.lacerta.model.ListItem; import one.nem.lacerta.model.ListItem;
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
ArrayList<ListItem> listItems; ArrayList<ListItem> listItems;
public ListItemAdapter(ArrayList<ListItem> listItems){ DocumentSelectListener listener;
this.listItems = listItems;
}
public ListItemAdapter() { public ListItemAdapter(DocumentSelectListener listener){
this.listItems = new ArrayList<>(); this.listItems = new ArrayList<>();
this.listener = listener;
} }
public void setListItems(ArrayList<ListItem> listItems) { public void setListItems(ArrayList<ListItem> listItems) {
@@ -43,6 +44,12 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface); holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
holder.title.setText(listItem.getTitle()); holder.title.setText(listItem.getTitle());
holder.description.setText(listItem.getDescription()); holder.description.setText(listItem.getDescription());
holder.itemView.setOnClickListener( v -> {
Intent intent = new Intent(v.getContext(), ViewerMainActivity.class);
intent.putExtra("documentId", listItem.getItemId());
v.getContext().startActivity(intent);
});
} }
@Override @Override
@@ -1,50 +1,11 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:background="@color/colorSurface">
<androidx.coordinatorlayout.widget.CoordinatorLayout <androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_item_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
app:contentScrim="@color/colorSecondaryContainer"
android:background="@color/colorSurface"
android:layout_width="match_parent"
android:layout_height="160dp"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:collapsedTitleGravity="start|center_vertical"
app:expandedTitleGravity="start|bottom"
app:expandedTitleMarginBottom="16dp"
app:expandedTitleMarginStart="16dp"
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:title="HOGE" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_item_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</FrameLayout> </FrameLayout>
+3 -1
View File
@@ -5,7 +5,7 @@ plugins {
android { android {
namespace 'one.nem.lacerta.feature.library' namespace 'one.nem.lacerta.feature.library'
compileSdk 33 compileSdk 34
defaultConfig { defaultConfig {
minSdk 26 minSdk 26
@@ -51,5 +51,7 @@ dependencies {
implementation project(':data') implementation project(':data')
implementation project(':utils')
} }
@@ -0,0 +1,5 @@
package one.nem.lacerta.feature.library;
public interface DocumentSelectListener {
void onDocumentSelect(String documentId);
}
@@ -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);
}
});
}
}
@@ -3,11 +3,16 @@ package one.nem.lacerta.feature.library;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@@ -15,6 +20,9 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -22,8 +30,10 @@ import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint; import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.data.Document; import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.tag.DocumentTag; import one.nem.lacerta.model.document.tag.DocumentTag;
import one.nem.lacerta.utils.LacertaLogger;
@@ -35,36 +45,18 @@ import one.nem.lacerta.model.document.tag.DocumentTag;
@AndroidEntryPoint @AndroidEntryPoint
public class LibraryTopFragment extends Fragment { public class LibraryTopFragment extends Fragment {
// @Inject @Inject
// Document document; LacertaLibrary lacertaLibrary;
// TODO: Rename parameter arguments, choose names that match @Inject
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER LacertaLogger logger;
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
public LibraryTopFragment() { public LibraryTopFragment() {
// Required empty public constructor // Required empty public constructor
} }
public static LibraryTopFragment newInstance() {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment LibraryTopFragment.
*/
// TODO: Rename and change types and number of parameters
public static LibraryTopFragment newInstance(String param1, String param2) {
LibraryTopFragment fragment = new LibraryTopFragment(); LibraryTopFragment fragment = new LibraryTopFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
@@ -72,10 +64,6 @@ public class LibraryTopFragment extends Fragment {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
} }
@@ -84,23 +72,35 @@ public class LibraryTopFragment extends Fragment {
// Inflate the layout for this fragment // Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_library_top, container, false); View view = inflater.inflate(R.layout.fragment_library_top, container, false);
// Use view.findViewById instead of findViewById setHasOptionsMenu(true);
RecyclerView documentRecyclerView = view.findViewById(R.id.document_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
documentRecyclerView.setLayoutManager(layoutManager);
//データを取得
// List<DocumentMeta> metas = document.getAllDocumentMetas(100);
// Toast.makeText(getContext(), "Documents: " + Integer.toString(metas.size()), Toast.LENGTH_LONG).show();
// Create and set the adapter
// DocumentAdapter adapter = new DocumentAdapter(metas);
// documentRecyclerView.setAdapter(adapter);
// Use a LinearLayoutManager to specify the layout
return view; return view;
} }
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view);
ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> {
Toast.makeText(getContext(), documentId, Toast.LENGTH_SHORT).show();
});
recyclerView.setAdapter(listItemAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
lacertaLibrary.getLibraryPage(10).thenAccept(libraryItemPage -> {
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
listItemAdapter.setLibraryItemPage(libraryItemPage);
getActivity().runOnUiThread(() -> {
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
});
});
}
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.dir_menu, menu);
super.onCreateOptionsMenu(menu, inflater);
}
} }
@@ -0,0 +1,74 @@
package one.nem.lacerta.feature.library;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.ListItem;
public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListItemViewHolder>{
LibraryItemPage libraryItemPage;
DocumentSelectListener listener;
public ListItemAdapter(DocumentSelectListener listener) {
this.listener = listener;
}
public void setLibraryItemPage(LibraryItemPage libraryItemPage) {
this.libraryItemPage = libraryItemPage;
}
@NonNull
@Override
public ListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
return new ListItemViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ListItemViewHolder holder, int position) {
ListItem listItem = libraryItemPage.getListItems().get(position);
holder.icon.setImageResource(listItem.getItemType().getIconId());
holder.icon.setColorFilter(one.nem.lacerta.shared.ui.R.color.colorOnSurface);
holder.title.setText(listItem.getTitle());
holder.description.setText(listItem.getDescription());
holder.itemView.setOnClickListener( v -> {
// Intent intent = new Intent(v.getContext(), ViewerMainActivity.class);
// intent.putExtra("documentId", listItem.getItemId());
// v.getContext().startActivity(intent);
});
}
@Override
public int getItemCount() {
return this.libraryItemPage == null ? 0
: this.libraryItemPage.getListItems() == null ? 0 : this.libraryItemPage.getListItems().size();
}
public static class ListItemViewHolder extends RecyclerView.ViewHolder{
ImageView icon;
TextView title;
TextView description;
public ListItemViewHolder(@NonNull View itemView) {
super(itemView);
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
}
}
}
@@ -1,32 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:theme="@style/Theme.Lacerta"
tools:context=".LibraryTopFragment">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryContainer"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="Library"
app:titleTextColor="@color/colorOnPrimaryContainer" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/document_list" android:id="@+id/library_item_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tool_bar" />
</androidx.constraintlayout.widget.ConstraintLayout> </FrameLayout>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_item_create_new_folder"
android:icon="@drawable/developer_mode_24px"
android:title="@string/app_name"
app:showAsAction="ifRoom"/> <!-- TODO-rca: change this -->
</menu>
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
android { android {
namespace 'one.nem.lacerta.feature.scan' namespace 'one.nem.lacerta.feature.scan'
compileSdk 33 compileSdk 34
defaultConfig { defaultConfig {
minSdk 26 minSdk 26
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
android { android {
namespace 'one.nem.lacerta.feature.search' namespace 'one.nem.lacerta.feature.search'
compileSdk 33 compileSdk 34
defaultConfig { defaultConfig {
minSdk 26 minSdk 26
@@ -1,50 +1,11 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:background="@color/colorSurface">
<androidx.coordinatorlayout.widget.CoordinatorLayout <androidx.recyclerview.widget.RecyclerView
android:id="@+id/setting_item_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
app:contentScrim="@color/colorSecondaryContainer"
android:background="@color/colorSurface"
android:layout_width="match_parent"
android:layout_height="160dp"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:collapsedTitleGravity="start|center_vertical"
app:expandedTitleGravity="start|bottom"
app:expandedTitleMarginBottom="16dp"
app:expandedTitleMarginStart="16dp"
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:title="@string/setting_title" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/setting_item_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</FrameLayout> </FrameLayout>
@@ -0,0 +1,30 @@
package one.nem.lacerta.model.pref;
public enum FeatureSwitchOverride {
ENABLE_DEBUG_MENU("enableDebugMenu"),
ENABLE_SEARCH("enableSearch"),
SHOW_DISPLAY_MENU("showDisplayMenu"),
SHOW_DATA_MENU("showDataMenu"),
SHOW_SCAN_MENU("showScanMenu");
private final String key;
FeatureSwitchOverride(String key) {
this.key = key;
}
public String getKey() {
return key;
}
public static FeatureSwitchOverride fromKey(String key) {
for (FeatureSwitchOverride value : values()) {
if (value.getKey().equals(key)) {
return value;
}
}
return null;
}
}
@@ -7,13 +7,13 @@ import one.nem.lacerta.model.document.DocumentDetail;
public interface DocumentProcessor { public interface DocumentProcessor {
// ページ操作 // ページ操作
void addNewPageToLast(Bitmap bitmap) throws Exception; DocumentProcessor addNewPageToLast(Bitmap bitmap) throws Exception;
void addNewPagesToLast(Bitmap[] bitmaps) throws Exception; DocumentProcessor addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
void insertPageAtIndex(Bitmap bitmap, int index) throws Exception; DocumentProcessor insertPageAtIndex(Bitmap bitmap, int index) throws Exception;
void removePageAtIndex(int index) throws Exception; DocumentProcessor removePageAtIndex(int index) throws Exception;
// 更新 // 更新
void updatePageAtIndex(Bitmap bitmap, int index); DocumentProcessor updatePageAtIndex(Bitmap bitmap, int index);
// ページ取得 // ページ取得
Bitmap getPageAtIndex(int index); Bitmap getPageAtIndex(int index);
@@ -70,7 +70,7 @@ public class DocumentProcessorImpl implements DocumentProcessor{
@Override @Override
public void addNewPageToLast(Bitmap bitmap) throws Exception{ public DocumentProcessor addNewPageToLast(Bitmap bitmap) throws Exception{
logger.debug("addNewPageToLast", "called"); logger.debug("addNewPageToLast", "called");
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
@@ -85,19 +85,23 @@ public class DocumentProcessorImpl implements DocumentProcessor{
logger.info("addNewPageToLast", "finished"); logger.info("addNewPageToLast", "finished");
logger.info("addNewPageToLast", "filename: " + filename); logger.info("addNewPageToLast", "filename: " + filename);
return this;
} }
@Override @Override
public void addNewPagesToLast(Bitmap[] bitmaps) throws Exception{ public DocumentProcessor addNewPagesToLast(Bitmap[] bitmaps) throws Exception{
logger.debug("addNewPagesToLast", "called"); logger.debug("addNewPagesToLast", "called");
for (Bitmap bitmap : bitmaps) { for (Bitmap bitmap : bitmaps) {
addNewPageToLast(bitmap); addNewPageToLast(bitmap);
} // TODO-rca: 効率悪いので改善する } // TODO-rca: 効率悪いので改善する
return this;
} }
@Override @Override
public void insertPageAtIndex(Bitmap bitmap, int index) throws Exception { public DocumentProcessor insertPageAtIndex(Bitmap bitmap, int index) throws Exception {
logger.debug("addNewPageAfterIndex", "called"); logger.debug("addNewPageAfterIndex", "called");
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
@@ -109,16 +113,18 @@ public class DocumentProcessorImpl implements DocumentProcessor{
this.documentDetail.getPages().add(index, page); this.documentDetail.getPages().add(index, page);
lacertaVcs.insertPage(index, filename); lacertaVcs.insertPage(index, filename);
return this;
} }
@Override @Override
public void removePageAtIndex(int index) { public DocumentProcessor removePageAtIndex(int index) {
return null;
} }
@Override @Override
public void updatePageAtIndex(Bitmap bitmap, int index) { public DocumentProcessor updatePageAtIndex(Bitmap bitmap, int index) {
return null;
} }
@Override @Override
@@ -6,6 +6,7 @@ import androidx.room.Insert;
import androidx.room.Query; import androidx.room.Query;
import androidx.room.Update; import androidx.room.Update;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.source.database.entity.DocumentEntity;
@@ -4,6 +4,9 @@ import androidx.room.Dao;
import androidx.room.Insert; import androidx.room.Insert;
import androidx.room.Query; import androidx.room.Query;
import java.util.ArrayList;
import java.util.List;
import one.nem.lacerta.source.database.entity.FolderEntity; import one.nem.lacerta.source.database.entity.FolderEntity;
@Dao @Dao
@@ -15,6 +18,9 @@ public interface FolderDao {
@Query("SELECT * FROM Folder WHERE public_path = :publicPath") @Query("SELECT * FROM Folder WHERE public_path = :publicPath")
FolderEntity findByPublicPath(String publicPath); FolderEntity findByPublicPath(String publicPath);
@Query("SELECT * FROM Folder WHERE public_path = :publicPath LIMIT :limit")
List<FolderEntity> findByPublicPathWithLimit(String publicPath, int limit);
@Insert @Insert
void insert(FolderEntity folderEntity); void insert(FolderEntity folderEntity);
@@ -37,7 +37,11 @@ public class FileManagerImpl implements FileManager {
@AssistedInject @AssistedInject
public FileManagerImpl(LacertaLogger logger, @Assisted Path rootDir) { public FileManagerImpl(LacertaLogger logger, @Assisted Path rootDir) {
this.logger = logger; this.logger = logger;
if (rootDir == null) {
throw new IllegalArgumentException("rootDir must not be null");
}
this.rootDir = rootDir; this.rootDir = rootDir;
this.path = rootDir;
} }
// for generate new instance // for generate new instance
@@ -62,6 +66,10 @@ public class FileManagerImpl implements FileManager {
try { try {
resolvedPath = resolvedPath.resolve(pathPart); resolvedPath = resolvedPath.resolve(pathPart);
} catch (Exception e) { } catch (Exception e) {
logger.error("resolveStringPath", e.getMessage());
logger.debug("resolveStringPath", "this.path: " + this.path);
logger.debug("resolveStringPath", "pathPart: " + pathPart);
logger.debug("resolveStringPath", "resolvedPath: " + resolvedPath);
throw new IOException("Invalid path: " + path); throw new IOException("Invalid path: " + path);
} }
} }
@@ -0,0 +1,19 @@
package one.nem.lacerta.utils;
public class FeatureSwitch {
public static class Meta {
public static boolean canOverrideSwitch = false;
}
public static class FeatureMaster {
public static boolean enableSearch = true;
public static boolean enableDebugMenu = true;
}
public static class Setting {
public static boolean showDisplayMenu = false;
public static boolean showDataMenu = false;
public static boolean showScanMenu = false;
}
}
@@ -20,7 +20,9 @@ public class DeviceInfoUtilsImpl implements DeviceInfoUtils {
@Override @Override
public Path getExternalStorageDirectory() { public Path getExternalStorageDirectory() {
// TODO-rca: 結果がnullだった場合の処理を追加する? if (applicationContext.getExternalFilesDir(null) == null) {
throw new RuntimeException("applicationContext.getExternalFilesDir(null) is null");
}
return Objects.requireNonNull(applicationContext.getExternalFilesDir(null)).toPath(); return Objects.requireNonNull(applicationContext.getExternalFilesDir(null)).toPath();
} }
@@ -31,7 +33,9 @@ public class DeviceInfoUtilsImpl implements DeviceInfoUtils {
@Override @Override
public Path getExternalStorageDirectory(String type) { public Path getExternalStorageDirectory(String type) {
// TODO-rca: 結果がnullだった場合の処理を追加する? if(applicationContext.getExternalFilesDir(type) == null) {
throw new RuntimeException("applicationContext.getExternalFilesDir(" + type + ") is null");
}
return Objects.requireNonNull(applicationContext.getExternalFilesDir(type)).toPath(); return Objects.requireNonNull(applicationContext.getExternalFilesDir(type)).toPath();
} }
@@ -4,13 +4,17 @@ package one.nem.lacerta.utils.impl;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import javax.inject.Inject;
import dagger.hilt.android.qualifiers.ApplicationContext; import dagger.hilt.android.qualifiers.ApplicationContext;
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
import one.nem.lacerta.utils.repository.SharedPrefUtils; import one.nem.lacerta.utils.repository.SharedPrefUtils;
public class SharedPrefUtilsImpl implements SharedPrefUtils{ public class SharedPrefUtilsImpl implements SharedPrefUtils{
private final Context applicationContext; private final Context applicationContext;
@Inject
public SharedPrefUtilsImpl(@ApplicationContext Context applicationContext) { public SharedPrefUtilsImpl(@ApplicationContext Context applicationContext) {
this.applicationContext = applicationContext; this.applicationContext = applicationContext;
} }
@@ -26,4 +30,34 @@ public class SharedPrefUtilsImpl implements SharedPrefUtils{
// Editorの取得 // Editorの取得
return applicationContext.getSharedPreferences(name, Context.MODE_PRIVATE).edit(); return applicationContext.getSharedPreferences(name, Context.MODE_PRIVATE).edit();
} }
@Override
public SharedPreferences getSharedPreferences(String name) {
return applicationContext.getSharedPreferences(name, Context.MODE_PRIVATE);
}
@Override
public SharedPreferences getSharedPreferences() {
return applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE); // TODO-rca: 決め打ちやめる?
}
@Override
public boolean getFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride) {
return getSharedPreferences().getBoolean(featureSwitchOverride.getKey(), false);
}
@Override
public void setFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride, boolean value) {
getEditor().putBoolean(featureSwitchOverride.getKey(), value).apply();
}
@Override
public boolean getIsFirstLaunch() {
return getSharedPreferences().getBoolean("isFirstLaunch", true);
}
@Override
public void setIsFirstLaunch(boolean value) {
getEditor().putBoolean("isFirstLaunch", value).apply();
}
} }
@@ -17,6 +17,8 @@ import one.nem.lacerta.utils.LacertaLogger;
public class XmlMetaParserImpl implements XmlMetaParser{ public class XmlMetaParserImpl implements XmlMetaParser{
String TAG = getClass().getSimpleName();
@Inject @Inject
LacertaLogger logger; LacertaLogger logger;
@@ -35,13 +37,18 @@ public class XmlMetaParserImpl implements XmlMetaParser{
meta.setRevisionId(rootElement.getElementsByTagName("revisionId").item(0).getTextContent()); meta.setRevisionId(rootElement.getElementsByTagName("revisionId").item(0).getTextContent());
ArrayList<XmlMetaPageModel> pages = new ArrayList<>(); ArrayList<XmlMetaPageModel> pages = new ArrayList<>();
for(int i = 0; i < rootElement.getElementsByTagName("pages").getLength(); i++) { for (int i = 0; i < rootElement.getElementsByTagName("page").getLength(); i++) {
Element pageElement = (Element) rootElement.getElementsByTagName("page").item(i); Element pageElement = (Element) rootElement.getElementsByTagName("page").item(i);
XmlMetaPageModel page = new XmlMetaPageModel(); XmlMetaPageModel page = new XmlMetaPageModel();
page.setFilename(pageElement.getElementsByTagName("filename").item(0).getTextContent()); page.setFilename(pageElement.getElementsByTagName("filename").item(0).getTextContent());
pages.add(page); pages.add(page);
} }
logger.debug(TAG, "Parsed Meta: " + meta.getRevisionId() + " " + pages.size() + " pages.");
for (XmlMetaPageModel page : pages) {
logger.debug(TAG, "\tPage: " + page.getFilename());
}
meta.setPages(pages); meta.setPages(pages);
return meta; return meta;
@@ -2,6 +2,8 @@ package one.nem.lacerta.utils.repository;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
public interface SharedPrefUtils { public interface SharedPrefUtils {
// Shared preferences editorの取得 // Shared preferences editorの取得
@@ -10,4 +12,15 @@ public interface SharedPrefUtils {
// TODO-rca: 名称をenumで管理する? // TODO-rca: 名称をenumで管理する?
SharedPreferences.Editor getEditor(String name); SharedPreferences.Editor getEditor(String name);
SharedPreferences getSharedPreferences(String name);
SharedPreferences getSharedPreferences();
boolean getFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride);
void setFeatureSwitchOverride(FeatureSwitchOverride featureSwitchOverride, boolean value);
boolean getIsFirstLaunch();
void setIsFirstLaunch(boolean value);
} }