Search in sources :

Example 1 with FileListActionsBottomSheetCreatorBinding

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()));
}
Also used : OCCapability(com.owncloud.android.lib.resources.status.OCCapability) DirectEditing(com.owncloud.android.lib.common.DirectEditing) ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) Gson(com.google.gson.Gson) Creator(com.owncloud.android.lib.common.Creator) View(android.view.View) FileListActionsBottomSheetCreatorBinding(com.owncloud.android.databinding.FileListActionsBottomSheetCreatorBinding)

Aggregations

View (android.view.View)1 Gson (com.google.gson.Gson)1 FileListActionsBottomSheetCreatorBinding (com.owncloud.android.databinding.FileListActionsBottomSheetCreatorBinding)1 ArbitraryDataProvider (com.owncloud.android.datamodel.ArbitraryDataProvider)1 Creator (com.owncloud.android.lib.common.Creator)1 DirectEditing (com.owncloud.android.lib.common.DirectEditing)1 OCCapability (com.owncloud.android.lib.resources.status.OCCapability)1