Compare commits

..
167 Commits
Author SHA1 Message Date
r-ca 18eee403ef fixUI 2024-01-23 02:09:36 +09:00
r-ca b820f42007 iroiro, コミット履歴を表示できるように 2024-01-23 02:04:25 +09:00
r-ca af8935cd7f アイテムレイアウト作成 2024-01-23 01:46:47 +09:00
r-ca 6c50675938 修正 2024-01-23 01:29:30 +09:00
r-ca 791084b737 依存関係追加 2024-01-23 01:28:22 +09:00
r-ca 15d4a369d8 移動 2024-01-23 01:27:20 +09:00
r-ca 07e14eb90c getRevisionHistoryByDocumentId実装 2024-01-23 01:27:11 +09:00
r-ca b13f048c7e Adapter作成 2024-01-23 01:15:46 +09:00
r-ca f0ed4327ca Model作成 2024-01-23 01:13:00 +09:00
r-ca b852e9b7ee RevListFragment作成 2024-01-23 01:05:45 +09:00
ろむねこ ca063709dd Merge pull request #94 from lacerta-doc/improve/fixui
Improve/fixui
2024-01-23 01:03:40 +09:00
r-ca 67de02b502 画面推移で発生する問題を概ね解消した 2024-01-23 00:56:31 +09:00
r-ca 5fafbec247 Revert "コンテナフラグメント作成"
This reverts commit 14ff9abab9.
2024-01-23 00:45:15 +09:00
r-ca e104b3d8ff Revert "引数削除など"
This reverts commit 4714e3d8cb.
2024-01-23 00:45:15 +09:00
r-ca d8d8a5932b Revert "WIP"
This reverts commit 113a2fd3d2.
2024-01-23 00:45:14 +09:00
r-ca 113a2fd3d2 WIP 2024-01-23 00:45:02 +09:00
r-ca 4714e3d8cb 引数削除など 2024-01-23 00:38:17 +09:00
r-ca 14ff9abab9 コンテナフラグメント作成 2024-01-23 00:37:23 +09:00
r-ca 1105c17fca WIp 2024-01-23 00:36:26 +09:00
r-ca 37a18704e3 バックスタックに積まずにナビゲーションするメソッドを追加 2024-01-22 23:48:09 +09:00
r-ca d5df291c81 バックスタックに積まずにナビゲーションするメソッドを追加 2024-01-22 23:47:46 +09:00
r-ca 3178e9233b iroiro 2024-01-22 23:46:23 +09:00
r-ca 004bedb45f フォルダを正常に取得できるように, 作成できるように 2024-01-22 23:35:30 +09:00
r-ca de30eb241c ドキュメントを正常に取得できるようになった 2024-01-22 23:29:49 +09:00
r-ca c7f2a3eebe Daoクエリ追加 2024-01-22 23:28:15 +09:00
r-ca 2a7e329ad7 parentIdに切り替え WIP 2024-01-22 23:20:39 +09:00
r-ca 52f41881fd Iroiro 2024-01-22 20:48:47 +09:00
r-ca 68fb0b719b CreateFolder改修 2024-01-22 20:23:36 +09:00
r-ca da8d4fb4fc PublicPathを生成するメソッド作成 2024-01-22 20:22:51 +09:00
r-ca f7d07b0ec3 パス解決メソッドを作成 2024-01-22 20:21:01 +09:00
r-ca 7f71e818a8 fix 2024-01-22 20:10:04 +09:00
r-ca fc6cbb9d37 一部廃止 2024-01-22 20:06:19 +09:00
r-ca df3edbf354 Model修正 2024-01-22 20:03:56 +09:00
r-ca d40b188f87 Model修正 2024-01-22 20:03:42 +09:00
r-ca 253c77d6f5 Dao修正 2024-01-22 20:00:45 +09:00
r-ca b87b635d2b DBバージョンインクリメント 2024-01-22 19:59:21 +09:00
r-ca 9df033af73 Entity更新 2024-01-22 19:58:59 +09:00
r-ca 58e0686304 Entity更新 2024-01-22 19:58:20 +09:00
r-ca a0f89de1ac WIP 2024-01-22 19:41:54 +09:00
r-ca fe4999384a Fix 2024-01-22 19:28:42 +09:00
r-ca bc304f8535 WIP 2024-01-22 19:22:24 +09:00
r-ca e77fafc108 WIP 2024-01-22 19:22:15 +09:00
r-ca 305cbcd679 WIP 2024-01-22 19:17:09 +09:00
r-ca c06d7e6b15 引数のフォルダ名を使って取得開始前にToolBarをinitするように 2024-01-22 18:43:46 +09:00
r-ca 1648e0b7c1 フォルダ名を引数にとるようにした 2024-01-22 18:42:50 +09:00
r-ca 04db160548 フォルダ名を引数にとるようにした 2024-01-22 18:41:24 +09:00
r-ca 611c5b516d 不要な実装を削除 2024-01-22 18:40:24 +09:00
r-ca 734f75b4c7 iroiro 2024-01-22 18:35:18 +09:00
r-ca 6e0c473c66 setupToolbar実装 2024-01-22 18:24:53 +09:00
r-ca 20828e2f0f ステータスバーの色を合わせる処理を移植 2024-01-22 18:18:12 +09:00
r-ca 3b684bec53 不要な実装を削除 2024-01-22 18:15:41 +09:00
r-ca afef074242 ビルドエラー回避 2024-01-22 18:14:42 +09:00
r-ca 1ceb3e29b7 実装修正 2024-01-22 18:14:11 +09:00
r-ca a5fa89252c Merge branch 'develop' into improve/fixui
# Conflicts:
#	app/src/main/java/one/nem/lacerta/MainActivity.java
#	feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java
2024-01-22 18:13:44 +09:00
ろむねこ 106bb93644 Merge pull request #93 from lacerta-doc/feature/library/open_folder
Feature/library/open folder
2024-01-22 18:11:00 +09:00
r-ca ab39cd4d00 レイアウト復元 2024-01-22 17:26:03 +09:00
r-ca d1a5cd2f23 実装整理 2024-01-22 17:24:05 +09:00
r-ca 0dc69e1d73 実装整理 2024-01-22 17:22:52 +09:00
r-ca 3d8ab69742 実装整理 2024-01-22 17:22:41 +09:00
r-ca 6bc43869c9 レイアウト復元 2024-01-22 17:21:54 +09:00
r-ca 63dfbc120d レイアウト復元 2024-01-22 17:21:30 +09:00
r-ca 064c4edfbe レイアウト復元 2024-01-22 17:20:39 +09:00
r-ca 1a80d00319 フォルダを開けるように WIP 2024-01-22 13:29:40 +09:00
r-ca 3f893fc580 インタフェース修正 2024-01-22 12:16:56 +09:00
r-ca 225058f836 壊れたImportを修正 2024-01-22 12:11:06 +09:00
r-ca c23b92d386 リネーム 2024-01-22 12:10:45 +09:00
ろむねこ 41e5ab2349 Merge pull request #92 from lacerta-doc/feature/library/create_folder
Feature/library/create folder
2024-01-22 12:09:26 +09:00
r-ca 580e79b03a Revert "InputDialogのWrapper作成 WIP"
This reverts commit 301fab8024.
2024-01-22 12:07:52 +09:00
r-ca 301fab8024 InputDialogのWrapper作成 WIP 2024-01-22 12:07:46 +09:00
r-ca 281238a38e 作成するフォルダの名前を指定できるように 2024-01-22 12:07:07 +09:00
r-ca 81fa259985 フォルダを作成できるように 2024-01-22 11:55:38 +09:00
r-ca b2c6085933 パースメソッドを追加 2024-01-22 11:54:39 +09:00
r-ca caf3a0dd34 絶対パスを正常に解決できるように 2024-01-22 11:50:29 +09:00
r-ca c4e10b9487 絶対パスを正常に解決できるように 2024-01-22 11:49:45 +09:00
r-ca b05ee22c29 createFolder関数実装 2024-01-22 11:34:03 +09:00
ろむねこ 839433dbb1 Merge pull request #91 from lacerta-doc/test
Test
2024-01-22 11:28:31 +09:00
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
68 changed files with 1790 additions and 289 deletions

No files matched your search

+2 -2
View File
@@ -4,10 +4,10 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="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>
-1
View File
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
+4
View File
@@ -78,4 +78,8 @@ dependencies {
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,10 +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.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();
}
}
+2 -2
View File
@@ -18,7 +18,7 @@
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"
@@ -32,6 +32,6 @@
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>
+1 -1
View File
@@ -19,7 +19,7 @@
<item
android:id="@id/feature_debug_navigation"
android:icon="@drawable/developer_mode_24px"
android:title="@string/debug_menu_title"/>
android:title="@string/debug_menu_title" />
<item
android:id="@id/feature_setting_navigation"
+1 -1
View File
@@ -2,7 +2,7 @@
<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" />
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
android {
namespace 'one.nem.lacerta.component.common'
compileSdk 33
compileSdk 34
defaultConfig {
minSdk 26
+1 -1
View File
@@ -5,7 +5,7 @@ plugins {
android {
namespace 'one.nem.lacerta.component.scanner'
compileSdk 33
compileSdk 34
defaultConfig {
minSdk 26
@@ -161,13 +161,14 @@ public class ScannerManagerActivity extends AppCompatActivity {
dialog.setCancelable(false);
dialog.show();
DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする
document.createDocument(documentMeta).thenAccept((documentDetail1) -> {
Bitmap[] bitmaps = new Bitmap[this.croppedImages.size()];
this.croppedImages.toArray(bitmaps);
addPagesToDocumentDetail(documentDetail1, bitmaps).thenRun(() -> {
dialog.dismiss();
finish();
});
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();
});
}
@@ -175,7 +176,7 @@ public class ScannerManagerActivity extends AppCompatActivity {
private CompletableFuture<Void> addPagesToDocumentDetail(DocumentDetail documentDetail, Bitmap[] bitmaps) {
return CompletableFuture.runAsync(() -> {
try {
documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps);
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());
+25 -1
View File
@@ -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,30 @@ 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')
implementation project(':vcs')
}
@@ -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>
@@ -0,0 +1,129 @@
package one.nem.lacerta.component.viewer;
import android.graphics.Bitmap;
import android.os.Bundle;
import androidx.appcompat.widget.Toolbar;
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.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);
// Toolbar
Toolbar toolbar = view.findViewById(R.id.toolbar);
toolbarSetup(toolbar, true, "Revision List");
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;
}
/**
* 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.viewer_menu);
toolbar.setOnMenuItemClickListener(item -> {
if (item.getItemId() == R.id.action_open_vcs_rev_list) {
// Open vcs rev list
getParentFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, ViewerVcsRevListFragment.newInstance(documentId))
.commit();
return true;
} else {
return false;
}
});
});
}
}
@@ -0,0 +1,5 @@
package one.nem.lacerta.component.viewer;
public interface ItemClickListener {
void onItemClick(String fileName); // DEBUG
}
@@ -0,0 +1,80 @@
package one.nem.lacerta.component.viewer;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import one.nem.lacerta.model.VcsRevModel;
import one.nem.lacerta.utils.FeatureSwitch;
public class RevAdapter extends RecyclerView.Adapter<RevAdapter.RevViewHolder>{
private ArrayList<VcsRevModel> revModels;
public RevAdapter(ArrayList<VcsRevModel> revModels) {
this.revModels = revModels;
}
public RevAdapter() {
}
public void setRevModels(ArrayList<VcsRevModel> revModels) {
this.revModels = revModels;
}
@NonNull
@Override
public RevAdapter.RevViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.viewer_rev_list_item, parent, false);
return new RevAdapter.RevViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull RevAdapter.RevViewHolder holder, int position) {
VcsRevModel revModel = revModels.get(position);
holder.title.setText(revModel.getCommitMessage());
if (FeatureSwitch.Vcs.disableBranchDisplay) {
// holder.detail.setText(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(revModel.getCreatedAt().toInstant()));
holder.detail.setText("DateTimePlaceholder");
} else {
// holder.detail.setText(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(revModel.getCreatedAt().toInstant()) + " " + revModel.getBranchName());
holder.detail.setText("DateTimePlaceholder" + " " + revModel.getBranchName());
}
holder.revId.setText("RevID: " + revModel.getId());
}
@Override
public int getItemCount() {
if (revModels == null) {
return 0;
} else {
return revModels.size();
}
}
class RevViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView detail;
TextView revId;
public RevViewHolder(@NonNull View itemView) {
super(itemView);
title = itemView.findViewById(R.id.rev_item_title);
detail = itemView.findViewById(R.id.rev_item_detail);
revId = itemView.findViewById(R.id.rev_item_id);
}
}
}
@@ -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,66 @@
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();
}
// Navigation
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, ComponentViewerTopFragment.newInstance(documentId))
.commit();
}
}
@@ -0,0 +1,95 @@
package one.nem.lacerta.component.viewer;
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 javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.utils.LacertaLogger;
import one.nem.lacerta.vcs.LacertaVcs;
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
/**
* A simple {@link Fragment} subclass.
* Use the {@link ViewerVcsRevListFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class ViewerVcsRevListFragment extends Fragment {
@Inject
LacertaVcsFactory lacertaVcsFactory;
@Inject
LacertaLogger logger;
LacertaVcs lacertaVcs;
private String documentId;
public ViewerVcsRevListFragment() {
// Required empty public constructor
}
public static ViewerVcsRevListFragment newInstance(String documentId) {
ViewerVcsRevListFragment fragment = new ViewerVcsRevListFragment();
Bundle args = new Bundle();
args.putString("documentId", documentId);
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_viewer_vcs_rev_list, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// Init arg
if (getArguments() != null) {
this.documentId = getArguments().getString("documentId");
logger.debug("ViewerVcsRevListFragment", "documentId: " + documentId);
}
// Init vcs
lacertaVcs = lacertaVcsFactory.create(documentId);
// Init view
RecyclerView recyclerView = view.findViewById(R.id.rev_list);
// Init adapter
RevAdapter revAdapter = new RevAdapter();
// Set adapter
recyclerView.setAdapter(revAdapter);
// Set layout manager
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
lacertaVcs.getRevisionHistory().thenAccept(revModels -> {
logger.debug("ViewerVcsRevListFragment", "revModels.size(): " + revModels.size());
getActivity().runOnUiThread(() -> {
revAdapter.setRevModels(revModels);
revAdapter.notifyDataSetChanged();
});
});
}
}
@@ -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,12 @@
<?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=".ViewerVcsRevListFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rev_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
@@ -0,0 +1,20 @@
<?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"
android:layout_marginBottom="16dp"
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,55 @@
<?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">
<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_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/rev_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/rev_item_detail"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="2023/01/01 00:00:00 - hogehoge"
android:textColor="@color/colorOnSurfaceSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rev_item_title" />
<TextView
android:id="@+id/rev_item_id"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="12sp"
android:text="dd76a029-51f1-40f7-b316-a0c74bbfebb1(Example)"
android:textColor="@color/colorOnSurfaceSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rev_item_detail" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_open_vcs_rev_list"
android:title="Open VCS Rev List" />
</menu>
@@ -0,0 +1,21 @@
<?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/component_viewer_navigation"
app:startDestination="@id/componentViewerTopFragment">
<fragment
android:id="@+id/componentViewerTopFragment"
android:name="one.nem.lacerta.component.viewer.ComponentViewerTopFragment"
android:label="ComponentViewerTopFragment" >
<action
android:id="@+id/action_componentViewerTopFragment_to_viewerVcsRevListFragment"
app:destination="@id/viewerVcsRevListFragment" />
</fragment>
<fragment
android:id="@+id/viewerVcsRevListFragment"
android:name="one.nem.lacerta.component.viewer.ViewerVcsRevListFragment"
android:label="fragment_viewer_vcs_rev_list"
tools:layout="@layout/fragment_viewer_vcs_rev_list" />
</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> updateDocument(DocumentMeta meta, DocumentDetail detail);
CompletableFuture<Void> updateDocument(DocumentDetail detail);
CompletableFuture<DocumentDetail> getDocument(String documentId);
}
@@ -7,6 +7,7 @@ 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 {
@@ -15,10 +16,14 @@ public interface LacertaLibrary {
CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit);
CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit, int offset);
// Get Library page
CompletableFuture<LibraryItemPage> getLibraryPage(int limit);
CompletableFuture<LibraryItemPage> getLibraryPage(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);
}
@@ -18,6 +18,7 @@ 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;
@@ -78,7 +79,7 @@ public class DocumentImpl implements Document {
documentEntity.defaultBranch = meta.getDefaultBranch();
documentEntity.updatedAt = meta.getUpdatedAt();
documentEntity.createdAt = meta.getCreatedAt();
documentEntity.publicPath = meta.getPath().getStringPath();
documentEntity.parentId = meta.getParentId();
documentEntity.tagIds = meta.getTagIds();
database.documentDao().insert(documentEntity);
@@ -87,6 +88,9 @@ public class DocumentImpl implements Document {
LacertaVcs vcs = vcsFactory.create(meta.getId());
vcs.createDocument(meta.getId());
// XmlMeta
updateXmlMeta(detail).join();
return detail;
});
}
@@ -100,7 +104,7 @@ 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);
}
@@ -113,8 +117,9 @@ public class DocumentImpl implements Document {
}
@Override
public CompletableFuture<Void> updateDocument(DocumentMeta meta, DocumentDetail detail) {
public CompletableFuture<Void> updateDocument(DocumentDetail detail) {
return CompletableFuture.supplyAsync(() -> {
updateXmlMeta(detail).join();
return null;
});
}
@@ -133,15 +138,17 @@ public class DocumentImpl implements Document {
meta.setDefaultBranch(documentEntity.defaultBranch);
meta.setUpdatedAt(documentEntity.updatedAt);
meta.setCreatedAt(documentEntity.createdAt);
meta.setPath(new PublicPath().resolve(documentEntity.publicPath));
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;
});
}
@@ -150,7 +157,13 @@ public class DocumentImpl implements Document {
return CompletableFuture.supplyAsync(() -> {
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
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) {
logger.error(TAG, "DocumentMeta parse error");
logger.trace(TAG, e.getMessage());
@@ -174,7 +187,7 @@ public class DocumentImpl implements Document {
}
for (XmlMetaPageModel xmlMetaPageModel : xmlMetaPageModels) {
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) {
logger.error(TAG, "Bitmap decode error");
logger.trace(TAG, e.getMessage());
@@ -185,4 +198,24 @@ public class DocumentImpl implements Document {
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,9 +1,12 @@
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;
@@ -12,10 +15,13 @@ 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 {
@@ -60,24 +66,61 @@ public class LacertaLibraryImpl implements LacertaLibrary {
return null; // TODO-rca: Implement
}
@Override
public CompletableFuture<LibraryItemPage> getLibraryPage(int limit) {
return CompletableFuture.supplyAsync(() -> {
return null;
});
}
@Override
public CompletableFuture<LibraryItemPage> getLibraryPage(int limit, int offset) {
return CompletableFuture.supplyAsync(() -> {
return null;
});
}
@Override
public CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit) {
return CompletableFuture.supplyAsync(() -> {
return null;
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;
});
}
@@ -87,4 +130,71 @@ public class LacertaLibraryImpl implements LacertaLibrary {
return null;
});
}
@Override
public CompletableFuture<String> createFolder(String parentId, String name) {
return CompletableFuture.supplyAsync(() -> {
FolderEntity folderEntity = new FolderEntity();
folderEntity.id = UUID.randomUUID().toString();
folderEntity.name = name;
folderEntity.parentId = parentId;
database.folderDao().insert(folderEntity);
return folderEntity.id;
});
}
@Override
public CompletableFuture<PublicPath> getPublicPath(String itemId, ListItemType itemType) {
return CompletableFuture.supplyAsync(() -> {
if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
DocumentEntity documentEntity = database.documentDao().findById(itemId);
if (documentEntity == null) {
logger.warn("LacertaLibraryImpl", itemId + " is not found.");
return null;
}
PublicPath publicPath = recursiveResolve(documentEntity.parentId);
publicPath.resolve(documentEntity.title);
return publicPath;
} else if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
FolderEntity folderEntity = database.folderDao().findById(itemId);
if (folderEntity == null) {
return null;
}
return recursiveResolve(folderEntity.id);
} else {
logger.warn("LacertaLibraryImpl", "Unknown ListItemType: " + itemType);
return null;
}
});
}
/**
* 再帰的にパスを解決する
*
* @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 -1
View File
@@ -4,7 +4,7 @@ plugins {
android {
namespace 'one.nem.lacerta.feature.common'
compileSdk 33
compileSdk 34
defaultConfig {
minSdk 26
+3 -1
View File
@@ -5,7 +5,7 @@ plugins {
android {
namespace 'one.nem.lacerta.feature.home'
compileSdk 33
compileSdk 34
defaultConfig {
minSdk 26
@@ -57,4 +57,6 @@ dependencies {
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,5 +1,6 @@
package one.nem.lacerta.feature.home;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
@@ -9,6 +10,7 @@ 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;
@@ -28,6 +30,7 @@ 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;
@@ -68,6 +71,7 @@ public class HomeTopFragment extends Fragment {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
setHasOptionsMenu(true);
return view;
}
@@ -78,7 +82,12 @@ public class HomeTopFragment extends Fragment {
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.setLayoutManager(new LinearLayoutManager(getContext()));
@@ -88,32 +97,12 @@ public class HomeTopFragment extends Fragment {
listItemAdapter.notifyItemRangeInserted(0, listItems.size());
});
});
}
CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
Toolbar toolbar = view.findViewById(R.id.toolbar);
// Set the Toolbar
((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
}
}
});
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.drawer_menu, menu);
super.onCreateOptionsMenu(menu, inflater);
}
}
@@ -1,5 +1,6 @@
package one.nem.lacerta.feature.home;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -11,18 +12,18 @@ 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;
public ListItemAdapter(ArrayList<ListItem> listItems){
this.listItems = listItems;
}
DocumentSelectListener listener;
public ListItemAdapter() {
public ListItemAdapter(DocumentSelectListener listener){
this.listItems = new ArrayList<>();
this.listener = listener;
}
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.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
+3 -1
View File
@@ -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')
}
@@ -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);
}
@@ -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);
}
});
}
}
@@ -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;
}
});
});
}
}
@@ -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>
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
android {
namespace 'one.nem.lacerta.feature.scan'
compileSdk 33
compileSdk 34
defaultConfig {
minSdk 26
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
android {
namespace 'one.nem.lacerta.feature.search'
compileSdk 33
compileSdk 34
defaultConfig {
minSdk 26
@@ -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;
@@ -0,0 +1,80 @@
package one.nem.lacerta.model;
import java.util.ArrayList;
import java.util.Date;
public class VcsRevModel {
String id;
String documentId;
String branchName;
String commitMessage;
Date createdAt;
ArrayList<String> logIds;
public VcsRevModel(String id, String documentId, String branchName, String commitMessage, Date createdAt, ArrayList<String> logIds) {
this.id = id;
this.documentId = documentId;
this.branchName = branchName;
this.commitMessage = commitMessage;
this.createdAt = createdAt;
this.logIds = logIds;
}
// Empty constructor
public VcsRevModel() {
}
public String getId() {
return id;
}
public String getDocumentId() {
return documentId;
}
public String getBranchName() {
return branchName;
}
public String getCommitMessage() {
return commitMessage;
}
public Date getCreatedAt() {
return createdAt;
}
public ArrayList<String> getLogIds() {
return logIds;
}
public void setId(String id) {
this.id = id;
}
public void setDocumentId(String documentId) {
this.documentId = documentId;
}
public void setBranchName(String branchName) {
this.branchName = branchName;
}
public void setCommitMessage(String commitMessage) {
this.commitMessage = commitMessage;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public void setLogIds(ArrayList<String> logIds) {
this.logIds = logIds;
}
}
@@ -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
@@ -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);
@@ -4,6 +4,9 @@ import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import java.util.ArrayList;
import java.util.List;
import one.nem.lacerta.source.database.entity.FolderEntity;
@Dao
@@ -12,8 +15,11 @@ public interface FolderDao {
@Query("SELECT * FROM Folder WHERE id = :id")
FolderEntity findById(String id);
@Query("SELECT * FROM Folder WHERE public_path = :publicPath")
FolderEntity findByPublicPath(String publicPath);
@Query("SELECT * FROM Folder WHERE parent_id = :parentId")
List<FolderEntity> findByParentId(String parentId);
@Query("SELECT * FROM Folder WHERE parent_id IS NULL")
List<FolderEntity> findRootFolders();
@Insert
void insert(FolderEntity folderEntity);
@@ -40,6 +40,6 @@ public class DocumentEntity {
@ColumnInfo(name = "tag_ids")
public List<String> tagIds; // タグ
@ColumnInfo(name = "public_path")
public String publicPath; // 公開パス
@ColumnInfo(name = "parent_id")
public String parentId; // 親フォルダID
}
@@ -16,7 +16,7 @@ public class FolderEntity {
@ColumnInfo(name = "title")
public String name; // フォルダ名
@ColumnInfo(name = "public_path")
public String publicPath; // 公開パス
@ColumnInfo(name = "parent_id")
public String parentId; // 親フォルダID
}
@@ -37,7 +37,11 @@ public class FileManagerImpl implements FileManager {
@AssistedInject
public FileManagerImpl(LacertaLogger logger, @Assisted Path rootDir) {
this.logger = logger;
if (rootDir == null) {
throw new IllegalArgumentException("rootDir must not be null");
}
this.rootDir = rootDir;
this.path = rootDir;
}
// for generate new instance
@@ -62,6 +66,10 @@ public class FileManagerImpl implements FileManager {
try {
resolvedPath = resolvedPath.resolve(pathPart);
} 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);
}
}
@@ -0,0 +1,23 @@
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 = false;
public static boolean enableDebugMenu = false;
}
public static class Vcs {
public static boolean disableBranchDisplay = 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
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();
}
@@ -31,7 +33,9 @@ public class DeviceInfoUtilsImpl implements DeviceInfoUtils {
@Override
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();
}
@@ -4,13 +4,17 @@ package one.nem.lacerta.utils.impl;
import android.content.Context;
import android.content.SharedPreferences;
import javax.inject.Inject;
import dagger.hilt.android.qualifiers.ApplicationContext;
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
import one.nem.lacerta.utils.repository.SharedPrefUtils;
public class SharedPrefUtilsImpl implements SharedPrefUtils{
private final Context applicationContext;
@Inject
public SharedPrefUtilsImpl(@ApplicationContext Context applicationContext) {
this.applicationContext = applicationContext;
}
@@ -26,4 +30,34 @@ public class SharedPrefUtilsImpl implements SharedPrefUtils{
// Editorの取得
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{
String TAG = getClass().getSimpleName();
@Inject
LacertaLogger logger;
@@ -35,13 +37,18 @@ public class XmlMetaParserImpl implements XmlMetaParser{
meta.setRevisionId(rootElement.getElementsByTagName("revisionId").item(0).getTextContent());
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);
XmlMetaPageModel page = new XmlMetaPageModel();
page.setFilename(pageElement.getElementsByTagName("filename").item(0).getTextContent());
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);
return meta;
@@ -2,6 +2,8 @@ package one.nem.lacerta.utils.repository;
import android.content.SharedPreferences;
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
public interface SharedPrefUtils {
// Shared preferences editorの取得
@@ -10,4 +12,15 @@ public interface SharedPrefUtils {
// TODO-rca: 名称をenumで管理する?
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);
}
@@ -1,5 +1,10 @@
package one.nem.lacerta.vcs;
import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
import one.nem.lacerta.model.VcsRevModel;
public interface LacertaVcs {
// Actions
@@ -13,6 +18,8 @@ public interface LacertaVcs {
public void generateRevisionAtCurrent(String message);
public CompletableFuture<ArrayList<VcsRevModel>> getRevisionHistory();
// debug
public void printLog();
@@ -3,11 +3,13 @@ package one.nem.lacerta.vcs.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import javax.inject.Inject;
import dagger.assisted.Assisted;
import dagger.assisted.AssistedInject;
import one.nem.lacerta.model.VcsRevModel;
import one.nem.lacerta.source.database.LacertaDatabase;
import one.nem.lacerta.source.database.entity.VcsLogEntity;
import one.nem.lacerta.source.database.entity.VcsRevEntity;
@@ -122,6 +124,27 @@ public class LacertaVcsImpl implements LacertaVcs {
logger.debug(TAG, "New revision inserted: " + vcsRevEntity.id);
}
@Override
public CompletableFuture<ArrayList<VcsRevModel>> getRevisionHistory() {
return CompletableFuture.supplyAsync(() -> {
logger.debug(TAG, "getRevisionHistoryByDocumentId");
ArrayList<VcsRevModel> vcsRevModels = new ArrayList<>();
List<VcsRevEntity> vcsRevEntities = database.vcsRevDao().findByDocumentId(this.documentId);
vcsRevEntities.forEach(vcsRevEntity -> {
VcsRevModel vcsRevModel = new VcsRevModel();
vcsRevModel.setId(vcsRevEntity.id);
vcsRevModel.setDocumentId(vcsRevEntity.documentId);
vcsRevModel.setBranchName(vcsRevEntity.branchName);
vcsRevModel.setCommitMessage(vcsRevEntity.commitMessage);
vcsRevModel.setLogIds(vcsRevEntity.logIds);
vcsRevModels.add(vcsRevModel);
});
return vcsRevModels;
});
}
@Override
public void printLog() {
logger.debug(TAG, "printLog");