Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShareItems - sharing files #187

Closed
db0321 opened this issue Oct 10, 2023 · 12 comments
Closed

ShareItems - sharing files #187

db0321 opened this issue Oct 10, 2023 · 12 comments
Assignees
Labels
enhancement New feature or request feedback Awaiting feedback

Comments

@db0321
Copy link

db0321 commented Oct 10, 2023

need NSPreviewRepresentingActivityItem and NSPreviewRepresentableActivityItem for sharing files on MacOS Venture 13.3 with NSSharingServicePicker

@db0321 db0321 changed the title ShareItems - ShareItems - sharing files Oct 10, 2023
@DelphiWorlds DelphiWorlds self-assigned this Oct 10, 2023
@DelphiWorlds DelphiWorlds added the enhancement New feature or request label Oct 10, 2023
@DelphiWorlds
Copy link
Owner

For my reference, and for anyone else interested in how this may be approached:
https://developer.apple.com/documentation/sharedwithyou/adding_shared_content_collaboration_to_your_app?language=objc

@DelphiWorlds
Copy link
Owner

Having said that, can you indicate the reasons for wanting support for this? This is just to clarify the requirement

@DelphiWorlds DelphiWorlds added the feedback Awaiting feedback label Oct 10, 2023
@db0321
Copy link
Author

db0321 commented Oct 11, 2023

I am trying to send files via share sheet on Mac with OS Ventura 13.3. The ShareItems demo seems to work with texts and images, but not with files. An empty share sheet appears when I try to share file. I think the problem is in unit DW.ShareItems.Mac in procedure Share in line LActivityItems.addObject(TNSFileWrapper.Alloc.initWithURL(LURL, 0));
I think thar LURL needs other type of container to appear in share sheet.

@DelphiWorlds
Copy link
Owner

OK, thanks.. I'll look into it

@db0321
Copy link
Author

db0321 commented Oct 11, 2023

Thank you ... also, it would be great to be be able to use share sheet in Microsoft Windows as well.

@DelphiWorlds
Copy link
Owner

Regarding Windows, please see this. If you know of a close equivalent, please let me know

@db0321
Copy link
Author

db0321 commented Oct 11, 2023

It seems to me that Windows.ApplicationModel.DataTransfer could do the similar thing on MS Windows, i.e. access share sheet panel. It initiates the user interface for sharing content with another app programmatically.

Where IDataTransferManagerInterop is alternative for desktop applications

https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/display-ui-objects#for-classes-that-implement-idatatransfermanagerinterop

and static class DataTransferManager is for UWP apps
https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.datatransfer.datatransfermanager?view=winrt-22621

@DelphiWorlds
Copy link
Owner

I think the problem on macOS may be that TNSFileWrapper is not needed, i.e. the line instead of

  LActivityItems.addObject(TNSFileWrapper.Alloc.initWithURL(LURL, 0))

should be:

  LActivityItems.addObject(LURL);

I'll test later this evening, but you might also like to try

@db0321
Copy link
Author

db0321 commented Oct 11, 2023

I have just found out that this works for me:

LActivityItems.addObject(TNSitemProvider.Alloc.initWithContentsOfURL(LURL));

the share sheet appers correctly

@DelphiWorlds
Copy link
Owner

Thanks.. I'll incorporate the change

@db0321
Copy link
Author

db0321 commented Oct 11, 2023

If possible, I would also suggest to replace line

FPicker.showRelativeToRect(MakeNSRect(0,,0,0,0), LView, CGRectMinYEdge); // <----- Might need to adjust the values in MakeNSRect

with this code

mR.TopLeft:=aControl.LocalToAbsolute(pointf(0,0));
mR.BottomRight:=aControl.LocalToAbsolute(pointf(aControl.Width, aControl.Height));
FPicker.showRelativeToRect(MakeNSRect(mR.Left, LView.Bounds.size.height-mR.Bottom, mR.Width, mR.Height), LView, CGRectMinYEdge);

where mR is TRectF

to position the share sheet below the aControl

@DelphiWorlds
Copy link
Owner

Closing as the requirements have been met, other than the request for Windows support, which is now in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feedback Awaiting feedback
Projects
None yet
Development

No branches or pull requests

2 participants