Page MenuHomePhabricator

mobile-html interaction handling
Open, NormalPublic



Apps need to know information about any user interaction on the mobile-html article page so it can respond appropriately


Add setInteractionHandler(interactionHandler) to the JS bridge

interactionHandler would be a function that takes a dictionary with a required action property that indicates what action was taken. Any other properties are the user information for that action. For example, tapping a link would produce {action: "link", href: "/wiki/otherpage"}. Other examples would be {action: "edit_section", section_id: 0} and {action: "reference", reference_id: "id2", adjacent_reference_ids: ["id1", "id2", "id3"]}.

When the user interacts with the page, the interactionHandler is called with the appropriate information.

Event Timeline

JoeWalsh created this task.Apr 3 2019, 2:55 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 3 2019, 2:55 PM
LGoto triaged this task as Normal priority.
JoeWalsh updated the task description. (Show Details)Apr 3 2019, 4:53 PM

@bearND this handles what's in both of those files as well as some new functionality. I don't think either approach should be directly re-used since there's platform-specific js-to-native bridging in each. Instead, the each app's native code calls into js to register the interactionHandler with the appropriate message handler.

On iOS the app would call:
wmf.setInteractionHandler((interaction) => { window.webkit.messageHandlers.interaction.postMessage(interaction); });

On Android (assuming there will be a new JavascriptInterface called InteractionWebInterface that could be used directly) the app would call:
wmf.setInteractionHandler((interaction) => {; });

JoeWalsh updated the task description. (Show Details)Tue, May 7, 1:46 PM