cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Clelland <iclell...@chromium.org>
Subject Re: [Android] 4.0.x plugin fixes
Date Fri, 06 Jun 2014 17:20:17 GMT
This is the code that I'd be using to get, for instance, the File plugin
from the FileTransfer plugin:

    Class webViewClass = webView.getClass();
    PluginManager pm;
    try {
        Method gpm = webViewClass.getMethod("getPluginManager");
        pm = (PluginManager) gpm.invoke(webView);
    } catch (NoSuchMethodException e) {
        Field pmf = webViewClass.getField("pluginManager");
        pm = (PluginManager)pmf.get(webView);
    }
    FileUtils filePlugin = (FileUtils) pm.getPlugin("File");


This would replace both the old-style field access:

    FileUtils filePlugin =
(FileUtils)(webView.pluginManager.getPlugin("File"));

and the new-style getter:

    FileUtils filePlugin =
(FileUtils)(webView.getPluginManager().getPlugin("File"));
It's not so bad, maybe. We would have to include it in three or four places
in our plugins, and then they would work with both 3.x and 4.x branches.
Other devs could follow suit, or just publish different versions, or just
develop for 4.x and above :)

Ian

On Fri, Jun 6, 2014 at 12:09 PM, Andrew Grieve <agrieve@chromium.org> wrote:

> I like the reflection idea since that will let us avoid branching & make
> the plugins work with both 3.x and 4.x. Others will hit the same problem,
> but likely others will want a way to target both versions as the solution.
>
>
> On Fri, Jun 6, 2014 at 10:51 AM, Ian Clelland <iclelland@chromium.org>
> wrote:
>
> > This has been bugging me for a bit now. We definitely need a branch for
> > development on the plugins. (FTR, there's a pluggable_webview branch on
> > file, file-transfer and media-capture already, with this particular fix.
> We
> > can rename that)
> >
> > We're going to have trouble releasing these plugins when we release
> > cordova-android 4.0.0 -- I don't think that the tools right now will
> > support having two installable versions of a plugin, distinguished only
> by
> > one of the <platform> version requirements. That's a deficiency that we
> > need to fix before 4.0.
> >
> > Alternately, we use reflection in our core plugins to see whether the
> > WebView class has these methods, and support both 3.x and 4.x with the
> same
> > code. That's a pretty ugly solution, though, and doesn't help anyone else
> > in the same situation.
> >
> >
> > On Fri, Jun 6, 2014 at 9:56 AM, Marcel Kinard <cmarcelk@gmail.com>
> wrote:
> >
> > > That is my first thought as well. Perhaps name the plugin branch
> > something
> > > like “android-4.0”?
> > >
> > > On Jun 5, 2014, at 5:38 PM, Steven Gill <stevengill97@gmail.com>
> wrote:
> > >
> > > > 4.0 branch for the plugins?
> > > >
> > > >
> > > > On Thu, Jun 5, 2014 at 2:33 PM, Joe Bowser <bowserj@gmail.com>
> wrote:
> > > >
> > > >> Hey
> > > >>
> > > >> So, since we're wanting to introduce new APIs, such as
> > > >> getPluginManager() and getPlugin() on the WebView itself, we're
> going
> > > >> to need to update our plugins.  I did some work on this today, but
I
> > > >> need to know where these changes should live, since I don't think
> they
> > > >> belong in master until 4.0.x on Android is released.
> > > >>
> > > >> So, What should we do with this?  Any ideas?
> > > >>
> > > >> Joe
> > > >>
> > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message