feat: "Ask Conduit" context menu on text selection

This commit is contained in:
cogwheel0
2025-08-29 13:05:31 +05:30
parent f0b9e8e2b0
commit c9fd68eff8
3 changed files with 49 additions and 1 deletions

View File

@@ -70,6 +70,21 @@
</intent-filter>
</activity>
<!-- Adds a text-selection action (Android) shown in the selection toolbar.
It forwards the selected text into our existing share flow so the
Dart share handler receives it just like a regular share. -->
<activity
android:name=".ProcessTextActivity"
android:exported="true"
android:label="Ask Conduit"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<!-- Background streaming service -->
<service
android:name=".BackgroundStreamingService"

View File

@@ -0,0 +1,31 @@
package app.cogwheel.conduit
import android.app.Activity
import android.content.Intent
import android.os.Bundle
/**
* Entry point for Android's text selection context menu (ACTION_PROCESS_TEXT).
* This activity immediately forwards the selected text to the app via an
* ACTION_SEND intent targeted at MainActivity so the existing share handler
* pipeline (share_handler) processes it uniformly.
*/
class ProcessTextActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val text = intent?.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT)?.toString() ?: ""
val sendIntent = Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(Intent.EXTRA_TEXT, text)
// Route directly to our MainActivity so share_handler sees it
setClass(this@ProcessTextActivity, MainActivity::class.java)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
startActivity(sendIntent)
finish()
}
}

View File

@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>Ask Conduit</string>
<!-- Uncomment below lines if you want to use a custom group id rather than the default. Set it in Build Settings -> User-Defined -->
<!-- <key>AppGroupId</key>
<string>$(CUSTOM_GROUP_ID)</string> -->