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 url fix #154

Merged
merged 1 commit into from
May 15, 2023
Merged

Intent url fix #154

merged 1 commit into from
May 15, 2023

Conversation

elpaxel
Copy link
Contributor

@elpaxel elpaxel commented May 12, 2023

Fix opening intent:// url from javascript and by left click.

Fix opening intent:// url from javascript and by left click.
@truefedex
Copy link
Owner

@elpaxel please explain why this is needed. Can you tell me where the intent:// URLs is used? And why open them through onOpenInExternalAppRequested if askUserAndOpenInExternalApp is used further in the code? Your code will automatically open the external application, but other TVbro users have complained about this behavior, so a permission request from the user has been added.

@elpaxel
Copy link
Contributor Author

elpaxel commented May 12, 2023

So right now if I'm doing this on the page:

location.href = "intent://some_video_url.m3u8#Intent;action=android.intent.VIEW;scheme=https;type=video/*;S.subtitles_location=/some_subtitles.vtt;end";

then TVbro says there is no app for this type of url.

I have used "onOpenInExternalAppRequested" because there is "Intent.parseUri(url, Intent.URI_INTENT_SCHEME)". I guess this way my url parsed correctly and "subtitles_location" that I use for VLC will be in place. Second reason because that function is the old version of intent handling I guess (old fix).

As for the code further in and "askUserAndOpenInExternalApp", it uses "Intent(Intent.ACTION_VIEW, uri)". I guess it creates new Intent with ACTION_VIEW and expects "plain" url. Something like "intent://some_video_url.m3u8". But this way (again I guess) "subtitles_location" will be stripped. I have made this assumptions by reading code because as of now it is failing there.

It is working fine with my fix but my reflections may be wrong because I don't use Kotlin and didn't read your code too deeply.

@elpaxel
Copy link
Contributor Author

elpaxel commented May 12, 2023

So I have changed this:
val intent = Intent(Intent.ACTION_VIEW, uri)
to this:
val intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME)
and everything working fine.

This edit based on this docs.

When used with parseUri(String, int), any other scheme will result in a generic VIEW action for that raw URI.

So the code flow remains the same.

Links tested to work:
intent://some_video_url.m3u8#Intent;action=android.intent.VIEW;scheme=https;type=video/*;S.subtitles_location=/some_subtitles.vtt;end
https://some_video_url.m3u8
magnet:?xt=urn:btih:some_hash

But this way there is permission popup appearing every time. A little bit annoying.
I think it is better to not trigger permission popup when you specifically using intent:// scheme.

@ggg70 ggg70 mentioned this pull request May 14, 2023
@truefedex truefedex changed the base branch from master to develop May 15, 2023 12:46
@truefedex truefedex merged commit 63a3a83 into truefedex:develop May 15, 2023
@truefedex
Copy link
Owner

@elpaxel Thank you for explanations. I think may be I will change a bit this behaviour later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants