dennisjzh / GwtMobile-PhoneGap

gwtmobile-phonegap is a GWT wrapper of the PhoneGap Javascript library. PhoneGap is a cross-platform development framework that provides core mobile device features to web-based mobile apps. GWT by Google is a new way of developing web applications -- write apps in Java then compile into javascript. gwtmobile-phonegap enables a GWT mobile application to use PhoneGap functions.
57 stars 14 forks source link

Added some plugins #4

Closed smithimage closed 12 years ago

smithimage commented 12 years ago

Hi there dennisjzh.

I have added some new plugins, I tried to merge both our work however the ChildBrowser had changed a bit a so I could not merge it completely. It had in your version got static functions.

I dont know if I have merged it into the package structure you want, if not perhaps you can just copy the plugins you feel fit in your GwtMobile-Phongap.

The plugins i have added / updated is (all added plugins are ios ones by the way): DatePicker Sharekit Prompt TestFlight MapKit NotificationEx TabBar CustomUrl

dennisjzh commented 12 years ago

smithimage, good deal! i will get to it quickly. btw, all plugins are ios? no android love? :-)

smithimage commented 12 years ago

No Android love yet unfortunately... :)

dennisjzh commented 12 years ago

I merged your pull request as it-is. Some external .js files will be removed later on. I try not to include external files in the source tree.

Do you have any test code on the use of these plugins? that would help me include these plugins in the kitchen sink demo.

smithimage commented 12 years ago

Hi there dennisjzh!

Forgive me for my late reply, however time is a bit scarce at the moment :). I could / will absolutely try to add some examples to the kitchen sink demo. However all plugins are quite dependent on some external .js, objective C .m .h files but also some configuration in the xcode project such as the info.plist file etc.

How would you like me to set those up / document them? Should I add a readme file into each plugin directory, which explains how one should ad the .js file to the .gwt file etc. and references the originating readme files from each phonegap plugin?

By the way did the package structure work? I noticed that you left the iphone package as sibling to the mapkitplug and the nativecontrols. Is the mapkitplug and nativecontrols ported to andriod as well? If not should we put those in the iphone package as well or bring the plugins in the iphone package up one level so that all plugins will be siblings in the plugins package?

best regards smithimage

dennisjzh commented 12 years ago

smithimage,

If you can add some examples to the kitchen sink demo, that would be perfect. I don't think you will need to add a readme file for each plugin. The plugin source code repository should be the best source for install instructions.

I started looking into your code and have some thoughts. The overall coding is solid. But there are places where I see changes are needed. Basically, the gwt mobile phonegap code follows a "simple and unsophisticated" approach. Only one java file is created for each phonegap feature (or plugin). Since most of the java code is simple wrapper code, it will not make the code hard to read even if the file size is big. In reality, most of the gwt mobile phonegap file size is not big at all. Also, most phonegap objects in the javascript world have only one instance. Therefore, using static method in the wrapper code is sufficient in most cases. Lastly, I consider that the use of event bus and event handlers with phonegap is overkill. I believe an implementation of simple callback is good enough for normal use cases.

I updated the ChildBrowser plugin with the ideas mentioned above. The other plugins will be changed in similar way as well. You can take a look at my recent commit for the changes with the child browser plugin.

smithimage commented 12 years ago

Hi again dennisjzh!

I will start adding examples on the plugins asap.

I agree that the GWT wrapper code should be as thin as possible. I must confess that some of the wrappers were written during my learning of JSNI and is not using the best patterns (eventbus etc.). I have now lately used more and more callback interfaces instead (se Prompt plugin). You state "The other plugins will be changed in similar way as well." Do you intend to change them or do you want me to do it? If you do the changes I will wait with the kitchensink examples so that they correspond with the coming changes.

By the way do you have any thoughts in regard to the namespace issue I mentioned in my previous message?

Best regards.

smithimage

dennisjzh commented 12 years ago

I updated most of the plugins. You can start creating demos for the ones in the iphone package.

I don't think I changed the package of mapkitplug and nativecontrols. But they will be moved to the iphone package when I get to them tomorrow. I created two sub-packages under plugins, one for iphone, one for android. Plugins that are only available on one platform go into one of the sub-packages.

smithimage commented 12 years ago

Hi again I have started to implement a few examples DatePicker, Prompt and NotificationEx are finished. You can pull them if you like..

dennisjzh commented 12 years ago

smithimage, did you send me a pull request? BTW, I finished updating your code. You can sync up with the changes if you have not done so yet. Thx.

smithimage commented 12 years ago

Ohh no forgot.. I will..

I just did a pull from you repo so all should be in sync..

By the way have you noticed errors from the GWT compiler stating that Classes that extend JavaScriptObject must have final member methods?

dennisjzh commented 12 years ago

Indeed. I don't know when but eclipse stopped displaying this kind of errors on the source code editor. Fixed. Thanks for pointing it out.