We added the "add to home" shortcut functionality, originally captured in #224
Since then, some users have reported that it's not working for them. Let's capture some data about which Launchers are not working to see if it's specifically a Launcher problem or something else.
I can confirm that the two launchers mentioned here as well as Apolo launcher are not working for me on a Samsung Galaxy S8 (8.1) and a Google Pixel XL (9.0).
Tested on a Samsung S6 (Android 7.0)
✅ Fastkey
✅ Apolo
The shortcuts are created as you'd expect.
Tested on a Pixel 2 (Android 9.0)
👎FastKey
👎Apolo
It seems that the shortcut is created, but not on the Launcher you'd expect - it adds it to the default Pixel Launcher every time you create one.
I don't know what the solution is yet, though.
The same happens on Chrome; ie, it doesn't work on other Launchers. 😞
I'll leave this open for now, and if anyone has more info they can add it, but it may well be we can't do anything else here. It might just be that the Launchers need to implement something to allow the action to happen.
I tested this further and when using Fastkey launcher, the shortcut is not crested - both on DuckDuckGo and Google Chrome for Android. It's interesting that it works for @cdrussell on Samsung S6 though.
I've also shared this GitHub issue link with the developers of Fastkey on email, to share any ideas they might have.
@arunsathiya what OS version are you using? I suspect the problem only exists on newer versions of Android, maybe Oreo and newer.
@CDRussell I am on Android 8.1.0 at the moment. Also noting that it's a OnePlus 5, which might be offering a flavoured version of Android, not stock.
I looked into this some more and it appears that ShortcutManagerCompat.isRequestPinShortcutSupported(context) returns false when using launchers that do not support the add to home feature (which includes the launchers we confirmed as not working on Android 8+; it seems to return true on older Android versions using said launchers, however).
Since other competing browsers seem to also have this issue with the launchers we've tested, and given @CDRussell's experience with the add to home feature behaving unpredictably on certain launchers (i.e. making a shortcut on an inactive launcher - not cool!), I think maybe it would be best to either do the ShortcutManagerCompat.isRequestPinShortcutSupported(context) check on button click and handle it there or update the view model canAddToHome = true to use the result of ShortcutManagerCompat.isRequestPinShortcutSupported(context) instead of true, which I believe will effectively "grey it out" for unsupported configurations, though I have not tested this.
If you like these ideas and do not have time to implement/test them, I would be happy to implement and thoroughly test these approaches.
For reference: https://developer.android.com/reference/android/support/v4/content/pm/ShortcutManagerCompat
Thanks for the info, @In2deep73. You are very much right that we should be checking ShortcutManagerCompat.isRequestPinShortcutSupported(context) which we aren't currently doing.
This will return false when the current Launcher doesn't support the shortcut. If your favourite Launcher doesn't currently support them, that's an issue for the Launcher to resolve (if it wants to), and there's nothing further we can do to force it on them.
So it seems there are two parts of this problem:
ShortcutManagerCompat.isRequestPinShortcutSupported(context)com.android.launcher.action.INSTALL_SHORTCUT to support shortcuts. If anyone is raising an issue with a Launcher about this issue, point them to the source code of ShortcutManagerCompat.isRequestPinShortcutSupported() method; there may be more work required by the Launchers, but that's for them to support. I have created a PR for the changes this app needs: #382. If anyone could test that branch out, I'd be most grateful.
@arunsathiya if you want to follow-up on your email to Fastkey, tell them they likely need to support com.android.launcher.action.INSTALL_SHORTCUT.
That is only used on newer OS versions (>= API 26; Oreo and newer) so that's why Fastkey shortcuts work on older OS versions but not on newer ones.
Fixed by #382
Thanks again all for your help in raising, diagnosing and solving the problem! 🎉
@CDRussell I shall do that, thanks for getting to the bottom of this and fixing it! 🏆
Most helpful comment
Thanks for the info, @In2deep73. You are very much right that we should be checking
ShortcutManagerCompat.isRequestPinShortcutSupported(context)which we aren't currently doing.This will return false when the current Launcher doesn't support the shortcut. If your favourite Launcher doesn't currently support them, that's an issue for the Launcher to resolve (if it wants to), and there's nothing further we can do to force it on them.
So it seems there are two parts of this problem:
ShortcutManagerCompat.isRequestPinShortcutSupported(context)com.android.launcher.action.INSTALL_SHORTCUTto support shortcuts. If anyone is raising an issue with a Launcher about this issue, point them to the source code ofShortcutManagerCompat.isRequestPinShortcutSupported()method; there may be more work required by the Launchers, but that's for them to support.I have created a PR for the changes this app needs: #382. If anyone could test that branch out, I'd be most grateful.