Waboodoo / HTTP-Shortcuts

Android app to create home screen shortcuts that trigger arbitrary HTTP requests
https://http-shortcuts.rmy.ch
MIT License
1.17k stars 113 forks source link

I'd like to open the shortcuts from a specific browser #267

Closed chagai95 closed 2 years ago

chagai95 commented 2 years ago

Use case: Every time I open a shortcut it opens a new tab so I'd like to use opening these shortcuts from a different browser which I can clutter with open tabs and occasionally just close all tabs.

chagai95 commented 2 years ago

Maybe this is helpful: https://stackoverflow.com/questions/10267952/android-launching-specific-url-with-specific-browser

chagai95 commented 2 years ago

I'm assuming I could add that here? https://github.com/Waboodoo/HTTP-Shortcuts/blob/1ca4389d26bd1954499e919e6087eb2c95885e62/HTTPShortcuts/app/src/main/kotlin/ch/rmy/android/http_shortcuts/activities/ExecuteActivity.kt#L505

How would I go about making this configurable?

Waboodoo commented 2 years ago

Hi,

This is already somewhat possible. You can open a specific app with specific data (in this case a URL) by using the app's Scripting capabilities, specifically the sendIntent function.

Try creating a "Scripting Shortcut" and inserting the following code snippet into it:

sendIntent({
    type: 'activity',
    action: 'android.intent.action.VIEW',
    dataUri: 'https://example.com',
    packageName: 'com.android.chrome',
});

What this will do is it tries to open a specific app (in this case Google Chrome, but you can easily swap out the package name of a different browser app) and sends the specified URL to it (just insert your own URL there).

Find more information about Scripting here: https://http-shortcuts.rmy.ch/scripting

chagai95 commented 2 years ago

Amazing I'll try it out, thx so much! Is there a way to open the link as a WebView inside the app? That'll solve the problem of a new tab altogether and also solve another problem I'm having - the website I'm trying to open caches the time so either the WebView which I'm assuming doesn't have caches or I'll have to pass the time with JavaScript into the url each time with the current time...

Waboodoo commented 2 years ago

No, that's not possible, or at least not in the way I think you want. The app is not meant as to be used as a browser, but to send HTTP requests. So you can set it up to fetch a page and load the response into a webview, but it will not behave like it would in a normal browser. For example there will be no JavaScript support, and any link on that page would open an external browser. This is intended for displaying simple HTML responses, not fully fletched websites, so probably it does not work well for your usecase.

chagai95 commented 2 years ago

Thanks!

Waboodoo commented 2 years ago

I will include an option into the app to allow defining a custom browser for Browser Shortcuts, to facilitate this a bit. It will be part of the next release (2.14.0).