Skip to content

Create topic-based share targets for quicker sharing#164

Open
photown wants to merge 4 commits into
binwiederhier:mainfrom
photown:dynamic-share-targets
Open

Create topic-based share targets for quicker sharing#164
photown wants to merge 4 commits into
binwiederhier:mainfrom
photown:dynamic-share-targets

Conversation

@photown

@photown photown commented Mar 18, 2026

Copy link
Copy Markdown

These changes update MainActivity to create dynamic shortcuts as the subscriptions are observed. These shortcuts are shown in the share sheet whenever the user shares content with the supported mime types (text, images, audio, video).

For reference, shortcuts are shown in 2 main ways:

  • As direct share targets in the share sheet (introduced in SDK 29)
  • As shortcuts when long-pressing on an app in launchers (introduced in SDK 25)

Relevant notes:

  • The subscription shortcuts use the display name of the subscription (if set) or the topic name
  • The subscription shortcuts use the subscription icon if set
  • When deleting a subscription, the dynamic shortcut is removed immediately
  • When the user shares through a dynamic shortcut, ShareActivity is pre-filled with the topic name
  • Dynamic shortcuts work for multiple surfaces, not just the share sheet. When the user long-presses on the Ntfy app, they can see the topic shortcuts there as well. Tapping on them opens the same ShareActivity but with ACTION_VIEW rather than ACTION_SEND. I created a change to gracefully handle this case, so that it routes to DetailActivity.
  • Additionally, a new preference is introduced under a new "Sharing" category in the global app preferences. The preference allows the user to enable auto-sharing whenever they share text or files using the direct share targets from the share sheet. This saves the user the effort of tapping on the publish button.

This change was tested in the following configurations:

  • My personal device with SDK 36 (latest)
  • Emulator with SDK 26 (lowest supported level for the Ntfy app). That's from before direct share exists but shortcuts still work there.
  • Emulator with SDK 28 (the last version before introducing direct share). Also confirmed to work as expected.
  • Emulator with SDK 29 (first version that supports direct share). Direct share works here as expected.

Here's a screenshot of me sharing a web page. You can see the topic-based share target (I've set the name to "my topic"):

Screenshot_20260318-012004

And here is a screenshot of the new preference to allow automatic publishing:
Screenshot_20260320_030414

This commit updates MainActivity to create dynamic shortcuts as the subscriptions are observed. These shortcuts are shown in the share sheet whenever the user shares content with the supported mime types (text, images, audio, video).

Relevant notes:
- The subscription shortcuts use the display name of the subscription (if set) or the topic name
- The subscription shortcuts use the subscription icon if set
- When deleting a subscription, the dynamic shortcut is removed immediately
- When the user shares through a dynamic shortcut, ShareActivity is pre-filled with the topic name
@photown photown changed the title Create dynamic shortcuts for topics for quicker sharing Create topic-based share targets for quicker sharing Mar 18, 2026
@photown
photown force-pushed the dynamic-share-targets branch 2 times, most recently from 531d876 to c79e205 Compare March 19, 2026 07:04
The dynamic shortcuts that were added for the share sheet also appear when long-pressing on the app in the launcher. These launcher shortcuts start ShareActivity as well, but with the ACTION_VIEW action instead of ACTION_SEND.

Since it does not make sense to start a sharing activity from a launcher-level shortcut, this case is handled gracefully by re-routing ShareActivity to DetailActivity.
@photown
photown force-pushed the dynamic-share-targets branch 3 times, most recently from 51e5b16 to 93019b2 Compare March 20, 2026 06:54
This change introduces a new boolean preference in the global app settings, which allows users to automatically publish the shared content when it's shared directly to a topic from the share sheet. It's false by default.

When the setting is true and there is valid content to share (text or file), ShareActivity automatically calls the publish API without the user having to tap the publish button.
@photown
photown force-pushed the dynamic-share-targets branch from 93019b2 to ac20b31 Compare March 21, 2026 01:58
@binwiederhier

Copy link
Copy Markdown
Owner

I dislike new settings, because I don't want ntfy to be an app with 800,000 toggles and options. What would be the downsides of just enabling this by default for everyone?

@photown

photown commented Apr 8, 2026

Copy link
Copy Markdown
Author

The Android share sheet allows up to 8 direct share targets per app, so the downside would be that users who have multiple topics will have their share sheets potentially flooded with these share targets. Maybe that's not a big deal though. I'm happy to turn it on by default.

Instead of creating a new preference, auto send will be enabled by default. Whenever the user taps on a dynamic target in the share sheet, it will be automatically sent without the user having to tap the send button.
@photown

photown commented Jul 7, 2026

Copy link
Copy Markdown
Author

@binwiederhier I removed the new settings. Now auto send is enabled by default for users who tap on the dynamic targets from the share sheet. Please take a look.

@wunter8

wunter8 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The Android share sheet allows up to 8 direct share targets per app, so the downside would be that users who have multiple topics will have their share sheets potentially flooded with these share targets. Maybe that's not a big deal though. I'm happy to turn it on by default.

The new settings toggle was just to control whether or not the message auto-sends, right? Since it didn't let you disable the dynamic shortcuts entirely, flooding the share sheet is still a potential concern, right?

@photown

photown commented Jul 7, 2026

Copy link
Copy Markdown
Author

Yes, that's correct. Since share targets are ordered by usage frequency, maybe having 8 share targets isn't a concern since users will still see the most frequently used ones first. I can check if we can limit the share targets to a lower number if needed, e.g. only publish the top 3 as dynamic targets. But as far as I know, other apps don't have extra logic for that.

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.

3 participants