Skip to content

Add sharing functionality to receive links from other apps#62

Merged
yogeshpaliyal merged 6 commits intomasterfrom
copilot/fix-46
Sep 12, 2025
Merged

Add sharing functionality to receive links from other apps#62
yogeshpaliyal merged 6 commits intomasterfrom
copilot/fix-46

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 7, 2025

This PR implements the ability to receive links via Android's sharing mechanism from other apps. Users can now share URLs from browsers, social media apps, or any other app directly to Deepr for saving as deeplinks.

Implementation Details

The implementation adds an Android intent filter to handle ACTION_SEND intents with text/plain MIME type. When a URL is shared to Deepr:

  1. The app opens automatically with the save dialog pre-populated
  2. The shared URL is validated using the existing isValidDeeplink() function
  3. Users can add a name and save the deeplink normally
  4. Invalid shared content shows an appropriate error message

Technical Changes

AndroidManifest.xml: Added intent filter to receive share intents

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>

MainActivity.kt: Extract shared text from incoming intents and pass to UI layer

val sharedText = when {
    intent?.action == Intent.ACTION_SEND -> {
        if (intent.type == "text/plain") {
            intent.getStringExtra(Intent.EXTRA_TEXT)
        } else null
    }
    else -> null
}

Home.kt: Auto-populate save dialog with shared URLs via LaunchedEffect

LaunchedEffect(sharedText) {
    if (!sharedText.isNullOrBlank() && saveDialogInfo == null) {
        if (isValidDeeplink(sharedText)) {
            saveDialogInfo = SaveDialogInfo(sharedText, false)
        } else {
            Toast.makeText(context, "Invalid deeplink from shared content", Toast.LENGTH_SHORT).show()
        }
    }
}

User Experience

  • Seamless Integration: Works with Android's native sharing system
  • Automatic Population: Save dialog opens instantly with shared URL
  • Error Handling: Graceful handling of invalid shared content
  • Preserved Functionality: All existing features remain unchanged

Supported Sources

  • Web browsers (Chrome, Firefox, Edge, etc.)
  • Social media apps (Twitter, Reddit, LinkedIn, etc.)
  • Messaging apps (WhatsApp, Telegram, etc.)
  • Any app that shares text/plain content containing URLs

The implementation uses minimal, surgical changes that follow existing code patterns and preserve all current functionality while adding this highly requested feature.

Fixes #46.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/agents/gradle-instrumentation-agent-8.13.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.13 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits September 7, 2025 17:40
Co-authored-by: yogeshpaliyal <9381846+yogeshpaliyal@users.noreply.github.com>
Co-authored-by: yogeshpaliyal <9381846+yogeshpaliyal@users.noreply.github.com>
Copilot AI changed the title [WIP] Add links via sharing from other apps Add sharing functionality to receive links from other apps Sep 7, 2025
Copilot AI requested a review from yogeshpaliyal September 7, 2025 17:43
@yogeshpaliyal yogeshpaliyal marked this pull request as ready for review September 12, 2025 04:21
@yogeshpaliyal yogeshpaliyal merged commit 079fafc into master Sep 12, 2025
1 check passed
@yogeshpaliyal yogeshpaliyal deleted the copilot/fix-46 branch September 12, 2025 05:30
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.

Add links via sharing from other apps

2 participants