Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intent/Activity API for opening the Card Browser #11885

Closed
shocklateboy92 opened this issue Jul 19, 2022 · 5 comments · Fixed by #11899
Closed

Intent/Activity API for opening the Card Browser #11885

shocklateboy92 opened this issue Jul 19, 2022 · 5 comments · Fixed by #11899
Labels
Accepted Maintainers welcome a PR implementing this feature Enhancement
Milestone

Comments

@shocklateboy92
Copy link

Is your feature request related to a problem? Please describe.
At the moment, I have a website with my relevant anki notes to things like nid:1238753945. I have to select the text (which is rather painful on mobile) and click "Card Browser" in the context menu to go to it.

Describe the solution you'd like
An intent API for navigating to the Card Browser with an action parameter filled in as the search query.
Since you can deep-link to intents with a specially crafted hyperlinks in web apps, this would make the experience much nicer. I could make the nid:1238753945 text a hyperlink that automatically opens AnkiDroid to the right note when tapped.

Describe alternatives you've considered
Since it's not possible to use the native API from a website, I tried to see if context menu intents can already be triggered from a hyperlink. Unfortunately, I'm not very experienced in android development and couldn't figure out how to craft that intent hyperlink by looking at the AndroidManifest.xml.
If it's already possible, that would be great! If not, I'm hoping it would just be a small change to the way the intent is exported.

@david-allison david-allison added Accepted Maintainers welcome a PR implementing this feature Enhancement labels Jul 19, 2022
@david-allison
Copy link
Member

david-allison commented Jul 19, 2022

I don't believe this is possible yet. Sounds like a great idea. Pull requests welcome!

@mikehardy
Copy link
Member

interesting, from the doc you linked "A little known feature..." indeed it is! I work with mobile apps and dynamic links from firebase a lot but did not know the chrome browser could do this.

From their example they mention consulting the zxing AndroidManifest to see the scheme definition, it's here, and it appears you just need to define whatever scheme you want (e.g., ankidroid):

https://github.com/zxing/zxing/blob/5231442ebc14ae7f1eb6d916983705b682d1bf96/android/AndroidManifest.xml#L82-L88

      <!-- Support zxing://scan/?... like iPhone app -->
      <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="zxing" android:host="scan" android:path="/"/>
      </intent-filter>

seems like we could define our "verbs" as hosts on whatever filters we want, make sure they are DEFAULT/BROWSABLE so they can open the app, that the filters are defined for the right activity in our app, and we pass in the parameters we need and it would work.

As David said, PRs welcome, this would be interesting

@david-allison
Copy link
Member

For reference, what AnkiMobile uses: https://docs.ankimobile.net/url-schemes.html

@mikehardy
Copy link
Member

looks like it doesn't support search, perhaps @dae has an opinion on what URL scheme he'd like to see for a note id search to open card browser?

@dae
Copy link
Contributor

dae commented Jul 20, 2022

x-callback-url is an iOS thing, so it might not be practical to use the same scheme on both platforms. But I'd suggest using a generic search endpoint where the search string is passed in, rather than making something specific for note ids.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Maintainers welcome a PR implementing this feature Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants