use of com.owncloud.android.databinding.FileListActionsBottomSheetCreatorBinding in project android by nextcloud.
the class OCFileListBottomSheetDialog method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = FileListActionsBottomSheetFragmentBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
if (getWindow() != null) {
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
int primaryColor = ThemeColorUtils.primaryColor(getContext(), true);
ThemeDrawableUtils.tintDrawable(binding.menuIconUploadFiles.getDrawable(), primaryColor);
ThemeDrawableUtils.tintDrawable(binding.menuIconUploadFromApp.getDrawable(), primaryColor);
ThemeDrawableUtils.tintDrawable(binding.menuIconDirectCameraUpload.getDrawable(), primaryColor);
ThemeDrawableUtils.tintDrawable(binding.menuIconMkdir.getDrawable(), primaryColor);
binding.addToCloud.setText(getContext().getResources().getString(R.string.add_to_cloud, ThemeUtils.getDefaultDisplayNameForRootFolder(getContext())));
OCCapability capability = fileActivity.getCapabilities();
if (capability != null && capability.getRichDocuments().isTrue() && capability.getRichDocumentsDirectEditing().isTrue() && capability.getRichDocumentsTemplatesAvailable().isTrue() && !file.isEncrypted()) {
binding.templates.setVisibility(View.VISIBLE);
}
String json = new ArbitraryDataProvider(getContext().getContentResolver()).getValue(user, ArbitraryDataProvider.DIRECT_EDITING);
if (!json.isEmpty() && !file.isEncrypted()) {
DirectEditing directEditing = new Gson().fromJson(json, DirectEditing.class);
if (!directEditing.getCreators().isEmpty()) {
binding.creatorsContainer.setVisibility(View.VISIBLE);
for (Creator creator : directEditing.getCreators().values()) {
FileListActionsBottomSheetCreatorBinding creatorViewBinding = FileListActionsBottomSheetCreatorBinding.inflate(getLayoutInflater());
View creatorView = creatorViewBinding.getRoot();
creatorViewBinding.creatorName.setText(String.format(fileActivity.getString(R.string.editor_placeholder), fileActivity.getString(R.string.create_new), creator.getName()));
creatorViewBinding.creatorThumbnail.setImageDrawable(MimeTypeUtil.getFileTypeIcon(creator.getMimetype(), creator.getExtension(), user, getContext()));
creatorView.setOnClickListener(v -> {
actions.showTemplate(creator, creatorViewBinding.creatorName.getText().toString());
dismiss();
});
binding.creators.addView(creatorView);
}
}
}
if (!deviceInfo.hasCamera(getContext())) {
binding.menuDirectCameraUpload.setVisibility(View.GONE);
}
// create rich workspace
if (FileMenuFilter.isEditorAvailable(getContext().getContentResolver(), user, MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN) && file != null && !file.isEncrypted()) {
// != "": info set -> hide button
if (file.getRichWorkspace() == null || !"".equals(file.getRichWorkspace())) {
binding.menuCreateRichWorkspace.setVisibility(View.GONE);
} else {
binding.menuCreateRichWorkspace.setVisibility(View.VISIBLE);
}
} else {
binding.menuCreateRichWorkspace.setVisibility(View.GONE);
}
setupClickListener();
setOnShowListener(d -> BottomSheetBehavior.from((View) binding.getRoot().getParent()).setPeekHeight(binding.getRoot().getMeasuredHeight()));
}
Aggregations