mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2026-11-07 19:47:36 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aeb56b9ef5 |
No files matched your search
@@ -1,17 +0,0 @@
|
||||
---
|
||||
name: 不具合用テンプレート
|
||||
about: 不具合用テンプレート
|
||||
title: "[BUG]: "
|
||||
labels: バグ
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
# 概要
|
||||
<!-- Issueの概要 -->
|
||||
|
||||
# 詳細
|
||||
<!-- バグの詳細 -->
|
||||
|
||||
# 影響箇所
|
||||
<!-- 予想される影響箇所(省略可) -->
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
name: 改善用テンプレート
|
||||
about: 改善用テンプレート
|
||||
title: "[IMPROVE]"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
# 概要
|
||||
<!-- Issueの概要 -->
|
||||
|
||||
# 詳細
|
||||
<!-- 改善内容の詳細 -->
|
||||
|
||||
# 影響箇所
|
||||
<!-- 予想される影響箇所(省略可) -->
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: 新機能用テンプレート
|
||||
about: 新規能用テンプレート
|
||||
title: ''
|
||||
labels: 新機能
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
# 概要
|
||||
<!-- Issueの概要 -->
|
||||
|
||||
# 詳細
|
||||
<!-- 機能の詳細 -->
|
||||
|
||||
# 関連Issue
|
||||
<!-- 関連するIssueがあれば -->
|
||||
|
||||
# 影響箇所
|
||||
<!-- 予想される影響箇所(省略可) -->
|
||||
@@ -1,18 +0,0 @@
|
||||
# 概要
|
||||
<!-- PRの概要 -->
|
||||
|
||||
# 関連Issue
|
||||
- #000 <!-- 関連するIssueを指定(なければ省略可) -->
|
||||
|
||||
# 詳細
|
||||
<!-- 詳細 -->
|
||||
|
||||
# 影響箇所
|
||||
<!-- 予想される影響箇所 -->
|
||||
|
||||
# チェック
|
||||
<!-- 参考用, 全てにチェックがついている必要があるわけではありません -->
|
||||
- [ ] 機能として完成している
|
||||
- [ ] WIP(Work in progress: 作業中)
|
||||
- [ ] 正常にビルド/起動ができる
|
||||
- [ ] 既存の機能を壊していない
|
||||
Generated
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<value>
|
||||
<entry key="app">
|
||||
<State />
|
||||
</entry>
|
||||
</value>
|
||||
</component>
|
||||
</project>
|
||||
Generated
-8
@@ -4,14 +4,6 @@
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2024-01-20T07:15:21.179573376Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="LocalEmulator" identifier="path=/home/rca/.android/avd/Pixel_3a_API_34_extension_level_7_x86_64.avd" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
</selectionStates>
|
||||
</component>
|
||||
|
||||
Generated
+1
-8
@@ -4,6 +4,7 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="jbr-17" />
|
||||
<option name="modules">
|
||||
@@ -22,14 +23,6 @@
|
||||
<option value="$PROJECT_DIR$/feature/library" />
|
||||
<option value="$PROJECT_DIR$/feature/scan" />
|
||||
<option value="$PROJECT_DIR$/feature/search" />
|
||||
<option value="$PROJECT_DIR$/feature/setting" />
|
||||
<option value="$PROJECT_DIR$/model" />
|
||||
<option value="$PROJECT_DIR$/processor" />
|
||||
<option value="$PROJECT_DIR$/shared" />
|
||||
<option value="$PROJECT_DIR$/shared/ui" />
|
||||
<option value="$PROJECT_DIR$/source" />
|
||||
<option value="$PROJECT_DIR$/utils" />
|
||||
<option value="$PROJECT_DIR$/vcs" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveExternalAnnotations" value="false" />
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# 概要
|
||||
<!-- PRの概要 -->
|
||||
|
||||
# 関連Issue
|
||||
- #000 <!-- 関連するIssueを指定(なければ省略可) -->
|
||||
|
||||
# 詳細
|
||||
<!-- 詳細 -->
|
||||
|
||||
# 影響箇所
|
||||
<!-- 予想される影響箇所 -->
|
||||
|
||||
# チェック
|
||||
<!-- 参考用, 全てにチェックがついている必要があるわけではありません -->
|
||||
- [ ] 機能として完成している
|
||||
- [ ] WIP(Work in progress: 作業中)
|
||||
- [ ] 正常にビルド/起動ができる
|
||||
- [ ] 既存の機能を壊していない
|
||||
@@ -1,49 +1,7 @@
|
||||
# Lacerta
|
||||
WIP
|
||||
## モジュール設計
|
||||
|
||||

|
||||
|
||||
## メモ
|
||||
- アイコン: Google Material Icons https://fonts.google.com/icons (Weight:300, Grade:0, Optical size: 24px)
|
||||
|
||||
## モジュール構成
|
||||
### モジュール一覧
|
||||
- `component` : コンポーネント
|
||||
- `common` : 共通コンポーネント
|
||||
- UIの中で共通で使う要素(メニューアイテムとか)
|
||||
- `scanner` : スキャナー
|
||||
- スキャナーの実装
|
||||
- `viewer` : ビューワー
|
||||
- ドキュメントビューワーの実装
|
||||
- `data` : データ
|
||||
- UIからデータを取得/保存するためのラッパーモジュール
|
||||
- `Document` : ドキュメント関係
|
||||
- WIP(JavaDocを参照してください, 余裕があったら追記します)
|
||||
- `feature` : 機能モジュール(ナビゲーションからみた機能で分割)
|
||||
- `common`: 共通機能
|
||||
- 設定画面とか、どこからでも呼ばれうる画面
|
||||
- `debug`: デバッグメニュー
|
||||
- `home`: ホーム画面
|
||||
- `library`: ライブラリ画面
|
||||
- `scan`: スキャン画面
|
||||
- `search`: 検索画面
|
||||
- `model` : モデル
|
||||
- データモデルをまとめたモジュール (WIP)
|
||||
- `document` : ドキュメント
|
||||
- `meta` : メタデータ
|
||||
- `processor` : プロセッサ
|
||||
- いくつかの処理をまとめたモジュール
|
||||
- `DocumentProcessor` : ドキュメント処理(ドキュメントにページを追加したり更新したり)
|
||||
- `shared` :
|
||||
- 共有リソース
|
||||
- `source` : ソース
|
||||
- (バックエンドが使うのでとりあえず後回し、フロントから直接操作することは絶対にありません)
|
||||
- `utils` : ユーティリティ
|
||||
- ちょっとしたユーティリティをまとめたモジュール
|
||||
- `LacertaLogger` : ロガー
|
||||
- `XmlMetaParser` : XMLメタデータパーサー(フロントから直接操作することは絶対にありません)
|
||||
|
||||

|
||||
|
||||
## コーディング規則/推奨(WIP)
|
||||
### 規則
|
||||
|
||||
+22
-37
@@ -11,35 +11,13 @@ android {
|
||||
applicationId "one.nem.lacerta"
|
||||
minSdk 26
|
||||
targetSdk 33
|
||||
|
||||
// ベータ, Internal, Release問わず毎回インクリメントする
|
||||
// https://developer.android.com/studio/publish/versioning#versioningsettings
|
||||
versionCode 1
|
||||
versionName "0.1.0"
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug { // 開発メンバー用
|
||||
debuggable true
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
|
||||
matchingFallbacks = ['release']
|
||||
}
|
||||
internal_release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
|
||||
matchingFallbacks = ['release']
|
||||
}
|
||||
beta_release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
|
||||
matchingFallbacks = ['release']
|
||||
}
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
@@ -59,6 +37,27 @@ dependencies {
|
||||
androidTestImplementation libs.androidx.test.ext.junit
|
||||
androidTestImplementation libs.androidx.test.espresso.core
|
||||
|
||||
// 内部モジュール
|
||||
// Feature
|
||||
implementation project(':feature:home')
|
||||
implementation project(':feature:search')
|
||||
implementation project(':feature:library')
|
||||
implementation project(':feature:scan')
|
||||
implementation project(':feature:debug') // デバッグメニュー
|
||||
|
||||
// // Component
|
||||
// implementation project(':component:common')
|
||||
// implementation project(':component:scanner')
|
||||
// implementation project(':component:viewer')
|
||||
|
||||
// // Data
|
||||
// implementation project(':data:repository')
|
||||
//
|
||||
// // Source
|
||||
// implementation project(':data:source:database')
|
||||
// implementation project(':data:source:preference')
|
||||
//
|
||||
implementation project(':data')
|
||||
// Hilt (DI)
|
||||
implementation libs.com.google.dagger.hilt.android
|
||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||
@@ -68,18 +67,4 @@ dependencies {
|
||||
implementation libs.navigation.ui
|
||||
implementation libs.navigation.dynamic.features.fragment
|
||||
|
||||
// Feature
|
||||
implementation project(':feature:home')
|
||||
implementation project(':feature:search')
|
||||
implementation project(':feature:library')
|
||||
implementation project(':feature:scan')
|
||||
implementation project(':feature:debug') // デバッグメニュー
|
||||
implementation project(':feature:setting') // 設定画面
|
||||
|
||||
implementation project(':data')
|
||||
implementation project(':shared:ui')
|
||||
|
||||
implementation project(':model')
|
||||
|
||||
implementation project(':utils')
|
||||
}
|
||||
@@ -2,17 +2,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="false" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.media.action.IMAGE_CAPTURE" />
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
@@ -33,16 +22,6 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="one.nem.lacerta.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,7 +1,6 @@
|
||||
package one.nem.lacerta;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.material.color.DynamicColors;
|
||||
|
||||
@@ -12,14 +11,6 @@ public class LacertaApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
if (DynamicColors.isDynamicColorAvailable()) {
|
||||
Log.d("DynamicColors", "DynamicColors is available. Applying to activities...");
|
||||
DynamicColors.applyToActivitiesIfAvailable(this);
|
||||
} else {
|
||||
Log.d("DynamicColors", "DynamicColors is not available.");
|
||||
}
|
||||
|
||||
DynamicColors.applyToActivitiesIfAvailable(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +1,40 @@
|
||||
package one.nem.lacerta;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
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.pref.FeatureSwitchOverride;
|
||||
import one.nem.lacerta.utils.FeatureSwitch;
|
||||
|
||||
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 {
|
||||
|
||||
@Inject
|
||||
SharedPrefUtils sharedPrefUtils;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// Debug
|
||||
FragmentManager supportFragmentManager = getSupportFragmentManager();
|
||||
|
||||
NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment);
|
||||
NavController navController = navHostFragment.getNavController();
|
||||
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
|
||||
|
||||
// Initialize app
|
||||
if (sharedPrefUtils.getIsFirstLaunch()) initializeApp();
|
||||
NavigationUI.setupWithNavController(bottomNavigationView, navController);
|
||||
|
||||
// Init navigation
|
||||
try {
|
||||
FragmentManager supportFragmentManager = getSupportFragmentManager();
|
||||
NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment);
|
||||
assert navHostFragment != null;
|
||||
NavController navController = navHostFragment.getNavController();
|
||||
NavigationUI.setupWithNavController(bottomNavigationView, navController);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e("Init", "Failed to init navigation");
|
||||
Log.e("Init", "Searchable Error code: " + "894b5941-3bc0-46fe-b752-0dbc88be29a8");
|
||||
Toast.makeText(this, "Failed to init navigation", Toast.LENGTH_LONG).show();
|
||||
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));
|
||||
Toast.makeText(this, "testMessage", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:theme="@style/Theme.Lacerta"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
@@ -18,19 +17,15 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/main_nav"
|
||||
tools:layout="@layout/fragment_home_top" />
|
||||
tools:layout="@layout/fragment_debug_menu" />
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_nav"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorSecondaryContainer"
|
||||
app:itemIconTint="@color/colorOnSecondaryContainer"
|
||||
app:itemTextColor="@color/colorOnSecondaryContainer"
|
||||
app:itemActiveIndicatorStyle="@style/Lacerta.Custom.Indicator"
|
||||
app:labelVisibilityMode="selected"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:menu="@menu/bottom_nav_menu"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,29 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@id/feature_home_navigation"
|
||||
android:icon="@drawable/home_24px"
|
||||
android:title="@string/home_title"/>
|
||||
|
||||
<item
|
||||
android:id="@id/feature_search_navigation"
|
||||
android:icon="@drawable/search_24px"
|
||||
android:title="@string/search_title"/>
|
||||
|
||||
<item
|
||||
android:id="@id/feature_library_navigation"
|
||||
android:icon="@drawable/folder_24px"
|
||||
android:title="@string/library_title"/>
|
||||
|
||||
<item
|
||||
android:id="@id/feature_debug_navigation"
|
||||
android:icon="@drawable/developer_mode_24px"
|
||||
android:title="@string/debug_menu_title" />
|
||||
android:title="DebugMenu"/>
|
||||
|
||||
<item
|
||||
android:id="@id/feature_setting_navigation"
|
||||
android:icon="@drawable/settings_24px"
|
||||
android:title="@string/setting_title"/>
|
||||
|
||||
</menu>
|
||||
@@ -2,17 +2,9 @@
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/app_main_nav"
|
||||
app:startDestination="@id/feature_home_navigation">
|
||||
app:startDestination="@id/feature_debug_navigation">
|
||||
|
||||
<include app:graph="@navigation/feature_debug_navigation" />
|
||||
|
||||
<include app:graph="@navigation/feature_library_navigation" />
|
||||
|
||||
<include app:graph="@navigation/feature_home_navigation" />
|
||||
|
||||
<include app:graph="@navigation/feature_search_navigation" />
|
||||
|
||||
<include app:graph="@navigation/feature_setting_navigation" />
|
||||
|
||||
|
||||
</navigation>
|
||||
@@ -0,0 +1,7 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.Lacerta" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- UI -->
|
||||
<color name="ui_bg">@android:color/system_neutral1_50</color>
|
||||
<color name="ui_fg">@android:color/system_neutral1_900</color>
|
||||
<color name="ui_fg_disabled">@android:color/system_neutral1_400</color>
|
||||
<color name="ui_fg_secondary">@android:color/system_neutral2_600</color> <!-- A12 B2: 700 -->
|
||||
<color name="ui_accent">@color/accent_dark</color>
|
||||
<color name="ui_accent_inverse">@color/accent_light</color>
|
||||
<color name="ui_accent_variant">@color/accent_variant_dark</color>
|
||||
<color name="ui_surface">@android:color/system_accent1_50</color>
|
||||
<color name="ui_primary_surface">@android:color/system_accent1_100</color>
|
||||
<color name="changelog_bg">@android:color/system_neutral2_50</color>
|
||||
<color name="changelog_border">@android:color/system_neutral1_400</color>
|
||||
<color name="error">#DA000E</color>
|
||||
<color name="success">#008753</color>
|
||||
|
||||
<!-- Launcher icon -->
|
||||
<color name="launcher_fg">@android:color/system_neutral2_700</color>
|
||||
<color name="launcher_bg">@android:color/background_light</color>
|
||||
|
||||
<color name="accent_light">@android:color/system_accent1_300</color>
|
||||
<color name="accent_dark">@android:color/system_accent1_600</color>
|
||||
<color name="accent_variant_light">@android:color/system_accent3_100</color>
|
||||
<color name="accent_variant_dark">@android:color/system_accent3_600</color>
|
||||
|
||||
<!-- Material3 colors -->
|
||||
<color name="colorPrimaryLight">@color/material_dynamic_primary40</color>
|
||||
<color name="colorPrimaryDark">@color/material_dynamic_primary80</color>
|
||||
<color name="colorPrimaryContainerLight">@color/material_dynamic_primary90</color>
|
||||
<color name="colorPrimaryContainerDark">@color/material_dynamic_primary30</color>
|
||||
<color name="colorOnPrimaryContainerLight">@color/material_dynamic_primary10</color>
|
||||
<color name="colorOnPrimaryContainerDark">@color/material_dynamic_primary90</color>
|
||||
<color name="colorSecondaryContainerLight">@color/material_dynamic_secondary90</color>
|
||||
<color name="colorSecondaryContainerDark">@color/material_dynamic_secondary90</color>
|
||||
<color name="colorOnSecondaryContainerLight">@color/material_dynamic_secondary10</color>
|
||||
<color name="colorOnSecondaryContainerDark">@color/material_dynamic_secondary10</color>
|
||||
<color name="colorTertiaryLight">@color/material_dynamic_tertiary40</color>
|
||||
<color name="colorTertiaryDark">@color/material_dynamic_tertiary80</color>
|
||||
<color name="colorOnTertiaryLight">@color/material_dynamic_primary100</color>
|
||||
<color name="colorOnTertiaryDark">@color/material_dynamic_tertiary20</color>
|
||||
<color name="colorTertiaryContainerLight">@color/material_dynamic_tertiary90</color>
|
||||
<color name="colorTertiaryContainerDark">@color/material_dynamic_tertiary30</color>
|
||||
<color name="colorOnTertiaryContainerLight">@color/material_dynamic_tertiary10</color>
|
||||
<color name="colorOnTertiaryContainerDark">@color/material_dynamic_tertiary90</color>
|
||||
<color name="colorSurfaceLight">@color/material_dynamic_neutral99</color>
|
||||
<color name="colorSurfaceDark">@color/material_dynamic_neutral10</color>
|
||||
<color name="colorOnSurfaceLight">@color/material_dynamic_neutral10</color>
|
||||
<color name="colorOnSurfaceDark">@color/material_dynamic_neutral90</color>
|
||||
<color name="colorSurfaceVariantLight">@color/material_dynamic_neutral_variant90</color>
|
||||
<color name="colorSurfaceVariantDark">@color/material_dynamic_neutral_variant30</color>
|
||||
<color name="colorOnSurfaceVariantLight">@color/material_dynamic_neutral_variant30</color>
|
||||
<color name="colorOnSurfaceVariantDark">@color/material_dynamic_neutral_variant80</color>
|
||||
<color name="colorOutlineLight">@color/material_dynamic_neutral_variant50</color>
|
||||
<color name="colorOutlineDark">@color/material_dynamic_neutral_variant60</color>
|
||||
<color name="colorErrorContainerLight">#FFF9DEDC</color>
|
||||
<color name="colorErrorContainerDark">#FF8C1D18</color>
|
||||
<color name="colorOnErrorContainerLight">#FF410E0B</color>
|
||||
<color name="colorOnErrorContainerDark">#FFF9DEDC</color>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,9 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.Lacerta" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Lacerta" parent="Base.Theme.Lacerta" />
|
||||
</resources>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths>
|
||||
<cache-path name="cache" path="." />
|
||||
</paths>
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.component.common'
|
||||
compileSdk 34
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
@@ -32,6 +32,4 @@ dependencies {
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.androidx.test.ext.junit
|
||||
androidTestImplementation libs.androidx.test.espresso.core
|
||||
|
||||
implementation project(':shared:ui')
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
plugins {
|
||||
alias(libs.plugins.com.android.library)
|
||||
id 'com.google.dagger.hilt.android'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.component.scanner'
|
||||
compileSdk 34
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
@@ -30,26 +29,9 @@ 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
|
||||
|
||||
// Hilt (DI)
|
||||
implementation libs.com.google.dagger.hilt.android
|
||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||
|
||||
implementation 'com.websitebeaver:documentscanner:1.0.0'
|
||||
|
||||
implementation project(':shared:ui')
|
||||
implementation project(':model')
|
||||
|
||||
implementation project(':processor')
|
||||
|
||||
implementation project(':utils')
|
||||
|
||||
implementation project(':vcs')
|
||||
|
||||
implementation project(':data')
|
||||
}
|
||||
@@ -1,10 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".ScannerManagerActivity"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CaptureResultAdapter extends RecyclerView.Adapter<CaptureResultAdapter.ViewHolder> {
|
||||
private final ArrayList<CapturedData> results;
|
||||
|
||||
public CaptureResultAdapter(ArrayList<CapturedData> results) {
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaptureResultAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_scanner_component_manager_stub, parent, false);
|
||||
return new CaptureResultAdapter.ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(CaptureResultAdapter.ViewHolder holder, int position) {
|
||||
CapturedData result = results.get(position);
|
||||
holder.textViewPath.setText(result.getPath());
|
||||
holder.textViewResolutionHeight.setText(result.getResolutionHeight());
|
||||
holder.textViewResolutionWidth.setText(result.getResolutionWidth());
|
||||
holder.imageView.setImageBitmap(result.getBitmap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return results.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public TextView textViewPath;
|
||||
public TextView textViewResolutionHeight;
|
||||
public TextView textViewResolutionWidth;
|
||||
public ImageView imageView;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
textViewPath = view.findViewById(R.id.textViewPath);
|
||||
textViewResolutionHeight = view.findViewById(R.id.textViewResHeight);
|
||||
textViewResolutionWidth = view.findViewById(R.id.textViewResWidth);
|
||||
imageView = view.findViewById(R.id.imageViewResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
public class CapturedData {
|
||||
|
||||
private String path;
|
||||
private String resolutionHeight;
|
||||
private String resolutionWidth;
|
||||
private String size;
|
||||
private Bitmap bitmap;
|
||||
|
||||
// Constructor
|
||||
|
||||
public CapturedData(String path, String resolutionHeight, String resolutionWidth, String size, Bitmap bitmap) {
|
||||
this.path = path;
|
||||
this.resolutionHeight = resolutionHeight;
|
||||
this.resolutionWidth = resolutionWidth;
|
||||
this.size = size;
|
||||
this.bitmap = bitmap;
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public String getResolutionHeight() {
|
||||
return resolutionHeight;
|
||||
}
|
||||
|
||||
public String getResolutionWidth() {
|
||||
return resolutionWidth;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public Bitmap getBitmap() {
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
-251
@@ -1,251 +0,0 @@
|
||||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
import one.nem.lacerta.model.document.DocumentMeta;
|
||||
import one.nem.lacerta.model.document.path.DocumentPath;
|
||||
import one.nem.lacerta.processor.DocumentProcessor;
|
||||
import one.nem.lacerta.processor.factory.DocumentProcessorFactory;
|
||||
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link ScannerDataManagerStubFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
public class ScannerDataManagerStubFragment extends Fragment {
|
||||
|
||||
// TODO-rca: 時間があったらcacheを使うようにする?
|
||||
|
||||
// Results
|
||||
private ArrayList<CapturedData> results = new ArrayList<>();
|
||||
|
||||
private Uri photoURI;
|
||||
|
||||
private DocumentDetail documentDetail;
|
||||
|
||||
private DocumentProcessor documentProcessor;
|
||||
|
||||
@Inject
|
||||
DocumentProcessorFactory documentProcessorFactory;
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
@Inject
|
||||
DeviceInfoUtils deviceInfoUtils;
|
||||
|
||||
private final ActivityResultLauncher<Intent> cameraLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() == Activity.RESULT_OK) {
|
||||
try {
|
||||
if (getActivity() == null) {
|
||||
Log.d("ScannerDataManagerStubFragment", "getActivity() is null");
|
||||
return;
|
||||
}
|
||||
if (photoURI == null) {
|
||||
Log.d("ScannerDataManagerStubFragment", "photoURI is null");
|
||||
Toast.makeText(getActivity(), "photoURI is null", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
Bitmap imageBitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), photoURI);
|
||||
results.add(new CapturedData("Placeholder", Integer.toString(imageBitmap.getHeight()), Integer.toString(imageBitmap.getWidth()), "Placeholder", imageBitmap));
|
||||
} catch (IOException e) {
|
||||
Log.e("ScannerDataManagerStubFragment", "Error occurred while reading the file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public ScannerDataManagerStubFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static ScannerDataManagerStubFragment newInstance() {
|
||||
ScannerDataManagerStubFragment fragment = new ScannerDataManagerStubFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_scanner_data_manager_stub, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
// view.findViewById(R.id.button_call_camera).setOnClickListener(v -> {
|
||||
// Log.d("ScannerDataManagerStubFragment", "button_call_camera clicked");
|
||||
// Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
// if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
|
||||
// File photoFile = null;
|
||||
// try {
|
||||
// String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date());
|
||||
// String imageFileName = "JPEG_" + timeStamp + "_";
|
||||
// File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||
// photoFile = File.createTempFile(imageFileName, ".jpg", storageDir);
|
||||
// } catch (IOException ex) {
|
||||
// Log.e("ScannerDataManagerStubFragment", "Error occurred while creating the file", ex);
|
||||
// }
|
||||
// if (photoFile != null) {
|
||||
// photoURI = FileProvider.getUriForFile(getActivity(), "one.nem.lacerta.provider", photoFile);
|
||||
// takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||
// cameraLauncher.launch(takePictureIntent);
|
||||
// }
|
||||
// else {
|
||||
// Log.d("ScannerDataManagerStubFragment", "photoFile is null");
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// Log.d("ScannerDataManagerStubFragment", "camera not available");
|
||||
// }
|
||||
// updateResults();
|
||||
// });
|
||||
//
|
||||
// view.findViewById(R.id.button_create_documnent).setOnClickListener(v -> {
|
||||
// Log.d("ScannerDataManagerStubFragment", "button_create_documnent clicked");
|
||||
// Toast.makeText(getActivity(), "button_create_documnent clicked", Toast.LENGTH_LONG).show();
|
||||
//
|
||||
// this.documentDetail = createSampleDocumentDetail();
|
||||
//
|
||||
// });
|
||||
//
|
||||
// view.findViewById(R.id.button_init_document_processor).setOnClickListener(v -> {
|
||||
// Log.d("ScannerDataManagerStubFragment", "button_init_document_processor clicked");
|
||||
// Toast.makeText(getActivity(), "button_init_document_processor clicked", Toast.LENGTH_LONG).show();
|
||||
// // TODO-rca: ここでDocumentProcessorを初期化する
|
||||
// if (this.documentDetail == null) {
|
||||
// Toast.makeText(getActivity(), "documentDetail is null", Toast.LENGTH_LONG).show();
|
||||
// return;
|
||||
// }
|
||||
// this.documentProcessor = documentProcessorFactory.create(this.documentDetail);
|
||||
// Toast.makeText(getActivity(), "documentProcessor created", Toast.LENGTH_LONG).show();
|
||||
// try {
|
||||
// this.documentProcessor.init();
|
||||
// } catch (Exception e) {
|
||||
// Toast.makeText(getActivity(), "Error occurred while initializing documentProcessor", Toast.LENGTH_LONG).show();
|
||||
// Log.e("ScannerDataManagerStubFragment", "Error occurred while initializing documentProcessor", e);
|
||||
// }
|
||||
// Toast.makeText(getActivity(), "documentProcessor initialized", Toast.LENGTH_LONG).show();
|
||||
// });
|
||||
//
|
||||
// view.findViewById(R.id.button_add_page).setOnClickListener(v -> {
|
||||
// Log.d("ScannerDataManagerStubFragment", "button_add_page clicked");
|
||||
// Toast.makeText(getActivity(), "button_add_page clicked", Toast.LENGTH_LONG).show();
|
||||
// if (this.documentProcessor == null) {
|
||||
// Toast.makeText(getActivity(), "documentProcessor is null", Toast.LENGTH_LONG).show();
|
||||
// return;
|
||||
// }
|
||||
// Bitmap[] bitmaps = new Bitmap[results.size()];
|
||||
// for (int i = 0; i < results.size(); i++) {
|
||||
// bitmaps[i] = results.get(i).getBitmap();
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// this.documentProcessor.addNewPagesToLast(bitmaps);
|
||||
// } catch (Exception e) {
|
||||
// Toast.makeText(getActivity(), "Error occurred while adding pages", Toast.LENGTH_LONG).show();
|
||||
// Log.e("ScannerDataManagerStubFragment", "Error occurred while adding pages", e);
|
||||
// }
|
||||
//
|
||||
// Toast.makeText(getActivity(), "pages added", Toast.LENGTH_LONG).show();
|
||||
//
|
||||
// try {
|
||||
// this.documentProcessor.close();
|
||||
// } catch (Exception e) {
|
||||
// Toast.makeText(getActivity(), "Error occurred while closing documentProcessor", Toast.LENGTH_LONG).show();
|
||||
// Log.e("ScannerDataManagerStubFragment", "Error occurred while closing documentProcessor", e);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
public DocumentDetail createSampleDocumentDetail() {
|
||||
//
|
||||
// String id = UUID.randomUUID().toString();
|
||||
//
|
||||
// Toast.makeText(getActivity(), "Generated id: " + id, Toast.LENGTH_LONG).show();
|
||||
// //logger.debug("CreateSample", "Generated id: " + id);
|
||||
//
|
||||
// DocumentMeta meta = new DocumentMeta(
|
||||
// id,
|
||||
// "Sample" + DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now()),
|
||||
// new Date(),
|
||||
// new Date());
|
||||
//
|
||||
// DocumentPath path = new DocumentPath(
|
||||
// deviceInfoUtils.getExternalStorageDirectoryString(),
|
||||
// "Sample" + DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now()));
|
||||
//
|
||||
// return new DocumentDetail(meta, path, "SampleAuthor", "SampleDefaultBranch");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Log.d("ScannerDataManagerStubFragment", "onResume");
|
||||
updateResults();
|
||||
}
|
||||
|
||||
public void updateResults() {
|
||||
Log.d("ScannerDataManagerStubFragment", "updateResults");
|
||||
|
||||
// TODO-rca: エラーハンドリング
|
||||
RecyclerView recyclerView = getView().findViewById(R.id.result_recycler_view);
|
||||
|
||||
recyclerView.setLayoutManager(new androidx.recyclerview.widget.LinearLayoutManager(getContext()));
|
||||
recyclerView.setAdapter(new CaptureResultAdapter(this.results));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-220
@@ -1,220 +0,0 @@
|
||||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.annotation.AnimatorRes;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
import com.websitebeaver.documentscanner.DocumentScanner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
import one.nem.lacerta.model.document.DocumentMeta;
|
||||
import one.nem.lacerta.processor.factory.DocumentProcessorFactory;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
import one.nem.lacerta.data.Document;
|
||||
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
||||
|
||||
@AndroidEntryPoint
|
||||
public class ScannerManagerActivity extends AppCompatActivity {
|
||||
|
||||
String TAG = "ScannerManagerActivity";
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
@Inject
|
||||
Document document;
|
||||
|
||||
@Inject
|
||||
DocumentProcessorFactory documentProcessorFactory;
|
||||
|
||||
@Inject
|
||||
LacertaVcsFactory lacertaVcsFactory;
|
||||
|
||||
// Variables
|
||||
private ArrayList<Bitmap> croppedImages = new ArrayList<>();
|
||||
|
||||
View view;
|
||||
|
||||
DocumentScanner documentScanner = new DocumentScanner(
|
||||
this,
|
||||
(croppedImageResults) -> {
|
||||
logger.debug(TAG, "croppedImage size: " + croppedImageResults.size());
|
||||
ArrayList<Bitmap> croppedImages = new ArrayList<>();
|
||||
for (String result : croppedImageResults) {
|
||||
croppedImages.add(BitmapFactory.decodeFile(result));
|
||||
}
|
||||
processResult(croppedImages);
|
||||
return null;
|
||||
},
|
||||
(errorMessage) -> {
|
||||
// an error happened
|
||||
logger.error(TAG, "Error: " + errorMessage);
|
||||
logger.e_code("543a230e-cb9a-47a2-8131-3beecfe1c458");
|
||||
return null;
|
||||
},
|
||||
() -> {
|
||||
// user canceled document scan
|
||||
logger.debug(TAG, "User canceled document scan");
|
||||
return null;
|
||||
},
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_scanner_manager);
|
||||
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;
|
||||
});
|
||||
|
||||
MaterialToolbar toolbar = findViewById(R.id.top_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
documentScanner.startScan();
|
||||
// Init
|
||||
|
||||
this.view = findViewById(R.id.main); // TODO-rca:なんとかする
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(android.view.Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.scanner_result_toolbar, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(android.view.MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_save_new) {
|
||||
// 新ドキュメントとして保存
|
||||
Toast.makeText(this, "保存処理", Toast.LENGTH_SHORT).show();
|
||||
saveNewDocument();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_insert_exist) {
|
||||
// 既存ドキュメントに挿入
|
||||
Toast.makeText(this, "挿入処理", Toast.LENGTH_SHORT).show();
|
||||
insertToExistDocument();
|
||||
return true;
|
||||
} else if (item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void processResult(ArrayList<Bitmap> resultImages) {
|
||||
logger.debug(TAG, "processResult");
|
||||
|
||||
if (resultImages.isEmpty()) {
|
||||
logger.debug(TAG, "resultImages(arg) is empty");
|
||||
if (this.croppedImages.isEmpty()) {
|
||||
logger.debug(TAG, "this.resultImages is empty");
|
||||
logger.e_code("7cb0584e-74ef-48ec-848a-c4d14e75e15a");
|
||||
// TODO-rca: なんかする
|
||||
} else {
|
||||
logger.debug(TAG, "this.resultImages is not empty");
|
||||
updateResultView(this.croppedImages);
|
||||
}
|
||||
} else {
|
||||
logger.debug(TAG, "resultImages(arg) is not empty");
|
||||
updateResultView(resultImages);
|
||||
this.croppedImages = resultImages;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void saveNewDocument() {
|
||||
logger.debug(TAG, "saveNewDocument");
|
||||
// Deprecatedだが、中断機能が存在しないので操作をブロックする目的で(意図的に)使用
|
||||
ProgressDialog dialog = new ProgressDialog(this);
|
||||
dialog.setMessage("保存中..."); // TODO-rca: テキストをリソースに移動
|
||||
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする
|
||||
document.createDocument(documentMeta).thenAccept((documentDetail) -> {
|
||||
Bitmap[] bitmaps = new Bitmap[croppedImages.size()];
|
||||
croppedImages.toArray(bitmaps);
|
||||
logger.debug(TAG, "bitmaps.length: " + bitmaps.length);
|
||||
addPagesToDocumentDetail(documentDetail, bitmaps).join();
|
||||
document.updateDocument(documentDetail).join();
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> addPagesToDocumentDetail(DocumentDetail documentDetail, Bitmap[] bitmaps) {
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
document.updateDocument(documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps).getDocumentDetail()).join();
|
||||
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit");
|
||||
} catch (Exception e) {
|
||||
logger.error(TAG, "Error: " + e.getMessage());
|
||||
logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void insertToExistDocument() {
|
||||
logger.debug(TAG, "insertToExistDocument");
|
||||
// TODO-rca: 実装
|
||||
}
|
||||
|
||||
private void updateResultView(ArrayList<Bitmap> resultImages) {
|
||||
logger.debug(TAG, "updateResultView");
|
||||
|
||||
LinearLayout resultView = findViewById(R.id.result_list_container);
|
||||
ImageView selectedImage = findViewById(R.id.selected_image);
|
||||
resultView.removeAllViews();
|
||||
|
||||
for (Bitmap resultImage : resultImages) {
|
||||
View resultImageView = getLayoutInflater().inflate(R.layout.result_image_container_item, null);
|
||||
ImageView imageView = resultImageView.findViewById(R.id.result_image);
|
||||
imageView.setImageBitmap(resultImage);
|
||||
imageView.setOnClickListener(v -> {
|
||||
|
||||
selectedImage.setImageBitmap(resultImage);
|
||||
|
||||
for (int i = 0; i < resultView.getChildCount(); i++) {
|
||||
View child = resultView.getChildAt(i).findViewById(R.id.result_image);
|
||||
child.setSelected(false);
|
||||
}
|
||||
|
||||
v.setSelected(true);
|
||||
});
|
||||
|
||||
resultView.addView(resultImageView);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.websitebeaver.documentscanner.DocumentScanner;
|
||||
import com.websitebeaver.documentscanner.DocumentScannerActivity;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@AndroidEntryPoint
|
||||
public class ScannerManagerFragment extends Fragment {
|
||||
|
||||
String TAG = getClass().getSimpleName();
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
@Inject
|
||||
LacertaVcsFactory vcsFactory;
|
||||
|
||||
private static final boolean DEFAULT_SINGLE_PAGE = false;
|
||||
private boolean singlePage;
|
||||
|
||||
public ScannerManagerFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
// public static ScannerManagerFragment newInstance(boolean singlePage) {
|
||||
// ScannerManagerFragment fragment = new ScannerManagerFragment();
|
||||
// Bundle args = new Bundle();
|
||||
// args.putBoolean("singlePage", singlePage);
|
||||
// fragment.setArguments(args);
|
||||
// return fragment;
|
||||
// }
|
||||
|
||||
public static ScannerManagerFragment newInstance() {
|
||||
ScannerManagerFragment fragment = new ScannerManagerFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("singlePage", DEFAULT_SINGLE_PAGE);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
singlePage = getArguments().getBoolean("singlePage", DEFAULT_SINGLE_PAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_scanner_manager, container, false);
|
||||
|
||||
// ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
// ViewGroup.LayoutParams.MATCH_PARENT
|
||||
// );
|
||||
// view.setLayoutParams(layoutParams);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
// Init
|
||||
logger.debug(TAG, "called");
|
||||
|
||||
view.findViewById(R.id.button_intent_scanner_manager_activity).setOnClickListener(v -> {
|
||||
// DocumentScannerActivityを起動する
|
||||
Intent intent = new Intent(requireActivity().getApplicationContext(), ScannerManagerActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.constraintlayout.utils.widget.ImageFilterView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.websitebeaver.documentscanner.DocumentScanner;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link ScannerScanFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class ScannerScanFragment extends Fragment {
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
// private static final String MAX_SCAN_COUNT = "max_scan_count"; // 規定値
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
|
||||
|
||||
public ScannerScanFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static ScannerScanFragment newInstance(String param1) {
|
||||
ScannerScanFragment fragment = new ScannerScanFragment();
|
||||
Bundle args = new Bundle();
|
||||
// args.putString(MAX_SCAN_COUNT, param1);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
// mParam1 = getArguments().getString(MAX_SCAN_COUNT);
|
||||
// scan(Integer.parseInt(mParam1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DocumentScanner getDocumentScanner() {
|
||||
return new DocumentScanner(
|
||||
this,
|
||||
(croppedImageResults) -> {
|
||||
// display the first cropped image
|
||||
croppedImageView.setImageBitmap(
|
||||
BitmapFactory.decodeFile(croppedImageResults.get(0))
|
||||
);
|
||||
return null;
|
||||
},
|
||||
(errorMessage) -> {
|
||||
// an error happened
|
||||
return null;
|
||||
},
|
||||
() -> {
|
||||
// user canceled document scan
|
||||
return null;
|
||||
},
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
+8
-11
@@ -1,4 +1,4 @@
|
||||
package one.nem.lacerta.feature.debug;
|
||||
package one.nem.lacerta.component.scanner;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -8,15 +8,12 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link DebugMenuContainerFragment#newInstance} factory method to
|
||||
* Use the {@link ScannerScanResultFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
public class DebugMenuContainerFragment extends Fragment {
|
||||
public class ScannerScanResultFragment extends Fragment {
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -27,7 +24,7 @@ public class DebugMenuContainerFragment extends Fragment {
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public DebugMenuContainerFragment() {
|
||||
public ScannerScanResultFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
@@ -37,11 +34,11 @@ public class DebugMenuContainerFragment extends Fragment {
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment DebugMenuSubContainerFragment.
|
||||
* @return A new instance of fragment ScannerScanResultFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static DebugMenuContainerFragment newInstance(String param1, String param2) {
|
||||
DebugMenuContainerFragment fragment = new DebugMenuContainerFragment();
|
||||
public static ScannerScanResultFragment newInstance(String param1, String param2) {
|
||||
ScannerScanResultFragment fragment = new ScannerScanResultFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
@@ -62,6 +59,6 @@ public class DebugMenuContainerFragment extends Fragment {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_debug_menu_container, container, false);
|
||||
return inflater.inflate(R.layout.fragment_scanner_scan_result, container, false);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#00000000" />
|
||||
<corners android:radius="8dp" />
|
||||
<stroke android:color="#FF0000" android:width="2dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#00000000" />
|
||||
<corners android:radius="8dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -1,55 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/main"
|
||||
android:theme="@style/Theme.Lacerta"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/top_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorPrimaryContainer"
|
||||
app:titleTextColor="@color/colorOnPrimaryContainer"
|
||||
app:title="Preview"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="?attr/actionBarTheme"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/selected_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_above="@+id/horizontal_scroll"
|
||||
android:scaleType="centerInside"
|
||||
app:layout_constraintBottom_toTopOf="@+id/horizontal_scroll"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/top_toolbar" />
|
||||
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/horizontal_scroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:scrollbars="none"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/selected_image">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/result_list_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,93 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:theme="@style/Theme.Lacerta"
|
||||
tools:context=".ScannerDataManagerStubFragment" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/action_button_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:weightSum="2"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_call_camera"
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16px"
|
||||
android:layout_weight="1"
|
||||
android:text="Call camera" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/init_button_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/action_button_container">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_create_documnent"
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16px"
|
||||
android:layout_weight="1"
|
||||
android:text="Create Doc Obj" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_init_document_processor"
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16px"
|
||||
android:layout_weight="1"
|
||||
android:text="Init Processor" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/doc_button_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:weightSum="2"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/init_button_container">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_add_page"
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16px"
|
||||
android:layout_weight="1"
|
||||
android:text="Add page to last" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/result_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/doc_button_container" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ScannerManagerFragment">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_intent_scanner_manager_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".SettingDataPageFragment">
|
||||
tools:context=".ScannerScanFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<androidx.constraintlayout.utils.widget.ImageFilterView
|
||||
android:id="@+id/cropped_image_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toTopOf="@+id/linear_layout_buttons">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_margin="12dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:text="Saturation" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBar_saturation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:max="200"
|
||||
android:progress="100"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_margin="12dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:text="Contrast" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBar_contrast"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:max="200"
|
||||
android:progress="100"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_margin="12dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:text="Brightness" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBar_brightness"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="200"
|
||||
android:progress="100"
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_margin="12dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:text="Warmth" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBar_warmth"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="500"
|
||||
android:progress="100"
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_layout_buttons"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_save_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:insetLeft="12dp"
|
||||
android:insetRight="12dp"
|
||||
android:text="Save Image" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_kill_me"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:insetLeft="12dp"
|
||||
android:insetRight="12dp"
|
||||
android:text="Kill me" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,70 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="24px">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageViewResult"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@android:drawable/presence_video_online"
|
||||
android:adjustViewBounds="true"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageViewResult">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:text="Resolution:"
|
||||
android:textIsSelectable="false"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewResHeight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Height"
|
||||
android:textIsSelectable="false"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewResWidth"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Width"
|
||||
android:textIsSelectable="false"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewPath"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Path"
|
||||
android:textIsSelectable="false"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/result_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="64dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:background="@drawable/result_image_container_item_border"
|
||||
android:padding="8dp"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_save_new"
|
||||
android:icon="@drawable/save_24px"
|
||||
android:title="Save"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/action_insert_exist"
|
||||
android:icon="@drawable/ic_baseline_add_24"
|
||||
android:title="Save"
|
||||
app:showAsAction="ifRoom"/>
|
||||
</menu>
|
||||
@@ -1,11 +1,10 @@
|
||||
plugins {
|
||||
alias(libs.plugins.com.android.library)
|
||||
id 'com.google.dagger.hilt.android'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.component.viewer'
|
||||
compileSdk 34
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
@@ -30,28 +29,7 @@ dependencies {
|
||||
|
||||
implementation libs.androidx.appcompat
|
||||
implementation libs.com.google.android.material
|
||||
implementation libs.androidx.activity
|
||||
implementation libs.androidx.constraintlayout
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.androidx.test.ext.junit
|
||||
androidTestImplementation libs.androidx.test.espresso.core
|
||||
|
||||
// Navigation
|
||||
implementation libs.navigation.fragment
|
||||
implementation libs.navigation.ui
|
||||
implementation libs.navigation.dynamic.features.fragment
|
||||
|
||||
// DI
|
||||
implementation libs.com.google.dagger.hilt.android
|
||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||
|
||||
// shared
|
||||
implementation project(':shared:ui')
|
||||
|
||||
implementation project(':utils')
|
||||
|
||||
implementation project(':data')
|
||||
|
||||
implementation project(':model')
|
||||
|
||||
}
|
||||
@@ -1,10 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".ViewerMainActivity"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
package one.nem.lacerta.component.viewer;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.data.Document;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
import one.nem.lacerta.model.document.page.Page;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link ComponentViewerTopFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
public class ComponentViewerTopFragment extends Fragment {
|
||||
|
||||
@Inject
|
||||
Document document;
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
private static final String TAG = "ComponentViewerTopFragment";
|
||||
|
||||
private String documentId;
|
||||
|
||||
public ComponentViewerTopFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static ComponentViewerTopFragment newInstance(String documentId) {
|
||||
ComponentViewerTopFragment fragment = new ComponentViewerTopFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("documentId", documentId);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
documentId = getArguments().getString("documentId");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_component_viewer_top, container, false);
|
||||
|
||||
RecyclerView recyclerView = view.findViewById(R.id.body_recycler_view);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(fileName -> {
|
||||
Toast.makeText(getContext(), fileName, Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
recyclerView.setAdapter(viewerBodyAdapter);
|
||||
|
||||
document.getDocument(documentId).thenAccept(documentDetail -> {
|
||||
ArrayList<Page> pages = documentDetail.getPages();
|
||||
logger.debug(TAG, "pages.size(): " + pages.size());
|
||||
viewerBodyAdapter.setPages(pages);
|
||||
getActivity().runOnUiThread(() -> {
|
||||
viewerBodyAdapter.notifyItemRangeChanged(0, pages.size());
|
||||
});
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package one.nem.lacerta.component.viewer;
|
||||
|
||||
public interface ItemClickListener {
|
||||
void onItemClick(String fileName); // DEBUG
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
package one.nem.lacerta.component.viewer;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.Image;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import one.nem.lacerta.model.document.page.Page;
|
||||
|
||||
public class ViewerBodyAdapter extends RecyclerView.Adapter<ViewerBodyAdapter.ViewHolder>{
|
||||
|
||||
ArrayList<Page> pages;
|
||||
|
||||
ItemClickListener listener;
|
||||
|
||||
public ViewerBodyAdapter(ArrayList<Page> pages, ItemClickListener listener){
|
||||
this.pages = pages;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public ViewerBodyAdapter(ItemClickListener listener){
|
||||
this.pages = new ArrayList<>();
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setPages(ArrayList<Page> pages){
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewerBodyAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = View.inflate(parent.getContext(), R.layout.viewer_body_list_item, null);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewerBodyAdapter.ViewHolder holder, int position) {
|
||||
Bitmap bitmap = pages.get(position).getBitmap();
|
||||
holder.image.setImageBitmap(bitmap);
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return pages.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
ImageView image;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
image = itemView.findViewById(R.id.imageView);
|
||||
}
|
||||
}
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
package one.nem.lacerta.component.viewer;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
@AndroidEntryPoint
|
||||
public class ViewerMainActivity extends AppCompatActivity {
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
@Inject
|
||||
public ViewerMainActivity() {
|
||||
}
|
||||
|
||||
// Variables
|
||||
private static final String TAG = "ViewerMainActivity";
|
||||
String documentId;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_viewer_main);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
Intent intent = getIntent();
|
||||
try {
|
||||
documentId = intent.getStringExtra("documentId");
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error(TAG, "Failed to get documentId from intent");
|
||||
logger.error(TAG, "Searchable Error code: " + "f64c21a2-391f-4c40-92f6-183da459de21");
|
||||
Toast.makeText(this, "Failed to get documentId from intent", Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.nav_host_fragment, ComponentViewerTopFragment.newInstance(documentId))
|
||||
.commitNow();
|
||||
}
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
package one.nem.lacerta.component.viewer.model;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
public class ViewerBodyListItem {
|
||||
|
||||
Bitmap image;
|
||||
|
||||
public ViewerBodyListItem(Bitmap image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public Bitmap getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(Bitmap image) {
|
||||
this.image = image;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/colorSurface">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
app:contentScrim="@color/colorSecondaryContainer"
|
||||
android:background="@color/colorSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:fitsSystemWindows="true"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:collapsedTitleGravity="start|center_vertical"
|
||||
app:expandedTitleGravity="start|bottom"
|
||||
app:expandedTitleMarginBottom="16dp"
|
||||
app:expandedTitleMarginStart="16dp"
|
||||
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:title="Title" />
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/body_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="16dp"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:elevation="8dp"
|
||||
android:adjustViewBounds="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/component_viewer_navigation"
|
||||
app:startDestination="@id/componentViewerTopFragment">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/componentViewerTopFragment"
|
||||
android:name="one.nem.lacerta.component.viewer.ComponentViewerTopFragment"
|
||||
android:label="ComponentViewerTopFragment" />
|
||||
</navigation>
|
||||
@@ -1,4 +0,0 @@
|
||||
<resources>
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
</resources>
|
||||
+3
-21
@@ -8,7 +8,7 @@ android {
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
minSdk 24
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
@@ -38,24 +38,6 @@ dependencies {
|
||||
implementation libs.com.google.dagger.hilt.android
|
||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||
|
||||
// JGit
|
||||
implementation 'org.eclipse.jgit:org.eclipse.jgit:6.8.0.202311291450-r'
|
||||
|
||||
// Java Faker
|
||||
implementation 'com.github.javafaker:javafaker:1.0.2'
|
||||
|
||||
// Room
|
||||
implementation libs.androidx.room.runtime
|
||||
annotationProcessor libs.androidx.room.compiler
|
||||
|
||||
// Utilsモジュール
|
||||
implementation project(':utils')
|
||||
|
||||
// 型モジュール
|
||||
implementation project(':model')
|
||||
|
||||
// データソースモジュール
|
||||
implementation project(':source')
|
||||
|
||||
implementation project(':vcs')
|
||||
// libsディレクトリにあるライブラリを追加
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,26 +0,0 @@
|
||||
package one.nem.lacerta.data;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import one.nem.lacerta.model.document.DocumentMeta;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
import one.nem.lacerta.model.document.path.DocumentPath;
|
||||
import one.nem.lacerta.model.document.tag.DocumentTag;
|
||||
|
||||
/**
|
||||
* ドキュメントのデータを取得する
|
||||
*/
|
||||
public interface Document {
|
||||
|
||||
CompletableFuture<DocumentDetail> createDocument(DocumentMeta meta);
|
||||
|
||||
CompletableFuture<DocumentDetail> createDocument();
|
||||
|
||||
CompletableFuture<Void> deleteDocument(String documentId);
|
||||
|
||||
CompletableFuture<Void> updateDocument(DocumentDetail detail);
|
||||
|
||||
CompletableFuture<DocumentDetail> getDocument(String documentId);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package one.nem.lacerta.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
import one.nem.lacerta.model.ListItemType;
|
||||
|
||||
import one.nem.lacerta.model.LibraryItemPage;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
|
||||
public interface LacertaLibrary {
|
||||
|
||||
// Get History
|
||||
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);
|
||||
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit);
|
||||
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset);
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package one.nem.lacerta.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
|
||||
public interface LacertaSearch {
|
||||
|
||||
ArrayList<ListItem> autoSearch(String query, int limit);
|
||||
|
||||
ArrayList<ListItem> autoSearch(String query, int limit, int offset);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import one.nem.lacerta.data.repository.DeviceMeta;
|
||||
import one.nem.lacerta.data.model.DeviceMetaModel;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class DeviceMetaImpl implements DeviceMeta{
|
||||
|
||||
@Inject
|
||||
public DeviceMetaImpl() {
|
||||
}
|
||||
|
||||
public DeviceMetaModel getDeviceMeta() {
|
||||
DeviceMetaModel deviceMetaModel = new DeviceMetaModel(
|
||||
Build.MANUFACTURER,
|
||||
Build.MODEL,
|
||||
Build.VERSION.RELEASE,
|
||||
Build.VERSION.SDK_INT
|
||||
);
|
||||
return deviceMetaModel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
// Hilt
|
||||
import javax.inject.Inject;
|
||||
|
||||
// Lacerta/data
|
||||
import one.nem.lacerta.data.Document;
|
||||
|
||||
// Lacerta/model
|
||||
import one.nem.lacerta.model.PublicPath;
|
||||
import one.nem.lacerta.model.document.DocumentMeta;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
|
||||
// Lacerta/source
|
||||
import one.nem.lacerta.model.document.internal.XmlMetaModel;
|
||||
import one.nem.lacerta.model.document.internal.XmlMetaPageModel;
|
||||
import one.nem.lacerta.model.document.page.Page;
|
||||
import one.nem.lacerta.source.database.LacertaDatabase;
|
||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||
|
||||
// Lacerta/utils
|
||||
import one.nem.lacerta.source.file.FileManager;
|
||||
import one.nem.lacerta.source.file.factory.FileManagerFactory;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
// Lacerta/vcs
|
||||
import one.nem.lacerta.utils.XmlMetaParser;
|
||||
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
|
||||
import one.nem.lacerta.vcs.LacertaVcs;
|
||||
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
||||
|
||||
|
||||
public class DocumentImpl implements Document {
|
||||
|
||||
String TAG = getClass().getSimpleName();
|
||||
|
||||
@Inject
|
||||
LacertaLogger logger;
|
||||
|
||||
@Inject
|
||||
LacertaDatabase database;
|
||||
|
||||
@Inject
|
||||
LacertaVcsFactory vcsFactory;
|
||||
|
||||
@Inject
|
||||
FileManagerFactory fileManagerFactory;
|
||||
|
||||
@Inject
|
||||
DeviceInfoUtils deviceInfoUtils;
|
||||
|
||||
@Inject
|
||||
XmlMetaParser xmlMetaParser;
|
||||
|
||||
@Inject
|
||||
public DocumentImpl() {
|
||||
// Init
|
||||
// logger.debug(TAG, "called");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompletableFuture<DocumentDetail> createDocument(DocumentMeta meta) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
DocumentDetail detail = new DocumentDetail();
|
||||
detail.setMeta(meta);
|
||||
detail.setPages(new ArrayList<>());
|
||||
// Create DocumentEntity
|
||||
DocumentEntity documentEntity = new DocumentEntity();
|
||||
documentEntity.id = meta.getId();
|
||||
documentEntity.title = meta.getTitle();
|
||||
documentEntity.author = meta.getAuthor();
|
||||
documentEntity.defaultBranch = meta.getDefaultBranch();
|
||||
documentEntity.updatedAt = meta.getUpdatedAt();
|
||||
documentEntity.createdAt = meta.getCreatedAt();
|
||||
documentEntity.publicPath = meta.getPath().getStringPath();
|
||||
documentEntity.tagIds = meta.getTagIds();
|
||||
|
||||
database.documentDao().insert(documentEntity);
|
||||
|
||||
// Vcs
|
||||
LacertaVcs vcs = vcsFactory.create(meta.getId());
|
||||
vcs.createDocument(meta.getId());
|
||||
|
||||
// XmlMeta
|
||||
updateXmlMeta(detail).join();
|
||||
|
||||
return detail;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<DocumentDetail> createDocument() {
|
||||
DocumentMeta meta = new DocumentMeta();
|
||||
meta.setId(UUID.randomUUID().toString());
|
||||
meta.setTitle("New Document");
|
||||
meta.setAuthor("author");
|
||||
meta.setDefaultBranch("master");
|
||||
meta.setUpdatedAt(new Date());
|
||||
meta.setCreatedAt(new Date());
|
||||
meta.setPath(new PublicPath().getRoot()); // TODO-rca: 2回インスタンスを生成していて無駄なのでなんとかする
|
||||
meta.setTags(new ArrayList<>());
|
||||
return createDocument(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> deleteDocument(String documentId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> updateDocument(DocumentDetail detail) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
updateXmlMeta(detail).join();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<DocumentDetail> getDocument(String documentId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
DocumentEntity documentEntity = database.documentDao().findById(documentId);
|
||||
if (documentEntity == null) {
|
||||
throw new IllegalArgumentException("documentId is not found");
|
||||
}
|
||||
DocumentMeta meta = new DocumentMeta();
|
||||
meta.setId(documentEntity.id);
|
||||
meta.setTitle(documentEntity.title);
|
||||
meta.setAuthor(documentEntity.author);
|
||||
meta.setDefaultBranch(documentEntity.defaultBranch);
|
||||
meta.setUpdatedAt(documentEntity.updatedAt);
|
||||
meta.setCreatedAt(documentEntity.createdAt);
|
||||
meta.setPath(new PublicPath().resolve(documentEntity.publicPath));
|
||||
meta.setTags(new ArrayList<>()); // TODO-rca: タグを取得する
|
||||
|
||||
DocumentDetail detail = new DocumentDetail();
|
||||
|
||||
getPagesByXmlMeta(documentId).thenCompose(xmlMetaPageModels -> getPagesByXmlMetaPageModel(documentId, xmlMetaPageModels)).thenAccept(pages -> {
|
||||
logger.debug(TAG, "pages: " + pages.size());
|
||||
detail.setMeta(meta);
|
||||
detail.setPages(pages);
|
||||
}).join();
|
||||
|
||||
return detail;
|
||||
});
|
||||
}
|
||||
|
||||
private CompletableFuture<ArrayList<XmlMetaPageModel>> getPagesByXmlMeta(String documentId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
|
||||
try {
|
||||
ArrayList<XmlMetaPageModel> xmlMetaPageModels = xmlMetaParser.deserialize(fileManager.resolve(documentId).loadXml("meta.xml")).getPages();
|
||||
// Debug
|
||||
logger.debug(TAG, "xmlMetaPageModels: " + xmlMetaPageModels.size());
|
||||
for (XmlMetaPageModel xmlMetaPageModel : xmlMetaPageModels) {
|
||||
logger.debug(TAG, "\txmlMetaPageModel: " + xmlMetaPageModel.getFilename());
|
||||
}
|
||||
return xmlMetaPageModels;
|
||||
} catch (IOException e) {
|
||||
logger.error(TAG, "DocumentMeta parse error");
|
||||
logger.trace(TAG, e.getMessage());
|
||||
logger.e_code("db18c04a-1625-4871-9e4e-918d805568ac");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
private CompletableFuture<ArrayList<Page>> getPagesByXmlMetaPageModel(String documentId, ArrayList<XmlMetaPageModel> xmlMetaPageModels) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ArrayList<Page> pages = new ArrayList<>();
|
||||
FileManager fileManager;
|
||||
try {
|
||||
fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory()).resolve(documentId);
|
||||
} catch (IOException e) {
|
||||
logger.error(TAG, "FileManager resolve error");
|
||||
logger.trace(TAG, e.getMessage());
|
||||
logger.e_code("2235e8ee-4177-46f8-af6b-084381b202e6");
|
||||
return null;
|
||||
}
|
||||
for (XmlMetaPageModel xmlMetaPageModel : xmlMetaPageModels) {
|
||||
try {
|
||||
pages.add(new Page(xmlMetaPageModel.getFilename(), fileManager.resolve("raw").loadBitmap(xmlMetaPageModel.getFilename())));
|
||||
} catch (IOException e) {
|
||||
logger.error(TAG, "Bitmap decode error");
|
||||
logger.trace(TAG, e.getMessage());
|
||||
logger.e_code("3bba8c8f-90fb-4a24-a726-7ea201929f8b");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return pages;
|
||||
});
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> updateXmlMeta(DocumentDetail documentDetail) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
// TODO-rca: リビジョンIDを検証する, 挿入する
|
||||
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());
|
||||
ArrayList<XmlMetaPageModel> xmlMetaPageModels = new ArrayList<>();
|
||||
for (Page page : documentDetail.getPages()) {
|
||||
xmlMetaPageModels.add(new XmlMetaPageModel(page.getFileName()));
|
||||
}
|
||||
try {
|
||||
fileManager.createDirectoryIfNotExist(documentDetail.getMeta().getId()).resolve(documentDetail.getMeta().getId())
|
||||
.createFileIfNotExist("meta.xml").resolve("meta.xml").saveXml(xmlMetaParser.serialize(new XmlMetaModel("revisionId_PLACEHOLDER", xmlMetaPageModels)));
|
||||
} catch (IOException e) {
|
||||
logger.error(TAG, "DocumentMeta serialize error");
|
||||
logger.trace(TAG, e.getMessage());
|
||||
logger.e_code("e3b4d0c9-5b7e-4b7e-9e9a-5b8b8b8b8b8b");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import one.nem.lacerta.data.model.documents.DocumentMeta;
|
||||
import one.nem.lacerta.data.repository.Documents;
|
||||
|
||||
public class DocumentsImpl implements Documents {
|
||||
|
||||
@Inject
|
||||
public DocumentsImpl() {
|
||||
}
|
||||
|
||||
public ArrayList<DocumentMeta> getRecentDocuments(int limit) {
|
||||
return null; // TODO-rca:
|
||||
}
|
||||
|
||||
public ArrayList<DocumentMeta> getStarredDocuments(int limit) {
|
||||
return null; // TODO-rca:
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.model.LibraryItemPage;
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
import one.nem.lacerta.model.ListItemType;
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
import one.nem.lacerta.source.database.LacertaDatabase;
|
||||
import one.nem.lacerta.source.database.common.DateTypeConverter;
|
||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
public class LacertaLibraryImpl implements LacertaLibrary {
|
||||
|
||||
LacertaLogger logger;
|
||||
LacertaDatabase database;
|
||||
|
||||
@Inject
|
||||
public LacertaLibraryImpl(LacertaLogger logger, LacertaDatabase database) {
|
||||
this.logger = logger;
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
// 5秒フリーズさせる
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
List<DocumentEntity> documentEntities = database.documentDao().getRecentDocument(limit);
|
||||
|
||||
ArrayList<ListItem> listItems = new ArrayList<>();
|
||||
for (DocumentEntity documentEntity : documentEntities) {
|
||||
ListItem listItem = new ListItem();
|
||||
listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
||||
listItem.setTitle(documentEntity.title);
|
||||
listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt));
|
||||
listItem.setItemId(documentEntity.id);
|
||||
listItems.add(listItem);
|
||||
}
|
||||
|
||||
return listItems;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<ArrayList<ListItem>> getRecentDocument(int limit, int offset) {
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
//package one.nem.lacerta.data.impl;
|
||||
//
|
||||
//import one.nem.lacerta.data.LacertaLibrary;
|
||||
//import one.nem.lacerta.model.LibraryItemPage;
|
||||
//import one.nem.lacerta.model.ListItem;
|
||||
//import one.nem.lacerta.model.ListItemType;
|
||||
//import one.nem.lacerta.model.document.DocumentDetail;
|
||||
//
|
||||
//import one.nem.lacerta.model.document.DocumentMeta;
|
||||
//import one.nem.lacerta.model.document.path.DocumentPath;
|
||||
//import one.nem.lacerta.utils.LacertaLogger;
|
||||
//
|
||||
//import com.github.javafaker.DateAndTime;
|
||||
//import com.github.javafaker.Faker;
|
||||
//
|
||||
//import java.text.DateFormat;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Objects;
|
||||
//import java.util.UUID;
|
||||
//
|
||||
//import javax.inject.Inject;
|
||||
//
|
||||
///**
|
||||
// * LacertaLibraryのスタブ実装
|
||||
// */
|
||||
//public class LacertaLibraryStubImpl implements LacertaLibrary {
|
||||
//
|
||||
// LacertaLogger logger;
|
||||
//
|
||||
// Faker faker;
|
||||
//
|
||||
// @Inject
|
||||
// public LacertaLibraryStubImpl(LacertaLogger logger) {
|
||||
// faker = new Faker(); // Init Faker
|
||||
// this.logger = logger;
|
||||
// logger.debug("LibraryStub", "Initialized");
|
||||
// }
|
||||
//
|
||||
// // Internal Methods
|
||||
//
|
||||
// // Generate Stub Data
|
||||
// private LibraryItemPage generateStubLibraryItemPage(int limit, String pageId) {
|
||||
// logger.debug("LibraryStub", "generateStubLibraryItemPage");
|
||||
// ArrayList<ListItem> listItems = new ArrayList<>();
|
||||
// int itemTotal = faker.number().numberBetween(1, limit); // 実際に返却するアイテム数を決定
|
||||
// int folderTotal;
|
||||
// // フォルダ数の抽選
|
||||
// if (itemTotal > 4) {
|
||||
// folderTotal = faker.number().numberBetween(1, itemTotal - 2);
|
||||
// }
|
||||
// else {
|
||||
// if (itemTotal > 2) {
|
||||
// folderTotal = 1;
|
||||
// }
|
||||
// else { // ドキュメント数がゼロにならないように
|
||||
// folderTotal = 0;
|
||||
// }
|
||||
// }
|
||||
// int documentTotal = itemTotal - folderTotal; // ドキュメント数を決定
|
||||
// logger.debug("LibraryStub", "itemTotal: " + itemTotal);
|
||||
// logger.debug("LibraryStub", "folderTotal: " + folderTotal);
|
||||
// logger.debug("LibraryStub", "documentTotal: " + documentTotal);
|
||||
//
|
||||
// // フォルダを生成
|
||||
// for (int i = 0; i < folderTotal; i++) {
|
||||
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_FOLDER));
|
||||
// }
|
||||
// // ドキュメントを生成
|
||||
// for (int i = 0; i < documentTotal; i++) {
|
||||
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
|
||||
// }
|
||||
//
|
||||
// LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||
// libraryItemPage.setListItems(listItems);
|
||||
// if (pageId == null) {
|
||||
// libraryItemPage.setPageId(UUID.randomUUID().toString());
|
||||
// } else {
|
||||
// libraryItemPage.setPageId(pageId);
|
||||
// }
|
||||
// libraryItemPage.setPageTitle("FakePage" + faker.number().digits(3));
|
||||
//
|
||||
// return libraryItemPage;
|
||||
// }
|
||||
//
|
||||
// private ListItem generateStubListItem(ListItemType itemType) {
|
||||
// if (itemType == ListItemType.ITEM_TYPE_FOLDER) {
|
||||
// ListItem listItem = new ListItem();
|
||||
// listItem.setTitle("FakeFolder" + faker.number().digits(3));
|
||||
// listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
|
||||
// listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
|
||||
// listItem.setItemId(UUID.randomUUID().toString());
|
||||
// return listItem;
|
||||
// } else if (itemType == ListItemType.ITEM_TYPE_DOCUMENT) {
|
||||
// ListItem listItem = new ListItem();
|
||||
// listItem.setTitle("FakeDocument" + faker.book().title());
|
||||
// listItem.setDescription("Updated at " + DateFormat.getDateTimeInstance().format(faker.date().birthday()));
|
||||
// listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT);
|
||||
// listItem.setItemId(UUID.randomUUID().toString());
|
||||
// return listItem;
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private LibraryItemPage getRecentDocumentPage(int limit) {
|
||||
// int itemTotal = faker.number().numberBetween(1, limit);
|
||||
// ArrayList<ListItem> listItems = new ArrayList<>();
|
||||
// for (int i = 0; i < itemTotal; i++) {
|
||||
// listItems.add(generateStubListItem(ListItemType.ITEM_TYPE_DOCUMENT));
|
||||
// }
|
||||
// // DescriptionからDateを抽出して新しい順にソート
|
||||
// listItems.sort((a, b) -> {
|
||||
// String aDate = a.getDescription().substring(11);
|
||||
// String bDate = b.getDescription().substring(11);
|
||||
// return bDate.compareTo(aDate);
|
||||
// });
|
||||
// LibraryItemPage libraryItemPage = new LibraryItemPage();
|
||||
// libraryItemPage.setListItems(listItems);
|
||||
// libraryItemPage.setPageId(UUID.randomUUID().toString());
|
||||
// libraryItemPage.setPageTitle("RecentDocument");
|
||||
// return libraryItemPage;
|
||||
// }
|
||||
//
|
||||
// private DocumentDetail generateStubDocumentDetail(String id) throws IllegalArgumentException {
|
||||
//
|
||||
// if (Objects.isNull(id)) {
|
||||
// throw new IllegalArgumentException("id is null");
|
||||
// }
|
||||
//
|
||||
// DocumentMeta documentMeta = new DocumentMeta();
|
||||
// documentMeta.setId(id);
|
||||
// documentMeta.setTitle("FakeDocument" + faker.book().title());
|
||||
// documentMeta.setCreatedAt(faker.date().birthday());
|
||||
// documentMeta.setUpdatedAt(faker.date().birthday()); // TODO-rca: 更新日のほうが古くなることがあるのでなんとかする?
|
||||
// ArrayList<String> tagIds = new ArrayList<>();
|
||||
//
|
||||
// DocumentDetail documentDetail = new DocumentDetail();
|
||||
// documentDetail.setMeta(documentMeta);
|
||||
//// documentDetail.setPath(null); // TODO-rca: なんとかする
|
||||
//// documentDetail.setAuthor(faker.name().fullName());
|
||||
//// documentDetail.setRepository(null); // TODO-rca: なんとかする
|
||||
// return documentDetail;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 履歴ページを取得する
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public ArrayList<ListItem> getRecentDocument(int limit) {
|
||||
// return getRecentDocumentPage(limit).getListItems();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 履歴ページを取得する
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @param offset 取得するアイテムのオフセット
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public ArrayList<ListItem> getRecentDocument(int limit, int offset) {
|
||||
// return getRecentDocumentPage(limit).getListItems();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ライブラリページを取得する
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public LibraryItemPage getLibraryPage(int limit) {
|
||||
// return generateStubLibraryItemPage(limit, null);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ライブラリページを取得する
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @param offset 取得するアイテムのオフセット
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public LibraryItemPage getLibraryPage(int limit, int offset) {
|
||||
// return generateStubLibraryItemPage(limit, null);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ライブラリページを取得する
|
||||
// * @param pageId ページID
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public LibraryItemPage getLibraryPage(String pageId, int limit) {
|
||||
// return generateStubLibraryItemPage(limit, pageId);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ライブラリページを取得する
|
||||
// * @param pageId ページID
|
||||
// * @param limit 取得するアイテム数
|
||||
// * @param offset 取得するアイテムのオフセット
|
||||
// * @return ページオブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public LibraryItemPage getLibraryPage(String pageId, int limit, int offset) {
|
||||
// return generateStubLibraryItemPage(limit, pageId);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * ドキュメント詳細を取得する
|
||||
// * @param id ドキュメントID
|
||||
// * @return ドキュメント詳細オブジェクト
|
||||
// */
|
||||
// @Override
|
||||
// public DocumentDetail getDocumentDetailById(String id) throws IllegalArgumentException {
|
||||
// return generateStubDocumentDetail(id);
|
||||
// }
|
||||
//}
|
||||
@@ -1,53 +0,0 @@
|
||||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import one.nem.lacerta.data.LacertaSearch;
|
||||
import one.nem.lacerta.model.ListItem;
|
||||
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
public class LacertaSearchStubImpl implements LacertaSearch {
|
||||
|
||||
private LacertaLibrary library;
|
||||
private LacertaLogger logger;
|
||||
|
||||
|
||||
@Inject
|
||||
public LacertaSearchStubImpl(LacertaLibrary library, LacertaLogger logger) {
|
||||
this.library = library;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* 検索
|
||||
* @param query 検索クエリ
|
||||
* @param limit 最大取得件数
|
||||
* @return 検索結果
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<ListItem> autoSearch(String query, int limit) {
|
||||
// logger.debug("SearchStub", "autoSearch");
|
||||
// logger.debug("SearchStub", "query: " + query);
|
||||
// return library.getLibraryPage(limit).getListItems();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 検索
|
||||
* @param query 検索クエリ
|
||||
* @param limit 最大取得件数
|
||||
* @param offset オフセット
|
||||
* @return 検索結果
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<ListItem> autoSearch(String query, int limit, int offset) {
|
||||
// logger.debug("SearchStub", "autoSearch");
|
||||
// logger.debug("SearchStub", "query: " + query);
|
||||
// return library.getLibraryPage(limit, offset).getListItems();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext;
|
||||
import one.nem.lacerta.data.repository.SharedPref;
|
||||
|
||||
import one.nem.lacerta.data.model.shared_pref.enums.SharedPrefType;
|
||||
|
||||
public class SharedPrefImpl implements SharedPref{
|
||||
|
||||
private final Context applicationContext;
|
||||
|
||||
@Inject
|
||||
public SharedPrefImpl(@ApplicationContext Context applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedPreferences getSharedPreferencesByTag(SharedPrefType sharedPrefType) {
|
||||
return applicationContext.getSharedPreferences(sharedPrefType.getTag(), Context.MODE_PRIVATE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package one.nem.lacerta.data.impl.stub;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import one.nem.lacerta.data.model.documents.DocumentMeta;
|
||||
|
||||
import one.nem.lacerta.data.model.documents.enums.DocumentType;
|
||||
|
||||
import one.nem.lacerta.data.repository.Documents;
|
||||
|
||||
public class DocumentsImpl implements Documents {
|
||||
|
||||
@Inject
|
||||
public DocumentsImpl() {
|
||||
}
|
||||
|
||||
public ArrayList<DocumentMeta> getRecentDocuments(int limit) { // Generate dummy data
|
||||
ArrayList<DocumentMeta> documentMetaList = new ArrayList<>();
|
||||
for (int i = 0; i < limit; i++) {
|
||||
DocumentMeta documentMeta = new DocumentMeta();
|
||||
documentMeta.id = UUID.randomUUID().toString();
|
||||
documentMeta.name = "Document " + i;
|
||||
documentMeta.created = new Date();
|
||||
documentMeta.type = new Random(i).nextInt()/2 == 0 ? DocumentType.OTHER : DocumentType.NOTEBOOK;
|
||||
documentMeta.tags = new String[] {"tag1", "tag2", "tag3"};
|
||||
documentMeta.categories = new String[] {"category1", "category2", "category3"};
|
||||
documentMetaList.add(documentMeta);
|
||||
}
|
||||
|
||||
return documentMetaList;
|
||||
}
|
||||
|
||||
public ArrayList<DocumentMeta> getStarredDocuments(int limit) { // Generate dummy data
|
||||
ArrayList<DocumentMeta> documentMetaList = new ArrayList<>();
|
||||
for (int i = 0; i < limit; i++) {
|
||||
DocumentMeta documentMeta = new DocumentMeta();
|
||||
documentMeta.id = UUID.randomUUID().toString();
|
||||
documentMeta.name = "Document " + i;
|
||||
documentMeta.created = new Date();
|
||||
documentMeta.type = new Random(i).nextInt()/2 == 0 ? DocumentType.OTHER : DocumentType.NOTEBOOK;
|
||||
documentMeta.tags = new String[] {"tag1", "tag2", "tag3"};
|
||||
documentMeta.categories = new String[] {"category1", "category2", "category3"};
|
||||
documentMetaList.add(documentMeta);
|
||||
}
|
||||
|
||||
return documentMetaList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package one.nem.lacerta.data.model;
|
||||
|
||||
public class DeviceMetaModel {
|
||||
private String DeviceManufacturer;
|
||||
private String DeviceModel;
|
||||
private String AndroidVersion;
|
||||
private int AndroidApiLevel;
|
||||
|
||||
public DeviceMetaModel(String DeviceManufacturer, String DeviceModel, String AndroidVersion, int AndroidApiLevel) {
|
||||
this.DeviceManufacturer = DeviceManufacturer;
|
||||
this.DeviceModel = DeviceModel;
|
||||
this.AndroidVersion = AndroidVersion;
|
||||
this.AndroidApiLevel = AndroidApiLevel;
|
||||
}
|
||||
|
||||
// Getters
|
||||
// TODO-rca: ボイラープレートコードなので削減する
|
||||
|
||||
public String getDeviceManufacturer() {
|
||||
return DeviceManufacturer;
|
||||
}
|
||||
|
||||
public String getDeviceModel() {
|
||||
return DeviceModel;
|
||||
}
|
||||
|
||||
public String getAndroidVersion() {
|
||||
return AndroidVersion;
|
||||
}
|
||||
|
||||
public int getAndroidApiLevel() {
|
||||
return AndroidApiLevel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package one.nem.lacerta.data.model.documents;
|
||||
|
||||
public class DocumentDetail {
|
||||
// ドキュメントの詳細情報
|
||||
private DocumentMeta documentMeta;
|
||||
|
||||
// TODO-rca: ドキュメントの詳細情報を格納するフィールドを追加する
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package one.nem.lacerta.data.model.documents;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import one.nem.lacerta.data.model.documents.enums.DocumentType;
|
||||
|
||||
// TODO-rca: Dateをデバイスのロケールに合わせてStringに変換するメソッドを実装する?
|
||||
public class DocumentMeta {
|
||||
// ドキュメントのメタ情報
|
||||
public String id; // ドキュメントの内部ID(UUIDv4?)
|
||||
public String name; // ドキュメントの名前
|
||||
public DocumentType type; // ドキュメントの種類
|
||||
public Date created; // ドキュメントの作成日時
|
||||
public String[] tags; // ドキュメントのタグ
|
||||
public String[] categories; // ドキュメントのカテゴリ
|
||||
|
||||
public DocumentMeta(String id, String name, Date created, DocumentType type, String[] tags, String[] categories) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.created = created;
|
||||
this.type = type;
|
||||
this.tags = tags;
|
||||
this.categories = categories;
|
||||
}
|
||||
|
||||
public DocumentMeta() {
|
||||
this.id = "";
|
||||
this.name = "";
|
||||
this.created = new Date();
|
||||
this.type = DocumentType.OTHER;
|
||||
this.tags = new String[0];
|
||||
this.categories = new String[0];
|
||||
}
|
||||
|
||||
// TODO-rca: ボイラープレートコードなので削減する
|
||||
// Getter
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public DocumentType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String[] getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public String[] getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
// Setter
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
if (name == null) {
|
||||
this.name = "";
|
||||
} else {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
if (created == null) {
|
||||
this.created = new Date();
|
||||
} else {
|
||||
this.created = created;
|
||||
}
|
||||
}
|
||||
|
||||
public void setType(DocumentType type) {
|
||||
if (type == null) {
|
||||
this.type = DocumentType.OTHER;
|
||||
} else {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTags(String[] tags) {
|
||||
if (tags == null) {
|
||||
this.tags = new String[0];
|
||||
} else {
|
||||
this.tags = tags;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCategories(String[] categories) {
|
||||
if (categories == null) {
|
||||
this.categories = new String[0];
|
||||
} else {
|
||||
this.categories = categories;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package one.nem.lacerta.data.model.documents.enums;
|
||||
|
||||
public enum DocumentType {
|
||||
// ドキュメントの種類
|
||||
// TODO: ユーザーがドキュメントの種類を追加できるようにする
|
||||
|
||||
// テキスト
|
||||
TEXTBOOK,
|
||||
// ノート
|
||||
NOTEBOOK,
|
||||
// ワークブック
|
||||
WORKBOOK,
|
||||
// レシート
|
||||
RECEIPT,
|
||||
// チケット
|
||||
TICKET,
|
||||
// メモ
|
||||
MEMO,
|
||||
// その他
|
||||
OTHER
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package one.nem.lacerta.data.model.shared_pref.enums;
|
||||
|
||||
public enum SharedPrefType {
|
||||
|
||||
COMMON("common"),
|
||||
USERDATA("userdata");
|
||||
|
||||
private String tag;
|
||||
|
||||
SharedPrefType(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package one.nem.lacerta.data.module;
|
||||
|
||||
import one.nem.lacerta.data.impl.DeviceMetaImpl;
|
||||
import one.nem.lacerta.data.repository.DeviceMeta;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.hilt.InstallIn;
|
||||
// Singleton
|
||||
import dagger.hilt.components.SingletonComponent;
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent.class)
|
||||
abstract class DeviceMetaModule {
|
||||
|
||||
@Binds
|
||||
public abstract DeviceMeta bindDeviceMeta(DeviceMetaImpl deviceMetaImpl);
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package one.nem.lacerta.data.module;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.hilt.InstallIn;
|
||||
import dagger.hilt.components.SingletonComponent;
|
||||
|
||||
import one.nem.lacerta.data.Document;
|
||||
import one.nem.lacerta.data.impl.DocumentImpl;
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent.class) // TODO-rca: Singletonであるべきか考える
|
||||
abstract public class DocumentModule {
|
||||
|
||||
@Binds
|
||||
public abstract Document bindDocument(DocumentImpl documentImpl);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package one.nem.lacerta.data.module;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.hilt.InstallIn;
|
||||
import dagger.hilt.components.SingletonComponent;
|
||||
|
||||
import one.nem.lacerta.data.repository.Documents;
|
||||
import one.nem.lacerta.data.impl.DocumentsImpl;
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent.class)
|
||||
abstract public class DocumentsModule {
|
||||
|
||||
@Binds
|
||||
public abstract Documents bindDocuments(DocumentsImpl documentsImpl);
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package one.nem.lacerta.data.module;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.hilt.InstallIn;
|
||||
import dagger.hilt.android.components.FragmentComponent;
|
||||
import dagger.hilt.migration.DisableInstallInCheck;
|
||||
|
||||
import one.nem.lacerta.data.LacertaLibrary;
|
||||
import one.nem.lacerta.data.impl.LacertaLibraryImpl;
|
||||
import one.nem.lacerta.utils.LacertaLogger;
|
||||
|
||||
@Module
|
||||
// Fragmentにinstall
|
||||
@InstallIn(FragmentComponent.class)
|
||||
abstract public class LacertaLibraryModule {
|
||||
|
||||
@Binds
|
||||
public abstract LacertaLibrary bindLacertaLibrary(LacertaLibraryImpl impl);
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package one.nem.lacerta.data.module;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.hilt.InstallIn;
|
||||
import dagger.hilt.android.components.FragmentComponent;
|
||||
import one.nem.lacerta.data.LacertaSearch;
|
||||
import one.nem.lacerta.data.impl.LacertaSearchStubImpl;
|
||||
|
||||
@Module
|
||||
@InstallIn(FragmentComponent.class)
|
||||
abstract public class LacertaSearchModule {
|
||||
|
||||
@Binds
|
||||
public abstract LacertaSearch bindLacertaSearch(LacertaSearchStubImpl impl);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package one.nem.lacerta.data.module;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.hilt.InstallIn;
|
||||
import dagger.hilt.components.SingletonComponent;
|
||||
import one.nem.lacerta.data.impl.SharedPrefImpl;
|
||||
import one.nem.lacerta.data.repository.SharedPref;
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent.class)
|
||||
abstract public class SharedPrefModule {
|
||||
|
||||
@Binds
|
||||
public abstract SharedPref bindSharedPref(SharedPrefImpl sharedPrefImpl);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package one.nem.lacerta.data.processor;
|
||||
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
|
||||
import one.nem.lacerta.model.document.DocumentDetail;
|
||||
|
||||
public interface DocumentProcessor {
|
||||
// TODO-rca: Initをここでやるべきか検討する?, Documentモデルを作るべきか検討する?
|
||||
|
||||
void setDocumentDetail(DocumentDetail documentDetail);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package one.nem.lacerta.data.processor.impl;
|
||||
|
||||
public class DocumentProcessorImpl {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package one.nem.lacerta.data.repository;
|
||||
|
||||
import one.nem.lacerta.data.model.DeviceMetaModel;
|
||||
|
||||
public interface DeviceMeta {
|
||||
DeviceMetaModel getDeviceMeta();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package one.nem.lacerta.data.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import one.nem.lacerta.data.model.documents.DocumentDetail;
|
||||
import one.nem.lacerta.data.model.documents.DocumentMeta;
|
||||
|
||||
public interface Documents {
|
||||
|
||||
ArrayList<DocumentMeta> getRecentDocuments(int limit);
|
||||
|
||||
ArrayList<DocumentMeta> getStarredDocuments(int limit);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package one.nem.lacerta.data.repository;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import one.nem.lacerta.data.model.shared_pref.enums.SharedPrefType;
|
||||
|
||||
public interface SharedPref {
|
||||
|
||||
// タグのTypoを防ぐ為にEnumで管理して取得させるやつ
|
||||
SharedPreferences getSharedPreferencesByTag(SharedPrefType sharedPrefType);
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,60 @@
|
||||
package one.nem.lacerta.source.pref.impl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext;
|
||||
|
||||
import one.nem.lacerta.source.pref.repository.Common;
|
||||
|
||||
public class CommonImpl implements Common {
|
||||
|
||||
Context applicationContext;
|
||||
|
||||
@Inject
|
||||
public CommonImpl(@ApplicationContext Context applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public String getStringValue(String key) {
|
||||
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
|
||||
return pref.getString(key, "");
|
||||
}
|
||||
|
||||
public void setStringValue(String key, String value) {
|
||||
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = pref.edit();
|
||||
editor.putString(key, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public boolean isExist(String key) {
|
||||
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
|
||||
return pref.contains(key);
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = pref.edit();
|
||||
editor.remove(key);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public ArrayList<String> getExistKeys() {
|
||||
SharedPreferences pref = applicationContext.getSharedPreferences("common", Context.MODE_PRIVATE);
|
||||
// キーだけをArrayListに切り出す
|
||||
return new ArrayList<>(pref.getAll().keySet());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,16 @@
|
||||
package one.nem.lacerta.source.pref.module;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.hilt.InstallIn;
|
||||
import dagger.hilt.components.SingletonComponent;
|
||||
import one.nem.lacerta.source.pref.impl.CommonImpl;
|
||||
import one.nem.lacerta.source.pref.repository.Common;
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent.class)
|
||||
abstract public class CommonModule {
|
||||
|
||||
@Binds
|
||||
public abstract Common bindCommon(CommonImpl commonImpl);
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,18 @@
|
||||
package one.nem.lacerta.source.pref.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public interface Common {
|
||||
// さまざまな用途で使うPref
|
||||
|
||||
String getStringValue(String key);
|
||||
|
||||
void setStringValue(String key, String value);
|
||||
|
||||
boolean isExist(String key);
|
||||
|
||||
void remove(String key);
|
||||
|
||||
ArrayList<String> getExistKeys();
|
||||
}
|
||||
File renamed without changes.
@@ -4,7 +4,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.feature.common'
|
||||
compileSdk 34
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
|
||||
@@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'one.nem.lacerta.feature.debug'
|
||||
compileSdk 34
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
minSdk 26
|
||||
@@ -45,30 +45,9 @@ dependencies {
|
||||
implementation libs.com.google.dagger.hilt.android
|
||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||
|
||||
// JGit
|
||||
implementation 'org.eclipse.jgit:org.eclipse.jgit:6.8.0.202311291450-r'
|
||||
|
||||
// 内部モジュール
|
||||
// data
|
||||
implementation project(':data')
|
||||
|
||||
// Debug
|
||||
implementation project(':source')
|
||||
implementation project(':utils')
|
||||
|
||||
// 型
|
||||
implementation project(':model')
|
||||
|
||||
// Shared
|
||||
implementation project(':shared:ui')
|
||||
|
||||
// Scanner
|
||||
implementation project(':component:scanner')
|
||||
|
||||
// Processor
|
||||
implementation project(':processor')
|
||||
|
||||
// LacertaVcs
|
||||
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=".DebugMenuContainerActivity"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package one.nem.lacerta.feature.debug;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
public class DebugMenuContainerActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_debug_menu_container);
|
||||
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;
|
||||
});
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package one.nem.lacerta.feature.debug;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link DebugMenuDocProcessorTesterFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class DebugMenuDocProcessorTesterFragment extends Fragment {
|
||||
public DebugMenuDocProcessorTesterFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static DebugMenuDocProcessorTesterFragment newInstance() {
|
||||
DebugMenuDocProcessorTesterFragment fragment = new DebugMenuDocProcessorTesterFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_debug_menu_doc_processor_tester, container, false);
|
||||
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package one.nem.lacerta.feature.debug;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import one.nem.lacerta.feature.debug.common.adapter.DebugMenuListItemAdapter;
|
||||
import one.nem.lacerta.feature.debug.common.model.DebugMenuListItem;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link DebugMenuDocumentTesterTopFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class DebugMenuDocumentTesterTopFragment extends Fragment {
|
||||
public DebugMenuDocumentTesterTopFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
public static DebugMenuDocumentTesterTopFragment newInstance() {
|
||||
DebugMenuDocumentTesterTopFragment fragment = new DebugMenuDocumentTesterTopFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_debug_menu_document_tester_top, container, false);
|
||||
|
||||
RecyclerView recyclerView = view.findViewById(R.id.debug_menu_document_tester_recycler_view);
|
||||
recyclerView.setLayoutManager(new androidx.recyclerview.widget.LinearLayoutManager(getContext()));
|
||||
|
||||
List<DebugMenuListItem> debugMenuDocTesterListItems = new ArrayList<>();
|
||||
|
||||
// debugMenuDocTesterListItems.add(new DebugMenuListItem("DocumentListFragment", "DocumentListFragment", R.id.action_debugMenuDocumentTesterTopFragment_to_debugMenuDocumentTesterListFragment, true));
|
||||
// debugMenuDocTesterListItems.add(new DebugMenuListItem("DocumentManagerFragment", "DocumentManagerFragment", R.id.action_debugMenuDocumentTesterTopFragment_to_debugMenuDocumentTesterManageFragment, true));
|
||||
|
||||
|
||||
DebugMenuListItemAdapter adapter = new DebugMenuListItemAdapter(debugMenuDocTesterListItems);
|
||||
recyclerView.setAdapter(adapter);
|
||||
return view;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package one.nem.lacerta.feature.debug;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import one.nem.lacerta.data.repository.DeviceMeta;
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link DebugMenuFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
|
||||
@AndroidEntryPoint
|
||||
public class DebugMenuFragment extends Fragment {
|
||||
|
||||
@Inject
|
||||
DeviceMeta deviceMeta;
|
||||
|
||||
@Inject
|
||||
|
||||
|
||||
public DebugMenuFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static DebugMenuFragment newInstance() {
|
||||
DebugMenuFragment fragment = new DebugMenuFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_debug_menu, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
view.findViewById(R.id.btn_debug_menu_scan).setOnClickListener( v -> {
|
||||
// スキャン機能呼び出し
|
||||
Toast.makeText(getContext(), "testMessage", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
view.findViewById(R.id.btn_debug_menu_shared_pref_editor).setOnClickListener( v -> {
|
||||
// Fragment移動
|
||||
Navigation.findNavController(view).navigate(R.id.action_debugMenuFragment_to_debugSharedPrefEditorFragment);
|
||||
});
|
||||
|
||||
view.findViewById(R.id.btn_debug_menu_clear_pref).setOnClickListener( v -> {
|
||||
// SharedPrefClear
|
||||
});
|
||||
|
||||
view.findViewById(R.id.btn_debug_menu_call_play_ground).setOnClickListener( v -> {
|
||||
Navigation.findNavController(view).navigate(R.id.action_debugMenuFragment_to_debugPlayGroundFragment);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loaded 100 of 334 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user