Page MenuHomePhabricator

Text selection and sharing does not work with HTC Sense
Closed, ResolvedPublic

Description

When selecting a text on the Wikipedia Android App the header is supposed to change and show a share button to use the "Share a fact" feature. This share button does not appear on Android with HTC Sense but only the native text selection widget appears (see screenshot).

Android Version 4.1.1
HTC Sense Version 4+

2015-04-15_16.56.38.png (960×540 px, 196 KB)

Event Timeline

Bene raised the priority of this task from to Needs Triage.
Bene updated the task description. (Show Details)
Bene subscribed.

@Bene What happens if you tap the share button?

Just the default sharing dialog appears, and when selecting an option, it contains only the selected text.

2015-04-15_17.11.06.png (960×540 px, 128 KB)

It's rather related to this code I guess: https://github.com/wikimedia/apps-android-wikipedia/blob/8e6a483085490424f936e0b2347e600f7ffe0a82/wikipedia/src/main/java/org/wikipedia/page/PageActivity.java#L847

Check what kind of ActionMode this is...
If its tag is non-null, it means that the ActionMode is one of ours (History,
Saved Pages, or Find In Page). Otherwise, it must be the default WebView text-
highlighting ActionMode, in which case we'll invoke the Share adapter!

Maybe the default share adapter on the WebView can be disabled somehow?

It is related precisely to the code that @Deskana mentioned.
The way that we hook into the default context buttons is by searching for them by name (the actual name of the resource ID). On certain devices, these buttons simply do not have a name, so there's no way for us to "find" them, or distinguish them from each other. At the moment we don't have a solution for this (but suggestions are welcome).

As I suggested, I'd not try to use the default context menu which Android provides but rather add a context menu in the action bar on top of the app as shown in the promotion video. See also the pages I've linked above.

As I suggested, I'd not try to use the default context menu which Android provides but rather add a context menu in the action bar on top of the app as shown in the promotion video. See also the pages I've linked above.

That's part of the issue; the context menu at the top of the screen is the default one that Android provides on that model of phone. It varies from phone to phone.

This problem is actually really complex, and is all because some phone manufacturers decide to ignore the standards they're supposed to be following. :-(

@Bene Sure, we could entirely override the default context menu and provide our own, but if we do that, then we'd have to re-implement all the other context buttons ("copy", "select all", "search") ourselves, and the WebView doesn't provide publicly-accessible methods for interacting with its contents that way.

Change 209277 had a related patch set uploaded (by Dbrant):
Make sure Share button works on all devices.

https://gerrit.wikimedia.org/r/209277

Change 209277 merged by jenkins-bot:
Make sure Share button works on all devices.

https://gerrit.wikimedia.org/r/209277

Checked with 2.0.101-alpha-2015-05-05
There is a Share menu that appears when text selection is made.

Screenshot_2015-05-14-14-37-09.jpg (1×800 px, 594 KB)

Berlin.jpg (360×640 px, 50 KB)

Berlin (1).jpg (360×640 px, 47 KB)

The Share card for Berlin - there is a bug filed: T99144