Skip to content

Commit

Permalink
open card browser and search using ankimobile-style deep links (#11899)
Browse files Browse the repository at this point in the history
  • Loading branch information
krmanik authored Aug 20, 2022
1 parent eeb59af commit 5c72117
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions AnkiDroid/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@
android:configChanges="keyboardHidden|orientation|locale|screenSize|uiMode"
android:parentActivityName=".DeckPicker"
>
<intent-filter android:label="@string/card_browser">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "anki://x-callback-url/browser” -->
<data android:scheme="anki" android:host="x-callback-url" android:path="/browser"/>
</intent-filter>
</activity>
<activity
android:name=".ModelBrowser"
Expand Down
6 changes: 6 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,12 @@ open class CardBrowser :
initNavigationDrawer(findViewById(android.R.id.content))
startLoadingCollection()

// search card using deep links
intent.data?.getQueryParameter("search")?.let {
mSearchTerms = it
searchCards()
}

// for intent coming from search query js api
intent.getStringExtra("search_query")?.let {
mSearchTerms = it
Expand Down

0 comments on commit 5c72117

Please sign in to comment.