Bangle.js: Intents - extending functionality #2769
No reviewers
Labels
No labels
device mi band 7
activity post processing
activity/health
Android 12
Android 13
android integrations
architecture
Bangle.js
bug
changes requested
charts
deprecation notice
details not provided
developer documentation
device amazfit band 5
device amazfit bip
device amazfit cor
device Casio
device fossil
device garmin
device gtr 2e
device gts 2 mini
device h30
device hplus
device huami
device Huawei
device liveview
device mi band
device mi band 2
device mi band 3
device mi band 4
device mi band 5
device mi band 6
device no.1 f1
device pace
device pebble
device pebble 2
device pinetime infinitime
device request
device sony
device support
device watch 9
device xiaomi
discussion
documentation
duplicate
enhancement
feature request
Gadgetbridge
good first issue
help wanted
i am developing my own app can you help
icebox
intent api
internationalisation
invalid
needs work
network companion app
new device
no feedback
not a bug
notifications
one of the 1000 issues about disconnection
pairing/connecting
potentially fixed / confirm and close
question
research
security
seems abandoned
Solved, waiting for F-Droid release
suggest to close
task
user interface / UX
wear os
weather
wontfix
Zepp OS
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Freeyourgadget/Gadgetbridge#2769
Loading…
Reference in a new issue
No description provided.
Delete branch "Ganblejs/Gadgetbridge:Intents"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The additions in this PR has been developed together with @gfwilliams in this forum post and this closed PR to his Gadgetbridge-fork. I have also gotten input from José Rebelo, vanous and Sylvia in the Gadgetbridge matrix chat. Thank you to everyone!
Gadgetbridge with a Bangle.js now supports starting activities in addition to sending broadcasts. Targeting services is yet to be implemented.
action, category, mimetype, data, extra, package, class and target information can now be supplied to intents (these are also the corresponding keys to use when programming intent messages to send to gadgetbridge). Values to pass to target are "", "broadcastreceiver", "activity", "service" or target can be left out.
Template for initiating an intent through javascript-code from a Bangle.js app that sends message to Gadgetbridge:
Bluetooth.println(JSON.stringify({t:"intent", action:"", category:"", mimetype:"", data:"", package:"", class:"", target:"", extra:{someKey:"someValueOrString"}}));
Key/value-pairs in the template above can be omitted if not applicable in the specific case.
Things to consider:
Future work for another PR:
Follow up PR: #2826
WIP: Intentsto IntentsIntentsto Bangle.js : Intents - extending functionalityBangle.js : Intents - extending functionalityto Bangle.js: Intents - extending functionalityShould permission "Display over other apps" also be introduced for the main build variant, since intents for Bangle.js is present there as well?
Thank you, we will look at it.
@ -287,2 +287,4 @@
}
if (BuildConfig.FLAVOR.equals("banglejs") &&
ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.SYSTEM_ALERT_WINDOW) == PackageManager.PERMISSION_DENIED) {
I've now noticed this doesn't behave as for other permissions and like I want/expect it to. When launching "Bangle.js Gadgetbridge" the associated pop-up to this permission will always show, even if the the setting is enabled.
@Ganblejs, how would I go about trying this? Can you please give some example of how I could test it (besides looking at the code)?
Thank you.
Do you mean specifically what I mentioned in my last comment:
Or the PR in general?
In case of the former I reproduce the bug on my end by:
In case of the latter, do you have a Bangle.js to test with yourself?
EDIT:
How it works:
Bluetooth.println(JSON.stringify({t:"intent", action:"android.intent.action.VIEW", category:"android.intent.category.DEFAULT", package:"com.spotify.music", data:"spotify:track:5QEFFJ5tAeRlVquCUNpAJY:play", target:"activity" }));
If it's possible to emulate the Bangle.js Gadgetbridge receiving the message in (2.) I think maybe you could test the code just as well without a Bangle.js. I've been browsing the GB code to try and understand how I could achieve this. I've come across the "ADD TEST DEVICE MANUALLY" debug option in the app - can that be used in some way?
I've written a Bangle.js app for testing some intents, mainly for spotify-actions for now. Other intent-messages can be implemented if it's needed. I've tested it on my Bangle.js 2 but I think it should work on a Bangle.js 1 as well.
It can be loaded to the watch here.
The code for the app can be reviewed here.
Ping! @vanous. Just in case you weren't alerted to/didn't notice my latest comments. Fully understand if you're occupied with other things.
Hi, yes, i am aware but unfortunatelly i do not have either bangle nor spotify...
These examples are helpful. Can you please rebase this branch? Thank you.
a653c18844
tof8102767e4
@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
I think we should add this + the permission check on the default flavor, since there are for sure people using the F-Droid build with a Bangle.js
Makes sense.
I've however noticed that the permission check doesn't seem to work for this permission.
As stated before I rebased the PR re this:
I've now noticed this doesn't behave as for other permissions and like I want/expect it to. When launching "Bangle.js Gadgetbridge" the associated pop-up to this permission will always show, even if the the setting is enabled.
I've moved it to the main AndroidManifest.xml now.
Permission check is now working and present in the default flavor.
@ -295,2 +295,2 @@
<string name="pref_summary_device_intents">Allow Bangle.js watch apps to send Android Intents, and allow other apps on Android (like Tasker) to send data to Bangle.js with the com.banglejs.uart.tx Intent.</string>
<string name="pref_summary_sync_calendar">Enables calendar alerts, even when disconnected</string>
<string name="pref_summary_device_intents">Allow Bangle.js watch apps to send Android Intents, and allow other apps on Android (like Tasker) to send data to Bangle.js with the com.banglejs.uart.tx Intent. Needs permission to display over other apps to work in the background.</string>
<string name="pref_summary_sync_calendar">Enables calendar alerts, even when disconnected</string>
(nitpick) thre's an extra tab at the end of this line
I've removed it now.
As stated before rebasing:
I've now noticed this doesn't behave as for other permissions and like I want/expect it to. When launching "Bangle.js Gadgetbridge" the associated pop-up to this permission will always show, even if the the setting is enabled.
Bangle.js: Intents - extending functionalityto WIP: Bangle.js: Intents - extending functionalityAdded WIP tag since the I have to sort out the permission check for displaying over other apps. Or possibly rethink and do without it.
Could we instead have a boolean stored for checking if the user has clicked 'ok' to go to the settings-page before, maybe?
WIP: Bangle.js: Intents - extending functionalityto Bangle.js: Intents - extending functionality@vanous @joserebelo
I just removed the WIP tag and think the PR is ready to be merged or at least reviewed again. Getting permissions for displaying over other apps works as expected now.
Cool, i will look at it during the week. Can you please squash the commits and rebase on top of the master? I can also do it via the webinterface I believe...
0879e3d613
to9c1b9d1e03
Squashed and rebased! Hopefully I did it correctly.
9c1b9d1e03
to2ad14b9442
2ad14b9442
to60c7f79366
OK, seems alright. The message to paint over other apps will be new for people and unexpected, but the message is clear, mentions Bangle and if people do not want that, it can be dismissed. I am merging it in now. 🤞
And of course thank you @Ganblejs for all the work and testing!
Thank you and everyone else for helping out as well!
Follow up PR: #2826