Week Beginning 10th November 2014

This week was almost entirely devoted to completing work on the Scots School Dictionary app.  I had previously completed a second version of the app based on feedback received from various people and had then received feedback on this updated version, resulting in a small number of tweaks being required.  I had hoped that implementing these changes, wrapping the apps for iOS and Android, testing these wrapped versions and submitting them to the App and Play stores would only take up 2-3 days but in the end these tasks took up 4-5 days.  I’d forgotten just how many hoops you need to jump through in order to submit an App to Apple, alas.

The updates resulting from feedback took about half a day to get sorted.  These included adding in the proper introduction text and the help text that was supplied by Chris and fixing the ‘full text’ search.  Rather foolishly, I’d set the ‘full text’ search to search the description of entries but not the headword itself.  This led to no results being found when the headword didn’t actually appear in the description, which was a bit of a confusing situation.  The search facility works a lot better now that I’ve fixed this little quirk.

After making the necessary tweaks to the code I then set about wrapping it using Apache Cordova (http://cordova.apache.org/).  This really is an excellent and remarkably simple to use tool.  It runs from the command line and with a few simple commands you can easily convert your HTML / CSS / JavaScript code into an app that will run on the platform of your choosing.  Type in ‘cordova platform add ios’ and your project is set up to create an iOS app.  Type in ‘cordova build’ and it builds the apps for all of the platforms you have specified.  I quickly managed to get an iOS and an Android version of my app set up and running in emulators on my dinky little MacBook air laptop.  However, I knew there were two areas that would need further work:

1. External links opened up the target website within the app, replacing the app itself and then offering no way for the user to get back to the app.  (Well, with Android devices you always have a handy ‘back’ button available but iOS devices have no such button).

 

I tried rectifying this using plain HTML (e.g. target=”_blank”), using JavaScript and other system options but none of these worked.  What I needed was a Cordova plug-in called ‘In App Browser’ (http://plugins.cordova.io/#/package/org.apache.cordova.inappbrowser).   Adding this at the command line worked without any problems and then a JavaScript call to ‘window.open()’ allows you to control where links get opened.  You can either open them in the devices web browser or within an in-app browser that includes a handy ‘close’ button allowing users to return to the app.   I had originally intended to use the external web browser option but after trying it out I decided that the in-app version was better as it provided an easy and obvious way for user’s to get back to the app.

2. Sound files wouldn’t play in the Android version of the app.  Using the HTML5 audio tag works fine in iOS.  The play / pause button looks a bit clunky but the sounds play without any problems.  The same cannot be said for Android.  The HTML 5 audio ‘play’ button appears but pressing it does nothing.  A bit of Googling revealed one possible cause for this – Android devices need a different path to the sound file directory to be specified – ‘/android_asset/www/’ needs to be added before any other directory you have.  However, even after adding this I just couldn’t get any sounds to play.

 

In order to get the sounds to work I had to use another Cordova plugin – this time the ‘media’ one (http://plugins.cordova.io/#/package/org.apache.cordova.media).  I’d attempted to use this before when developing the STELLA apps but I had run into difficulties and had abandoned my attempts, but this time I managed to get things working.  Rather than using the HTML5 Audio tag this plugin uses JavaScript to play the files and also allows you to style your own buttons for controlling playback.  The only difficulty I had was that iOS and Android still required different paths to the sound files to be specified but I used another handy feature of Cordova to get around this.  You can create platform specific versions of files by setting up a ‘merges’ directory.  Anything within ‘merges/android’ will replace the standard version of the file for the Android platform only when the app is built.  Simply placing a small script with the alternative path in this directory got the sound files working on both platforms.

With the app now fully working in iOS and Android emulators it was time to test them out on actual devices.  I tried the app on my iPad and my Nexus 4 phone and didn’t run into any difficulties whatsoever.  The next step was to actually submit the app to the stores.  For Apple devices this is a somewhat laborious process that involves generating icons at a somewhat ridiculous number of sizes, creating screenshots of the app running on a wide variety of screen sizes and dealing with provisioning profiles and itunesconnect.  I simply couldn’t figure out how to submit the app to itunesconnect from within xCode following the instructions given by Apple and this seemed to be a problem with my account already being associated with the University of Glasgow account.  In the end I had to submit it via the ApplicationLoader utlity instead, using Chris’s account rather than my own.  I eventually got the app submitted though.

I’d never submitted an Android app to the Play store before and the first hurdle I encountered was the fee charged to do so.  Although Apple charges developers an annual $100 a year fee to publish stuff on the App Store I had thought it was free on Android devices.  However, it turns out that you do still have to pay a one off fee of $25.  Chris sorted this out and I began the submission process.  For Android you need to get Cordova to build a release version (the default is a debug version) and this can be accomplished by the command ‘cordova build android –release’, which creates an APK file in the ‘platforms/android/ant-built’ directory.  I also realised that I needed to replace the default Cordova icons with proper icons.  Four sizes were required (36, 48, 72, 96), replacing the ‘icon.png’ files within various folders within ‘platforms/res’.  A rebuild was required to pull these in.

The Android app file is ‘unsigned’ at this stage and there are still some processes that need to be completed before the app can be submitted.  I achieved this by following the ‘Signing you app manually’ steps detailed on this page: http://developer.android.com/tools/publishing/app-signing.html .  After completing this I managed to upload the APK file, supply store icons, screenshots, descriptions etc and submit the app for publication.  Apple can take up to two weeks to approve an app with Google is a little more swift (and no doubt less thorough).  I submitted the app to Google on Friday and on Saturday the app was available from the Google Play store.  If you have an android device search for ‘Scots Dictionary’ and you will find it.  Phew!

Other than app related stuff I had a meeting with Gerry Carruthers to discuss a project he’s putting together and made a couple of tweaks to the Digital Humanities Network website.  Next week I intend to return to Mapping Metaphor work and also to spend some more time on the Scots Thesaurus.