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

ui: Implement support for Android Dynamic Shortcuts

Open tturner opened this issue 2 years ago • 3 comments

This is an updated version of the pull request https://github.com/WireGuard/wireguard-android/pull/48 to try to make it more likely to be merged.

The hard work was done by @gergely-sallai Gergely Sallai in their fork. I have tweaked it as follows:

  • update to compile against the current master branch
  • made a small cosmetic change to the alignment of the UI component
  • squashed into a single commit for simplicity

I hope this is the right way to get this merged and that I haven't broken any github etiquette!

Original pull request information reproduced below:

Added support for Android Dynamic Shortcuts. Dynamic Shortcuts is a standard Android feature that is supported by most of the launchers.

How does this work for users? Now users can request the app to add shortcuts to their favourite tunnels. When the user enables this for a specific tunnel, 2 dynamic shortcuts are created, one to UP the tunnel, other is to DOWN it.

Additionally this functionality enables users to use certain automation apps to automatically toggle tunnels. For example the built-in Bixby Routines on Samsung devices. (This was my original motivation for adding this feature, but I was trying to incorporate it in a way that could benefit all users.)

What changes were made to previous components to support this? TunnelToggleActivity is now more broadly used. Previously it seemed to be only called from TileService in certain situations. A new button has been added next to the tunnel toggle switch for each tunnel item. Added androidx shortcuts library Limitations and possible points for future improvement To my best knowledge all of these -- expect the first point -- were there previous to my PR, and I can help to sort these out if needed.

Tooltip popup for the "add shortcuts" button is only available for devices running API 26 and up. This could be solved generally via TooltipCompat, but I didn't want to complicate the code because of this. As doing this with the compat lib can not be done purely from XML.. TunnelToggleActivity can be shown briefly when a tunnel is toggled, and it can look weird. This could possibly be solved by adding some design to the activity and showing it a bit longer in a controlled manner, maybe with some animation. There may be some misconfigurations around material colors, it caused me some rendering differences on certain OS version with the button colors. I believe this could be solved with a refactor to support Material You (M3) and its dynamic colors, and fall back to a default on older versions. I do not know what is the intended design language of the app, so I didn't dare to refactor it just yet. :)

tturner avatar Jun 11 '23 14:06 tturner

Why it can not work on DDNS for IPv6. It always shows 'WireGuard / GoBackend : DNS host <domain.name> failed to resolve ; trying again'.However it can work on [<IPv6>]:port.

MoLanShao avatar Aug 20 '23 16:08 MoLanShao

Thanks for this patch. And sorry it's taken so long to review it.

I left some comments for @gergely-sallai or @tturner to address.

One question: why not just have a single toggle action, rather than separate up&down actions? Seems to add a lot of GUI clutter.

zx2c4 avatar May 12 '25 14:05 zx2c4

Is there any interest in addressing the review comments on this PR? I'm open to merging this after review.

msfjarvis avatar Sep 19 '25 18:09 msfjarvis