Friday, April 15, 2011

Extending the PhoneGap API – Third-Party Plugins (ChildBrowser)

As we are preparing for Emerging Technologies for the Enterprise, I did not want to forget the rest of the series on PhoneGap API that Hiedi Utley has been penning.  Here is part 4.


Extending the PhoneGap API – Third-Party Plugins (ChildBrowser)


So the last post was all about editing PhoneGap classes to add a little something extra, today it’s about using a third-party plugin that you may have downloaded from somewhere or gotten from someone.
The plugins that we will be using today are from Jesse MacFayden (aka @purplecabbage on twitter). The original source code for the plugins can be downloaded from github here: https://github.com/purplecabbage/phonegap-plugins.git
You can also get the entire source for my sample project “HelloPhoneGap” from github here: https://github.com/hutley/HelloPhoneGap.git


Read more..

Friday, April 8, 2011

Extending the PhoneGap API

 Here is the third installment of Hiedi Utley's series on PhoneGap.  We hope you are finding this series helpful as you learn more about developing for mobile applications.

Extending the PhoneGap API
If you’ve had a chance to play with PhoneGap a bit, chances are you have wanted it to do something that it doesn’t already do. Alas, don’t worry! You don’t have to put in a ticket and hope that the PhoneGap developers agree with you and implement it in some future release, if you can write a little Objective-C then you can do it yourself and use it in your own iOS project.
The topic at hand is all about extending the PhoneGap API whether it’s by editing existing PhoneGap classes, downloading a third-party plugin from somewhere, or by writing your own plugin from scratch. For this post I will concentrate on editing the PhoneGap classes, in later posts I’ll give step-by-step instructions on using a third-party plugin and how to create your own plugin.
If you haven’t already had a chance to read my earlier posts on PhoneGap internals and using the PhoneGap API – you may want to peruse them before reading on.


Read more...


Thursday, March 31, 2011

Using the PhoneGap API

 

We are a little behind in posting Hiedi Utley's PhoneGap Tutorial Series.  Or she is a very fast writer.
In this post, Hiedi discusses the features of PhoneGap API.



Using the PhoneGap API

Welcome to the second installment of my PhoneGap Tutorial Series! This post is a continuation of PhoneGap Project Structure and Internals so if you haven’t already, you may want to peruse that post before continuing on.
We already know that PhoneGap is an open source framework for writing applications using typical web technologies like HTML, CSS, and JavaScript and that the PhoneGap architecture supplies JavaScript wrappers to access native phone features. What you may NOT know is how extensive those features really are or how to actually use them.
This article is all about getting familiar with the current features of the PhoneGap API and how to use them with the iPhone iOS.


Read more..

Monday, March 21, 2011

What is in my Spring Context?

When we are learning Spring, there are times we are not sure which beans are in the Spring context. Especially when we use convenient features of Spring 3 such as <context:annotation-driven/> or <context:component-scan/>. As developers, we want to inspect the classes that are automatically registered providing the opportunity to look at the source code and javadocs to see what each class does.


JUnit Tests get Application Context

Our JUnit tests have the ability to inject the Application Context. This is one of the many benefits of @RunWith(SpringJUnit4ClassRunner.class)


@ContextConfiguration(value = "/META-INF/spring/test-app-context.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class BeansInContextTest {

@Autowired
ApplicationContext applicationContext;



Simple Code

Let's loop through all the beans that are defined or discovered with the following code.


@Before
public void setup() {
logger.debug("********************");
String[] beans = applicationContext.getBeanDefinitionNames();
for (String o : beans) {
logger.debug("________________________");
logger.debug("BEAN = " + o);
logger.debug("\tType = " + applicationContext.getType(o));
String[] aliases = applicationContext.getAliases(o);
if (aliases != null && aliases.length > 0) {
for (String a : aliases) {
logger.debug("\tAliased as: " + a);
}
}
}

logger.debug("********************");
logger.debug("*** Number of Beans = {} ***",
applicationContext.getBeanDefinitionCount());
logger.debug("********************");
}
}




What is the Alias?

We can define beans with "id" which by XML law requires it to be unique per file. This restricts us in the ability to use special symbols for the name should we want to. I recommend using "id" unless absolutely necessary. However, should we what to refer to the bean with multiple names or use special symbols, we can use the "name" attribute. By comma separating the tokens, we have the opportunity to refer to a bean with any of the tokens provided.
<bean name="mailServer/default, mailServer" class="..."/>
If no, "id" is provided, the first token becomes the primary and the subse quent tokens become aliases. Does this matter in the usage of the beans? No. But to find "all" the names of the beans, we would display the aliases in addition to the bean names.

The Full Test Code

package com.chariot.sample;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@ContextConfiguration(value = "/META-INF/spring/test-app-context.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class BeansInContextTest {
private final Logger logger = LoggerFactory
.getLogger(BeansInContextTest.class);

@Autowired
ApplicationContext applicationContext;

@Before
public void setup() {
logger.debug("********************");
String[] beans = applicationContext.getBeanDefinitionNames();
for (String o : beans) {
logger.debug("________________________");
logger.debug("BEAN = " + o);
logger.debug("\tType = " + applicationContext.getType(o));
String[] aliases = applicationContext.getAliases(o);
if (aliases != null && aliases.length > 0) {
for (String a : aliases) {
logger.debug("\tAliased as: " + a);
}
}
}

logger.debug("********************");
logger.debug("*** Number of Beans = {} ***",
applicationContext.getBeanDefinitionCount());
logger.debug("********************");
}
}


Sample Bean Context


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:annotation-config/>

<bean id="myBean" class="MyCoolBean"/>

</beans>


Experiment and Have Fun

Add beans to the config file. Import other config files and see what happens.

Wanna Learn More?

Learn more about what goes on Spring Context by attending a Core Spring Training class at Chariot.





Thursday, March 17, 2011

PhoneGap Tutorial Series – #1 Project Structure and Internals

Heidi Utley, one of the members of our mobile practice, has been working with PhoneGap for one of our clients. She decided to create a series of posts focusing on using PhoneGap for iPhone development.

This first one discusses the project structure.  Future posts will review the PhoneGap API, installing a third party plugin, and last building your own PhoneGap plugin.

What is PhoneGap?


PhoneGap is an open source framework for writing applications using typical web technologies like HTML, CSS, and javascript. The PhoneGap architecture supplies javascript wrappers that allow a developer to access native phone features (like contacts, GPS, and the camera) by writing their app against the PhoneGap javascript API.
The basic gist is that the typical web developer will be able to write a standalone HTML/CSS/javascript application that runs in a WebKit browser with access to native functions just by calling the PhoneGap javascript. PhoneGap aides the developer by abstracting the complexities of native development by allowing the developer to write the app in well-known technology without having to learn the intricacies of each mobile platform and thereby hiding the complexity of writing the same application multiple times in various native languages (like Objective-C for the iPhone or Java for Android).

Read more...

Stay tuned as we have more discussions around mobile development. Our team continues with their research, for Chariot's own projects (our conference app for Philly ETE) and for our clients. 

Thursday, March 10, 2011

Xcode3 – Debugging iOS Unit Tests

A recent blog post by Hiedi Utley (no, she is not related to our knee challenged second baseman), Chariot's newest team addition.  Hiedi has been working in our mobile practice.  She reviews some of the challenges of being a Java developer and moving to an iOS environment.


Here is an excerpt from this post:



So you have some unit tests (yeah!) and they are failing …. now what?


Over the course of my career these past few years, I have become a developer that writes more test code than production code in an effort to never have to spend the wee hours of the morning debugging a horrible production issue. As a java developer turned mobile developer, there are several things that I miss about coding in Java but the number one thing is unit tests.
Don’t get me wrong – I know what you are thinking – probably something along the lines of: “Do a little research dummy! Xcode has a nice Unit Test Bundle target that we can use to run unit tests! All you have to do is write them!” Right…..
Or maybe after a little more googling around you may even point me to this excellent Apple documentation that explains the process of setting up and running my newly created unit tests but there is a huge section missing from this guide…


Monday, March 7, 2011

Mobile Design Part 3

 The next installment of Kevin Griffin's blog on Mobile Design.

Cognitive Effort.

In this installment of my thoughts on mobile design, I thought we would take a look at the concept of ‘cognitive effort’. I think I first heard that term used in reference to design from William Van Hecke (@fetjuel) when he spoke at Voices that Matter in Philly. When a guy from The OmniGroup talks to be about making great apps, I tend to shut up and listen.
We have all thought about cognitive effort at some point:
  • “Does this screen look too busy?”
  • “We should move this functionality out of this screen” are signs you thinking about it.
What increases cognitive effort?
Every question, action, dialog, gesture, tap, shake, voice communiqué we ask the user ultimately ends in some kind of effort be it physical, cognitive or verbal. Sometimes we intentionally make these things progressively harder, games for example. Sometimes we unintentionally make these things progressively harder, continually adding functionality to a screen.

Read more...