grocy-android
grocy-android copied to clipboard
Support Deeplinks
I use Grocy alot with home assistant and I was wondering would it be possible to make the deep links accessible from the action.VIEW intent?
I've got an idea to open the shopping list when my wife or I enter a geofence around the local shop - something like below - but I don't know if it's possible / useful to anyone else to to support such a feature in Grocy Android
`automation:
- alias: Open Shopping List When At Shops
trigger:
...
action:
- service: notify.mobile_app_<your_device_id_here> data: message: "command_activity" title: "grocy://shoppingModeFragment" data: channel: "xyz.zedler.patrick.grocy" tag: "android.intent.action.VIEW"`
Mmh I'm not using Home Assistant, so I can't say how this could work... The deeplinks for the pages are all accessible from the outside I think, because the launcher shortcuts use them. I don't know what I could do for you, because I did't get it what's missing for you... :-)
The example automation looks like it should work, but I can't tell you more, sorry.
Thanks for the reply @MrJohnZoidberg , the code above doesn't work as I'd hoped but that's fine.
I will have a play myself with the code and see if I can work it out. I thinks it's something in the AndroidManifest.xml cause the only activity I can call from outside the app is the SplashActivity but looking at the code it's MainActivity that handles deeplinks.
If I get it working I will submit a pull request you can consider
@nxfifteen You would have to set exported="true" for the MainActivity. Currently only activities with intents (launcher activities like SplashActivity) need this attribute, but if you want other activities to be visible for external apps and services, they also require this attribute.
@nxfifteen What is the current status? If you can get it working with Patrick's info you could create a pull request for it. :-)
Apologies for the hold up! I got it working thanks to @patzly 's feedback. I was testing it on me and my wife's phones and everything seems to be working as planned.
Sadly work also picked up and getting it committed and pushed fell on the back burner 😕. I'll get a pull request submitted tonight
Is there any progress on this topic? Would be interested in seeing your solution @nxfifteen. 🙂
@nxfifteen Please give us an update on your work or at least some solution you've tested so we can close this issue. :)
I'm really sorry about the radio silence, its been a long summer!
I was able to get it to work by adjusting the AndroidManifest.xml file and replacing this
<activity
android:name=".activity.MainActivity"
android:theme="@style/Theme.Grocy.BottomAppBar"
android:windowSoftInputMode="adjustPan" />
with this instead
<activity
android:name=".activity.MainActivity"
android:theme="@style/Theme.Grocy.BottomAppBar"
android:windowSoftInputMode="adjustPan"
android:exported="true">
<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="grocy"
android:host="shoppingmodefragment" />
</intent-filter>
</activity>
BUT that was 283 commits back. I'll sync up my fork now and make sure there is not anything that's changed in the mean time
Can be closed with #573. Thanks for your solution @nxfifteen!