March 29, 2009

QuickConnectiPhone 1.5 beta 5 now available

Posted in iPhone development tagged , , , , , , at 2:34 am by tetontech

Version 1.5 beta 5 includes the ability to have multiple databases open at the same time.  A new method, close, has also been added to the the JavaScript DataAccessObject.

I also spent some time doing some cleanup of some memory leaks on the Objective-C side of the framework and making sure that the Xcode and Dashcode versions of the JavaScript files have the same code content.

If there are no more major defects this will be come release candidate one.

Advertisements

March 19, 2009

Development Roadmap

Posted in Android Development, iPhone development tagged , , , , , , , , at 11:02 pm by tetontech

I have updated the development roadmap based on Apple’s 3.0 release.  The roadmap can be found on the wiki.  Let me know what order in which you would like the features implemented.

March 17, 2009

QuickConnectiPhone and iPhone OS 3.0

Posted in Uncategorized at 5:35 pm by tetontech

Apple is currently giving a presentation on what new API’s will be available in the new 3.0 version of iPhone OS.

I’m looking forward to implementing these new features for QuickConnectiPhone.

1.  google maps.  I can now replace the current Objective-C implementation with a standard one.  The JavaScript side functions that currently exist won’t change but there may be new additions.

2.  Bluetooth networking.  Since the current QuickConnect Ad hoc networking implementation already uses Bonjour this capability may already be included in QC.  I’ll have to check it out.

3.  Streaming Audio and Video.  A good addition to QCiPhone’s playAudio functionality.  I can hardly wait.

4.  Push notificaitons.  Great to finally be able to add this to QC.

5.  In app email.

6.  proximity sensor.

7.  iPod library access.

It looks like there are many more.  It will be great to add as many of these as possible to QuickConnectiPhone.

March 14, 2009

QuickConnectiPhone 1.5 Beta 4

Posted in iPhone development tagged , , , , , , , , , , at 8:18 pm by tetontech

Beta 4 has been uploaded and is now available.  It includes the ability to play multiple audio files at once, an example app PlayAudioFileExample another to show how to do AJAX/JSON calls using the ServerAccessObject, JSONDataExample, and fixes to the Xcode and Dashcode templates.

You can now add background continuously looping background audio and play other audio files at the same time.

March 12, 2009

AJAX and JSON. An example on the iPhone

Posted in iPhone development tagged , , , , , , , at 7:55 pm by tetontech

Since the iBlog example went away, it was too complex to understand easily, there has been a need for an example of how to do use AJAX and JSON together.  JSON is a great way to retrieve data from a server since the data is easily converted into one or more JavaScript objects.  The QuickConnectiPhone framework makes it very easy to make JSON requests and I have created an example called JSONDataExample that will be included in QC 1.5 Beta 4.

For the JSONDataExample application I found an open server that can serve up JSON strings.  It is a Yahoo! image description service.  I’ll use this service in this example.

To start with, here is the final product running in the emulator and launched from Dashcode.

A list of Thumbnail images built using JSON

A list of Thumbnail images built using JSON

The QuickConnectiPhone source code to accomplish this is very small.  As always we start with the mappings in the mappings.js file for which the code is seen below.  We first map the command pictures to a Business Control Function called loadPictureDataBCF.  This BCF is responsible for making our AJAX call.

mapCommandToBCF(‘pictures’, loadPictureDataBCF);

mapCommandToVCF(‘pictures’, displayPictureDataVCF);

Next we map the pictures command to a View Control Function, displayPictureDataVCF, that is responsible for updating the display based on the data retrieved from the service.  Having completed our mappings for the pictures command we can now create the two control functions.

The loadPictureDataBCF function is created in the functions.js file and makes use of the QuickConnectiPhone AJAX wrapper ServerAccessObject.  This wrapper is designed to make your use of AJAX as simple as possible.

The code below shows a new ServerAccessObject being created.  The constructor is passed the URL of the service without any parameters.

function loadPictureDataBCF(parameters){

var pictureService = new ServerAccessObject(http://search.yahooapis.com/ImageSearchService/V1/imageSearch’);

pictureService.getData(ServerAccessObject.TEXT, true,‘appid=YahooDemo&query=england&output=json’);

}


Once pictureService has been created it is now ready for use.  Since we are retrieving data from the server we use the ServerAccessObject’s getData method.  The three parameters are:

  1. The data type being requested (use text when requesting JSON)
  2. A boolean indicating if a forced refresh should be enforced (true means never used cached data)
  3. The query parameters to append to the URL
This code is all that is required to get data from a server or service.  The QuickConnectiPhone framework will handle all of the data passing and ensure that it gets passed to the displayPictureDataVCF View Control Function that was mapped earlier.
The displayPictureDataVCF is responsible for parsing the string into a JavaScript object and then updating the view.  The results parameter is a JavaScript array that contains the results of any and all calls to Business Control Functions.  It is an array because you can have any number of BCF’s mapped to a single command.  The framework executes them all and places each result in this results parameter.
Each result has a data attribute in addition to an error attribute and a few others.  This data attribute contains the JSON string requested in the BCF we saw earlier.  Since this JSON string contains all of the information we want we use the JSON library, included in QuickConnectiPhone, to generate a JavaScript object by calling JSON.parse.

function displayPictureDataVCF(results, parameters){

var dataObject = JSON.parse(results[0].data);

var resultSet = dataObject.ResultSet;

var overViewDisplay = document.getElementById(‘overView’);

overView.innerHTML = ‘Total Results: ‘+resultSet.totalResultsAvailable;

overView.innerHTML += ‘<br/>Results Retrieved: ‘+resultSet.totalResultsReturned+‘<hr/>’;

var allImageDescriptions = resultSet.Result;

var numImageDescriptions = allImageDescriptions.length;

var body = document.getElementsByTagName(‘body’)[0];

console.log(body);

for(var i = 0; i < numImageDescriptions; i++){

var anImageDescription = allImageDescriptions[i];

var aDisplay = document.createElement(‘div’);

aDisplay.className = ‘imgDisplay’;

body.appendChild(aDisplay);

var aThumbnail = document.createElement(‘img’);

aThumbnail.src = anImageDescription.Thumbnail.Url;

aDisplay.appendChild(aThumbnail);

}

}

Once we have the JavaScript object we iterate over all of the image descriptions, build elements to display the data and add them to the body of the page being displayed.  We are now done.

I hope this helps you see how to do JSON calls to a service using QuickConnectiPHone.

QuickConnectiPhone 1.5 Beta 3 is available

Posted in iPhone development tagged , , , , , , at 4:11 am by tetontech

The QC1.5 Beta 3 includes playing, looping, and stopping audio files that you ship with your application using JavaScript calls. For gapless looping playback use uncompressed file types such as wav files. Compressed files can be played without a gap between the loops if you modify the files. This posting describes how to modify mp3 files to playback without a ‘plop’ or gap.

Additional examples have been added.

  1. PlayAudioFileExample – an example of how to play and loop installed audio files.
  2. CustomListsExample – an example of how to create navigation lists that are more flexible than the Edge-To-Edge and Rounded Rectangle Lists but still change views in the stack

March 10, 2009

Playing looping audio files

Posted in Uncategorized tagged , , , , , , , , , at 3:48 pm by tetontech

QuickConnectiPhone 1.5 Beta 3 is going to include the playing of audio files using the new AVAudioPlayer made available in recent releases of the iPhone OS.  This will allow easy looping and greatly reduce the amount of code required in the QCiPhone framework.  All good.  I am including in this post the code that will be in Beta 3 so that those of you using 1.1.3 can put the code in the applications you are creating.

The code can also be used as an example of how to use the AVAudioPlayer Objective-C class.

Be aware that looping compressed files such as mp3’s will leave a ‘plop’ or gap in playing between loops.  If you want to avoid this you can use uncompressed files such as wav files or follow the advice onthis page.

The changes to com.js.  Replace the record, stopRecording, play, and stopPlaying functions with the following code.

function record(aFileName){

if(aFileName){

var params = new Array();

if(aFileName.indexOf(‘.’) == –1){

aFileName = aFileName+“.caf”;

}

params[0] = aFileName;

params[1] = “start”;

makeCall(“rec”, JSON.stringify(params));

}

}

function stopRecording(aFileName){

if(aFileName){

var params = new Array();

if(aFileName.indexOf(‘.’) == –1){

aFileName = aFileName+“.caf”;

}

params[0] = aFileName;

params[1] = “stop”;

makeCall(“rec”, JSON.stringify(params));

}

}

//set loop count to a number of loops or -1 for continuous looping

function play(aFileName, loopCount){

if(aFileName){

var params = new Array();

if(aFileName.indexOf(‘.’) == –1){

aFileName = aFileName+“.caf”;

}

params[0] = aFileName;

params[1] = “start”;

params[2] = 0;

if(loopCount){

params[2] = loopCount;

}

makeCall(“play”, JSON.stringify(params));

}

}

/*

* Pause is removed for now since the standard apple Objective-C

*  class fails to play an audio file that is paused.

*

function pausePlaying(aFileName){

if(aFileName){

var params = new Array();

if(aFileName.indexOf(‘.’) == -1){

aFileName = aFileName+”.caf”;

}

params[0] = aFileName;

params[1] = “pause”;

makeCall(“play”, JSON.stringify(params));

}

}

*/

function stopPlaying(aFileName){

if(aFileName){

var params = new Array();

if(aFileName.indexOf(‘.’) == –1){

aFileName = aFileName+“.caf”;

}

params[0] = aFileName;

params[1] = “stop”;

makeCall(“play”, JSON.stringify(params));

}

}

Replace the code in the Classes->CommandObjects->PlayAudioVCO.m Objective-C file with the following
//

//  PlayAudioVCO.m

//

/*

Copyright 2009 Lee S. Barney

This file is part of QuickConnectiPhone.

QuickConnectiPhone is free software: you can redistribute it and/or modify

it under the terms of the GNU Lesser General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

QuickConnectiPhone is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License

along with QuickConnectiPhone.  If not, see <http://www.gnu.org/licenses/>.

*/

#import <AVFoundation/AVFoundation.h>

#import “PlayAudioVCO.h”

#import “QuickConnectViewController.h”

@implementation PlayAudioVCO

+ (id) doCommand:(NSArray*) parameters{

NSString *flag = [parameters objectAtIndex:2];

QuickConnectViewController *aController = [parameters objectAtIndex:0];

if([flag compare:@”start”] == NSOrderedSame){

NSString *fileName = [parameters objectAtIndex:1];

NSArray *split = [fileName componentsSeparatedByString:@”.”];

NSString *audioFilePath = [[NSBundle mainBundle] pathForResource:[split objectAtIndex:0] ofType:[split objectAtIndex:1]];

if(audioFilePath == nil){

//recorded file.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

audioFilePath = [documentsDirectory stringByAppendingPathComponent:fileName];

}

AVAudioPlayer *audioPlayer =  [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:audioFilePath] error:NULL];

aController.audioPlayer = audioPlayer;

[audioPlayer release];

aController.audioPlayer.numberOfLoops = [parameters objectAtIndex:3];

[audioPlayer prepareToPlay];

BOOL plays = [audioPlayer play];

if(plays){

MESSAGE(@”done playing”);

}

else{

MESSAGE(@”play failed”);

}

}

else if([flag compare:@”pause”] == NSOrderedSame){

MESSAGE(@”pausing”);

[aController.audioPlayer pause];

}

else{

[aController.audioPlayer stop];

}

MESSAGE(@”done with PlayAudioVCO”);

return nil;

}

@end


March 9, 2009

Genealogy QuickConnectiPhone Example

Posted in iPhone development tagged , , , , , , , , at 6:09 am by tetontech

The people at FamilySearch asked me to create a video of a simple iPhone application accessing their web service to show at their upcoming conference.  I have stuck the results on the QuickConnect wiki.

The wiki page that has a short explanation and the link to the video is here.

March 7, 2009

QuickConnectiPhone 1.5 Beta 2 now available

Posted in iPhone development tagged , , , , , , , , , , , , at 11:14 pm by tetontech

The second beta of QC 1.5 is now available for download from the SourceForge link found in the right-hand bar of this blog.

It contains several changes and fixes requested by you as well as the new Charting and Graphing Library.  Using this library you can create Pie, Line, Filled Line, and bar charts quickly and easily.  If you take a look at the source code for the library you will find that it uses the new HTML5 canvas tag and JavaScript.  You can now create this easily from within your JavaScript application.

Another change is the inclusion of Xcode code completion macros for the common QuickConnect JavaScript functions.  Also included are macros for inserting the new pie, line, and bar charts.

I’ll make a video of how to use these.

I will also make a video on how to use the new Dashcode snippets for creating the charts.

Here are the changes, not including the earlier beta 1 changes, for beta 2.

Changes for 1.5 beta 2

1.  Charting library added (line, filled line, bar, and pie charts).

2.  apostrophe’s and ampersands now can be used in native database data without issue.

3.  Links in your html files are now handled by launching of all known and custom applications.

a.  http://, https://, feed:// – launches Mobile Safari

b.  mailto:// – launches Mail app

c.  http://maps.google.com – map app

d.  http://www.youtube.com – YouTube app

e.  itms:// – iTunes store app  (get the full URL from running iTunes onyour desktop machine);

f.  http://phobos.apple.com – App Store app(get the full URL from running iTunes on your desktop machine)

g. tel:// – iPhone only.  Dial a phone number (any phone number entered automatically becomes a link)

h. sms: – iPhone only.  Launch the sms app (notice that there are no // characters)

i. yourCustomURL:// – a custom URL for an application you have created.

4.  The play() JavaScript function now automatically detects if the audio file name passed as a parameter is part of your application package resources and plays it if it is.  If it is not, it will look to see if it is a recorded audio file and then play it.  Supported audio file types are:

a. mp3

b. wav

c. aifc

d. aiff

e. m4a

f. mp4

g. caf

h. aac

5.  Language, region, and TimeZone are now included in the device description received from the call to the getDeviceDescription() JavaScript function.

6.  Custom Dashcode code snippets that let you drag and drop QuickConnect functionality to your JavaScript application

a. Pie Chart

b. Line Chart

c. Bar Chart

7.  Custom Xcode JavaScript auto-completions that let you quickly add available QuickConnect functionality to your JavaScript application

a. piechart – insert pie chart creation code

b. barchart – insert bar chart creation code

c. linechart – insert line chart creation code

d. draggable – code to make an element draggable

e. resuzable – code to make an element resizable

f. changeable – code to make an element draggable and resizable

g. vmap – mapCommandToVCF call

h. bmap – mapCommandToBCF call

i. emap – mapCommandToECF call

j. valmap – mapCommandToValCF call

k. smap – mapCommandTo SCF call

l. vcf – create a View Control Function

m. bcf – create a Business Control Function

n. ecf – create an Error Control Function

o. valcf – create a Validation Control Function

p. scf – create a Security Control Function

q. debug – code to make a debug message call

r. logerror – code to log an error

s. findloc – findLocation call

t. device – getDeviceDescription call

u. showmap – showMap call

v. syssound – playSystemSound call

w. vibrate – vibrate call

x. showpicker – showPicer call

y. recordaudio – recordAudio call

z. playaudio – play call

aa. stopplayaudio – stopPlaying call

March 5, 2009

Creating Line Graphs on the iPhone

Posted in Uncategorized tagged , , , , , , , , , , at 11:49 pm by tetontech

I have finally been able to complete the line graphs(charts) portion of the Charting and Graphing QuickConnect library and am working on getting a final bug out of the Bar and Pie charts.

I plan on producing a video on how these are used and how to create them in your code but thought that a quick view of what is coming in V 1.5 beta 2 would be of interest.

I have put a few images here for you to see. The first is a line graph showing two separate data series being displayed. If you touch the data points, either directly or by moving your finger over them, the value and description of the point is displayed in the display area of the chart. You can also cycle through the values of a series by using the forward and backward arrows or by moving your finger across the color display bar.

A two series line chart

A two series line chart

The next image is of the same data but drawn as a filled line chart.

A two data series filled line chart

A two data series filled line chart

If you touch any of the data points the series that contains that value is brought to the front as you can see in this next image.

A two series filled line chart showing the second series in front.

A two series filled line chart showing the second series in front.

I have tried to make this as easy to use as I can.  Here is the code to create the filled chart.

var fill = false;

var shadow = true;

lineDisplay.chart = new QCLineChart(document.getElementById(‘lineChartDisplay’), ‘Animals’, shadow, fill);

lineDisplay.chart.addSeries(‘Some Animals’,[[‘cats’,15], [‘hipos’,2], [‘fish’,7], [‘dogs’,4]

, [‘bears’,20], [‘mice’,3], [‘elephants’,7], [‘dogs’,10], [‘kangaroo’,18]]);

lineDisplay.chart.addSeries(‘Other Animals’,[[‘gorillas’,10], [‘snakes’,5], [‘robins’,3],[‘rats’,4], [‘moose’,15], [‘deer’,14], [‘tigers’,0 ], [‘jaguar’,9], [’emu’,9]]);

lineDisplay.chart.display();

To change it to a standard non-filled chart just change the fill variable to false.

%d bloggers like this: