Skip to content

Commit

Permalink
enhacement: allow the apkg packages to be shared with AnkiDroid
Browse files Browse the repository at this point in the history
  • Loading branch information
criticalAY authored and BrayanDSO committed Mar 20, 2024
1 parent 2bf7a5d commit 08e543d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion AnkiDroid/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="application/apkg"/>
<data android:mimeType="application/colpkg"/>
<data android:mimeType="application/vnd.anki"/>
<data android:mimeType="application/x-apkg"/>
<data android:mimeType="application/x-colpkg"/>
<data android:mimeType="application/octet-stream"/>
<data android:mimeType="application/zip"/>
<data android:mimeType="text/tab-separated-values"/>
<data android:mimeType="text/comma-separated-values"/>
</intent-filter>
Expand Down
22 changes: 12 additions & 10 deletions AnkiDroid/src/test/java/com/ichi2/anki/IntentHandlerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,19 @@ class IntentHandlerTest {

@Test
fun textImportIntentReturnsTextImport() {
// TSV import
var intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(Uri.parse("content://valid"), "text/tab-separated-values")
var expected = getLaunchType(intent)
assertThat(expected, equalTo(LaunchType.TEXT_IMPORT))
testIntentType("content://valid", "text/tab-separated-values", LaunchType.TEXT_IMPORT)
testIntentType("content://valid", "text/comma-separated-values", LaunchType.TEXT_IMPORT)

// CSV import
intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(Uri.parse("content://valid"), "text/comma-separated-values")
expected = getLaunchType(intent)
assertThat(expected, equalTo(LaunchType.TEXT_IMPORT))
// Test for ACTION_SEND
testIntentType("content://valid", "text/tab-separated-values", LaunchType.TEXT_IMPORT, Intent.ACTION_SEND)
testIntentType("content://valid", "text/comma-separated-values", LaunchType.TEXT_IMPORT, Intent.ACTION_SEND)
}

private fun testIntentType(data: String, type: String, expected: LaunchType, action: String = Intent.ACTION_VIEW) {
val intent = Intent(action)
intent.setDataAndType(Uri.parse(data), type)
val actual = getLaunchType(intent)
assertThat(actual, equalTo(expected))
}

@Test
Expand Down

0 comments on commit 08e543d

Please sign in to comment.