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

Handle URLs #159

Open
Shagon94 opened this issue Aug 1, 2023 · 10 comments
Open

Handle URLs #159

Shagon94 opened this issue Aug 1, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@Shagon94
Copy link

Shagon94 commented Aug 1, 2023

Is your feature request related to a problem? Please describe.

IT would be nice if the app had supported URLs - that in turn would allow for a nice home-assistant integration - allowing the app to be turned via another app.

Describe the solution you'd like

Something like:

        <!-- Accepts URIs that begin with "smarttwitchtv://open” -->
        <data android:scheme="smarttwitchtv"
              android:host="open" />

Describe alternatives you've considered

None

Additional context

In home-assistant you can open apps, so for example to turn on plex or youtube:

     - show_name: true
        show_icon: true
        type: button
        icon: mdi:youtube
        tap_action:
          action: call-service
          service: remote.turn_on
          data:
            activity: vnd.youtube://
          target:
            entity_id: remote.atvremote
        hold_action:
          action: none
      - show_name: true
        show_icon: true
        type: button
        icon: mdi:plex
        tap_action:
          action: call-service
          service: remote.turn_on
          data:
            activity: plex://
          target:
            entity_id: remote.atvremote
        hold_action:
          action: none

I basically reference plex:// to open plex and vnd.youtube:// to open youtube. Having this would allow for even more features - such as allowing SmartTV Client for Twitch to open the URL from the launcher directory to the activity.

@fgl27
Copy link
Owner

fgl27 commented Aug 1, 2023

I'll take a look and add on future update.

@fgl27 fgl27 added the enhancement New feature or request label Aug 1, 2023
@SebRut
Copy link

SebRut commented Sep 22, 2024

I'd like to have this feature as well for a home-assistant integration. I have some experience developing android apps and might be able to develop the android side for this.
@fgl27 any pointers about what would need to be changed, how to pass the url data to the webview?

@fgl27
Copy link
Owner

fgl27 commented Sep 22, 2024

You can send the url to js calling a new method here

//Same as in smartTwitchTV/release/api.js

If you go to the java code you can see examples of smartTwitchTV calls.

@fgl27
Copy link
Owner

fgl27 commented Sep 22, 2024

If you wanna to test a js method you can follow this

https://github.com/fgl27/SmartTwitchTV?tab=readme-ov-file#inside-the-apk

@SebRut
Copy link

SebRut commented Sep 23, 2024

Seems like I'm not able to build the app without requiring bigger changes. Seems like https://github.com/GCX-HCI/tray is deprecated and not available from repositories anymore.

@fgl27
Copy link
Owner

fgl27 commented Sep 23, 2024

Are you sure? Can see the errors?

I build just fine

@SebRut
Copy link

SebRut commented Sep 23, 2024

This is the error im getting:

Configuration cache state could not be cached: field `__librarySourceSets__` of task `:app:mapDebugSourceSetPaths` of type `com.android.build.gradle.tasks.MapSourceSetPathsTask`: error writing value of type 'org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection'
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find net.grandcentrix.tray:tray:0.12.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/net/grandcentrix/tray/tray/0.12.0/tray-0.12.0.pom
       - https://repo.maven.apache.org/maven2/net/grandcentrix/tray/tray/0.12.0/tray-0.12.0.pom
       - https://plugins.gradle.org/m2/net/grandcentrix/tray/tray/0.12.0/tray-0.12.0.pom
       - https://oss.sonatype.org/content/repositories/snapshots/net/grandcentrix/tray/tray/0.12.0/tray-0.12.0.pom
     Required by:
         project :app

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

If you're using the same machine regularly the library might still be in local gradle cache. You could try ./gradlew :app:assembleDebug --refresh-dependencies to trigger a build with redownloaded dependencies.

Checking https://mvnrepository.com/artifact/net.grandcentrix.tray/tray/0.12.0 also indicates that the dependency is not present in any of the usual repositories.

@fgl27
Copy link
Owner

fgl27 commented Sep 23, 2024

I fix that also check this as that is the next error

b421b6a

@SebRut
Copy link

SebRut commented Sep 26, 2024

@fgl27 I'm able to build and run the app now (after commenting out the Firebase/Crashlytics stuff in PlayerActivity too) and can parse deeplink intents. But tbh I'm a bit lost in how to use the extracted data. It seems like "starting a stream" from the deeplink info for example could happen here https://github.com/fgl27/SmartTwitchTV/blob/master/apk/app/src/main/java/com/fgl27/twitch/PlayerActivity.java#L1520 . But in my understanding the web app more or less always expects some web state to exist when performing actions, so that there's no easy "open this channels page in the web app" command yet.
Am I missing something or are there any pointers on what could be called in the web app side of the app?

@fgl27
Copy link
Owner

fgl27 commented Sep 26, 2024

The app can receive an intent when it is not running, in that scenario it saves the intent, so when the app opens it can send that intent to the webview... seems odd as the intent opens the app, but when it does the webview or PlayerActivity are not yet running.

We already have intents from the home screen

private static Intent createAppIntent(Context context, String channel_obj, int channel_type) {

To mod this you will need

  • Add an extra to the intent… new Gson().toJson(new PreviewObj("URL_FROM_INTENT", "URL", 0))
  • Make sure the action is defined and can be properly filtered
  • New boolean similar to isChannelIntent but isURLIntent for the action
  • Update some boolean checks to make sure the intent is saved and retrievable by the web implementation

Here I will add the new type handle to deal with all the URL
https://github.com/fgl27/SmartTwitchTV/blob/25a592bee5fa96451adfc93ddf04b023cdc15d42/app/specific/Main.js#L3184C27-L3184C31

Make sure once you are done to share with me all possible URLs… Channel, VOD, live, video wherever there is.
If it is needed to evaluate if it is live or just channel, all of that will be done by that new intent JS code.

is a little confusing but the app is not ready to receive a random intent, once this is done I can improve to make things easier to understand and make the handle of multiple intents simpler, but you make something I check and improve.

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

No branches or pull requests

3 participants