moveDocument実装

This commit is contained in:
ろむねこ 2024-01-29 10:43:35 +09:00
parent 9861dfe5b6
commit e583481b9a
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -29,6 +29,7 @@ import dagger.hilt.android.AndroidEntryPoint;
import one.nem.lacerta.component.common.LacertaApplyTagDialog; import one.nem.lacerta.component.common.LacertaApplyTagDialog;
import one.nem.lacerta.component.common.LacertaSelectRevDialog; import one.nem.lacerta.component.common.LacertaSelectRevDialog;
import one.nem.lacerta.component.common.LacertaSelectRevDialogListener; import one.nem.lacerta.component.common.LacertaSelectRevDialogListener;
import one.nem.lacerta.component.common.picker.LacertaDirPickerDialog;
import one.nem.lacerta.component.common.picker.LacertaFilePickerDialog; import one.nem.lacerta.component.common.picker.LacertaFilePickerDialog;
import one.nem.lacerta.data.Document; import one.nem.lacerta.data.Document;
import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.data.LacertaLibrary;
@ -247,7 +248,7 @@ public class ViewerContainerFragment extends Fragment {
deleteDocument(); deleteDocument();
return true; return true;
} else if (item.getItemId() == R.id.action_move) { } else if (item.getItemId() == R.id.action_move) {
Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show(); moveDocument();
return true; return true;
} else if (item.getItemId() == R.id.action_combine) { } else if (item.getItemId() == R.id.action_combine) {
combineDocument(); combineDocument();
@ -281,6 +282,24 @@ public class ViewerContainerFragment extends Fragment {
lacertaSelectRevDialog.show(getParentFragmentManager(), "select_rev_dialog"); lacertaSelectRevDialog.show(getParentFragmentManager(), "select_rev_dialog");
} }
private void moveDocument() {
LacertaDirPickerDialog lacertaDirPickerDialog = new LacertaDirPickerDialog();
lacertaDirPickerDialog.setListener((name, dirId) -> {
logger.debug("MoveDocument", "Selected dir: " + name + ", " + dirId);
document.moveDocument(documentId, dirId).thenAccept(aVoid -> {
getActivity().runOnUiThread(() -> {
// Stop Activity
getActivity().finish(); // TODO-rca: ファイル移動後に終了するべきかは検討
});
});
});
lacertaDirPickerDialog.setTitle("ファイルの移動")
.setMessage("ファイルを移動するフォルダを選択してください。")
.setPositiveButtonText("移動")
.setNegativeButtonText("キャンセル");
lacertaDirPickerDialog.show(getParentFragmentManager(), "select_dir_dialog");
}
private void deleteDocument() { private void deleteDocument() {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext()); MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext());
builder.setTitle("ファイルの削除"); builder.setTitle("ファイルの削除");