@@ -99,11 +99,42 @@ class IntentHandlerTest {
9999 testIntentType(" content://valid" , " text/csv" , LaunchType .TEXT_IMPORT )
100100 testIntentType(" content://valid" , " text/tsv" , LaunchType .TEXT_IMPORT )
101101
102- // Test for ACTION_SEND
103- testIntentType(" content://valid" , " text/tab-separated-values" , LaunchType .TEXT_IMPORT , Intent .ACTION_SEND )
104- testIntentType(" content://valid" , " text/comma-separated-values" , LaunchType .TEXT_IMPORT , Intent .ACTION_SEND )
105- testIntentType(" content://valid" , " text/csv" , LaunchType .TEXT_IMPORT , Intent .ACTION_SEND )
106- testIntentType(" content://valid" , " text/tsv" , LaunchType .TEXT_IMPORT , Intent .ACTION_SEND )
102+ // Test for ACTION_SEND with file streams (should still be TEXT_IMPORT)
103+ testIntentTypeWithStream(" content://valid" , " text/tab-separated-values" , LaunchType .TEXT_IMPORT )
104+ testIntentTypeWithStream(" content://valid" , " text/comma-separated-values" , LaunchType .TEXT_IMPORT )
105+ testIntentTypeWithStream(" content://valid" , " text/csv" , LaunchType .TEXT_IMPORT )
106+ testIntentTypeWithStream(" content://valid" , " text/tsv" , LaunchType .TEXT_IMPORT )
107+ }
108+
109+ @Test
110+ fun sharedTextIntentStartsApp () {
111+ // Test that sharing plain text content (not files) opens the note editor
112+ // instead of attempting CSV import
113+ val intent =
114+ Intent (Intent .ACTION_SEND ).apply {
115+ type = " text/plain"
116+ putExtra(Intent .EXTRA_TEXT , " Some shared text content" )
117+ }
118+
119+ val expected = getLaunchType(intent)
120+
121+ assertThat(expected, equalTo(LaunchType .SHARED_TEXT ))
122+ }
123+
124+ @Test
125+ fun sharePlainTextDoesNotTriggerCsvImport () {
126+ val intent =
127+ Intent (Intent .ACTION_SEND ).apply {
128+ type = " text/plain"
129+ putExtra(Intent .EXTRA_TEXT , " This is some shared text that should create a note" )
130+ // No EXTRA_STREAM means this is shared text content, not a file
131+ }
132+
133+ val launchType = getLaunchType(intent)
134+
135+ // Should NOT be TEXT_IMPORT (which would trigger CSV import and fail)
136+ // Should be SHARED_TEXT (which launches note editor directly)
137+ assertThat(launchType, equalTo(LaunchType .SHARED_TEXT ))
107138 }
108139
109140 private fun testIntentType (
@@ -128,4 +159,18 @@ class IntentHandlerTest {
128159
129160 assertThat(expected, equalTo(LaunchType .DEFAULT_START_APP_IF_NEW ))
130161 }
162+
163+ private fun testIntentTypeWithStream (
164+ data : String ,
165+ type : String ,
166+ expected : LaunchType ,
167+ ) {
168+ val intent =
169+ Intent (Intent .ACTION_SEND ).apply {
170+ putExtra(Intent .EXTRA_STREAM , data.toUri())
171+ this .type = type
172+ }
173+ val actual = getLaunchType(intent)
174+ assertThat(actual, equalTo(expected))
175+ }
131176}
0 commit comments