mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
ドキュメントのリネームだけ実装
This commit is contained in:
parent
8038b7e198
commit
eeeef90ec2
|
@ -11,9 +11,14 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
import com.google.android.material.textfield.TextInputEditText;
|
||||||
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
import dagger.hilt.android.AndroidEntryPoint;
|
||||||
|
import one.nem.lacerta.data.Document;
|
||||||
import one.nem.lacerta.data.LacertaLibrary;
|
import one.nem.lacerta.data.LacertaLibrary;
|
||||||
import one.nem.lacerta.model.document.page.Page;
|
import one.nem.lacerta.model.document.page.Page;
|
||||||
import one.nem.lacerta.model.pref.ToxiDocumentModel;
|
import one.nem.lacerta.model.pref.ToxiDocumentModel;
|
||||||
|
@ -35,6 +40,9 @@ public class ViewerContainerFragment extends Fragment {
|
||||||
@Inject
|
@Inject
|
||||||
LacertaLibrary lacertaLibrary;
|
LacertaLibrary lacertaLibrary;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Document document;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private String documentId;
|
private String documentId;
|
||||||
private String documentName;
|
private String documentName;
|
||||||
|
@ -133,7 +141,7 @@ public class ViewerContainerFragment extends Fragment {
|
||||||
Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show();
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.action_rename) {
|
} else if (item.getItemId() == R.id.action_rename) {
|
||||||
Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show();
|
renameDocument();
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.action_delete) {
|
} else if (item.getItemId() == R.id.action_delete) {
|
||||||
Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Work in progress", Toast.LENGTH_SHORT).show();
|
||||||
|
@ -147,4 +155,31 @@ public class ViewerContainerFragment extends Fragment {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user