feat: "Ask Conduit" context menu on text selection
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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> -->
|
||||
|
||||
Reference in New Issue
Block a user