Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No menu entry to add shortcut to home screen #4423

Open
opk12 opened this issue Nov 6, 2021 · 15 comments
Open

No menu entry to add shortcut to home screen #4423

opk12 opened this issue Nov 6, 2021 · 15 comments
Labels
A-Shortcuts O-Occasional Affects or can be seen by some users regularly or most users rarely S-Tolerable Low/no impact on users T-Defect Something isn't working: bugs, crashes, hangs and other reported problems

Comments

@opk12
Copy link

opk12 commented Nov 6, 2021

Steps to reproduce

On my phone, the room settings screen and the app's long-tap context menu have no option to add a shortcut on the home screen. Shortcuts do work in other apps on the same phone.

element_bug_shortcut

Intended result and actual result

What did you expect?

To see options to add a shortcut to the home.

What happened instead?

There are no options to add a shortcut to the home.

Your phone model

Samsung

Operating system version

Android 7

Application version and app store

Element Android 1.3.3 (40103030) from F-Droid

Homeserver

matrix.org

Will you send logs?

No

@opk12 opk12 added the T-Defect Something isn't working: bugs, crashes, hangs and other reported problems label Nov 6, 2021
@bmarty
Copy link
Member

bmarty commented Nov 8, 2021

The app is checking here the returned value of isRequestPinShortcutSupported() before displaying this action item.
There is maybe a missing permission, can you check on the device app settings?

@bmarty bmarty added A-Shortcuts O-Occasional Affects or can be seen by some users regularly or most users rarely S-Tolerable Low/no impact on users labels Nov 8, 2021
@opk12
Copy link
Author

opk12 commented Nov 8, 2021

Install shortcuts and uninstall shortcuts are in the list for other apps, but not for Element. Do I report to F-droid?

tutti all1 all2

@ouchadam
Copy link
Contributor

which version of android 7 is the device running? from my understanding android added shortcut support in 7.1.1, so if this device is running 7.0 then unfortunately we won't be able to add shortcuts

https://developer.android.com/reference/android/content/pm/ShortcutManager.html (Api 25)
https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels

@opk12
Copy link
Author

opk12 commented Nov 17, 2021

Version 7.1.1. As said above, the other apps have working shortcuts and have install shortcuts/remove shortcuts in the "All permissions" list, Element does not.

@ouchadam
Copy link
Contributor

@bmarty this might actually be a simple case of using the ShorcutManagerCompat instead

By default the system version seems to support android 8.0+ but the compat version can go lower

Note: See also the support library counterpart ShortcutManagerCompat.isRequestPinShortcutSupported(Context), which supports Android versions lower than VERSION_CODES#O using the legacy private intent com.android.launcher.action.INSTALL_SHORTCUT.

@bmarty
Copy link
Member

bmarty commented Nov 17, 2021

Yes, this is the current imple : https://github.com/vector-im/element-android/blob/main/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt#L57. Is there something else you are thinking about?

@ouchadam
Copy link
Contributor

ah 🤦 I confused the ShortcutCreator for the system version

@opk12
Copy link
Author

opk12 commented Nov 17, 2021

The X-Needs-Info label is still present - is there other info I can provide about the phone?

@ouchadam
Copy link
Contributor

nope, only needed to confirm the exact android 7 version, have removed

@opk12
Copy link
Author

opk12 commented Nov 17, 2021

Ok. I have not experience in Android development, but where do the install shortcuts / remove shortcuts in the "All permissions" list come from for the other apps? I mean, the app has a hard-coded manifest with the permissions list? Or a build tool generates the list based on the invoked system library's methods?

@ouchadam
Copy link
Contributor

ideally the permission should come through via the ShortcutCompat library but there's something strange going on...

I'm also able to reproduce the issue on a 7.1.1 emulator and fix it by manually adding the com.android.launcher.permission.INSTALL_SHORTCUT permission

7.1.1 10 7.1.1 WITH PERMISSION 7.1.1 LAUNCHER (WP)
2021-11-17T17:53:47,088292286+00:00 Screenshot_20211117_175523 2021-11-17T17:59:18,282005910+00:00 2021-11-17T18:03:21,888363673+00:00

For some reason the shortcut permission is being commented by the ShortcutBadger library out during the manifest merging process

2021-11-17T18:05:37,932070832+00:00

@ouchadam
Copy link
Contributor

it seems the workaround is to long press the element icon from the launcher which will show shortcut options and then long press those to add to the homescreen

@opk12
Copy link
Author

opk12 commented Nov 17, 2021

it seems the workaround is to long press the element icon from the launcher which will show shortcut options and then long press those to add to the homescreen

How? When I long-press the Element icon on the home (Samsung builtin home screen), I have Select multiple items - Remove shortcut - Sleep - Uninstall - App info. Long-pressing them has the effect of a short press.

@bmarty
Copy link
Member

bmarty commented Nov 17, 2021

For some reason the shortcut permission is being commented by the ShortcutBadger library out during the manifest merging process

It was commented 7 years ago...

Maybe just add

<uses-permission
        android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
        android:maxSdkVersion="25" />

in our Manifest as a workaround, WDYT @ouchadam ?

@ouchadam
Copy link
Contributor

ouchadam commented Nov 18, 2021

How? When I long-press the Element icon on the home (Samsung builtin home screen), I have Select multiple items - Remove shortcut - Sleep - Uninstall - App info. Long-pressing them has the effect of a short press.

I see, this must be launcher dependant, using the Pixel launcher on 7.1.1 I'm able to long press the launcher icon which reveals the launcher shortcuts which I can then long press to add to the home screen


<uses-permission
        android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
        android:maxSdkVersion="25" />

in our Manifest as a workaround, WDYT @ouchadam ?

sounds reasonable to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Shortcuts O-Occasional Affects or can be seen by some users regularly or most users rarely S-Tolerable Low/no impact on users T-Defect Something isn't working: bugs, crashes, hangs and other reported problems
Projects
None yet
Development

No branches or pull requests

3 participants