Archive for the ‘phonegap’ Category

* Work

Posted on January 11th, 2010 by Dave Johnson. Filed under phonegap.


Crap it has been busy at work the past few months!

More to come soon though since I am working on a few small JavaScript libraries and two services that I will be releasing soon!

There has of course also been a tonne of amazing work being done on PhoneGap (tests, Palm, Nokia, simulator) - though not by me so much :)

Check out the latest at GitHub http://github.com/phonegap

Tags: , , .



* Long Live PhoneGap for BlackBerry

Posted on July 30th, 2009 by Dave Johnson. Filed under phonegap.


There have been some new developments in the PhoneGap on BlackBerry breathing new life into the project! It all boils down to the fact that in RIM OS >= 4.6 there is a browser rendering option that you can set to make the browser render using the modern rendering engine rather than the archaic one from OS 4.2.

It look something like this:

_renderingSession.getRenderingOptions().setProperty(
  RenderingOptions.CORE_OPTIONS_GUID, 17000, true);

After much trial and error it was found that the BrowserContentManager did not support this rendering option (and RIM says it is completely unsupported / experimental anyhow) yet the Field returned from BrowserContent.getDisplayableContent() does support it!

Long story short it looks like PhoneGap on RIM OS >= 4.6 is going to work really well.

Next up is looking at the new features in OS 5.0.

Tags: , , , .



* PhoneGap iPhone Approval

Posted on June 13th, 2009 by Dave Johnson. Filed under mobile, phonegap.


The guys over at Rhomobile posted about IPhone App Store rejection issues the other day - I can only assume due to the recent problems that some users of PhoneGap have been having. Rhomobile and PhoneGap are similar in that they are frameworks that enable developers to build native mobile apps in a language they are familiar with, Ruby and JavaScript respectively.

I think that they are pretty much spot on in terms of their interpretation of the App Store rule 3.2.2 that states:

An Application may not itself install or launch other executable code by any means, including without limitation through the use of a plug-in architecture, calling other frameworks, other APIs or otherwise. No interpreted code may be downloaded and used in an Application except for code that is interpreted and run by Apple’s Published APIs and built-in interpreter(s).

The two key points in this App Store rule are where it says an app “may not itself install or launch other executable code by any means” and this is exactly what users of PhoneGap are doing if their apps are downloading JavaScript over the network rather than including it in the application www folder. By downloading JavaScript over the network at runtime the application is downloading and running interpreted code that Apple has not control over during their app approval process.

So if any of you PhoneGap developers are worried about Apple rejecting your app just make sure that you don’t download any JavaScript at runtime and instead include it in the application. Having said that, also make sure that you apps don’t look like you just took a shit and emailed it to Apple :)

That is just my thoughts on the issue, whether or not that is the *real* reason that Apple is rejecting PhoneGap apps we may never know but that is certainly one reason that they would do it I think. It could just be because they feel like it

Tags: , , , .



* Eclipse Plugin Q&A

Posted on March 25th, 2009 by Dave Johnson. Filed under Web, phonegap, programming.


If you are one of the unfortunate few that has decided to, for profit or insanity, write an Eclipse plugin here are a few of the questions that I had during my ordeal and the answer or closest thing to an answer that I can come up with.

Q: How should I get started with Eclipse plug-ins?

A: Read a book. I did not do this and really regret it now I think. There are few different ones available that I assume explain all the intricacies. The Google can only help so much. Having said that, the approach that I took was to look at the code of another Eclipse plug-in and borrow from that :) Some of the better links I put up on Delicious.

Q: How do I make my plugin show up in the new project list?

A: This one seems like it should be easy to find out how to do but it actually wasn’t that easy. So it is pretty easy to get started using one of the samples in Eclipse like the file editor sample that creates a “New file” wizard. While that wizard does not launch from the “New project” menu it can be augmented to be a project creation wizard pretty easily. The important bit is setting project=”true” on your wizard in the plugin.xml file for the Eclipse newWizards extension.

<extension point="org.eclipse.ui.newWizards">
  <wizard
    project="true" ... />

Q: Now that I have a new project wizard how do I know that a project was created using that wizard or is that type of project so that you can create debug or run configurations accordingly?

A: This is where project “Natures” come in. A project can have different natures associated with it to support different functionality in Eclipse. You need to create a class that implements the IProjectNature interface.

public class PhoneGapProjectNature implements IProjectNature

You can reference that project Nature from the plugin.xml through the org.eclipse.core.resources.natures extension point.

<extension id="com.phonegap.phonegapnature" name="PhoneGap Nature"
  point="org.eclipse.core.resources.natures">
  <runtime>
    <run class="com.phonegap.project.PhoneGapProjectNature"/>
  </runtime>
  <builder id="com.phonegap.phonegapbuilder"></builder>
</extension>

This enables one to connect certain builders to a nature - in the case of PhoneGap we don’t actually use a builder since it is just HTML and JavaScript but we do set and read the nature from the plug-in code.

To set the nature of the project when it is created in the new project wizard we can set the project nature(s) on the project description like this:

IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProjectDescription description =
  workspace.newProjectDescription(newProjectHandle.getName());
description.setNatureIds(new String[] { PhoneGapPlugin.PHONEGAP_NATURE_ID });

In the case of PhoneGap, we use this project nature information in the properties of the Run and Debug configurations such that a developer can create configurations and choose the project that the configuration should launch when they click Run or Debug. In the configuration we iterate over the projects collection of the workspace and check if each project has the PhoneGap nature, if it does we add it to a combo box.

boolean bb = projects[i].hasNature(PhoneGapPlugin.PHONEGAP_NATURE_ID);
if (projects[i].hasNature(PhoneGapPlugin.PHONEGAP_NATURE_ID)) {
  projectCombo.add(projects[i].getName());
}

Q: How do I store preferences and configuration default values?

A: In your AddLaunch method of the LaunchAdder, which you call from the createProject method of your NewProjecWizard class like this:

SimulatorLaunchAdder.addSimulatorLaunch(projectHandle.getName(),
  projectHandle.getName(), "");

you will need have some code like this:

ILaunchConfigurationWorkingCopy wc = DebugPlugin.getDefault()
.getLaunchManager().getLaunchConfigurationType(
  "com.phonegap.debug.SimulatorLaunchConfigurationType")
.newInstance(null, DebugPlugin.getDefault()
.getLaunchManager().generateUniqueLaunchConfigurationNameFrom(projectName));
wc.setAttribute("KEY", "value");
final ILaunchConfiguration config = wc.doSave();

Q: How do I access resources like files to populate a new project with?

A: Put any files that you will want to copy to a project into a namespace like com.phonegap.resources then you can access it like this:

String rootContent = StreamUtils.readContent(
this.getClass().getResourceAsStream("/com/phonegap/resources/root.html"), null
);

Where StreamUtils is just a wrapper for doing the stream reading.

Q: I am getting a “class not found” error when I debug what should I do?

A: Get Eclipse 3.4 if you don’t already have it.

Q: I want to support the debug / run menus but to do that I need org.eclipse.debug.ui/core references - where do I find those?

A: Add them to the dependcies list in the plugin.xml visual editor. First add core then the ui one will be available.

That’s about all I can muster for the moment but will try to put up some more tips later!

Tags: , , , , , .



* PhoneGap Project

Posted on March 24th, 2009 by Dave Johnson. Filed under phonegap, programming.


So I started putting together some wireframes for my first real PhoneGap project tonight. I have become sort of bored playing with BlackBerry and Android native development and figured it was about time to actually build something on top of the platform. The only problem I am having is that I can’t currently do offline apps on BlackBerry so am really looking forward to the next version of the RIM OS as I hear they may have fixed some of my gripes.

In the mean time I have been working on the PhoneGap simulator and Eclipse plugin as well that should be ready very soon - I actually have the simulator launching from my Eclipse PhoneGap project which is pretty cool.

Tags: , , .



* PhoneGap Eclipse Plugin

Posted on February 18th, 2009 by Dave Johnson. Filed under Uncategorized, phonegap.


I have been putting this off for a while but finally got around to getting some Eclipse Plugin action going for PhoneGap.

More news on this very soon!

Tags: , , , .



* BlackBerry PhoneGap RIP

Posted on January 25th, 2009 by Dave Johnson. Filed under mobile, phonegap.


I was probably the only one working on PhoneGap for BlackBerry and now there might not be anyone. I have officially given up my BlackBerry programming endeavours for the time being in favour of greener pastures in the form of a Google Android G1. The final straw was when I found that the BrowserContentManager, which is the class one can use in their own BlackBerry application to render HTML content, does not support the same APIs as the actual web browser on the phone! In version 4.6 of the BlackBerry OS they introduced a proper, and fairly decent, web browser (that is definitely *not* WebKit as so many people like to say) and yet the BrowserContentManager is stuck back in the OS 4.2 days. Not sure if the Storm (OS 4.7) has changed that or not, although the API of the normal browser in 4.7 is identical to 4.6 so I assume not and somone on the BlackBerry support forums corroborates my findings.

I am working on my first Android application today and will hopefully get some PhoneGap work in there too.

Tags: , , , , .



* BlackBerry Browser Oddities

Posted on January 4th, 2009 by Dave Johnson. Filed under phonegap.


So for PhoneGap on BlackBerry I was using a BrowserContentManager to achieve the PhoneGap functionality. I finally got around to installing the BlackBerry Bold 9000 simulator (OS 4.6) with hopes that the BrowserContentManager would support nice things like Node.innerHTML and other things that one might like for making web apps.

Alas, I was terribly wrong. Here is what the BrowserContentManager content looks like:

And the native BlackBerry browser looks like this:

The main things to notice are:

  • the font in the native browser is way nicer (anti-aliasing goes a long way I guess)
  • the buttons are different
  • there is no CSS being applied in the BrowserContentManager
  • the BrowserContentManager does not appear to support the mouse pointer mode

Of course not visible is the very different JavaScript DOM API…

I am still investigating but so far I am not very impressed by the functionality of the BrowserContentManager. Is there a better way to achieve the PhoneGap functionality?

Tags: , , , .



* Rich Mobile Applications

Posted on December 16th, 2008 by Dave Johnson. Filed under AJAX, phonegap.


Like the MiniDisc or the Atari Jaguar CD, web applications, rich internet applications to be specific, are a thing of the past. Yes a bold statement to be sure. Well maybe not a thing of the past but certainly in their current form.

I think that @PanMan summed it up best when he tweeted:

Phonegap is definitely one of the most exiting developments for mobile developers these days…

Yes the future is PhoneGap and the future is Rich Mobile Applications - RMAs for short. They can run on the phone native or as a web page but we of course think that being able to build applications using JavaScript and HTML rather than Objective-C and still having access to all the fun phone APIs like geolocation, mapping, calling / SMSing people, bluetooth etc is a very nice thing indeed.

Tags: , , .



* BlackBerry PhoneGap Progress Report

Posted on December 6th, 2008 by Dave Johnson. Filed under phonegap.


BlackBerry PhoneGap
We had a PhoneGap sprint just over a week ago which was pretty successful for me and my BlackBerry ambitions as well as everyone else. Through that sprint and over the past week, despite some setbacks, I got the OS v4.5 installed on my phone and the simulator on my computer giving me access to a few new things but I was sad to find that a few other things were still sorely lacking that are pretty important for something like PhoneGap. Just so you know, OS v4.5 is the latest OS that will run on my Curve 8310 - 4.6 will run on the Bold, Pearl Flip and newer Curves while 4.7 works on the Storm. The two biggest gaffs by RIM are in the BlackBerry web browser for OS v4.5 where that the following rather important features are missing:

  1. You can’t pass function pointers to setTimeout.
  2. You can’t access DOM Nodes in any way shape or form (aside from form fields). So there is no getElementById or innerHTML on the resulting nodes. This make web application development a little bit difficult.
  3. There is no XMLHttpRequest object.
  4. While not really expected, there is no SQLite support
    anywhere on the phone as of yet, let alone the browser.

Anyhow, despite those setbacks on the v4.5 OS I did get the communication between the BlackBerry device and the web page all dialed now. Not only that but I have implemented the W3C geolocation API and am going to follow that same pattern for the other APIs. Check out the geolocation JavaScript interface as well as the platform specific implementation.

In the actual BlackBerry code there is lots of boiler plate stuff. The main hurdle was figuring what the best (or any) way to embed the browser in the application was and enable communication between JavaScript in the browser and the BlackBerry Java code. In the end I pretty much had to take the route of implementing the browser myself through the BrowserContentManager. This means that I have to implement lots of functionality, but it also means that I am in control of cookies and responsible for accepting them from JavaScript in the web page through the implementation of the browser fields RenderingApplication.eventOccurred method when the event type is EVENT_SET_HTTP_COOKIE and returning them to JavaScript by implementing the RenderingApplication.GetHTTPCookie method.

When the set cookie event occurs I parse out the cookies looking for one named bb_command and expect it to contain some JSON object (that is parsed with the J2ME port of a Java JSON lib) with a command property (like for opening maps or getting the GPS location) and some arguments (like points to plot on the map or how long to vibrate for). The case statement just looks like this:

switch (command)
{
  case 0:
    this._getLocation = true;
    this.startLocationUpdate();
    break;
  case 1:
    Invoke.invokeApplication(
      Invoke.APP_TYPE_MAPS,
      new MapsArguments(MapsArguments.ARG_LOCATION_DOCUMENT,
      getLocationDocument(args))
    );
    break;
  case 2:
    Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA,
      new CameraArguments()
    );
    break;
  case 3:
    if (Alert.isVibrateSupported())
      Alert.startVibrate(getVibrateDuration(args));
    break;
  case 4:
    Invoke.invokeApplication(Invoke.APP_TYPE_PHONE,
      new PhoneArguments(PhoneArguments.ARG_CALL,
        getPhoneNumber(args)
      )
    );
    break;
  default:
}

where args is just a JSON string that the various methods like getPhoneNumber parse to get the args they want.

I will post some more specific code snippets like how to send text messages and so on very soon.

Tags: , , , , , , , , .