Last modified: 2012-02-24 02:52:33 UTC
Created attachment 9564 [details] Patch on Github It may be useful to open web links to Wikipedia form other apps (mail, facebook, twitter) in Wikipedia application rather than in a web browser. We can implement it with an android intent. I began to write a patch. What do you think about it ?
https://github.com/Tpt/Wikipedia/commit/4c670328bee7330095cdd83a64a74f19d44c5b5f
If it works, please just put a pull request on Github
Appears to work, though there's a couple things I'd recommend tweaking. Probably need to escape that URL before passing it into the query string; otherwise we might lose some chars. <http://en.wikipedia.org/wiki/AT&T> and <http://en.wikipedia.org/wiki/%3F> both pass through correctly, but I'm just suspicious. :) Some oddities: * Open Wikipedia app * switch to another app (say Gmail) * follow a Wikipedia link in this app to another page and open it in Wikipedia app A Wikipedia app screen pops up, loading the article. Neat! * now hold down 'home' button and switch to some other randon app * hold down 'home' and switch back to Wikipedia You're seeing the original page you had open before, not the one you followed a link to. * hold down 'home' and switch back to that other app (Gmail) Now we see the Wikipedia view again, in the context of this other app, instead of the rest of the app. * hitting 'back' from there can get us back to Gmail/etc While this feels natural for a single view/back cycle, going to other apps back back it looks very wrong. I'm also a little unsure about the input processing; if we somehow manage to get a bogus URL in there, does it load inline or does it pop back over to regular browser?
Escape URL : it's done by Android framework when it send it to the app. The app open only links to Wikipedia (wikipedia.org). If you can't open an other url like google.com in the app (it is android:host="*.wikipedia.org" in the manifest) For this problem of come back : it's because the link is open in an other instance of the main activity, I don't know how solve it.
The problem of come back is intended behaviour of Android. You get the same kind of things with thd default android browser or other apps. So that doesn't need to be solved.
So is there no way to actually go back to the launched app if we hit home?
The solution is to use the option android:launchMode="singleTask" of the android manifest. Here is a pull request that implement this way : https://github.com/wikimedia/WikipediaMobile/pull/114
There is an implementation here (https://github.com/wikimedia/WikipediaMobile/tree/open-intent) based on work/idaes from Tpt. It follows the Android guidelines and uses standard launch modes. Should be merged in after a bit of discussion
Merged https://github.com/wikimedia/WikipediaMobile/tree/open-intent