Brion VIBBER has submitted this change and it was merged. Change subject: Handle external links ......................................................................
Handle external links Change-Id: I8c94b6fe9d621c50dfd9c0c75796c939d315360b --- M wikipedia/src/main/java/org/wikimedia/wikipedia/LinkHandler.java 1 file changed, 17 insertions(+), 1 deletion(-) Approvals: Brion VIBBER: Verified; Looks good to me, approved diff --git a/wikipedia/src/main/java/org/wikimedia/wikipedia/LinkHandler.java b/wikipedia/src/main/java/org/wikimedia/wikipedia/LinkHandler.java index 38cd142..1bdd059 100644 --- a/wikipedia/src/main/java/org/wikimedia/wikipedia/LinkHandler.java +++ b/wikipedia/src/main/java/org/wikimedia/wikipedia/LinkHandler.java @@ -1,6 +1,8 @@ package org.wikimedia.wikipedia; import android.content.Context; +import android.content.Intent; +import android.net.Uri; import android.util.Log; import com.squareup.otto.Bus; import org.json.JSONException; @@ -34,16 +36,30 @@ this.bridge.addListener("linkClicked", this); } + private void handleExternalLink(String href) { + Intent intent = new Intent(); + intent.setAction(Intent.ACTION_VIEW); + intent.setData(Uri.parse(href)); + context.startActivity(intent); + } + @Override public void onMessage(String messageType, JSONObject messagePayload) { try { String href = messagePayload.getString("href"); + if (href.startsWith("//")) { + // That's a protocol specific link! Make it https! + href = "https:" + href; + } + Log.d("Wikipedia", "Link clicked was " + href); if (href.startsWith("/wiki/")) { // TODO: Handle fragments String pageName = href.replace("/wiki/", ""); bus.post(new NewWikiPageNavigationEvent(new PageTitle(null, pageName))); + } else { + // Assume everything else is an external link... for now! + handleExternalLink(href); } - Log.d("Wikipedia", "Link clicked was " + href); } catch (JSONException e) { throw new RuntimeException(e); } -- To view, visit https://gerrit.wikimedia.org/r/93424 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8c94b6fe9d621c50dfd9c0c75796c939d315360b Gerrit-PatchSet: 7 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Yuvipanda <yuvipa...@gmail.com> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits