Skip to content

Add CopyToClipboard block to Sharing component (Android & iOS)#3741

Open
Akashgite1 wants to merge 8 commits intomit-cml:masterfrom
Akashgite1:feature-copy-to-clipboard
Open

Add CopyToClipboard block to Sharing component (Android & iOS)#3741
Akashgite1 wants to merge 8 commits intomit-cml:masterfrom
Akashgite1:feature-copy-to-clipboard

Conversation

@Akashgite1
Copy link
Contributor

@Akashgite1 Akashgite1 commented Jan 25, 2026

General items:

  • I have updated the relevant documentation files under docs/
  • My code follows the:
    • Google Java style guide
    • Google JavaScript style guide
  • ant tests passes on my machine

If your code changes how something works on the device (i.e., it affects the companion):

  • I branched from ucr
  • My pull request has ucr as the base

Further, if you've changed the blocks language or another user-facing designer/blocks API (added a SimpleProperty, etc.):

  • I have updated the corresponding version number in YaVersion.java
  • I have updated the corresponding upgrader in YoungAndroidFormUpgrader.java
  • I have updated the corresponding entries in versioning.js

For all other changes:

  • I branched from master
  • My pull request has master as the base

What does this PR accomplish?

This PR adds a new CopyToClipboard method to the Sharing component, allowing developers to copy text to the system clipboard without invoking the platform share sheet.

The implementation works consistently across platforms:

  • Android uses ClipboardManager and ClipData
  • iOS uses UIPasteboard.general

The change is additive and backward compatible.

Summary

This PR adds a new CopyToClipboard method to the Sharing component, allowing apps to copy text to the system clipboard without invoking the platform share sheet.

Platform support

  • Android: Uses ClipboardManager and ClipData
  • iOS: Uses UIPasteboard.general

Versioning

  • Bumped SHARING_COMPONENT_VERSION from 1 → 2
  • Updated blocklyeditor/src/versioning.js (no upgrade required)

Notes

This is an additive, backward-compatible change. No existing blocks or behaviors are modified, and no SCM upgrades are required.
No YoungAndroidFormUpgrader changes are required since this PR only adds a new method and does not alter existing properties or block semantics.

Resolves #3736

@AppInventorWorkerBee
Copy link
Collaborator

Can one of the admins verify this patch?

1 similar comment
@AppInventorWorkerBee
Copy link
Collaborator

Can one of the admins verify this patch?

@ewpatton ewpatton self-assigned this Jan 27, 2026
@ewpatton
Copy link
Member

@Akashgite1 Make sure to update YoungAndroidFormUpgrader.java, otherwise existing projects with a Sharing component will report an error.

Copy link
Contributor Author

@Akashgite1 Akashgite1 left a comment

Choose a reason for hiding this comment

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

Added Sharing component handling in YoungAndroidFormUpgrader for version 2 (CopyToClipboard).
This is an additive change; no property migrations are required.

Copy link
Member

@ewpatton ewpatton left a comment

Choose a reason for hiding this comment

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

Make sure to actually build and test this code as well.

Copy link
Contributor Author

@Akashgite1 Akashgite1 left a comment

Choose a reason for hiding this comment

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

@ewpatton

✅ Block Visible in UI

Block visible in UI

✅ Tested Locally
1️⃣ Custom Companion Build

Companion Test

Verified:

  • Clipboard content copies correctly
  • Able to paste into other apps successfully

2️⃣ Compiled APK

Compiled APK Test

Tested scenarios:

  • Empty string
  • Long string
  • Unicode strings (emoji & multilingual)
  • Multiple rapid invocations

No crashes or permission issues observed.

@Akashgite1 Akashgite1 requested a review from ewpatton February 2, 2026 09:23
@SusanRatiLane
Copy link
Contributor

@AppInventorWorkerBee ok to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement CopyToClipboard block for Sharing component

4 participants