grocy-android icon indicating copy to clipboard operation
grocy-android copied to clipboard

Support Deeplinks

Open nxfifteen opened this issue 2 years ago • 6 comments

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"`

nxfifteen avatar Apr 15 '22 17:04 nxfifteen

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.

dominiczedler avatar Apr 16 '22 00:04 dominiczedler

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 avatar Apr 16 '22 04:04 nxfifteen

@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.

patzly avatar Apr 17 '22 10:04 patzly

@nxfifteen What is the current status? If you can get it working with Patrick's info you could create a pull request for it. :-)

dominiczedler avatar Apr 27 '22 19:04 dominiczedler

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

nxfifteen avatar Apr 28 '22 05:04 nxfifteen

Is there any progress on this topic? Would be interested in seeing your solution @nxfifteen. 🙂

LC7894 avatar Aug 08 '22 00:08 LC7894

@nxfifteen Please give us an update on your work or at least some solution you've tested so we can close this issue. :)

dominiczedler avatar Sep 15 '22 23:09 dominiczedler

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

nxfifteen avatar Sep 16 '22 09:09 nxfifteen

Can be closed with #573. Thanks for your solution @nxfifteen!

dominiczedler avatar Sep 22 '22 23:09 dominiczedler