Compare commits

..

No commits in common. "develop" and "v0.1.0-internal1" have entirely different histories.

447 changed files with 1281 additions and 14442 deletions

View File

@ -1,17 +0,0 @@
---
name: 不具合用テンプレート
about: 不具合用テンプレート
title: "[BUG]: "
labels: バグ
assignees: ''
---
# 概要
<!-- Issueの概要 -->
# 詳細
<!-- バグの詳細 -->
# 影響箇所
<!-- 予想される影響箇所(省略可) -->

View File

@ -1,17 +0,0 @@
---
name: 改善用テンプレート
about: 改善用テンプレート
title: "[IMPROVE]"
labels: ''
assignees: ''
---
# 概要
<!-- Issueの概要 -->
# 詳細
<!-- 改善内容の詳細 -->
# 影響箇所
<!-- 予想される影響箇所(省略可) -->

View File

@ -1,20 +1,10 @@
---
name: 新機能用テンプレート
about: 新規用テンプレート
about: 新規開発Issue用テンプレート
title: ''
labels: 新機能
labels: ''
assignees: ''
---
# 概要
<!-- Issueの概要 -->
# 詳細
<!-- 機能の詳細 -->
# 関連Issue
<!-- 関連するIssueがあれば -->
# 影響箇所
<!-- 予想される影響箇所(省略可) -->
WIP

View File

@ -1,18 +0,0 @@
# 概要
<!-- PRの概要 -->
# 関連Issue
- #000 <!-- 関連するIssueを指定(なければ省略可) -->
# 詳細
<!-- 詳細 -->
# 影響箇所
<!-- 予想される影響箇所 -->
# チェック
<!-- 参考用, 全てにチェックがついている必要があるわけではありません -->
- [ ] 機能として完成している
- [ ] WIP(Work in progress: 作業中)
- [ ] 正常にビルド/起動ができる
- [ ] 既存の機能を壊していない

10
.idea/deploymentTargetDropDown.xml generated Normal file
View File

@ -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>

View File

@ -4,10 +4,10 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-01-20T07:15:21.179573376Z">
<DropdownSelection timestamp="2023-12-18T03:36:14.973846Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="LocalEmulator" identifier="path=/home/rca/.android/avd/Pixel_3a_API_34_extension_level_7_x86_64.avd" />
<DeviceId pluginId="PhysicalDevice" identifier="serial=ZY22H7V3G7" />
</handle>
</Target>
</DropdownSelection>

5
.idea/gradle.xml generated
View File

@ -4,7 +4,6 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
@ -23,15 +22,13 @@
<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/icon" />
<option value="$PROJECT_DIR$/shared/ui" />
<option value="$PROJECT_DIR$/source" />
<option value="$PROJECT_DIR$/utils" />
<option value="$PROJECT_DIR$/vcs" />
<option value="$PROJECT_DIR$/viewer2" />
</set>
</option>
<option name="resolveExternalAnnotations" value="false" />

2
.idea/misc.xml generated
View File

@ -1,6 +1,6 @@
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -1,18 +0,0 @@
# 概要
<!-- PRの概要 -->
# 関連Issue
- #000 <!-- 関連するIssueを指定(なければ省略可) -->
# 詳細
<!-- 詳細 -->
# 影響箇所
<!-- 予想される影響箇所 -->
# チェック
<!-- 参考用, 全てにチェックがついている必要があるわけではありません -->
- [ ] 機能として完成している
- [ ] WIP(Work in progress: 作業中)
- [ ] 正常にビルド/起動ができる
- [ ] 既存の機能を壊していない

View File

@ -1,40 +1,17 @@
# Lacerta
学習に便利な機能とGit-like VCSを持ったドキュメントスキャナ (Work In Progress)
(グループワーク)
WIP
## モジュール設計
![Untitled Diagram(2)(1) drawio(1)](https://github.com/lacerta-doc/Lacerta/assets/66072112/f9b9c40f-bed0-4ade-95c1-50e28df68f35)
![Untitled Diagram(2)](https://github.com/lacerta-doc/Lacerta/assets/66072112/9daabaca-5cdc-49f8-ac66-196c588a47c9)
## メモ
- アイコン: Google Material Icons https://fonts.google.com/icons (Weight:300, Grade:0, Optical size: 24px)
## モジュール構成
### モジュール一覧
- `component` : コンポーネント
- `common` : 共通コンポーネント
- `scanner` : スキャナー
- `viewer` : ビューワー
- `data` : UIからデータを取得/保存するためのラッパーモジュール
- `feature` : 機能モジュール(ナビゲーションからみた機能で分割)
- `common`: 共通機能
- `debug`: デバッグメニュー
- `home`: ホーム画面
- `library`: ライブラリ画面
- `scan`: スキャン画面 (廃止予定)
- `search`: 検索画面
- `model` : データモデルをまとめたモジュール
- `processor` : プロセッサ(例: `DocumentProcessor` : ドキュメント処理(ドキュメントにページを追加したり更新したり))
- `shared`: 共有リソース
- `ui`: UI要素(Theme, Drawable, Colorなど)
- `source` : ソース(DB/FileManagerなど)
- `utils` : ユーティリティ(ちょっとしたユーティリティをまとめたモジュール)
## コーディング規則/推奨(WIP)
### 規則
- `// TODO`コメントには任意のsuffixを付ける
- 全員が同じ`// TODO:`を使っていると検索がむずかしくなるため
- (例: `// TODO-rca:`)
### 推奨
- マジックナンバーは控える(必要な場合もあるので)
## Thanks for
- [SDA-SE/document-scanner-android](https://github.com/SDA-SE/document-scanner-android)
-

View File

@ -14,8 +14,8 @@ android {
// , Internal, Release問わず毎回インクリメントする
// https://developer.android.com/studio/publish/versioning#versioningsettings
versionCode 2
versionName "0.2.0"
versionCode 1
versionName "0.1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -59,6 +59,32 @@ 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')
implementation project(':shared:ui')
implementation project(':shared:icon')
// Hilt (DI)
implementation libs.com.google.dagger.hilt.android
annotationProcessor libs.com.google.dagger.hilt.compiler
@ -68,20 +94,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')
implementation project(':component:scanner')
}

View File

@ -2,25 +2,14 @@
<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"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher_final"
android:icon="@mipmap/ic_launcher"
android:name=".LacertaApplication"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_final_round"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Lacerta"
tools:targetApi="31">
@ -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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -1,12 +1,10 @@
package one.nem.lacerta;
import android.app.Application;
import android.util.Log;
import com.google.android.material.color.DynamicColors;
import dagger.hilt.android.HiltAndroidApp;
import one.nem.lacerta.utils.FeatureSwitch;
@HiltAndroidApp
public class LacertaApplication extends Application {
@ -14,17 +12,7 @@ public class LacertaApplication extends Application {
public void onCreate() {
super.onCreate();
if (DynamicColors.isDynamicColorAvailable()) {
Log.d("DynamicColors", "DynamicColors is available. Applying to activities...");
if (FeatureSwitch.Meta.disableDynamicColor) {
Log.d("DynamicColors", "DynamicColors is disabled by FeatureSwitch.");
} else {
DynamicColors.applyToActivitiesIfAvailable(this);
}
} else {
Log.d("DynamicColors", "DynamicColors is not available.");
}
// DynamicColorを有効化
DynamicColors.applyToActivitiesIfAvailable(this);
}
}

View File

@ -1,200 +1,40 @@
package one.nem.lacerta;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.navigation.NavController;
import androidx.navigation.NavOptions;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.NavigationUI;
import android.app.ActivityOptions;
import android.content.Intent;
import android.content.pm.PackageManager;
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.component.scanner.ScannerManagerActivity;
import one.nem.lacerta.model.FragmentNavigation;
import one.nem.lacerta.model.pref.FeatureSwitchOverride;
import one.nem.lacerta.utils.FeatureSwitch;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
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 implements FragmentNavigation {
@Inject
SharedPrefUtils sharedPrefUtils;
public class MainActivity extends AppCompatActivity {
@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();
// 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);
bottomNavigationView.setOnItemSelectedListener(item -> {
NavOptions navOptions = new NavOptions.Builder()
.setLaunchSingleTop(true)
.setEnterAnim(androidx.navigation.ui.R.anim.nav_default_enter_anim)
.setExitAnim(androidx.navigation.ui.R.anim.nav_default_exit_anim)
.setPopEnterAnim(androidx.navigation.ui.R.anim.nav_default_pop_enter_anim)
.setPopExitAnim(androidx.navigation.ui.R.anim.nav_default_pop_exit_anim)
.build();
navController.navigate(item.getItemId(), null, navOptions);
return true;
});
}
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));
// Fab
findViewById(R.id.scanFab).setOnClickListener(v -> {
Toast.makeText(this, "Scan", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this.getApplicationContext(), ScannerManagerActivity.class);
// startActivity(intent);
startActivity(intent, ActivityOptions.makeCustomAnimation(this, one.nem.lacerta.shared.ui.R.anim.nav_up_enter_anim, one.nem.lacerta.shared.ui.R.anim.nav_up_exit_anim).toBundle());
});
NavigationUI.setupWithNavController(bottomNavigationView, navController);
Toast.makeText(this, "testMessage", Toast.LENGTH_SHORT).show();
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 1) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, "Permission granted", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Permission denied", Toast.LENGTH_SHORT).show();
Toast.makeText(this, "カメラの権限は必須です.", Toast.LENGTH_LONG).show();
finish(); // Exit app
}
}
}
private void initializeApp() {
Log.d("Init", "Initializing app");
// Set feature switch override to default value
sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_SEARCH, FeatureSwitch.FeatureMaster.enableSearch);
sharedPrefUtils.setFeatureSwitchOverride(FeatureSwitchOverride.ENABLE_DEBUG_MENU, FeatureSwitch.FeatureMaster.enableDebugMenu);
// Set isFirstLaunch to false
sharedPrefUtils.setIsFirstLaunch(false);
}
private void applyFeatureSwitch(BottomNavigationView bottomNavigationView, FeatureSwitchOverride featureSwitchOverride, boolean defaultValue, int menuId) {
boolean isEnabled = FeatureSwitch.Meta.canOverrideSwitch ? sharedPrefUtils.getFeatureSwitchOverride(featureSwitchOverride) : defaultValue;
if (!isEnabled) bottomNavigationView.getMenu().removeItem(menuId);
}
@Override
public void navigateToFragment(Fragment fragment) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
.addToBackStack(null)
.commit();
}
@Override
public void navigateToFragment(Fragment fragment, boolean addToBackStack) {
if (addToBackStack) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
.addToBackStack(null)
.commit();
} else {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
.commit();
}
}
@Override
public void navigateToFragment(Fragment fragment, boolean addToBackStack, boolean clearBackStack) {
if (clearBackStack) {
getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
if (addToBackStack) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
.addToBackStack(null)
.commit();
} else {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, fragment)
.commit();
}
}
public void navigateToFragmentAlternate(Fragment fragment, boolean addToBackStack) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
// get the current fragment
Fragment currentFragment = getSupportFragmentManager().getPrimaryNavigationFragment();
// hide the current fragment
if (currentFragment != null) {
transaction.hide(currentFragment);
}
// Add the new fragment
transaction.add(R.id.nav_host_fragment, fragment);
// Add the transaction to the back stack if needed
if (addToBackStack) {
transaction.addToBackStack(null);
}
// Commit the transaction
transaction.commit();
// Update the primary navigation fragment
getSupportFragmentManager().beginTransaction().setPrimaryNavigationFragment(fragment).commit();
}
}

View File

@ -1,15 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<group android:scaleX="0.37"
android:scaleY="0.37"
android:translateX="302.4"
android:translateY="302.4">
<path
android:fillColor="@android:color/white"
android:pathData="M92.12,225.15L92.12,51.92L265.15,51.92L265.15,107.88L148.08,107.88L148.08,225.15L92.12,225.15ZM812.12,225.15L812.12,107.88L694.85,107.88L694.85,51.92L868.08,51.92L868.08,225.15L812.12,225.15ZM92.12,907.88L92.12,734.85L148.08,734.85L148.08,851.92L265.15,851.92L265.15,907.88L92.12,907.88ZM694.85,907.88L694.85,851.92L812.12,851.92L812.12,734.85L868.08,734.85L868.08,907.88L694.85,907.88ZM268.08,719.61Q268.08,724.42 271.83,728.17Q275.58,731.92 280.39,731.92L679.81,731.92Q684.42,731.92 688.27,728.17Q692.12,724.42 692.12,719.61L692.12,240.19Q692.12,235.58 688.27,231.73Q684.42,227.88 679.81,227.88L280.39,227.88Q275.58,227.88 271.83,231.73Q268.08,235.58 268.08,240.19L268.08,719.61ZM280.39,787.88Q251.74,787.88 231.93,768.07Q212.12,748.26 212.12,719.61L212.12,240.19Q212.12,211.76 231.93,191.84Q251.74,171.92 280.39,171.92L679.81,171.92Q708.24,171.92 728.16,191.84Q748.08,211.76 748.08,240.19L748.08,719.61Q748.08,748.26 728.16,768.07Q708.24,787.88 679.81,787.88L280.39,787.88ZM372.12,387.88L588.08,387.88L588.08,331.92L372.12,331.92L372.12,387.88ZM372.12,507.88L588.08,507.88L588.08,451.92L372.12,451.92L372.12,507.88ZM372.12,627.88L588.08,627.88L588.08,571.92L372.12,571.92L372.12,627.88ZM268.08,719.61L268.08,240.19Q268.08,235.58 268.08,231.73Q268.08,227.88 268.08,227.88L268.08,227.88Q268.08,227.88 268.08,231.73Q268.08,235.58 268.08,240.19L268.08,719.61Q268.08,724.42 268.08,728.17Q268.08,731.92 268.08,731.92L268.08,731.92Q268.08,731.92 268.08,728.17Q268.08,724.42 268.08,719.61Z"/>
</group>
</vector>

View File

@ -1,15 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#5F4769">
<group android:scaleX="0.377"
android:scaleY="0.377"
android:translateX="7.476"
android:translateY="7.476">
<path
android:fillColor="@android:color/white"
android:pathData="M7,3H4v3H2V1h5V3zM22,6V1h-5v2h3v3H22zM7,21H4v-3H2v5h5V21zM20,18v3h-3v2h5v-5H20zM19,18c0,1.1 -0.9,2 -2,2H7c-1.1,0 -2,-0.9 -2,-2V6c0,-1.1 0.9,-2 2,-2h10c1.1,0 2,0.9 2,2V18zM15,8H9v2h6V8zM15,11H9v2h6V11zM15,14H9v2h6V14z"/>
</group>
</vector>

View File

@ -18,33 +18,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_container" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorSecondaryContainer"
app:itemIconTint="@color/colorOnSecondaryContainer"
app:itemTextColor="@color/colorOnSecondaryContainer"
app:itemActiveIndicatorStyle="@style/Lacerta.Custom.Indicator"
app:labelVisibilityMode="selected"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_nav_menu" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/scanFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
android:clickable="true"
app:layout_constraintBottom_toTopOf="@+id/bottom_nav"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_baseline_add_24" />
app:menu="@menu/bottom_nav_menu"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -4,26 +4,17 @@
<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"/>
android:title="Home"/>
<item
android:id="@id/feature_library_navigation"
android:icon="@drawable/folder_24px"
android:title="@string/library_title"/>
android:title="Library"/>
<item
android:id="@id/feature_debug_navigation"
android:icon="@drawable/developer_mode_24px"
android:title="@string/debug_menu_title" />
android:title="Debug menu"/>
<item
android:id="@id/feature_setting_navigation"
android:icon="@drawable/settings_24px"
android:title="@string/setting_title"/>
</menu>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_final_background"/>
<foreground android:drawable="@drawable/ic_launcher_final_foreground"/>
</adaptive-icon>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_final_background"/>
<foreground android:drawable="@drawable/ic_launcher_final_foreground"/>
</adaptive-icon>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_temp_background"/>
<foreground android:drawable="@drawable/ic_launcher_temp_foreground"/>
</adaptive-icon>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_temp_background"/>
<foreground android:drawable="@drawable/ic_launcher_temp_foreground"/>
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 888 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1004 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -2,7 +2,7 @@
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/app_main_nav"
app:startDestination="@id/feature_home_navigation">
app:startDestination="@id/feature_debug_navigation">
<include app:graph="@navigation/feature_debug_navigation" />
@ -10,9 +10,5 @@
<include app:graph="@navigation/feature_home_navigation" />
<include app:graph="@navigation/feature_search_navigation" />
<include app:graph="@navigation/feature_setting_navigation" />
</navigation>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_final_background">#B8D3C3</color>
</resources>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_temp_background">#A386EB</color>
</resources>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<cache-path name="cache" path="." />
</paths>

View File

@ -1,11 +1,10 @@
plugins {
alias(libs.plugins.com.android.library)
id 'com.google.dagger.hilt.android'
}
android {
namespace 'one.nem.lacerta.component.common'
compileSdk 34
compileSdk 33
defaultConfig {
minSdk 26
@ -33,15 +32,4 @@ dependencies {
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 project(':shared:ui')
implementation project(':utils')
implementation project(':model')
implementation project(':data')
implementation project(':vcs')
}

View File

@ -1,83 +0,0 @@
package one.nem.lacerta.component.common;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import one.nem.lacerta.component.common.model.DocumentTagApplyTagDialogExtendedModel;
import one.nem.lacerta.model.document.tag.DocumentTag;
public class LacertaApplyTagAdapter extends RecyclerView.Adapter<LacertaApplyTagAdapter.LacertaApplyTagViewHolder>{
// Listener
public interface LacertaApplyTagDialogListener {
void itemChecked(View view, String tagId);
void itemUnchecked(View view, String tagId);
}
// Variables
private ArrayList<DocumentTagApplyTagDialogExtendedModel> documentTagArrayList;
private LacertaApplyTagDialogListener listener;
// Setter
public LacertaApplyTagAdapter setListener(LacertaApplyTagDialogListener listener) {
this.listener = listener;
return this;
}
public LacertaApplyTagAdapter setDocumentTagArrayList(ArrayList<DocumentTagApplyTagDialogExtendedModel> documentTagArrayList) {
this.documentTagArrayList = documentTagArrayList;
return this;
}
// Empty constructor
public LacertaApplyTagAdapter() {
}
@NonNull
@Override
public LacertaApplyTagAdapter.LacertaApplyTagViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.apply_tag_list_item, parent, false);
return new LacertaApplyTagAdapter.LacertaApplyTagViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull LacertaApplyTagAdapter.LacertaApplyTagViewHolder holder, int position) {
DocumentTagApplyTagDialogExtendedModel documentTag = documentTagArrayList.get(position);
if (holder.checkBox == null) {
Log.d("LacertaApplyTagAdapter", "onBindViewHolder: holder.checkBox is null");
}
holder.checkBox.setText(documentTag.getName());
holder.checkBox.setChecked(documentTag.getIsChecked());
holder.checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
listener.itemChecked(buttonView, documentTag.getId());
} else {
listener.itemUnchecked(buttonView, documentTag.getId());
}
});
}
@Override
public int getItemCount() {
return documentTagArrayList == null ? 0 : documentTagArrayList.size();
}
public class LacertaApplyTagViewHolder extends RecyclerView.ViewHolder {
CheckBox checkBox;
public LacertaApplyTagViewHolder(@NonNull View itemView) {
super(itemView);
checkBox = itemView.findViewById(R.id.tag_check_box);
}
}
}

View File

@ -1,184 +0,0 @@
package one.nem.lacerta.component.common;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Checkable;
import android.widget.EditText;
import android.widget.Toast;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.stream.Collectors;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.component.common.model.DocumentTagApplyTagDialogExtendedModel;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.document.tag.DocumentTag;
import one.nem.lacerta.utils.LacertaLogger;
@AndroidEntryPoint
public class LacertaApplyTagDialog extends DialogFragment {
@Inject
LacertaLogger logger;
@Inject
LacertaLibrary lacertaLibrary;
// Listener
public interface LacertaApplyTagDialogListener {
void onDialogPositiveClick(ArrayList<DocumentTag> appliedTags);
void onDialogNegativeClick();
}
// Variables
private String title;
private String message;
private String positiveButtonText;
private String negativeButtonText;
private String documentId;
private LacertaApplyTagDialogListener listener;
private ArrayList<DocumentTag> registeredTags;
private ArrayList<DocumentTag> appliedTags;
// Setter
public LacertaApplyTagDialog setListener(LacertaApplyTagDialogListener listener) {
this.listener = listener;
return this;
}
public LacertaApplyTagDialog setTitle(String title) {
this.title = title;
return this;
}
public LacertaApplyTagDialog setMessage(String message) {
this.message = message;
return this;
}
public LacertaApplyTagDialog setPositiveButtonText(String positiveButtonText) {
this.positiveButtonText = positiveButtonText;
return this;
}
public LacertaApplyTagDialog setNegativeButtonText(String negativeButtonText) {
this.negativeButtonText = negativeButtonText;
return this;
}
public LacertaApplyTagDialog setDocumentId(String documentId) {
this.documentId = documentId;
return this;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity());
LayoutInflater inflater = requireActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.lacerta_dialog_apply_tag, null);
// RecyclerView
RecyclerView recyclerView = view.findViewById(R.id.apply_tag_list);
LacertaApplyTagAdapter lacertaApplyTagAdapter = new LacertaApplyTagAdapter();
lacertaApplyTagAdapter.setListener(new LacertaApplyTagAdapter.LacertaApplyTagDialogListener() {
@Override
public void itemChecked(View view, String tagId) {
applyChangeToVariable(true, tagId);
}
@Override
public void itemUnchecked(View view, String tagId) {
applyChangeToVariable(false, tagId);
}
});
recyclerView.setAdapter(lacertaApplyTagAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
getDocumentTagArrayList(documentId).thenAccept(documentTagArrayList -> {
lacertaApplyTagAdapter.setDocumentTagArrayList(documentTagArrayList);
lacertaApplyTagAdapter.notifyDataSetChanged(); // TODO-rca: アニメーション
});
// Set the dialog title
builder.setTitle(title)
.setMessage(message)
.setView(view)
.setPositiveButton(positiveButtonText == null ? "OK" : positiveButtonText, (dialog, id) -> {
// Send the positive button event back to the host activity
listener.onDialogPositiveClick(this.appliedTags);
})
.setNegativeButton(negativeButtonText == null ? "Cancel" : negativeButtonText, (dialog, id) -> {
// Send the negative button event back to the host activity
listener.onDialogNegativeClick();
});
return builder.create();
}
private void applyChangeToVariable(boolean isChecked, String tagId) {
if (isChecked) {
this.registeredTags.stream().filter(tag -> tag.getId().equals(tagId)).findFirst().ifPresent(tag -> this.appliedTags.add(tag));
} else {
this.appliedTags.stream().filter(tag -> tag.getId().equals(tagId)).findFirst().ifPresent(tag -> this.appliedTags.remove(tag));
}
}
private CompletableFuture<ArrayList<DocumentTagApplyTagDialogExtendedModel>> getDocumentTagArrayList(String documentId) {
return CompletableFuture.supplyAsync(() -> {
ArrayList<DocumentTagApplyTagDialogExtendedModel> documentTagArrayList = new ArrayList<>();
setRegisteredTagList().thenRun(() -> setAppliedTagList(documentId).join()).thenAccept(Void -> {
logger.debug("getDocumentTagArrayList", "this.registeredTags.size(): " + this.registeredTags.size());
logger.debug("getDocumentTagArrayList", "this.appliedTags.size(): " + this.appliedTags.size());
documentTagArrayList.addAll(this.registeredTags.stream().map(tag -> {
DocumentTagApplyTagDialogExtendedModel documentTag = new DocumentTagApplyTagDialogExtendedModel(
new DocumentTag(tag.getId(), tag.getName(), tag.getColor()),
this.appliedTags.stream().anyMatch(appliedTag -> appliedTag.getId().equals(tag.getId()))
);
return documentTag;
}).collect(Collectors.toCollection(ArrayList::new)));
}).join();
return documentTagArrayList;
});
}
private CompletableFuture<Void> setRegisteredTagList() {
return CompletableFuture.runAsync(() -> {
this.registeredTags = new ArrayList<>();
this.lacertaLibrary.getTagList().thenAccept(documentTagList -> {
for (int i = 0; i < documentTagList.size(); i++) {
this.registeredTags.add(new DocumentTag(documentTagList.get(i).getId(), documentTagList.get(i).getName(), documentTagList.get(i).getColor()));
}
}).join();
});
}
private CompletableFuture<Void> setAppliedTagList(String documentId) {
return CompletableFuture.runAsync(() -> {
this.appliedTags = new ArrayList<>();
this.lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTagList -> {
for (int i = 0; i < documentTagList.size(); i++) {
this.appliedTags.add(new DocumentTag(documentTagList.get(i).getId(), documentTagList.get(i).getName(), documentTagList.get(i).getColor()));
}
}).join();
});
}
}

View File

@ -1,87 +0,0 @@
package one.nem.lacerta.component.common;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import androidx.fragment.app.DialogFragment;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
public class LacertaCreateTagDialog extends DialogFragment {
private String title;
private String message;
private String positiveButtonText;
private String negativeButtonText;
private LacertaCreateTagDialogListener listener;
// Setter
public LacertaCreateTagDialog setListener(LacertaCreateTagDialogListener listener) {
this.listener = listener;
return this;
}
public LacertaCreateTagDialog setTitle(String title) {
this.title = title;
return this;
}
public LacertaCreateTagDialog setMessage(String message) {
this.message = message;
return this;
}
public LacertaCreateTagDialog setPositiveButtonText(String positiveButtonText) {
this.positiveButtonText = positiveButtonText;
return this;
}
public LacertaCreateTagDialog setNegativeButtonText(String negativeButtonText) {
this.negativeButtonText = negativeButtonText;
return this;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity());
LayoutInflater inflater = requireActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.lacerta_dialog_create_tag, null);
// TextEdit
EditText tag_name_edit_text = view.findViewById(R.id.tag_name_edit_text);
com.google.android.material.textfield.TextInputLayout tag_name_text_input_layout = view.findViewById(R.id.tag_name_text_input_layout);
tag_name_text_input_layout.setHint("タグの名前");
EditText tag_color_edit_text = view.findViewById(R.id.tag_color_edit_text);
com.google.android.material.textfield.TextInputLayout tag_color_text_input_layout = view.findViewById(R.id.tag_color_text_input_layout);
tag_color_text_input_layout.setHint("タグの色(カラーコード)");
builder.setTitle(this.title == null ? "Create new tag" : this.title);
// Button
builder.setPositiveButton(positiveButtonText == null ? "OK" : positiveButtonText, (dialog, which) -> {
String tag_name = tag_name_edit_text.getText().toString();
String tag_color = tag_color_edit_text.getText().toString();
if (listener != null) {
listener.onPositiveClick(tag_name, tag_color);
}
});
builder.setNegativeButton(negativeButtonText == null ? "Cancel" : negativeButtonText, (dialog, which) -> {
if (listener != null) {
listener.onNegativeClick();
}
});
builder.setView(view);
return builder.create();
}
}

View File

@ -1,8 +0,0 @@
package one.nem.lacerta.component.common;
public interface LacertaCreateTagDialogListener {
void onPositiveClick(String tag_name, String tag_color);
void onNegativeClick();
}

View File

@ -1,4 +0,0 @@
package one.nem.lacerta.component.common;
public class LacertaEditMetaDialog {
}

View File

@ -1,163 +0,0 @@
package one.nem.lacerta.component.common;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.utils.LacertaLogger;
@AndroidEntryPoint
public class LacertaSelectDirDialog extends DialogFragment {
@Inject
LacertaLibrary lacertaLibrary;
@Inject
LacertaLogger logger;
private LacertaSelectDirDialogListener listener;
private String title;
private String message;
private String positiveButtonText;
private String negativeButtonText;
private SelectDirDialogItemAdapter adapter;
private RecyclerView recyclerView;
private TextView current_dir_text_view;
// Setter
public LacertaSelectDirDialog setListener(LacertaSelectDirDialogListener listener) {
this.listener = listener;
return this;
}
public LacertaSelectDirDialog setTitle(String title) {
this.title = title;
return this;
}
public LacertaSelectDirDialog setMessage(String message) {
this.message = message;
return this;
}
public LacertaSelectDirDialog setPositiveButtonText(String positiveButtonText) {
this.positiveButtonText = positiveButtonText;
return this;
}
public LacertaSelectDirDialog setNegativeButtonText(String negativeButtonText) {
this.negativeButtonText = negativeButtonText;
return this;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity());
LayoutInflater inflater = requireActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.lacerta_dialog_select_dir, null);
// 高さを画面の40%にする
int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.4);
view.setMinimumHeight(height);
this.recyclerView = view.findViewById(R.id.select_dir_recycler_view);
this.current_dir_text_view = view.findViewById(R.id.current_dir_text_view);
this.adapter = new SelectDirDialogItemAdapter(new LacertaSelectDirDialogInternalEventListener() {
@Override
public void onDirSelected(String name, String itemId) {
showRecyclerViewItem(itemId);
}
@Override
public void onBackSelected(String parentId) {
showRecyclerViewItem(parentId);
}
});
this.recyclerView.setAdapter(this.adapter);
builder.setView(view);
showRecyclerViewItem(null); // get root folder
builder.setTitle(this.title == null ? "Select a directory" : this.title);
builder.setMessage(this.message == null ? "Select a directory" : this.message);
builder.setPositiveButton(this.positiveButtonText == null ? "OK" : this.positiveButtonText, (dialog, which) -> {
if (listener != null) {
listener.onDirSelected(
adapter.getCurrentPageTitle() == null ? null : adapter.getCurrentPageTitle(),
adapter.getCurrentId() == null ? null : adapter.getCurrentId());
}
});
builder.setNegativeButton(this.negativeButtonText == null ? "Cancel" : this.negativeButtonText, (dialog, which) -> {
if (listener != null) {
listener.onCanceled();
}
});
return builder.create();
}
private void showRecyclerViewItem(String targetDirId) {
lacertaLibrary.getPublicPath(targetDirId, ListItemType.ITEM_TYPE_FOLDER).thenAccept(publicPath -> {
getActivity().runOnUiThread(() -> {
if (publicPath != null) {
current_dir_text_view.setText("/" + publicPath.getStringPath()); // TODO-rca: PublicPathの実装を修正する
} else {
current_dir_text_view.setText("/");
}
});
});
lacertaLibrary.getFolderList(targetDirId).thenAccept(libraryItemPage -> {
getActivity().runOnUiThread(() -> {
int currentCount = adapter.getItemCount();
String currentDirId = adapter.getCurrentId();
if (currentDirId == null) {
// Rootが関わる推移 (Rootからの推移)
adapter.setListItems(libraryItemPage);
adapter.notifyItemRangeRemoved(0, currentCount);
adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size());
} else if (libraryItemPage.getPageId() == null) {
// Rootが関わる推移 (Rootへの推移)
adapter.setListItems(libraryItemPage);
adapter.notifyItemRangeRemoved(0, currentCount);
adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size());
} else if (libraryItemPage.getPageId() != null) {
// Rootが関わらない推移
adapter.setListItems(libraryItemPage);
adapter.notifyItemRangeRemoved(1, currentCount);
adapter.notifyItemRangeInserted(1, libraryItemPage.getListItems().size());
} else {
// その他の遷移(安全側に倒すため全アイテム更新)
logger.warn("LacertaSelectDirDialog", "Unknown transition.");
logger.warn("LacertaSelectDirDialog", "currentDirId: " + currentDirId + ", libraryItemPage.getPageId(): " + libraryItemPage.getPageId());
adapter.setListItems(libraryItemPage);
adapter.notifyItemRangeRemoved(0, currentCount);
adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size());
}
});
});
}
}

View File

@ -1,6 +0,0 @@
package one.nem.lacerta.component.common;
public interface LacertaSelectDirDialogInternalEventListener {
void onDirSelected(String name, String itemId);
void onBackSelected(String parentId);
}

View File

@ -1,7 +0,0 @@
package one.nem.lacerta.component.common;
public interface LacertaSelectDirDialogListener {
void onDirSelected(String name, String itemId);
void onCanceled();
}

View File

@ -1,112 +0,0 @@
package one.nem.lacerta.component.common;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.utils.LacertaLogger;
import one.nem.lacerta.vcs.LacertaVcs;
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
@AndroidEntryPoint
public class LacertaSelectRevDialog extends DialogFragment {
@Inject
LacertaVcsFactory lacertaVcsFactory;
@Inject
LacertaLogger logger;
String title;
String documentId;
String message;
String negativeButtonText;
LacertaSelectRevDialogListener listener;
public LacertaSelectRevDialog setTitle(String title) {
this.title = title;
return this;
}
public LacertaSelectRevDialog setDocumentId(String documentId) {
this.documentId = documentId;
return this;
}
public LacertaSelectRevDialog setMessage(String message) {
this.message = message;
return this;
}
public LacertaSelectRevDialog setNegativeButtonText(String negativeButtonText) {
this.negativeButtonText = negativeButtonText;
return this;
}
public LacertaSelectRevDialog setListener(LacertaSelectRevDialogListener listener) {
this.listener = listener;
return this;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity());
LayoutInflater inflater = requireActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.lacerta_dialog_select_rev, null);
int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.4);
view.setMinimumHeight(height);
RecyclerView recyclerView = view.findViewById(R.id.select_rev_recycler_view);
SelectRevDialogItemAdapter adapter = new SelectRevDialogItemAdapter(revId -> {
if (listener != null) {
listener.onItemSelected(revId);
dismiss();
}
});
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
builder.setView(view);
if (this.documentId == null) {
logger.error("SelectRevDialog", "documentId is null");
logger.e_code("0296fb0c-07a3-4971-a280-bd1a61461bb7");
Toast.makeText(getContext(), "Sorry, something went wrong", Toast.LENGTH_SHORT).show();
dismiss();
}
LacertaVcs lacertaVcs = lacertaVcsFactory.create(this.documentId);
lacertaVcs.getRevisionHistory().thenAccept(revList -> {
adapter.setRevList(revList);
adapter.notifyDataSetChanged(); // TODO-rca:時間に応じてアニメーションをつける
});
builder.setTitle(title == null ? "Select Rev" : title);
builder.setMessage(message == null ? "Select Rev" : message);
builder.setNegativeButton(negativeButtonText == null ? "Cancel" : negativeButtonText, (dialog, which) -> {
if (listener != null) {
listener.onDialogCanceled();
dismiss();
}
});
return builder.create();
}
}

View File

@ -1,6 +0,0 @@
package one.nem.lacerta.component.common;
public interface LacertaSelectRevDialogInternalListener {
void onItemSelected(String revId);
}

View File

@ -1,8 +0,0 @@
package one.nem.lacerta.component.common;
public interface LacertaSelectRevDialogListener {
void onItemSelected(String revId);
void onDialogCanceled();
}

View File

@ -1,100 +0,0 @@
package one.nem.lacerta.component.common;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
public class SelectDirDialogItemAdapter extends RecyclerView.Adapter<SelectDirDialogItemAdapter.SelectDirDialogItemViewHolder> {
private LibraryItemPage libraryItemPage;
LacertaSelectDirDialogInternalEventListener listener;
public SelectDirDialogItemAdapter(LacertaSelectDirDialogInternalEventListener listener) {
this.listener = listener;
}
public void setListItems(LibraryItemPage libraryItemPage) {
this.libraryItemPage = libraryItemPage;
if (this.libraryItemPage.getPageId() != null) { // ルートディレクトリの場合は戻るボタンを表示しない
this.libraryItemPage.getListItems().add(0, new ListItem("戻る", " ", ListItemType.ITEM_TYPE_ACTION_BACK, null));
}
}
@NonNull
@Override
public SelectDirDialogItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
return new SelectDirDialogItemViewHolder(view);
}
@Override
public void onBindViewHolder(SelectDirDialogItemViewHolder holder, int position) {
ListItem listItem = libraryItemPage.getListItems().get(position);
holder.title.setText(listItem.getTitle());
holder.description.setText(listItem.getDescription());
holder.icon.setImageResource(listItem.getItemType().getIconId());
if(listItem.getItemType() == ListItemType.ITEM_TYPE_ACTION_BACK) {
holder.itemView.setOnClickListener(v -> listener.onBackSelected(this.libraryItemPage.getParentId()));
} else {
holder.itemView.setOnClickListener(v -> listener.onDirSelected(listItem.getTitle(), listItem.getItemId()));
}
}
@Override
public int getItemCount() {
return this.libraryItemPage == null ? 0 : this.libraryItemPage.getListItems().size();
}
public String getCurrentId() {
if (this.libraryItemPage == null) {
return null;
} else {
if (this.libraryItemPage.getPageId() == null) {
return null;
} else {
return this.libraryItemPage.getPageId();
}
}
}
public String getCurrentPageTitle() {
if (this.libraryItemPage == null) {
return null;
} else {
if (this.libraryItemPage.getPageId() == null) {
return null;
} else {
return this.libraryItemPage.getPageTitle();
}
}
}
public static class SelectDirDialogItemViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView description;
ImageView icon;
public SelectDirDialogItemViewHolder(@NonNull View itemView) {
super(itemView);
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
description.setVisibility(View.GONE); // 暫定
}
}
}

View File

@ -1,66 +0,0 @@
package one.nem.lacerta.component.common;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import one.nem.lacerta.model.VcsRevModel;
public class SelectRevDialogItemAdapter extends RecyclerView.Adapter<SelectRevDialogItemAdapter.SelectRevDialogItemViewHolder>{
ArrayList<VcsRevModel> revList;
LacertaSelectRevDialogInternalListener listener;
public SelectRevDialogItemAdapter(LacertaSelectRevDialogInternalListener listener) {
this.listener = listener;
}
public void setRevList(ArrayList<VcsRevModel> revList) {
this.revList = revList;
}
@NonNull
@Override
public SelectRevDialogItemAdapter.SelectRevDialogItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.common_rev_list_item, parent, false);
return new SelectRevDialogItemAdapter.SelectRevDialogItemViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull SelectRevDialogItemAdapter.SelectRevDialogItemViewHolder holder, int position) {
VcsRevModel rev = revList.get(position);
holder.title.setText(rev.getCommitMessage());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
holder.description.setText(simpleDateFormat.format(rev.getCreatedAt()));
holder.revId.setText("RevID: " + rev.getId());
holder.itemView.setOnClickListener(v -> listener.onItemSelected(rev.getId()));
}
@Override
public int getItemCount() {
return this.revList == null ? 0 : this.revList.size();
}
public class SelectRevDialogItemViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView description;
TextView revId;
public SelectRevDialogItemViewHolder(@NonNull View itemView) {
super(itemView);
title = itemView.findViewById(R.id.rev_item_title);
description = itemView.findViewById(R.id.rev_item_detail);
revId = itemView.findViewById(R.id.rev_item_id);
}
}
}

View File

@ -1,31 +0,0 @@
package one.nem.lacerta.component.common.model;
import one.nem.lacerta.model.document.tag.DocumentTag;
// TODO-rca: クラス名が長すぎ
/**
* DocumentTagを設定するダイアログで使うための拡張モデル
* チェックボックスの状態を保持するように
*/
public class DocumentTagApplyTagDialogExtendedModel extends DocumentTag {
private boolean isChecked;
public DocumentTagApplyTagDialogExtendedModel(DocumentTag documentTag) {
super(documentTag.getId(), documentTag.getName(), documentTag.getColor());
}
public DocumentTagApplyTagDialogExtendedModel(DocumentTag documentTag, boolean isChecked) {
super(documentTag.getId(), documentTag.getName(), documentTag.getColor());
this.isChecked = isChecked;
}
public boolean getIsChecked() {
return isChecked;
}
public void setIsChecked(boolean checked) {
isChecked = checked;
}
}

View File

@ -1,115 +0,0 @@
package one.nem.lacerta.component.common.picker;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.component.common.R;
import one.nem.lacerta.component.common.picker.base.LacertaFilePickerAdapterBase;
import one.nem.lacerta.component.common.picker.base.LacertaFilePickerDialogBase;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.PublicPath;
@AndroidEntryPoint
public class LacertaDirPickerDialog extends LacertaFilePickerDialogBase {
@Inject
LacertaLibrary lacertaLibrary;
// Listener
public interface LacertaDirPickerDialogListener {
void onDirSelected(String name, String dirId);
}
// Variables
LacertaDirPickerDialogListener listener;
// Setter
public LacertaDirPickerDialog setListener(LacertaDirPickerDialogListener listener) {
this.listener = listener;
return this;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity());
View view = LayoutInflater.from(getActivity()).inflate(R.layout.lacerta_dialog_select_dir, null);
// 高さを画面の40%にする
int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.4);
view.setMinimumHeight(height);
RecyclerView recyclerView = view.findViewById(R.id.select_dir_recycler_view);
TextView currentDirTextView = view.findViewById(R.id.current_dir_text_view);
LacertaFilePickerAdapterBase adapter = new LacertaFilePickerAdapterBase();
adapter.setListener(new LacertaFilePickerAdapterBase.LacertaFilePickerAdapterListener() {
@Override
public void onItemSelected(String dirId) {
updateList(adapter, dirId);
updatePublicPath(currentDirTextView, dirId);
}
@Override
public void onBackSelected(String dirId) {
updateList(adapter, dirId);
updatePublicPath(currentDirTextView, dirId);
}
});
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
this.updateList(adapter, null); // ルートディレクトリのリストを表示
// Init dialog
builder.setTitle(this.title == null ? "フォルダを選択" : this.title);
builder.setMessage(this.message == null ? "フォルダを選択してください" : this.message);
builder.setView(view);
builder.setPositiveButton(this.positiveButtonText == null ? "OK" : this.positiveButtonText, (dialog, which) -> {
if (listener != null) {
listener.onDirSelected(
adapter.getCurrentPageTitle(),
adapter.getCurrentId());
}
});
builder.setNegativeButton(this.negativeButtonText == null ? "キャンセル" : this.negativeButtonText, (dialog, which) -> {
if (listener != null) {
dismiss();
}
});
return builder.create();
}
private void updatePublicPath(TextView currentDirTextView, String folderId) {
lacertaLibrary.getPublicPath(folderId, ListItemType.ITEM_TYPE_FOLDER).thenAccept(publicPath -> {
this.updatePathTextView(currentDirTextView, publicPath, ListItemType.ITEM_TYPE_FOLDER);
});
}
private void updateList(LacertaFilePickerAdapterBase adapter, String folderId) {
lacertaLibrary.getFolderList(folderId).thenAccept(libraryItemPage -> {
int currentCount = adapter.getItemCount();
String currentId = adapter.getCurrentId();
// adapter.setListItems(libraryItemPage);
getActivity().runOnUiThread(() -> {
this.updateListView(adapter, libraryItemPage, currentCount, currentId);
});
});
}
}

View File

@ -1,42 +0,0 @@
package one.nem.lacerta.component.common.picker;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import one.nem.lacerta.component.common.picker.base.LacertaFilePickerAdapterBase;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
public class LacertaFilePickerAdapter extends LacertaFilePickerAdapterBase {
// Listener
public interface LacertaFilePickerAdapterListener extends LacertaFilePickerAdapterBase.LacertaFilePickerAdapterListener {
void onDocumentSelected(String documentId);
void onCombinedDocumentSelected(String documentId);
}
// Variables
LacertaFilePickerAdapterListener listener;
// Setter
public LacertaFilePickerAdapter setListener(LacertaFilePickerAdapterListener listener) {
this.listener = listener;
return this;
}
@Override
public void onBindViewHolder(LacertaFilePickerViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
if (libraryItemPage.getListItems().get(position).getItemType() == ListItemType.ITEM_TYPE_DOCUMENT) {
if (libraryItemPage.getListItems().get(position).getHasCombined()) {
holder.itemView.setOnClickListener(v -> {
listener.onCombinedDocumentSelected(libraryItemPage.getListItems().get(position).getItemId());
});
} else {
holder.itemView.setOnClickListener(v -> {
ListItem listItem = libraryItemPage.getListItems().get(position);
listener.onDocumentSelected(listItem.getItemId());
});
}
}
}
}

View File

@ -1,127 +0,0 @@
package one.nem.lacerta.component.common.picker;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.component.common.R;
import one.nem.lacerta.component.common.picker.base.LacertaFilePickerAdapterBase;
import one.nem.lacerta.component.common.picker.base.LacertaFilePickerDialogBase;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.ListItemType;
@AndroidEntryPoint
public class LacertaFilePickerDialog extends LacertaFilePickerDialogBase {
@Inject
LacertaLibrary lacertaLibrary;
// Listener
public interface LacertaFilePickerDialogListener {
void onFileSelected(String name, String fileId);
}
// Variables
LacertaFilePickerDialogListener listener;
// Setter
public LacertaFilePickerDialog setListener(LacertaFilePickerDialogListener listener) {
this.listener = listener;
return this;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity());
View view = LayoutInflater.from(getActivity()).inflate(R.layout.lacerta_dialog_select_dir, null);
// 高さを画面の40%にする
int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.4);
view.setMinimumHeight(height);
RecyclerView recyclerView = view.findViewById(R.id.select_dir_recycler_view);
TextView currentDirTextView = view.findViewById(R.id.current_dir_text_view);
LacertaFilePickerAdapter adapter = new LacertaFilePickerAdapter();
adapter.setListener(new LacertaFilePickerAdapter.LacertaFilePickerAdapterListener() {
@Override
public void onItemSelected(String dirId) {
updateList(adapter, dirId);
updatePublicPath(currentDirTextView, dirId);
}
@Override
public void onBackSelected(String dirId) {
updateList(adapter, dirId);
updatePublicPath(currentDirTextView, dirId);
}
@Override
public void onDocumentSelected(String documentId) {
if (listener != null) {
dismiss();
listener.onFileSelected(documentId, documentId);
}
}
@Override
public void onCombinedDocumentSelected(String documentId) {
if (listener != null) {
LacertaFilePickerSelectDocumentDialog dialog = new LacertaFilePickerSelectDocumentDialog();
dialog.setDocumentId(documentId);
dialog.setListener(documentId1 -> {
dismiss();
listener.onFileSelected(documentId1, documentId1);
});
dialog.show(getParentFragmentManager(), "select_document_dialog");
}
}
});
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
this.updateList(adapter, null); // ルートディレクトリのリストを表示
// Init dialog
builder.setTitle(this.title == null ? "ファイルを選択" : this.title);
builder.setMessage(this.message == null ? "ファイルを選択してください" : this.message);
builder.setView(view);
builder.setNegativeButton(this.negativeButtonText == null ? "キャンセル" : this.negativeButtonText, (dialog, which) -> {
dismiss();
});
return builder.create();
}
private void updatePublicPath(TextView currentDirTextView, String folderId) {
lacertaLibrary.getPublicPath(folderId, ListItemType.ITEM_TYPE_FOLDER).thenAccept(publicPath -> {
this.updatePathTextView(currentDirTextView, publicPath, ListItemType.ITEM_TYPE_FOLDER);
});
}
private void updateList(LacertaFilePickerAdapterBase adapter, String folderId) {
lacertaLibrary.getLibraryPage(folderId, 100).thenAccept(libraryItemPage -> { // TODO-rca: 100 is a magic number
int currentCount = adapter.getItemCount();
String currentId = adapter.getCurrentId();
// adapter.setListItems(libraryItemPage);
getActivity().runOnUiThread(() -> {
this.updateListView(adapter, libraryItemPage, currentCount, currentId);
});
});
}
}

View File

@ -1,75 +0,0 @@
package one.nem.lacerta.component.common.picker;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import one.nem.lacerta.component.common.R;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.document.DocumentMeta;
public class LacertaFilePickerSelectDocumentAdapter extends RecyclerView.Adapter<LacertaFilePickerSelectDocumentAdapter.LacertaFilePickerSelectDocumentViewHolder>{
// Listener
public interface LacertaFilePickerSelectDocumentAdapterListener {
void onDocumentSelected(String documentId);
}
// Variables
LacertaFilePickerSelectDocumentAdapterListener listener;
ArrayList<ListItem> listItems;
// Setter
public LacertaFilePickerSelectDocumentAdapter setListener(LacertaFilePickerSelectDocumentAdapterListener listener) {
this.listener = listener;
return this;
}
public void setListItems(ArrayList<ListItem> listItems) {
this.listItems = listItems;
}
@NonNull
@Override
public LacertaFilePickerSelectDocumentAdapter.LacertaFilePickerSelectDocumentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
return new LacertaFilePickerSelectDocumentViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull LacertaFilePickerSelectDocumentAdapter.LacertaFilePickerSelectDocumentViewHolder holder, int position) {
ListItem listItem = listItems.get(position);
holder.title.setText(listItem.getTitle());
holder.description.setVisibility(View.GONE);
holder.icon.setImageResource(listItem.getItemType().getIconId());
holder.itemView.setOnClickListener(v -> listener.onDocumentSelected(listItem.getItemId()));
}
@Override
public int getItemCount() {
return listItems == null ? 0 : listItems.size();
}
public class LacertaFilePickerSelectDocumentViewHolder extends RecyclerView.ViewHolder {
ImageView icon;
TextView title;
TextView description;
public LacertaFilePickerSelectDocumentViewHolder(@NonNull View itemView) {
super(itemView);
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
}
}
}

View File

@ -1,88 +0,0 @@
package one.nem.lacerta.component.common.picker;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.ArrayList;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.component.common.R;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.pref.ToxiDocumentModel;
@AndroidEntryPoint
public class LacertaFilePickerSelectDocumentDialog extends DialogFragment {
@Inject
LacertaLibrary lacertaLibrary;
// Listener
public interface LacertaFilePickerSelectDocumentDialogListener {
void onDocumentSelected(String documentId);
}
// Variables
LacertaFilePickerSelectDocumentDialogListener listener;
String documentId;
// Setter
public LacertaFilePickerSelectDocumentDialog setListener(LacertaFilePickerSelectDocumentDialogListener listener) {
this.listener = listener;
return this;
}
public LacertaFilePickerSelectDocumentDialog setDocumentId(String documentId) {
this.documentId = documentId;
return this;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity());
View view = LayoutInflater.from(getActivity()).inflate(R.layout.lacerta_dialog_select_doc, null);
// 高さを画面の40%にする
int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.4);
view.setMinimumHeight(height);
RecyclerView recyclerView = view.findViewById(R.id.document_list_recycler_view);
LacertaFilePickerSelectDocumentAdapter adapter = new LacertaFilePickerSelectDocumentAdapter();
adapter.setListener(documentId -> listener.onDocumentSelected(documentId));
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
builder.setTitle("追加先を選択");
builder.setView(view);
lacertaLibrary.getCombinedDocumentToxiList(this.documentId).thenAccept(toxiDocumentModels -> {
ArrayList<ListItem> listItems = new ArrayList<>();
for (ToxiDocumentModel toxiDocumentModel : toxiDocumentModels) {
listItems.add(new ListItem(toxiDocumentModel.titleCache, null, ListItemType.ITEM_TYPE_DOCUMENT, toxiDocumentModel.childDocumentId));
}
adapter.setListItems(listItems);
adapter.notifyDataSetChanged();
});
return builder.create();
}
}

View File

@ -1,110 +0,0 @@
package one.nem.lacerta.component.common.picker.base;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
public class LacertaFilePickerAdapterBase extends RecyclerView.Adapter<LacertaFilePickerAdapterBase.LacertaFilePickerViewHolder> {
// Listener
public interface LacertaFilePickerAdapterListener {
void onItemSelected(String dirId);
void onBackSelected(String dirId);
}
protected LibraryItemPage libraryItemPage;
protected LacertaFilePickerAdapterListener listener;
// Empty constructor
public LacertaFilePickerAdapterBase() {
}
public void setListItems(LibraryItemPage libraryItemPage) {
this.libraryItemPage = libraryItemPage;
if (this.libraryItemPage.getPageId() != null) { // ルートディレクトリの場合は戻るボタンを表示しない
this.libraryItemPage.getListItems().add(0, new ListItem("戻る", " ", ListItemType.ITEM_TYPE_ACTION_BACK, null));
}
}
public void setListener(LacertaFilePickerAdapterListener listener) {
this.listener = listener;
}
@NonNull
@Override
public LacertaFilePickerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.common_list_item, parent, false);
return new LacertaFilePickerViewHolder(view);
}
@Override
public void onBindViewHolder(LacertaFilePickerViewHolder holder, int position) {
ListItem listItem = libraryItemPage.getListItems().get(position);
holder.title.setText(listItem.getTitle());
holder.description.setText(listItem.getDescription());
holder.icon.setImageResource(listItem.getItemType().getIconId());
if(listItem.getItemType() == ListItemType.ITEM_TYPE_ACTION_BACK) {
holder.itemView.setOnClickListener(v -> listener.onBackSelected(this.libraryItemPage.getParentId()));
} else {
holder.itemView.setOnClickListener(v -> listener.onItemSelected(listItem.getItemId()));
}
}
@Override
public int getItemCount() {
return this.libraryItemPage == null ? 0 : this.libraryItemPage.getListItems().size();
}
public String getCurrentId() {
if (this.libraryItemPage == null) {
return null;
} else {
if (this.libraryItemPage.getPageId() == null) {
return null;
} else {
return this.libraryItemPage.getPageId();
}
}
}
public String getCurrentPageTitle() {
if (this.libraryItemPage == null) {
return null;
} else {
if (this.libraryItemPage.getPageId() == null) {
return null;
} else {
return this.libraryItemPage.getPageTitle();
}
}
}
public static class LacertaFilePickerViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView description;
ImageView icon;
public LacertaFilePickerViewHolder(@NonNull View itemView) {
super(itemView);
title = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_title);
description = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_description);
icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.item_icon);
description.setVisibility(View.GONE); // 暫定
}
}
}

View File

@ -1,88 +0,0 @@
package one.nem.lacerta.component.common.picker.base;
import android.widget.TextView;
import androidx.fragment.app.DialogFragment;
import javax.inject.Inject;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.PublicPath;
import one.nem.lacerta.utils.LacertaLogger;
public class LacertaFilePickerDialogBase extends DialogFragment {
@Inject
LacertaLogger logger;
// Variables
protected String title;
protected String message;
protected String positiveButtonText;
protected String negativeButtonText;
// Setter
public LacertaFilePickerDialogBase setTitle(String title) {
this.title = title;
return this;
}
public LacertaFilePickerDialogBase setMessage(String message) {
this.message = message;
return this;
}
public LacertaFilePickerDialogBase setPositiveButtonText(String positiveButtonText) {
this.positiveButtonText = positiveButtonText;
return this;
}
public LacertaFilePickerDialogBase setNegativeButtonText(String negativeButtonText) {
this.negativeButtonText = negativeButtonText;
return this;
}
// Methods
protected void updatePathTextView(TextView currentDirTextView, PublicPath publicPath, ListItemType listItemType) {
if (publicPath == null) {
currentDirTextView.setText("/");
} else {
if (listItemType == ListItemType.ITEM_TYPE_FOLDER) {
currentDirTextView.setText("/" + publicPath.getStringPath()); // TODO-rca: PublicPath側の実装を治すべき
} else {
currentDirTextView.setText("/" + publicPath.parent().getStringPath()); // TODO-rca: PublicPath側の実装を治すべき
}
}
}
protected void updateListView(LacertaFilePickerAdapterBase adapter, LibraryItemPage libraryItemPage, int currentCount, String currentDirId) {
if (currentCount == 0) {
// 初回表示
adapter.setListItems(libraryItemPage);
adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size());
} else if (currentDirId == null) {
// Rootが関わる推移 (Rootからの推移)
adapter.setListItems(libraryItemPage);
adapter.notifyItemRangeRemoved(0, currentCount);
adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size());
} else if (libraryItemPage.getPageId() == null) {
// Rootが関わる推移 (Rootへの推移)
adapter.setListItems(libraryItemPage);
adapter.notifyItemRangeRemoved(0, currentCount);
adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size());
} else if (libraryItemPage.getPageId() != null) {
// Rootが関わらない推移
adapter.setListItems(libraryItemPage);
adapter.notifyItemRangeRemoved(1, currentCount);
adapter.notifyItemRangeInserted(1, libraryItemPage.getListItems().size());
} else {
// その他の遷移(安全側に倒すため全アイテム更新)
logger.warn("FilePickerDialogBase", "Unknown transition.");
logger.warn("FilePickerDialogBase", "currentDirId: " + currentDirId + ", libraryItemPage.getPageId(): " + libraryItemPage.getPageId());
adapter.setListItems(libraryItemPage);
adapter.notifyItemRangeRemoved(0, currentCount);
adapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size());
}
}
}

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/tag_check_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="4dp"
android:text="CheckBox" />
</LinearLayout>

View File

@ -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:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="24dp"
android:paddingVertical="16dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/item_text_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/rev_item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginEnd="8dp"
android:text="Placeholder Title"
android:textColor="@color/colorOnSurface"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/rev_item_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="2023/01/01 00:00:00 - hogehoge"
android:textColor="@color/colorOnSurfaceSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rev_item_title" />
<TextView
android:id="@+id/rev_item_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:text="dd76a029-51f1-40f7-b316-a0c74bbfebb1(Example)"
android:textColor="@color/colorOnSurfaceSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rev_item_detail" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/apply_tag_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tag_name_text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingHorizontal="16dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/tag_name_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tag_color_text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingHorizontal="16dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<!-- todo: add color picker -->
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/tag_color_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/title_text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingHorizontal="16dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/tag_name_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/current_dir_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/select_dir_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
</LinearLayout>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/document_list_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
</FrameLayout>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/select_rev_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>

View File

@ -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,28 +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')
implementation project(':component:common')
}

View File

@ -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>

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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));
}
}

View File

@ -1,333 +0,0 @@
package one.nem.lacerta.component.scanner;
import android.Manifest;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
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.component.common.picker.LacertaFilePickerDialog;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.page.Page;
import one.nem.lacerta.processor.DocumentProcessor;
import one.nem.lacerta.processor.factory.DocumentProcessorFactory;
import one.nem.lacerta.utils.LacertaLogger;
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;
// @Inject
// public ScannerManagerActivity(LacertaLogger logger, Document document, LacertaLibrary lacertaLibrary, DocumentProcessorFactory documentProcessorFactory, LacertaVcsFactory lacertaVcsFactory) {
// this.logger = logger;
// this.document = document;
// this.lacertaLibrary = lacertaLibrary;
// this.documentProcessorFactory = documentProcessorFactory;
// this.lacertaVcsFactory = lacertaVcsFactory;
// }
@Inject
public ScannerManagerActivity() {
// Required empty public constructor
}
// Variables
private ArrayList<Bitmap> croppedImages = new ArrayList<>();
private boolean update = false;
private String documentId;
private int index = 0;
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
);
DocumentScanner documentScannerUpdate = new DocumentScanner( // TODO-rca: ひどすぎるのでなんとかする
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);
updatePage();
return null;
},
(errorMessage) -> {
// an error happened
logger.error(TAG, "Error: " + errorMessage);
logger.e_code("543a230e-cb9a-47a2-8131-3beecfe1c458");
finish();
return null;
},
() -> {
// user canceled document scan
logger.debug(TAG, "User canceled document scan");
finish();
return null;
},
null,
null,
1
);
@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;
});
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 1); // TODO-rca: リクエストコードを定数にする
}
MaterialToolbar toolbar = findViewById(R.id.top_toolbar);
setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
if (bundle != null) {
update = bundle.getBoolean("update", false);
documentId = bundle.getString("documentId");
index = bundle.getInt("index", 0);
}
if (this.update) {
documentScanner = documentScannerUpdate;
}
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) {
// 新ドキュメントとして保存
saveNewDocument();
return true;
}
else if (item.getItemId() == R.id.action_insert_exist) {
// 既存ドキュメントに挿入
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");
} 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, "Initial Commit").join();
document.updateDocument(documentDetail).join();
dialog.dismiss();
finish();
});
}
private CompletableFuture<Void> addPagesToDocumentDetail(DocumentDetail documentDetail, Bitmap[] bitmaps, String commitMessage) {
return CompletableFuture.runAsync(() -> {
try {
document.updateDocument(documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps).getDocumentDetail()).join();
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent(commitMessage == null ? "NONE" : commitMessage);
} catch (Exception e) {
logger.error(TAG, "Error: " + e.getMessage());
logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a");
}
});
}
private void updatePage() {
logger.debug(TAG, "updatePage");
// Deprecatedだが中断機能が存在しないので操作をブロックする目的で(意図的に)使用
ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("保存中..."); // TODO-rca: テキストをリソースに移動
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
dialog.show();
document.getDocument(documentId).thenAccept((documentDetail) -> {
DocumentProcessor documentProcessor = documentProcessorFactory.create(documentDetail);
if (croppedImages.size() != 1) {
logger.error(TAG, "croppedImages.size() != 1");
logger.e_code("d8e2b8c9-9b7e-4b7e-9e1e-9e3b8b8b8b8b");
return;
}
if (croppedImages.get(0) == null) {
logger.error(TAG, "croppedImages.get(0) == null");
logger.e_code("d8e2b8c9-9b7e-4b7e-9e1e-9e3b8b8b8b8b");
return;
}
documentProcessor.updatePageAtIndex(croppedImages.get(0), index);
document.updateDocument(documentProcessor.getDocumentDetail()).join();
lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent(index + "ページ目を更新"); // TODO-rca: メッセージを動的にする, 指定できるようにする
dialog.dismiss();
});
}
private void insertToExistDocument() {
logger.debug(TAG, "insertToExistDocument");
LacertaFilePickerDialog dialog = new LacertaFilePickerDialog();
dialog.setListener(((name, fileId) -> {
document.getDocument(fileId).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();
finish();
});
}));
dialog.setTitle("追加するドキュメントを選択");
dialog.show(getSupportFragmentManager(), "LacertaFilePickerDialog");
}
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);
}
selectedImage.setImageBitmap(resultImages.get(0));
}
}

View File

@ -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);
});
}
}

View File

@ -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
);
}
}

View File

@ -0,0 +1,64 @@
package one.nem.lacerta.component.scanner;
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 ScannerScanResultFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class ScannerScanResultFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
public ScannerScanResultFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment ScannerScanResultFragment.
*/
// TODO: Rename and change types and number of parameters
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);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_scanner_scan_result, container, false);
}
}

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -3,10 +3,12 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ViewerVcsRevListFragment">
tools:context=".ScannerScanFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rev_list"
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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/description_24px"
android:title="Insert"
app:showAsAction="ifRoom"/>
</menu>

View File

@ -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,39 +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')
implementation project(':vcs')
implementation project(':component:common')
// TODO-rca:
implementation "com.hendraanggrian.material:collapsingtoolbarlayout-subtitle:1.5.0"
// ViewPager2
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation project(':component:scanner') //
}

View File

@ -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>

View File

@ -1,73 +0,0 @@
package one.nem.lacerta.component.viewer.BookMark;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import java.util.UUID;
import javax.inject.Inject;
import one.nem.lacerta.component.viewer.R;
// BookMarkFragment.java
public class BookMarkFragment extends Fragment {
@Inject
BookmarkRepository bookmarkRepository;
private GestureDetector gestureDetector;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_bookmark, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
gestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
// ダブルタップが検出された時の処理
handleDoubleTap();
return true;
}
});
// ブックマークボタンがダブルタップされた時の処理
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
});
}
private void handleDoubleTap() {
// ダブルタップが検出された時の処理
// ブックマークを作成
String pageId = "current_page_id";
String title = "current_page_title";
Bookmark bookmark = new Bookmark(
UUID.randomUUID().toString(),
title,
pageId,
System.currentTimeMillis()
);
// ブックマークを保存
bookmarkRepository.addBookmark(bookmark);
// ユーザーに成功メッセージを表示
Toast.makeText(getContext(), "ダブルタップでブックマークが追加されました", Toast.LENGTH_SHORT).show();
}
}

Some files were not shown because too many files have changed in this diff Show More