Compare commits

...
126 Commits
Author SHA1 Message Date
r-ca 8f0bdbb89a hasCombined対応 2024-01-28 15:15:33 +09:00
r-ca 289f70c6cb ボタンに仮のリスナーを追加 2024-01-28 15:13:20 +09:00
r-ca fa9b86e909 レイアウト調整 2024-01-28 15:09:18 +09:00
r-ca 88c801aedf アイコンリソース追加 2024-01-28 15:03:27 +09:00
r-ca 6f9384039a カスタムタブレイアウト実装 WIP 2024-01-28 15:01:51 +09:00
r-ca 457eabcdf4 カスタムタブレイアウト作成 WIP 2024-01-28 14:57:41 +09:00
r-ca fa985b86bd 修正 2024-01-28 14:40:58 +09:00
r-ca 0dafecc75d Combine処理の変更に追従 2024-01-28 14:13:53 +09:00
r-ca 47c6478227 Combine処理の変更に追従 2024-01-28 14:13:47 +09:00
r-ca 671718ba83 Combine処理を変更 2024-01-28 14:13:17 +09:00
r-ca 0210bcaeb6 タイトルを表示できるように WIP 2024-01-28 14:07:23 +09:00
r-ca 3a13b8e4b7 親要素を追加するように 2024-01-28 13:54:09 +09:00
r-ca b3c1f3a949 ログ追加 2024-01-28 13:51:33 +09:00
r-ca c88ab85cf2 WIP 2024-01-28 13:51:04 +09:00
r-ca 8270156373 hasCombinedを初期化するように 2024-01-28 13:49:22 +09:00
r-ca aa2ee9462f 追加 2024-01-28 13:47:48 +09:00
r-ca 8052b9b329 追加 2024-01-28 13:47:34 +09:00
r-ca b7414cf8aa 追加 2024-01-28 13:47:21 +09:00
r-ca 435fe7b3ce hasCombinedに変更 2024-01-28 13:47:08 +09:00
r-ca b86843bd57 ListItemにisCombinedを追加 2024-01-28 13:46:03 +09:00
r-ca b9c1c521cf combine実装 2024-01-28 13:43:56 +09:00
r-ca f9df1379f4 JavaDoc対応 2024-01-28 13:40:23 +09:00
r-ca 4649399ef9 Combineされていないドキュメントの場合はTabLayoutを隠すように 2024-01-28 13:30:33 +09:00
r-ca e1bc6466e7 Toolbarのinitを起動時呼び出すように 2024-01-28 13:29:04 +09:00
r-ca eeeef90ec2 ドキュメントのリネームだけ実装 2024-01-28 13:28:13 +09:00
r-ca 8038b7e198 Toolbarを処理するメソッド実装 WIP 2024-01-28 13:23:16 +09:00
r-ca 3afe8ce4cb Bodyレイアウト 2024-01-28 13:17:29 +09:00
r-ca a239fd2f9c Combineされていないときの処理を追加 2024-01-28 13:14:34 +09:00
r-ca 314214f734 ViewerMainActivityからContainerを呼び出すように 2024-01-28 13:13:51 +09:00
r-ca 92167656fc コンテナフラグメント処理実装 WIP 2024-01-28 13:12:03 +09:00
r-ca beceec0abe Combineするときのタイトルをキャッシュするように 2024-01-28 13:09:26 +09:00
r-ca 0a96a9443d インターフェース変更, Impl変更 2024-01-28 13:07:32 +09:00
r-ca ff5ef8611a ToxiDocumentModel実装 2024-01-28 13:03:57 +09:00
r-ca 9110352f68 DBのバージョンをインクリメント 2024-01-28 13:00:42 +09:00
r-ca a2a3d2ab54 ToxiテーブルのEntityにタイトルのキャッシュを追加 2024-01-28 13:00:14 +09:00
r-ca 5f0e88d804 Adapter実装修正 2024-01-28 12:54:41 +09:00
r-ca 874946a38d ViewPager2に変更 2024-01-28 12:52:41 +09:00
r-ca 6ec0710bac 引数処理実装 2024-01-28 12:51:38 +09:00
r-ca adcf9f16b9 ViewerBodyFragment処理実装WIP 2024-01-28 12:49:58 +09:00
r-ca b7822945fd 引数処理, LoadDocumentメソッド実装 2024-01-28 12:49:06 +09:00
r-ca 2812b02ba2 Factoryメソッド実装 2024-01-28 12:39:10 +09:00
r-ca e6cdba337e HiltのInjectを追加 2024-01-28 12:37:48 +09:00
r-ca bd1ea74c4c PagerAdapter実装WIP 2024-01-28 12:35:16 +09:00
r-ca adb60b7fb2 依存関係にViewPager2を追加 2024-01-28 12:31:11 +09:00
r-ca a0dc49ab95 引数削除 2024-01-28 12:25:02 +09:00
r-ca f693c5e88b Bodyフラグメント作成 2024-01-28 12:24:45 +09:00
r-ca a349bc7317 引数削除 2024-01-28 12:23:59 +09:00
r-ca f9938867ae コンテナフラグメント作成 2024-01-28 12:23:31 +09:00
r-ca 79beb8f87f 結合アクションを実装 2024-01-28 11:44:05 +09:00
r-ca 8e1127586d 主キー指定漏れ 2024-01-28 11:39:23 +09:00
r-ca ff210f50a9 メニューにアイテムを追加 2024-01-28 11:34:58 +09:00
r-ca 6fbe4081d2 Merge branch 'develop' into combined_doc 2024-01-28 11:33:31 +09:00
ろむねこ e517e08b51 Merge pull request #120 from lacerta-doc/component/common/file_picker
ファイルピッカーを実装
2024-01-28 11:33:07 +09:00
r-ca 63f1dff6f0 修正忘れ対処 2024-01-28 11:31:55 +09:00
r-ca 8ec4e51eb0 不要なチェックを削除 2024-01-28 11:29:24 +09:00
r-ca b29df41b5e ファイルピッカー実装 2024-01-28 11:28:48 +09:00
r-ca 9978b26ace Baseを継承したアダプタを作成 2024-01-28 11:27:25 +09:00
r-ca f3afb68b18 継承先で使いたいのでProtectedに変更 2024-01-28 11:24:36 +09:00
r-ca 98e0ea6f85 クラス作成 2024-01-28 11:14:31 +09:00
ろむねこ f29e626f03 Merge pull request #119 from lacerta-doc/component/common/picker_improve
DirPicker改善
2024-01-28 11:12:40 +09:00
r-ca 383a7020ce 新ダイアログに変更 2024-01-28 11:02:44 +09:00
r-ca f71aabed2a リファクタリング 2024-01-28 11:02:28 +09:00
r-ca 8256d01682 ダイアログ高さ指定, 2024-01-28 11:02:23 +09:00
r-ca 4d7f38a0f7 PublicPathの生成ロジックを変更 2024-01-28 10:59:28 +09:00
r-ca 13e8ee7d87 データセット更新をUiスレッドでやるように(IndexOutOfBounds対策, デバイスのスペックなどの都合で挿入が更新に追いつかないと壊れるため) 2024-01-28 10:58:22 +09:00
r-ca 41776b360b updatePathTextViewをBase側に追加 2024-01-28 10:36:30 +09:00
r-ca 8a656f673d メソッドリネーム 2024-01-28 10:34:22 +09:00
r-ca e5ba889780 Setterをメソッドチェーンに対応 2024-01-28 10:31:40 +09:00
r-ca c717f4c596 新DirPicker実装 2024-01-28 10:28:48 +09:00
r-ca be64f5a186 Adapter, Dialogベース実装 2024-01-28 10:28:38 +09:00
r-ca 1654700ee0 クラス変数とSetterをBaseに移動 2024-01-28 10:11:26 +09:00
r-ca 7a106b1ed3 FilePickerDialogBase実装 WIP 2024-01-28 09:56:37 +09:00
r-ca 97b1806407 ディレクトリ整理 2024-01-28 09:26:22 +09:00
r-ca d7bfcd8970 getCombinedDocumentIdList実装 2024-01-28 09:08:56 +09:00
r-ca 575df32157 インターフェース変更 2024-01-28 09:08:17 +09:00
r-ca 0a98cfd8a5 uncombineDocument実装 2024-01-28 09:06:56 +09:00
r-ca cd784cad15 combineDocument実装 2024-01-28 09:06:13 +09:00
r-ca 68635e2f12 Impl生成 2024-01-27 17:24:38 +09:00
r-ca 244fba1616 必要なメソッドをリポジトリに追加 2024-01-27 17:24:18 +09:00
r-ca 3ac7c4072d Documentを作成するときに正しく既定値を設定するように 2024-01-27 17:21:39 +09:00
r-ca 4bdb1a489c すべてのコンストラクタで既定値(false)を入れるように 2024-01-27 17:20:50 +09:00
r-ca 45e6b9ab05 DocumentMetaにフラグを追加, コンストラクタ, Getter/Setter追加 2024-01-27 17:20:02 +09:00
r-ca 98b141f96f DocumentDaoのSelectクエリを修正(CombineのChildを含めないように 2024-01-27 17:13:51 +09:00
r-ca 4ffcd970b4 ToxiテーブルDao実装WIP 2024-01-27 17:09:52 +09:00
r-ca e43c3beda0 ToxiテーブルのDaoを追加 2024-01-27 17:08:04 +09:00
r-ca c43b516320 エンティティをLacertaDBに追加 2024-01-27 17:07:05 +09:00
r-ca e1f2a43d0b Toxiテーブル作成 2024-01-27 17:06:24 +09:00
r-ca 217b152c47 子/親をDocumentEntity単体で管理するように 2024-01-27 17:04:50 +09:00
r-ca a187ef3523 Revert "CombineDocumentEntity作成"
This reverts commit 74563f75b1.
2024-01-27 17:03:46 +09:00
r-ca 74563f75b1 CombineDocumentEntity作成 2024-01-27 17:03:25 +09:00
r-ca 055f1fdae1 DocumentEntityにisCombinedフラグを追加 2024-01-27 16:54:19 +09:00
ろむねこ 77830ca96b Merge pull request #118 from lacerta-doc/improve/ui3
UI改善
2024-01-27 16:33:22 +09:00
r-ca bda2b82cea アイコンに合わせてプロパティ名を変更 2024-01-27 16:23:35 +09:00
r-ca c05c80f3e7 アイコン変更 2024-01-27 16:22:59 +09:00
r-ca 9ba3c224c4 リファクタリング 2024-01-27 16:22:34 +09:00
r-ca 603a758ab6 不要なコードの削除, テキストを明示 2024-01-27 16:21:41 +09:00
r-ca c7f5502535 選択されたRevisionに推移できるように 2024-01-27 16:20:11 +09:00
r-ca 7ef75bb375 negativeButtonTextが指定されていない場合の既定値を追加 2024-01-27 16:17:52 +09:00
r-ca 78d4345313 イベントを受け取るように WIP 2024-01-27 16:17:09 +09:00
r-ca 542c04b908 アイテムにタッチリスナーを追加 2024-01-27 16:16:52 +09:00
r-ca cf257a44ec レイアウト修正 2024-01-27 16:13:01 +09:00
r-ca f812e6c38e 実際にRevisionを表示するように 2024-01-27 16:09:26 +09:00
r-ca 87c913811b 依存関係追加 2024-01-27 16:03:33 +09:00
r-ca 3cfd54faf0 RevDialog実装WIP 2024-01-27 16:01:03 +09:00
r-ca ffeb701b40 RevDialogAdapter実装WIP 2024-01-27 15:26:18 +09:00
r-ca c48e5becac レイアウトコピー 2024-01-27 15:16:58 +09:00
r-ca 7291ab243e イベントリスナ作成 2024-01-27 15:08:32 +09:00
r-ca a34109441f Rev選択画面のダイアログレイアウト作成 2024-01-27 15:04:09 +09:00
r-ca 75045c3fe3 検証用に設定したアニメーションをもとに戻した 2024-01-27 15:00:38 +09:00
r-ca 733371ecbc 検証用に設定したアニメーションをもとに戻した 2024-01-27 14:50:41 +09:00
r-ca 5096e8de23 iroiro 2024-01-27 14:36:06 +09:00
r-ca 6679f8389c ライブラリ画面のアニメーションを明示 2024-01-26 20:17:47 +09:00
r-ca 8df63b0ac6 アニメーションリソースをいくつか追加 2024-01-26 19:39:43 +09:00
r-ca 4df56774c3 セレクトダイアログの高さを画面の40%に変更 2024-01-26 19:38:14 +09:00
r-ca 834ee42353 リファクタ 2024-01-26 18:41:09 +09:00
r-ca 8a2b4ed12d 表示アニメーションを500ms以上かかった場合のみに 2024-01-26 18:41:05 +09:00
r-ca 58e74dbb16 表示アニメーションを500ms以上かかった場合のみに 2024-01-26 18:38:02 +09:00
r-ca 9d750b5244 リファクタリング 2024-01-26 18:33:44 +09:00
r-ca e96d213c33 パスをサブタイトルに表示するように 2024-01-26 18:33:02 +09:00
r-ca c2f62a5a84 依存関係追加 2024-01-26 18:16:24 +09:00
r-ca dbef7b45d1 ファイルのパスをサブタイトルとして表示するように 2024-01-26 18:16:00 +09:00
r-ca 3c079ffc23 SubtitleCollapsingToolbarLayoutに変更 2024-01-26 18:04:49 +09:00
r-ca f1667788aa バージョン変更 2024-01-26 18:00:46 +09:00
r-ca cad97ef7a3 Subtitle付きのCollapsingToolBarを追加 2024-01-26 17:55:18 +09:00
ろむねこ 5e5e98f0b6 Merge pull request #117 from lacerta-doc/tag/add
タグ管理画面の追加
2024-01-26 15:41:49 +09:00
ろむねこ 94def7bf1c Merge pull request #116 from lacerta-doc/tag/add
タグシステム実装 WIP
2024-01-25 16:56:03 +09:00
76 changed files with 2136 additions and 100 deletions

No files matched your search

@@ -8,9 +8,11 @@ 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;
@@ -60,6 +62,19 @@ public class MainActivity extends AppCompatActivity implements FragmentNavigatio
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");
@@ -83,7 +98,8 @@ public class MainActivity extends AppCompatActivity implements FragmentNavigatio
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);
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());
});
}
+2
View File
@@ -42,4 +42,6 @@ dependencies {
implementation project(':utils')
implementation project(':model')
implementation project(':data')
implementation project(':vcs')
}
@@ -79,8 +79,8 @@ public class LacertaSelectDirDialog extends DialogFragment {
LayoutInflater inflater = requireActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.lacerta_dialog_select_dir, null);
// 高さを画面の60%にする
int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.6);
// 高さを画面の40%にする
int height = (int) (getResources().getDisplayMetrics().heightPixels * 0.4);
view.setMinimumHeight(height);
this.recyclerView = view.findViewById(R.id.select_dir_recycler_view);
@@ -0,0 +1,112 @@
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();
}
}
@@ -0,0 +1,6 @@
package one.nem.lacerta.component.common;
public interface LacertaSelectRevDialogInternalListener {
void onItemSelected(String revId);
}
@@ -0,0 +1,8 @@
package one.nem.lacerta.component.common;
public interface LacertaSelectRevDialogListener {
void onItemSelected(String revId);
void onDialogCanceled();
}
@@ -0,0 +1,66 @@
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);
}
}
}
@@ -0,0 +1,115 @@
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);
});
});
}
}
@@ -0,0 +1,33 @@
package one.nem.lacerta.component.common.picker;
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);
}
// 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) {
holder.itemView.setOnClickListener(v -> {
ListItem listItem = libraryItemPage.getListItems().get(position);
listener.onDocumentSelected(listItem.getItemId());
});
}
}
}
@@ -0,0 +1,114 @@
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);
}
}
});
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);
});
});
}
}
@@ -0,0 +1,110 @@
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); // 暫定
}
}
}
@@ -0,0 +1,88 @@
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());
}
}
}
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="24dp"
android:paddingVertical="16dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/item_text_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/rev_item_title"
android:layout_width="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>
@@ -0,0 +1,10 @@
<?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>
+5
View File
@@ -58,4 +58,9 @@ dependencies {
implementation project(':component:common')
// TODO-rca: バージョンカタログに切り出す
implementation "com.hendraanggrian.material:collapsingtoolbarlayout-subtitle:1.5.0"
// ViewPager2
implementation "androidx.viewpager2:viewpager2:1.0.0"
}
@@ -0,0 +1,123 @@
package one.nem.lacerta.component.viewer;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.utils.LacertaLogger;
import one.nem.lacerta.vcs.LacertaVcs;
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
/**
* A simple {@link Fragment} subclass.
* Use the {@link ViewerBodyFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class ViewerBodyFragment extends Fragment {
@Inject
Document document;
@Inject
LacertaLibrary lacertaLibrary;
@Inject
LacertaLogger logger;
@Inject
LacertaVcsFactory lacertaVcsFactory;
// Variables
private String documentId;
private String documentName;
private String revisionId;
public ViewerBodyFragment() {
// Required empty public constructor
}
public static ViewerBodyFragment newInstance(String documentId, String documentName) {
ViewerBodyFragment fragment = new ViewerBodyFragment();
Bundle args = new Bundle();
args.putString("documentId", documentId);
args.putString("documentName", documentName);
fragment.setArguments(args);
return fragment;
}
public static ViewerBodyFragment newInstance(String documentId, String documentName, String revisionId) {
ViewerBodyFragment fragment = new ViewerBodyFragment();
Bundle args = new Bundle();
args.putString("documentId", documentId);
args.putString("documentName", documentName);
args.putString("revisionId", revisionId);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
documentId = getArguments().getString("documentId");
documentName = getArguments().getString("documentName");
revisionId = getArguments().getString("revisionId");
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_viewer_body, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
logger.debug("ViewerBodyFragment", "ViewerBodyFragment.onViewCreated");
RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
ViewerBodyAdapter viewerBodyAdapter = new ViewerBodyAdapter(fileName -> {
Toast.makeText(getContext(), fileName, Toast.LENGTH_SHORT).show();
// TODO-rca: なにか処理をもたせる
});
recyclerView.setAdapter(viewerBodyAdapter);
loadDocument(viewerBodyAdapter, documentId, revisionId);
}
private void loadDocument(ViewerBodyAdapter adapter, String documentId, String revisionId) {
if (revisionId == null) { // load latest revision
document.getDocument(documentId).thenAccept(document -> {
getActivity().runOnUiThread(() -> {
adapter.setPages(document.getPages());
adapter.notifyDataSetChanged();
});
});
} else { // load specified revision
LacertaVcs vcs = lacertaVcsFactory.create(documentId);
document.getDocumentPageListByFileNameList(documentId, vcs.getDocumentPagePathListRev(revisionId).join()).thenAccept(documentPageList -> {
getActivity().runOnUiThread(() -> {
adapter.setPages(documentPageList);
adapter.notifyDataSetChanged();
});
});
}
}
}
@@ -0,0 +1,243 @@
package one.nem.lacerta.component.viewer;
import android.os.Bundle;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
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.page.Page;
import one.nem.lacerta.model.pref.ToxiDocumentModel;
import one.nem.lacerta.utils.LacertaLogger;
/**
* A simple {@link Fragment} subclass.
* Use the {@link ViewerContainerFragment#newInstance} factory method to
* create an instance of this fragment.
*/
@AndroidEntryPoint
public class ViewerContainerFragment extends Fragment {
// Inject
@Inject
LacertaLogger logger;
@Inject
LacertaLibrary lacertaLibrary;
@Inject
Document document;
// Variables
private String documentId;
private String documentName;
private boolean hasCombined = false;
public ViewerContainerFragment() {
// Required empty public constructor
}
public static ViewerContainerFragment newInstance(String documentId, String documentName, boolean hasCombined) {
ViewerContainerFragment fragment = new ViewerContainerFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
args.putString("documentId", documentId);
args.putString("documentName", documentName);
args.putBoolean("hasCombined", hasCombined);
return fragment;
}
public static ViewerContainerFragment newInstance(String documentId, String documentName) {
ViewerContainerFragment fragment = new ViewerContainerFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
args.putString("documentId", documentId);
args.putString("documentName", documentName);
args.putBoolean("hasCombined", false);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null){
documentId = getArguments().getString("documentId");
documentName = getArguments().getString("documentName");
hasCombined = getArguments().getBoolean("hasCombined");
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_viewer_container, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// Init view pager
ViewPager2 viewPager = view.findViewById(R.id.view_pager);
// Init view pager adapter
ViewerViewPagerAdapter viewerViewPagerAdapter = new ViewerViewPagerAdapter(requireActivity());
viewPager.setAdapter(viewerViewPagerAdapter);
// Init tab layout
TabLayout tabLayout = view.findViewById(R.id.tab_layout);
// Init toolbar
Toolbar toolbar = view.findViewById(R.id.toolbar);
initToolbar(toolbar, true, documentName);
if (this.hasCombined) {
logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined);
lacertaLibrary.getCombinedDocumentToxiList(documentId).thenAccept(combinedDocumentToxiList -> {
logger.debug("ViewerContainerFragment", "combinedDocumentToxiList: " + combinedDocumentToxiList.size());
for (ToxiDocumentModel toxiDocumentModel : combinedDocumentToxiList) {
logger.debug("ViewerContainerFragment", "titleCache: " + toxiDocumentModel.getTitleCache());
viewerViewPagerAdapter
.addFragment(ViewerBodyFragment.newInstance(toxiDocumentModel.getChildDocumentId(), toxiDocumentModel.getTitleCache()),
toxiDocumentModel.getTitleCache());
}
viewerViewPagerAdapter.notifyItemRangeChanged(0, combinedDocumentToxiList.size());
});
} else {
logger.debug("ViewerContainerFragment", "hasCombined: " + hasCombined);
tabLayout.setVisibility(View.GONE);
viewerViewPagerAdapter.addFragment(ViewerBodyFragment.newInstance(documentId, documentName), documentName);
viewerViewPagerAdapter.notifyItemRangeChanged(0, 1);
}
// Attach tab layout to view pager
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
View customView = LayoutInflater.from(getContext()).inflate(R.layout.viewer_custom_tab, null);
TextView textView = customView.findViewById(R.id.tab_title);
textView.setText(viewerViewPagerAdapter.getTabTitle(position));
ImageButton imageButton = customView.findViewById(R.id.tab_modify);
imageButton.setOnClickListener(v -> {
Toast.makeText(getContext(), "Working!, Index:" + position, Toast.LENGTH_SHORT).show();
});
tab.setCustomView(customView);
}).attach();
}
/**
* Toolbarをinitする
*
* @param toolbar Toolbar
* @param showCloseButton Closeボタンを表示するかどうか
* @param title タイトル
*/
private void initToolbar(Toolbar toolbar, boolean showCloseButton, String title) {
getActivity().runOnUiThread(() -> {
// Close button
if (showCloseButton) {
toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.close_24px);
toolbar.setNavigationOnClickListener(v -> {
getActivity().finish();
});
} else {
toolbar.setNavigationIcon(null);
}
// Title
toolbar.setTitle(title);
// Menu
toolbar.inflateMenu(R.menu.viewer_menu);
toolbar.setOnMenuItemClickListener(item -> {
if (item.getItemId() == R.id.action_open_vcs_rev_list) {
Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show();
return true;
} else if (item.getItemId() == R.id.action_rename) {
renameDocument();
return true;
} else if (item.getItemId() == R.id.action_delete) {
Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show();
return true;
} else if (item.getItemId() == R.id.action_move) {
Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show();
return true;
} else if (item.getItemId() == R.id.action_combine) {
combineDocument();
return true;
} else {
return false;
}
});
});
}
private void combineDocument() {
LacertaFilePickerDialog lacertaFilePickerDialog = new LacertaFilePickerDialog();
lacertaFilePickerDialog.setListener((fileName, selectedId) -> {
lacertaLibrary.combineDocument(documentId, selectedId).thenAccept(aVoid -> {
getActivity().runOnUiThread(() -> {
Toast.makeText(getContext(), "結合しました", Toast.LENGTH_SHORT).show();
getActivity().finish(); // TODO-rca: 終了させずにUIを更新したい
});
});
});
lacertaFilePickerDialog
.setTitle("ファイルの結合")
.setMessage("結合するファイルを選択してください")
.setNegativeButtonText("キャンセル")
.show(getChildFragmentManager(), "LacertaFilePickerDialog");
}
/**
* ドキュメント名を変更する
*/
private void renameDocument() {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext());
builder.setTitle("ファイル名の変更");
builder.setMessage("ファイル名を入力してください");
View view = LayoutInflater.from(getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.lacerta_dialog_edit_text_layout, null);
TextInputEditText textInputEditText = view.findViewById(one.nem.lacerta.shared.ui.R.id.custom_edit_text);
TextInputLayout textInputLayout = view.findViewById(one.nem.lacerta.shared.ui.R.id.custom_text_input_layout);
textInputEditText.setText(documentName);
textInputLayout.setHint("ファイル名");
builder.setView(view);
builder.setPositiveButton("変更", (dialog, which) -> {
document.renameDocument(documentId, textInputEditText.getText().toString()).thenAccept(aVoid -> {
getActivity().runOnUiThread(() -> {
this.documentName = textInputEditText.getText().toString();
// TODO-rca: Toolbarのタイトルも変更する
});
});
});
builder.setNegativeButton("キャンセル", (dialog, which) -> {
dialog.cancel();
});
builder.show();
}
}
@@ -21,7 +21,14 @@ import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.component.common.LacertaSelectDirDialog;
import one.nem.lacerta.component.common.LacertaSelectDirDialogListener;
import one.nem.lacerta.component.common.LacertaSelectRevDialog;
import one.nem.lacerta.component.common.LacertaSelectRevDialogListener;
import one.nem.lacerta.component.common.picker.LacertaDirPickerDialog;
import one.nem.lacerta.component.common.picker.LacertaFilePickerAdapter;
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.ListItemType;
import one.nem.lacerta.model.document.page.Page;
import one.nem.lacerta.utils.FeatureSwitch;
import one.nem.lacerta.utils.LacertaLogger;
@@ -39,6 +46,9 @@ public class ViewerListFragment extends Fragment {
@Inject
Document document;
@Inject
LacertaLibrary lacertaLibrary;
@Inject
LacertaLogger logger;
@@ -92,7 +102,7 @@ public class ViewerListFragment extends Fragment {
// Toolbar
Toolbar toolbar = view.findViewById(R.id.toolbar);
toolbarSetup(toolbar, true, this.documentName == null ? "Document" : this.documentName);
toolbarSetup(toolbar, true, this.documentName == null ? "Document" : this.documentName, null);
RecyclerView recyclerView = view.findViewById(R.id.body_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
@@ -112,6 +122,8 @@ public class ViewerListFragment extends Fragment {
viewerBodyAdapter.notifyItemRangeChanged(0, pages.size());
if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.GONE);
});
}).thenCompose(aVoid -> lacertaLibrary.getPublicPath(documentId, ListItemType.ITEM_TYPE_DOCUMENT)).thenAccept(publicPath -> {
updateToolbarSubtitle(toolbar, "/" + publicPath.parent().getStringPath());
});
} else {
logger.debug(TAG, "revisionId: " + revisionId);
@@ -127,23 +139,35 @@ public class ViewerListFragment extends Fragment {
if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.GONE);
});
});
}).thenCompose(aVoid -> lacertaLibrary.getPublicPath(documentId, ListItemType.ITEM_TYPE_DOCUMENT)).thenAccept(publicPath -> {
updateToolbarSubtitle(toolbar, "/" + publicPath.parent().getStringPath()); // TODO-rca: リビジョンの場合はリビジョン名を表示する?
});
}
return view;
}
/**
* Toolbarのサブタイトルを更新
* @param subtitle サブタイトル
*/
private void updateToolbarSubtitle(Toolbar toolbar, String subtitle) {
getActivity().runOnUiThread(() -> {
toolbar.setSubtitle(subtitle);
});
}
/**
* ToolbarをInitする
*
* @param toolbar Toolbar
* @param showBackButton 戻るボタンを表示するか
* @param showCloseButton 戻るボタンを表示するか
* @param title タイトル
*/
private void toolbarSetup(Toolbar toolbar, boolean showBackButton, String title) {
private void toolbarSetup(Toolbar toolbar, boolean showCloseButton, String title, String Subtitle) {
getActivity().runOnUiThread(() -> {
if (showBackButton) {
toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px);
if (showCloseButton) {
toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.close_24px);
toolbar.setNavigationOnClickListener(v -> {
// Stop Activity
getActivity().finish();
@@ -152,13 +176,26 @@ public class ViewerListFragment extends Fragment {
toolbar.setNavigationIcon(null);
}
toolbar.setTitle(title);
if (Subtitle != null) toolbar.setSubtitle(Subtitle);
toolbar.inflateMenu(R.menu.viewer_menu);
toolbar.setOnMenuItemClickListener(item -> {
if (item.getItemId() == R.id.action_open_vcs_rev_list) {
// Open vcs rev list
getParentFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, ViewerVcsRevListFragment.newInstance(documentId, documentName))
.commit();
LacertaSelectRevDialog lacertaSelectRevDialog = new LacertaSelectRevDialog();
lacertaSelectRevDialog.setDocumentId(this.documentId).setTitle("リビジョンの選択").setMessage("リビジョンを選択してください。").setNegativeButtonText("キャンセル");
lacertaSelectRevDialog.setListener(new LacertaSelectRevDialogListener() {
@Override
public void onItemSelected(String revId) {
getParentFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, ViewerListFragment.newInstance(documentId, documentName, revisionId))
.commit();
}
@Override
public void onDialogCanceled() {
logger.debug(TAG, "Canceled");
}
});
lacertaSelectRevDialog.show(getParentFragmentManager(), "select_rev_dialog");
return true;
} else if (item.getItemId() == R.id.action_rename) {
@@ -205,30 +242,36 @@ public class ViewerListFragment extends Fragment {
builder.show();
return true;
} else if (item.getItemId() == R.id.action_move) {
// Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show();
LacertaSelectDirDialog lacertaSelectDirDialog = new LacertaSelectDirDialog();
lacertaSelectDirDialog.setListener(new LacertaSelectDirDialogListener() {
@Override
public void onDirSelected(String name, String itemId) {
logger.debug(TAG, "Selected dir: " + name + ", " + itemId);
document.moveDocument(documentId, itemId).thenAccept(aVoid -> {
getActivity().runOnUiThread(() -> {
// Stop Activity
getActivity().finish(); // TODO-rca: ファイル移動後に終了するべきかは検討
});
LacertaDirPickerDialog lacertaDirPickerDialog = new LacertaDirPickerDialog();
lacertaDirPickerDialog.setListener((name, dirId) -> {
logger.debug(TAG, "Selected dir: " + name + ", " + dirId);
document.moveDocument(documentId, dirId).thenAccept(aVoid -> {
getActivity().runOnUiThread(() -> {
// Stop Activity
getActivity().finish(); // TODO-rca: ファイル移動後に終了するべきかは検討
});
}
@Override
public void onCanceled() {
logger.debug(TAG, "Canceled");
}
});
});
lacertaSelectDirDialog.setTitle("ファイルの移動")
.setMessage("ファイルを移動するフォルダを選択してください。")
.setPositiveButtonText("移動")
.setNegativeButtonText("キャンセル");
lacertaSelectDirDialog.show(getParentFragmentManager(), "select_dir_dialog");
lacertaDirPickerDialog.setTitle("ファイルの移動")
.setMessage("ファイルを移動するフォルダを選択してください。")
.setPositiveButtonText("移動")
.setNegativeButtonText("キャンセル");
lacertaDirPickerDialog.show(getParentFragmentManager(), "select_dir_dialog");
return true;
} else if(item.getItemId() == R.id.action_combine) {
LacertaFilePickerDialog lacertaFilePickerDialog = new LacertaFilePickerDialog();
lacertaFilePickerDialog.setListener((name, fileId) -> {
lacertaLibrary.combineDocument(documentId, fileId).thenAccept(aVoid -> {
getActivity().runOnUiThread(() -> {
// Stop Activity
getActivity().finish(); // TODO-rca: 終了せずにUIを更新したい
});
});
});
lacertaFilePickerDialog.setTitle("ファイルの結合")
.setMessage("結合するファイルを選択してください。")
.setNegativeButtonText("キャンセル");
lacertaFilePickerDialog.show(getParentFragmentManager(), "select_file_dialog");
return true;
} else {
return false;
@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.OnBackPressedCallback;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
@@ -29,6 +30,7 @@ public class ViewerMainActivity extends AppCompatActivity {
private static final String TAG = "ViewerMainActivity";
String documentId;
String documentName;
boolean hasCombined = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -41,10 +43,14 @@ public class ViewerMainActivity extends AppCompatActivity {
return insets;
});
// // Transition
// overridePendingTransition(one.nem.lacerta.shared.ui.R.anim.nav_up_enter_anim, one.nem.lacerta.shared.ui.R.anim.nav_up_exit_anim);
Intent intent = getIntent();
try {
documentId = intent.getStringExtra("documentId");
documentName = intent.getStringExtra("documentName");
hasCombined = intent.getBooleanExtra("hasCombined", false);
}
catch (Exception e) {
logger.error(TAG, "Failed to get documentId from intent");
@@ -54,8 +60,18 @@ public class ViewerMainActivity extends AppCompatActivity {
}
// Navigation
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, ViewerListFragment.newInstance(documentId, documentName))
.commit();
// getSupportFragmentManager().beginTransaction()
// .replace(R.id.nav_host_fragment, ViewerListFragment.newInstance(documentId, documentName))
// .commit();
if (hasCombined) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, ViewerContainerFragment.newInstance(documentId, documentName, hasCombined))
.commit();
} else {
getSupportFragmentManager().beginTransaction()
.replace(R.id.nav_host_fragment, ViewerContainerFragment.newInstance(documentId, documentName))
.commit();
}
}
}
@@ -0,0 +1,44 @@
package one.nem.lacerta.component.viewer;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import java.util.ArrayList;
public class ViewerViewPagerAdapter extends FragmentStateAdapter {
// Variables
private ArrayList<Fragment> fragmentArrayList = new ArrayList<>();
private ArrayList<String> fragmentTitleList = new ArrayList<>();
// Setter
public void addFragment(Fragment fragment, String title){
fragmentArrayList.add(fragment);
fragmentTitleList.add(title);
}
public ViewerViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
super(fragmentActivity);
}
@NonNull
@Override
public Fragment createFragment(int position) {
return fragmentArrayList.get(position);
}
@Override
public int getItemCount() {
return fragmentArrayList == null ? 0 : fragmentArrayList.size();
}
@Nullable
public CharSequence getTabTitle(int position) {
return fragmentTitleList.get(position);
}
}
@@ -13,7 +13,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
<com.google.android.material.appbar.SubtitleCollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
app:contentScrim="@color/colorSecondaryContainer"
android:background="@color/colorSurface"
@@ -35,7 +35,7 @@
app:layout_collapseMode="pin"
app:title="Title" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.SubtitleCollapsingToolbarLayout>
<ProgressBar
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".ViewerBodyFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</FrameLayout>
@@ -0,0 +1,66 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorSurface">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.SubtitleCollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
app:contentScrim="@color/colorSecondaryContainer"
android:background="@color/colorSurface"
android:layout_width="match_parent"
android:layout_height="160dp"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:collapsedTitleGravity="start|center_vertical"
app:expandedTitleGravity="start|bottom"
app:expandedTitleMarginBottom="16dp"
app:expandedTitleMarginStart="16dp"
app:expandedTitleTextAppearance="@style/TextAppearance.MaterialComponents.Headline4"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:title="Title" />
</com.google.android.material.appbar.SubtitleCollapsingToolbarLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
/>
<ProgressBar
android:id="@+id/loading_progress_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:indeterminate="true"
android:background="@color/colorSurface"
android:visibility="gone" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager2.widget.ViewPager2
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/view_pager"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</FrameLayout>
@@ -0,0 +1,25 @@
<?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="wrap_content"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp">
<TextView
android:id="@+id/tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TAB TITLE"
android:textSize="16sp"
android:layout_gravity="center"/>
<ImageButton
android:id="@+id/tab_modify"
android:layout_marginStart="8dp"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:background="@android:color/transparent"
android:src="@drawable/more_vert_24px"
android:layout_gravity="center_vertical" />
</LinearLayout>
@@ -16,4 +16,8 @@
android:id="@+id/action_move"
android:title="移動" />
<item
android:id="@+id/action_combine"
android:title="結合" />
</menu>
@@ -10,6 +10,7 @@ import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.PublicPath;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.tag.DocumentTag;
import one.nem.lacerta.model.pref.ToxiDocumentModel;
public interface LacertaLibrary {
@@ -43,4 +44,16 @@ public interface LacertaLibrary {
CompletableFuture<Void> addTagToDocument(String documentId, String tagId);
CompletableFuture<Void> removeTagFromDocument(String documentId, String tagId);
// Combined Document
CompletableFuture<Void> combineDocument(String parentId, String childId);
CompletableFuture<Void> uncombineDocument(String parentId, String childId);
// CompletableFuture<Void> combineDocument(String parentId, ArrayList<String> childIdList);
//
// CompletableFuture<Void> uncombineDocument(String parentId, ArrayList<String> childIdList);
CompletableFuture<ArrayList<ToxiDocumentModel>> getCombinedDocumentToxiList(String parentId);
}
@@ -81,6 +81,8 @@ public class DocumentImpl implements Document {
documentEntity.updatedAt = meta.getUpdatedAt();
documentEntity.createdAt = meta.getCreatedAt();
documentEntity.parentId = meta.getParentId();
documentEntity.isCombineChild = meta.getIsCombineChild();
documentEntity.isCombineParent = meta.getIsCombineParent();
database.documentDao().insert(documentEntity);
@@ -104,6 +106,8 @@ public class DocumentImpl implements Document {
meta.setUpdatedAt(new Date());
meta.setCreatedAt(new Date());
meta.setParentId(null);
meta.setIsCombineChild(false);
meta.setIsCombineParent(false);
return createDocument(meta);
}
@@ -8,6 +8,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
@@ -22,11 +23,13 @@ import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.PublicPath;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.tag.DocumentTag;
import one.nem.lacerta.model.pref.ToxiDocumentModel;
import one.nem.lacerta.source.database.LacertaDatabase;
import one.nem.lacerta.source.database.common.DateTypeConverter;
import one.nem.lacerta.source.database.entity.DocumentEntity;
import one.nem.lacerta.source.database.entity.FolderEntity;
import one.nem.lacerta.source.database.entity.TagEntity;
import one.nem.lacerta.source.database.entity.ToxiDocumentEntity;
import one.nem.lacerta.source.database.entity.ToxiDocumentTagEntity;
import one.nem.lacerta.utils.FeatureSwitch;
import one.nem.lacerta.utils.LacertaLogger;
@@ -54,6 +57,7 @@ public class LacertaLibraryImpl implements LacertaLibrary {
listItem.setTitle(documentEntity.title);
listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt));
listItem.setItemId(documentEntity.id);
listItem.setHasCombined(documentEntity.isCombineParent);
listItems.add(listItem);
}
@@ -103,6 +107,7 @@ public class LacertaLibraryImpl implements LacertaLibrary {
listItem.setTitle(childFolderEntity.name);
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
listItem.setItemId(childFolderEntity.id);
listItem.setHasCombined(false);
listItems.add(listItem);
}
@@ -115,6 +120,7 @@ public class LacertaLibraryImpl implements LacertaLibrary {
listItem.setTitle(documentEntity.title);
listItem.setDescription(simpleDateFormat.format(documentEntity.updatedAt));
listItem.setItemId(documentEntity.id);
listItem.setHasCombined(documentEntity.isCombineParent);
listItems.add(listItem);
}
@@ -164,6 +170,7 @@ public class LacertaLibraryImpl implements LacertaLibrary {
listItem.setTitle(childFolderEntity.name);
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
listItem.setItemId(childFolderEntity.id);
listItem.setHasCombined(false);
listItems.add(listItem);
}
@@ -294,6 +301,90 @@ public class LacertaLibraryImpl implements LacertaLibrary {
});
}
@Override
public CompletableFuture<Void> combineDocument(String targetId1, String tagetId2) {
return CompletableFuture.supplyAsync(() -> {
DocumentEntity target1DocumentEntity = database.documentDao().findById(targetId1);
DocumentEntity target2DocumentEntity = database.documentDao().findById(tagetId2);
if (target1DocumentEntity == null || target2DocumentEntity == null) {
logger.warn("LacertaLibraryImpl", "DocumentEntity is not found.");
return null;
}
target1DocumentEntity.isCombineChild = true;
target2DocumentEntity.isCombineChild = true;
database.documentDao().update(target1DocumentEntity);
database.documentDao().update(target2DocumentEntity);
logger.debug("LacertaLibraryImpl", "Database Query: Updated DocumentEntity");
DocumentEntity parentDocumentEntity = new DocumentEntity();
parentDocumentEntity.id = UUID.randomUUID().toString();
parentDocumentEntity.title = target1DocumentEntity.title + "(Combined)";
parentDocumentEntity.parentId = target1DocumentEntity.parentId;
parentDocumentEntity.author = target1DocumentEntity.author; // TODO-rca: Target1とTarget2の作者が異なる場合の処理
// CombinedなDocumentはいま作成された と考える
parentDocumentEntity.createdAt = new Date();
parentDocumentEntity.updatedAt = new Date();
parentDocumentEntity.isCombineParent = true;
parentDocumentEntity.isCombineChild = false;
database.documentDao().insert(parentDocumentEntity);
logger.debug("LacertaLibraryImpl", "Database Query: Inserted DocumentEntity");
insertCombineDocumentToxi(parentDocumentEntity.id, target1DocumentEntity.id, target1DocumentEntity.title);
insertCombineDocumentToxi(parentDocumentEntity.id, target2DocumentEntity.id, target2DocumentEntity.title);
return null;
});
}
private void insertCombineDocumentToxi(String parentId, String childId, String titleCache) {
ToxiDocumentEntity toxiDocumentEntity = new ToxiDocumentEntity();
toxiDocumentEntity.parentDocumentId = parentId;
toxiDocumentEntity.childDocumentId = childId;
toxiDocumentEntity.order = 0; // TODO-rca: 並び順の概念をもたせる
toxiDocumentEntity.isActive = true; // TODO-rca: タブから非表示にできるようにする
toxiDocumentEntity.titleCache = titleCache;
database.toxiDocumentDao().insert(toxiDocumentEntity);
logger.debug("LacertaLibraryImpl", "Database Query: Inserted ToxiDocumentEntity");
}
@Override
public CompletableFuture<Void> uncombineDocument(String parentId, String childId) {
return CompletableFuture.supplyAsync(() -> {
DocumentEntity parentDocumentEntity = database.documentDao().findById(parentId);
DocumentEntity childDocumentEntity = database.documentDao().findById(childId);
if (parentDocumentEntity == null || childDocumentEntity == null) {
logger.warn("LacertaLibraryImpl", "DocumentEntity is not found.");
return null;
}
parentDocumentEntity.isCombineParent = false;
childDocumentEntity.isCombineChild = false;
database.documentDao().update(parentDocumentEntity);
database.documentDao().update(childDocumentEntity);
logger.debug("LacertaLibraryImpl", "Database Query: Updated DocumentEntity");
database.toxiDocumentDao().deleteByParentIdAndChildId(parentId, childId);
logger.debug("LacertaLibraryImpl", "Database Query: Deleted ToxiDocumentEntity");
return null;
});
}
@Override
public CompletableFuture<ArrayList<ToxiDocumentModel>> getCombinedDocumentToxiList(String parentId) {
return CompletableFuture.supplyAsync(() -> {
List<ToxiDocumentEntity> toxiDocumentEntities = database.toxiDocumentDao().findByParentId(parentId);
ArrayList<ToxiDocumentModel> toxiDocumentModels = new ArrayList<>();
for (ToxiDocumentEntity toxiDocumentEntity : toxiDocumentEntities) {
ToxiDocumentModel toxiDocumentModel = new ToxiDocumentModel();
toxiDocumentModel.setParentDocumentId(toxiDocumentEntity.parentDocumentId);
toxiDocumentModel.setChildDocumentId(toxiDocumentEntity.childDocumentId);
toxiDocumentModel.setOrder(toxiDocumentEntity.order);
toxiDocumentModel.setActive(toxiDocumentEntity.isActive);
toxiDocumentModel.setTitleCache(toxiDocumentEntity.titleCache);
toxiDocumentModels.add(toxiDocumentModel);
}
return toxiDocumentModels;
});
}
/**
* 再帰的にパスを解決する
*
@@ -1,5 +1,5 @@
package one.nem.lacerta.feature.home;
public interface DocumentSelectListener {
void onDocumentSelect(String documentId, String documentName);
void onDocumentSelect(String documentId, String documentName, boolean hasCombined);
}
@@ -1,5 +1,6 @@
package one.nem.lacerta.feature.home;
import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
@@ -84,12 +85,13 @@ public class HomeTopFragment extends Fragment {
this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() {
@Override
public void onDocumentSelect(String documentId, String documentName) {
public void onDocumentSelect(String documentId, String documentName, boolean hasCombined) {
Intent intent = new Intent(getContext(), ViewerMainActivity.class);
Log.d("HomeTopFragment", "onDocumentSelect: " + documentId + " " + documentName);
intent.putExtra("documentId", documentId);
intent.putExtra("documentName", documentName);
startActivity(intent);
intent.putExtra("hasCombined", hasCombined);
startActivity(intent, ActivityOptions.makeCustomAnimation(getContext(), one.nem.lacerta.shared.ui.R.anim.nav_up_enter_anim, one.nem.lacerta.shared.ui.R.anim.nav_up_exit_anim).toBundle());
}
});
recyclerView.setAdapter(listItemAdapter);
@@ -106,20 +108,22 @@ public class HomeTopFragment extends Fragment {
}
private void updateList() {
long startTime = System.currentTimeMillis();
lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> {
long endTime = System.currentTimeMillis();
if (listItems == null) {
return;
}
this.listItemAdapter.setListItems(listItems);
getActivity().runOnUiThread(() -> {
Log.d("HomeTopFragment", "onViewCreated: " + listItems.size());
if (FeatureSwitch.RecyclerView.useSimpleNotifyMethod) {
if (endTime - startTime > 500) { // 500ms以上かかった場合は表示アニメーションをする
getActivity().runOnUiThread(() -> {
this.listItemAdapter.notifyItemRangeInserted(0, listItems.size());
});
} else {
getActivity().runOnUiThread(() -> {
this.listItemAdapter.notifyDataSetChanged();
} else {
// IndexOutOfBoundsExceptionを吐くことがあったので いったん
this.listItemAdapter.notifyItemRangeInserted(0, listItems.size() - 1);
}
});
});
}
});
}
@@ -46,7 +46,7 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
holder.description.setText(listItem.getDescription());
holder.itemView.setOnClickListener( v -> {
listener.onDocumentSelect(listItem.getItemId(), listItem.getTitle());
listener.onDocumentSelect(listItem.getItemId(), listItem.getTitle(), listItem.getHasCombined());
});
}
+2 -1
View File
@@ -55,5 +55,6 @@ dependencies {
implementation project(':component:viewer')
// TODO-rca: バージョンカタログに切り出す
implementation "com.hendraanggrian.material:collapsingtoolbarlayout-subtitle:1.5.0"
}
@@ -2,5 +2,5 @@ package one.nem.lacerta.feature.library;
public interface DocumentSelectListener {
void onFolderSelected(String folderId, String folderName);
void onDocumentSelected(String documentId, String documentName);
void onDocumentSelected(String documentId, String documentName, boolean hasCombined);
}
@@ -23,6 +23,7 @@ import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.component.viewer.ViewerMainActivity;
import one.nem.lacerta.data.LacertaLibrary;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.utils.FeatureSwitch;
import one.nem.lacerta.utils.LacertaLogger;
@@ -43,6 +44,7 @@ public class LibraryPageFragment extends Fragment {
String folderId;
String title;
String parentId;
Toolbar toolbar;
@Inject
@@ -128,12 +130,19 @@ public class LibraryPageFragment extends Fragment {
logger.debug("LibraryTopFragment", "getArguments() is null(maybe root)");
this.libraryItemPage = new LibraryItemPage();
}
this.toolbar = view.findViewById(R.id.library_toolbar);
// Toolbar Setup
toolbarSetup(view.findViewById(R.id.library_toolbar), this.folderId != null, this.title != null ? this.title : "ライブラリ");
toolbarSetup(this.toolbar, this.folderId != null, this.title != null ? this.title : "ライブラリ");
if(this.folderId == null) {
updateToolbarSubtitle(this.toolbar, null); //負荷軽減のため+邪魔なので(folderIdがnullの場合は、ルートフォルダを表示しているので)
} else {
lacertaLibrary.getPublicPath(this.folderId, ListItemType.ITEM_TYPE_FOLDER).thenAccept(publicPath -> {
updateToolbarSubtitle(this.toolbar, "/" + publicPath.parent().getStringPath());
});
}
// RecyclerView Setup
RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view);
this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() {
@Override
@@ -155,11 +164,12 @@ public class LibraryPageFragment extends Fragment {
}
@Override
public void onDocumentSelected(String documentId, String documentName) {
public void onDocumentSelected(String documentId, String documentName, boolean hasCombined) {
Intent intent = new Intent(getContext(), ViewerMainActivity.class);
logger.debug("LibraryTopFragment", "Document selected! documentId: " + documentId + ", documentName: " + documentName);
intent.putExtra("documentId", documentId);
intent.putExtra("documentName", documentName);
intent.putExtra("hasCombined", hasCombined);
startActivity(intent);
}
});
@@ -168,33 +178,8 @@ public class LibraryPageFragment extends Fragment {
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// Get library page and update RecyclerView items
lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> {
this.libraryItemPage = libraryItemPage;
if (this.parentId == null) {
this.parentId = libraryItemPage.getParentId();
}
if (this.title == null) {
this.title = libraryItemPage.getPageTitle();
// Toolbar init again
toolbarSetup(view.findViewById(R.id.library_toolbar), this.folderId != null, this.title != null ? this.title : "ライブラリ");
}
logger.debug("LibraryTopFragment", "Item selected! Total item page: " + this.libraryItemPage.getListItems().size());
if (!FeatureSwitch.RecyclerView.useSimpleNotifyMethod) {
getActivity().runOnUiThread(() -> { // TODO-rca: 実行条件を考える?
listItemAdapter.notifyItemRangeRemoved(0, this.libraryItemPage.getListItems().size() - 1);
});
}
listItemAdapter.setLibraryItemPage(this.libraryItemPage);
getActivity().runOnUiThread(() -> {
if (FeatureSwitch.RecyclerView.useSimpleNotifyMethod) {
listItemAdapter.notifyDataSetChanged();
} else {
listItemAdapter.notifyItemRangeInserted(0, this.libraryItemPage.getListItems().size() - 1);
}
});
});
updateItem(this.folderId);
}
/**
@@ -216,6 +201,7 @@ public class LibraryPageFragment extends Fragment {
lacertaLibrary.createFolder(pageId, input.getText().toString()).thenAccept(folderId -> {
// Refresh
updateItem(pageId);
});
});
builder.setNegativeButton("キャンセル", (dialog, which) -> {
@@ -226,19 +212,34 @@ public class LibraryPageFragment extends Fragment {
}
/**
* RecyclerViewのアイテムを更新する
* RecyclerViewのアイテムとUIを更新する
*/
private void updateItem(String pageId) {
long startTime = System.currentTimeMillis();
lacertaLibrary.getLibraryPage(pageId, 10).thenAccept(libraryItemPage -> {
long endTime = System.currentTimeMillis();
this.libraryItemPage = libraryItemPage;
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
getActivity().runOnUiThread(() -> {
listItemAdapter.notifyItemRangeRemoved(0, libraryItemPage.getListItems().size() - 1);
});
listItemAdapter.setLibraryItemPage(libraryItemPage);
getActivity().runOnUiThread(() -> {
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1);
});
if (endTime - startTime > 500) { // 500ms以上かかった場合は表示アニメーションをする
getActivity().runOnUiThread(() -> {
listItemAdapter.notifyItemRangeInserted(0, this.libraryItemPage.getListItems().size());
});
} else {
getActivity().runOnUiThread(() -> {
listItemAdapter.notifyDataSetChanged();
});
}
});
}
/**
* Toolbarのサブタイトルを更新
* @param subtitle サブタイトル
*/
private void updateToolbarSubtitle(Toolbar toolbar, String subtitle) {
getActivity().runOnUiThread(() -> {
toolbar.setSubtitle(subtitle);
});
}
@@ -45,7 +45,7 @@ public class ListItemAdapter extends RecyclerView.Adapter<ListItemAdapter.ListIt
holder.itemView.setOnClickListener( v -> {
if (listItem.getItemType() == ListItemType.ITEM_TYPE_DOCUMENT) {
listener.onDocumentSelected(listItem.getItemId(), listItem.getTitle());
listener.onDocumentSelected(listItem.getItemId(), listItem.getTitle(), listItem.getHasCombined());
}
else if (listItem.getItemType() == ListItemType.ITEM_TYPE_FOLDER) {
listener.onFolderSelected(listItem.getItemId(), listItem.getTitle());
@@ -13,7 +13,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.CollapsingToolbarLayout
<com.google.android.material.appbar.SubtitleCollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
app:contentScrim="@color/colorSecondaryContainer"
android:background="@color/colorSurface"
@@ -35,7 +35,7 @@
app:layout_collapseMode="pin"
app:title="HOGE" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.SubtitleCollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
@@ -12,10 +12,10 @@
<action
android:id="@+id/action_feature_library_top_fragment_self"
app:destination="@id/feature_library_top_fragment"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim"
app:enterAnim="@anim/nav_twitter_enter_anim"
app:exitAnim="@anim/nav_twitter_exit_anim"
app:popEnterAnim="@anim/nav_twitter_pop_enter_anim"
app:popExitAnim="@anim/nav_twitter_pop_exit_anim"
app:popUpTo="@id/feature_library_top_fragment"
app:popUpToInclusive="false"/>
</fragment>
@@ -10,6 +10,7 @@ public class ListItem {
String description;
ListItemType itemType;
String itemId;
boolean hasCombined;
// Constructor
@@ -20,6 +21,14 @@ public class ListItem {
this.itemId = itemId;
}
public ListItem(String title, String description, ListItemType itemType, String itemId, boolean hasCombined) {
this.title = title;
this.description = description;
this.itemType = itemType;
this.itemId = itemId;
this.hasCombined = hasCombined;
}
public ListItem() {
// Empty constructor
}
@@ -42,6 +51,10 @@ public class ListItem {
return itemId;
}
public boolean getHasCombined() {
return hasCombined;
}
// Setter
public void setTitle(String title) {
@@ -60,4 +73,8 @@ public class ListItem {
this.itemId = itemId;
}
public void setHasCombined(boolean hasCombined) {
this.hasCombined = hasCombined;
}
}
@@ -36,6 +36,10 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
String author;
boolean isCombineChild;
boolean isCombineParent;
// Constructor
public DocumentMeta() {
@@ -48,12 +52,16 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
this.parentId = null;
this.updatedAt = new Date();
this.createdAt = new Date();
this.isCombineChild = false;
this.isCombineParent = false;
}
public DocumentMeta(String title, String author) {
this.id = UUID.randomUUID().toString();
this.title = title;
this.author = author;
this.isCombineChild = false;
this.isCombineParent = false;
}
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, String author) {
@@ -62,6 +70,8 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
this.updatedAt = updatedAt;
this.createdAt = createdAt;
this.author = author;
this.isCombineChild = false;
this.isCombineParent = false;
}
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, String parentId, String author) {
@@ -71,6 +81,19 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
this.createdAt = createdAt;
this.parentId = parentId;
this.author = author;
this.isCombineChild = false;
this.isCombineParent = false;
}
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, String parentId, String author, boolean isCombineChild, boolean isCombineParent) {
this.id = id;
this.title = title;
this.updatedAt = updatedAt;
this.createdAt = createdAt;
this.parentId = parentId;
this.author = author;
this.isCombineChild = isCombineChild;
this.isCombineParent = isCombineParent;
}
// Getter
@@ -117,6 +140,20 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
return author;
}
/**
* ドキュメントの結合子フラグ(boolean)を取得する
*/
public boolean getIsCombineChild() {
return isCombineChild;
}
/**
* ドキュメントの結合親フラグ(boolean)を取得する
*/
public boolean getIsCombineParent() {
return isCombineParent;
}
// Setter
/**
@@ -167,6 +204,22 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
this.author = author;
}
/**
* ドキュメントの結合子フラグ(boolean)を設定する
* @param isCombineChild ドキュメントの結合子フラグ
*/
public void setIsCombineChild(boolean isCombineChild) {
this.isCombineChild = isCombineChild;
}
/**
* ドキュメントの結合親フラグ(boolean)を設定する
* @param isCombineParent ドキュメントの結合親フラグ
*/
public void setIsCombineParent(boolean isCombineParent) {
this.isCombineParent = isCombineParent;
}
/**
* updatedAtを現在時刻に設定する
*/
@@ -0,0 +1,68 @@
package one.nem.lacerta.model.pref;
public class ToxiDocumentModel {
// Field
public String parentDocumentId;
public String childDocumentId;
public int order;
public boolean isActive;
public String titleCache;
// Constructor
public ToxiDocumentModel() {
}
public ToxiDocumentModel(String parentDocumentId, String childDocumentId, int order, boolean isActive, String titleCache) {
this.parentDocumentId = parentDocumentId;
this.childDocumentId = childDocumentId;
this.order = order;
this.isActive = isActive;
this.titleCache = titleCache;
}
// Getter / Setter
public String getParentDocumentId() {
return parentDocumentId;
}
public void setParentDocumentId(String parentDocumentId) {
this.parentDocumentId = parentDocumentId;
}
public String getChildDocumentId() {
return childDocumentId;
}
public void setChildDocumentId(String childDocumentId) {
this.childDocumentId = childDocumentId;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public boolean isActive() {
return isActive;
}
public void setActive(boolean active) {
isActive = active;
}
public String getTitleCache() {
return titleCache;
}
public void setTitleCache(String titleCache) {
this.titleCache = titleCache;
}
}
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="105%"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXDelta="0" />
<scale
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="0.9"
android:fromYScale="0.9"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="0.5"
android:interpolator="@android:anim/linear_interpolator"
android:toAlpha="1" />
</set>
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXDelta="-105%" />
<scale
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="1"
android:fromYScale="1"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.9"
android:toYScale="0.9" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="1"
android:interpolator="@android:anim/linear_interpolator"
android:toAlpha="0.5" />
</set>
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="-105%"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXDelta="0" />
<scale
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="0.9"
android:fromYScale="0.9"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="0.5"
android:interpolator="@android:anim/linear_interpolator"
android:toAlpha="1" />
</set>
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:toXDelta="105%" />
<scale
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="1"
android:fromYScale="1"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.9"
android:toYScale="0.9" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="1"
android:interpolator="@android:anim/linear_interpolator"
android:toAlpha="0.5" />
</set>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_shortAnimTime"
android:fromXDelta="100%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0" />
</set>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_shortAnimTime"
android:fromXDelta="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="-20%p" />
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="1"
android:interpolator="@android:anim/linear_interpolator"
android:toAlpha="0.5" />
</set>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_shortAnimTime"
android:fromXDelta="-20%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0" />
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="0.5"
android:interpolator="@android:anim/linear_interpolator"
android:toAlpha="1" />
</set>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_shortAnimTime"
android:fromXDelta="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="100%p" />
</set>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="@android:integer/config_shortAnimTime"
android:fromDegrees="30"
android:interpolator="@android:anim/decelerate_interpolator"
android:pivotX="50%"
android:pivotY="90%"
android:toDegrees="0" />
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="@android:integer/config_shortAnimTime"
android:fromDegrees="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:pivotX="50%"
android:pivotY="90%"
android:toDegrees="-30" />
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="@android:integer/config_shortAnimTime"
android:fromDegrees="-30"
android:interpolator="@android:anim/decelerate_interpolator"
android:pivotX="50%"
android:pivotY="90%"
android:toDegrees="0" />
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="@android:integer/config_shortAnimTime"
android:fromDegrees="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:pivotX="50%"
android:pivotY="90%"
android:toDegrees="30" />
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="1"
android:toAlpha="0" />
</set>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@integer/config_navAnimTime"
android:fromXDelta="50%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0" />
<alpha
android:duration="@integer/config_navAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@integer/config_navAnimTime"
android:fromXDelta="0%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="-50%p" />
<alpha
android:duration="@integer/config_navAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@integer/config_navAnimTime"
android:fromXDelta="-50%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0%p" />
<alpha
android:duration="@integer/config_navAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@integer/config_navAnimTime"
android:fromXDelta="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="50%p" />
<alpha
android:duration="@integer/config_navAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_shortAnimTime"
android:fromXDelta="100%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0" />
</set>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="@android:integer/config_shortAnimTime"
android:fromXScale="1"
android:fromYScale="1"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.9"
android:toYScale="0.9" />
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="1"
android:interpolator="@android:anim/linear_interpolator"
android:toAlpha="0.5" />
</set>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="@android:integer/config_shortAnimTime"
android:fromXScale="0.9"
android:fromYScale="0.9"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" />
<alpha
android:duration="@android:integer/config_shortAnimTime"
android:fromAlpha="0.5"
android:interpolator="@android:anim/linear_interpolator"
android:toAlpha="1" />
</set>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_shortAnimTime"
android:fromXDelta="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="100%p" />
</set>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="100%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toYDelta="0" />
</set>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="1"
android:toAlpha="1" />
</set>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="1"
android:toAlpha="1" />
</set>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="100%p" />
</set>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="@integer/config_navAnimTime"
android:fromXScale="0.9"
android:fromYScale="0.9"
android:interpolator="@android:anim/decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" />
<alpha
android:duration="@integer/config_navAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="@integer/config_navAnimTime"
android:fromXScale="1"
android:fromYScale="1"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.05"
android:toYScale="1.05" />
</set>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="@integer/config_navAnimTime"
android:fromXScale="1.05"
android:fromYScale="1.05"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" />
</set>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="@integer/config_navAnimTime"
android:fromXScale="1"
android:fromYScale="1"
android:interpolator="@android:anim/accelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.9"
android:toYScale="0.9" />
<alpha
android:duration="@integer/config_navAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@color/colorOnSurface"
android:pathData="M480,770.77Q455.25,770.77 437.63,753.14Q420,735.52 420,710.77Q420,686.02 437.63,668.4Q455.25,650.77 480,650.77Q504.75,650.77 522.37,668.4Q540,686.02 540,710.77Q540,735.52 522.37,753.14Q504.75,770.77 480,770.77ZM480,540Q455.25,540 437.63,522.37Q420,504.75 420,480Q420,455.25 437.63,437.63Q455.25,420 480,420Q504.75,420 522.37,437.63Q540,455.25 540,480Q540,504.75 522.37,522.37Q504.75,540 480,540ZM480,309.23Q455.25,309.23 437.63,291.6Q420,273.98 420,249.23Q420,224.48 437.63,206.86Q455.25,189.23 480,189.23Q504.75,189.23 522.37,206.86Q540,224.48 540,249.23Q540,273.98 522.37,291.6Q504.75,309.23 480,309.23Z"/>
</vector>
@@ -5,11 +5,13 @@ import androidx.room.RoomDatabase;
// Entities
import one.nem.lacerta.source.database.dao.FolderDao;
import one.nem.lacerta.source.database.dao.ToxiDocumentDao;
import one.nem.lacerta.source.database.dao.ToxiDocumentTagDao;
import one.nem.lacerta.source.database.entity.FolderEntity;
import one.nem.lacerta.source.database.entity.TagEntity;
import one.nem.lacerta.source.database.entity.DocumentEntity;
import one.nem.lacerta.source.database.entity.LibraryEntity;
import one.nem.lacerta.source.database.entity.ToxiDocumentEntity;
import one.nem.lacerta.source.database.entity.ToxiDocumentTagEntity;
import one.nem.lacerta.source.database.entity.VcsRevEntity;
import one.nem.lacerta.source.database.entity.VcsLogEntity;
@@ -21,11 +23,12 @@ import one.nem.lacerta.source.database.dao.LibraryDao;
import one.nem.lacerta.source.database.dao.VcsRevDao;
import one.nem.lacerta.source.database.dao.VcsLogDao;
@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class, ToxiDocumentTagEntity.class}, version = 6)
@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class, ToxiDocumentTagEntity.class, ToxiDocumentEntity.class}, version = 8)
public abstract class LacertaDatabase extends RoomDatabase {
public abstract TagDao tagDao();
public abstract DocumentDao documentDao();
public abstract ToxiDocumentTagDao toxiDocumentTagDao();
public abstract ToxiDocumentDao toxiDocumentDao();
public abstract LibraryDao libraryDao();
public abstract VcsRevDao vcsRevDao();
public abstract VcsLogDao vcsLogDao();
@@ -29,13 +29,13 @@ public interface DocumentDao {
@Query("SELECT * FROM Document WHERE id IN (:ids)")
List<DocumentEntity> findByIds(List<String> ids);
@Query("SELECT * FROM Document WHERE parent_id = :parentId")
@Query("SELECT * FROM Document WHERE parent_id = :parentId AND is_combine_child = 0 ORDER BY created_at DESC")
List<DocumentEntity> findByParentId(String parentId);
@Query("SELECT * FROM Document WHERE parent_id IS NULL")
@Query("SELECT * FROM Document WHERE parent_id IS NULL AND is_combine_child = 0 ORDER BY created_at DESC")
List<DocumentEntity> findRootDocuments();
@Query("SELECT * FROM Document ORDER BY created_at DESC LIMIT :limit")
@Query("SELECT * FROM Document WHERE is_combine_child = 0 ORDER BY created_at DESC LIMIT :limit")
List<DocumentEntity> getRecentDocument(int limit);
// Insert
@@ -0,0 +1,35 @@
package one.nem.lacerta.source.database.dao;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
import java.util.List;
import one.nem.lacerta.source.database.entity.ToxiDocumentEntity;
@Dao
public interface ToxiDocumentDao {
@Query("SELECT * FROM toxi_document WHERE parent_document_id = :parentId AND is_active = 1 ORDER BY `order` ASC")
List<ToxiDocumentEntity> findByParentId(String parentId);
@Insert
void insert(ToxiDocumentEntity toxiDocument);
@Insert
void insertAll(ToxiDocumentEntity... toxiDocuments);
@Update
void update(ToxiDocumentEntity toxiDocument);
@Update
void updateAll(ToxiDocumentEntity... toxiDocuments);
@Query("DELETE FROM toxi_document WHERE parent_document_id = :parentId")
void deleteByParentId(String parentId);
@Query("DELETE FROM toxi_document WHERE parent_document_id = :parentId AND child_document_id = :childId")
void deleteByParentIdAndChildId(String parentId, String childId);
}
@@ -36,4 +36,10 @@ public class DocumentEntity {
@ColumnInfo(name = "parent_id")
public String parentId; // 親フォルダID
@ColumnInfo(name = "is_combine_child")
public boolean isCombineChild; // 結合されたドキュメントの子かどうか
@ColumnInfo(name = "is_combine_parent")
public boolean isCombineParent; // 結合されたドキュメントの親かどうか
}
@@ -0,0 +1,26 @@
package one.nem.lacerta.source.database.entity;
import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
@Entity(primaryKeys = {"parent_document_id", "child_document_id"}, tableName = "toxi_document")
public class ToxiDocumentEntity {
@ColumnInfo(name = "parent_document_id")
@NonNull
public String parentDocumentId;
@ColumnInfo(name = "child_document_id")
@NonNull
public String childDocumentId;
@ColumnInfo(name = "order")
public int order;
@ColumnInfo(name = "is_active")
public boolean isActive;
@ColumnInfo(name = "title_cache")
public String titleCache;
}