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

Receive share intents android #843

Merged

Conversation

ggichure
Copy link
Collaborator

@ggichure ggichure commented Oct 19, 2023

Pull Request Description

This PR adds support to handle incoming intents to create posts.
supporting images, text and URI.

~URIs are handled as plain text and as such will be in the body of the text. ~
Ability to handle URIs and derive title from links.

Issue Being Fixed

Issue Number: #639 #850

Screenshots / Recordings

Screenshot_1697987135 Screenshot_1697987122
Screenshot_1697987163 Screenshot_1697987170

grab_link_title

Checklist

  • Did you update CHANGELOG.md?
  • Did you use localized strings where applicable?
  • Did you add semanticLabels where applicable for accessibility?

@ggichure
Copy link
Collaborator Author

@micahmo CreatePostPage requires communityId, I reckon this should be optional given that on onCommunitySelected we can mutate this. Or is there something I'm missing?

@micahmo
Copy link
Member

micahmo commented Oct 19, 2023

@ggichure Thank you so much for taking this on!

CreatePostPage requires communityId

#836 made that optional.

https://github.com/thunder-app/thunder/pull/836/files#diff-1dfd79b4b214fd9ed9d53e1f2ac1f8ba62ee8a7efb0b81119ee00d7c478ae308R25-R26

EDIT: I see the confusion. The parameter is required, but nullable. You can pass just null if you want. Or you can remove required as well.

@ggichure ggichure marked this pull request as ready for review October 22, 2023 15:16
@ggichure ggichure changed the title Attempt receive share intents android Receive share intents android Oct 22, 2023
Copy link
Member

@micahmo micahmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, this LGTM! This is something I've been wanting for a while, so thanks for taking it on!!

I left some comments on the code.

I also tested this feature and had the following comments.

  • Is it possible to add a "subtitle" to the share intent? For example, Boost says "Create post" so it's obvious what's going to happen when you share.
    image
  • Is it possible to detect when a URL is shared and place it in the URL field instead of the body of the post? I would guess (but may be wrong) that the most common use case will be sharing news articles, which we would want to post as links.
  • This is just a general note, but it would be super cool if we could grab the article title from link and use that as suggested post title, like the Lemmy web UI does. Something for the future. 😊

BTW, I have a coding style note which is totally just a personal preference but I'd like to mention and maybe get some feedback. When checking the value of a nullable bool, I prefer to use an equality test against the value I want, rather than a fallback to the value I don't. For example, I find...

bool? myVal;
if (myVal == true) {}

much more clear than

bool? myVal;
if (myVal ?? false) {}

However again, that's just a preference on my part. 😊

lib/community/pages/create_post_page.dart Outdated Show resolved Hide resolved
lib/community/pages/create_post_page.dart Outdated Show resolved Hide resolved
lib/thunder/pages/thunder_page.dart Outdated Show resolved Hide resolved
macos/Flutter/GeneratedPluginRegistrant.swift Show resolved Hide resolved
@ggichure
Copy link
Collaborator Author

This is just a general note, but it would be super cool if we could grab the article title from link and use that as suggested post title, like the Lemmy web UI does. Something for the future.

This would be awesome. I'll add it as a feature request.

@ggichure
Copy link
Collaborator Author

Is it possible to add a "subtitle" to the share intent? For example, Boost says "Create post" so it's obvious what's going to happen when you share.

Done
Screenshot 2023-10-23 at 10 39 44

@ggichure
Copy link
Collaborator Author

Is it possible to detect when a URL is shared and place it in the URL field instead of the body of the post? I would guess (but may be wrong) that the most common use case will be sharing news articles, which we would want to post as links.

Done.

final uri = Uri.tryParse(initialText!);
      if (uri?.isAbsolute == true) {

@ggichure
Copy link
Collaborator Author

This is just a general note, but it would be super cool if we could grab the article title from link and use that as suggested post title, like the Lemmy web UI does. Something for the future.

This would be awesome. I'll add it as a feature request.

This has been done. Although currently only works for urls coming from intents.
I'll need some guidance on handling this for manually added links.

Copy link
Member

@micahmo micahmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for responding to all the feedback! I tested again and it works great. I'd say it's good to go! 😊

@micahmo micahmo mentioned this pull request Oct 24, 2023
3 tasks
Copy link
Member

@hjiangsu hjiangsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks again for doing this. I think this package also supports iOS so I can work on getting the iOS to handle this properly

@hjiangsu hjiangsu merged commit 7dc0232 into thunder-app:develop Oct 25, 2023
1 check passed
@micahmo micahmo mentioned this pull request Oct 26, 2023
3 tasks
@micahmo
Copy link
Member

micahmo commented Oct 30, 2023

It looks like all link handling (i.e., the "open by default" feature) is now triggering the create post page. 😞 I'll see if I can look into this but might need your help @ggichure.

EDIT: Looks like it's because navigateToPost is looking for InstanceBloc which isn't defined when triggering from share. Might need your help too @hjiangsu. 😆

EDIT 2: The other problem is that both receive_sharing_intent and uni_links are handling the intent.action.VIEW intent.

qemu-system-x86_64_hxPuk0utVy.mp4

@ggichure
Copy link
Collaborator Author

It looks like all link handling (i.e., the "open by default" feature) is now triggering the create post page. 😞 I'll see if I can look into this but might need your help @ggichure.

EDIT: Looks like it's because navigateToPost is looking for InstanceBloc which isn't defined when triggering from share. Might need your help too @hjiangsu. 😆
qemu-system-x86_64_hxPuk0utVy.mp4

Interesting. I'll aslo look into it.

@micahmo micahmo mentioned this pull request Oct 30, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants