Using Colemak on the FirefoxOS Flame

As I mentioned in my previous post, I have been using a FirefoxOSAs I mentioned in my previous post, I have been using a FirefoxOSFlame developer reference phone as my daily driver. It has nowbeen about two months, and I couldn’t be happier with the phone(you can read my initial review of the Flame here [0]    I use the Colemak layout for all of my keyboards, so I wasdisappointed when the FirefoxOS 2.2 builds had the Dvorak layoutbut not Colemak. As any good developer would do, I promptly clonedthe gaia repo[1]and got ready to muck around in the system’s keyboard app. Much tomy initial dismay of being able to contribute something sweet tothe community, I found that the Colemak layout was already there,it just wasn’t enabled in the default list of layouts tobuild. This means that instead of hacking together some JS, allthat is required to get the Colemak layout on your device isediting one line in a Makefile, building gaia, and flashing ontoyour device.
** You should backup your device before mucking around in gaia **
I am not going to write about hacking on Gaia itself, thatinformation can be readily had from Gaia’s MDN page[2].
Adding Colemak to the Keyboard LayoutsIn order to get the Colemak layout on your FirefoxOS device youmust first get the gaia source. It can be cloned from Github bydoing:
git clone https://github.com/mozilla-b2g/gaia     cd gaia        You can look in the /apps/keyboard directory to see the source ofthe system’s keyboard app, but we aren’t going to touch anythingin there. We are going to modify gaia’s toplevel Makefile.Open ‘Makefile’ in you editor of choice. Search for’GAIA_KEYBOARD_LAYOUTS’. In my gaia repo it in line 440. Thisenvironment variable is used to determine which keyboard layoutswill be built into the system’s keyboard app – exactly what wewant to modify.Feel free to modify this line as you see fit, but in order to getthe Colemak layout you must at least add ‘en-Colemak’ to the commaseparated list of layouts. Make sure to save the file after youedit it.
Now comes the slightly scary part, we are going to build a newversion of gaia and flash it onto our FirefoxOS device. Followingthese instructions[3] we can see what we need to do. On that page theis a note about only flashing a single app instead of all of thegaia apps; There is another MDN page[4] however that cautions thatusing the APP environment variable with ‘reset-gaia’ will put yourdevice in an unstable state (my experimentation also confirmsthis). So, we are going to have to build gaia in its entirety,which doesn’t take more that a few minutes.    First make sure that you have ADB installed on your machine. Thereare installation instructions on MDN[5], and that you have enabledUSB debugging on your device from within the Developer menu.    Next connect your device to your machine. If you are using a Flamedevice, you want to issue the following command:
make reset-gaia GAIA_DEV_PIXELS_PER_PX=1.5

The GAIA_DEV_PIXELS_PER_PX environment variable specifies that youwant to use higher resolution assets. This is mentioned in a notein MDN [6] but after the ‘make reset-gaia’ command so it is easy to miss itthe first time you build gaia.
Assuming there are no build failures, your device will reboot andafter you go through the initial setup screens, you will be ableenable the Colemak layout in the Keyboards Settingspanel.
[0] https://zachwick.com/posts/using_the_firefox_os_flame.txt[1] https://github.com/mozilla-b2g/gaia[2] https://developer.mozilla.org/en-US/Firefox_OS/Developing_Gaia[3] https://developer.mozilla.org/en-US/Firefox_OS/Developing_Gaia/Different_ways_to_run_Gaia[4] https://developer.mozilla.org/en-US/Firefox_OS/Developing_Gaia/Build_System_Primer[5] https://developer.mozilla.org/en-US/Firefox_OS/Debugging/Installing_ADB[6] https://developer.mozilla.org/en-US/Firefox_OS/Developing_Gaia/Different_ways_to_run_Gaia

Using the FirefoxOS Flame

I have been using a Firefox OS Flame developer reference phone as
my daily driver for a couple of weeks now. I thought that it would
be a good time to publish my thoughts on the hardware and
software, and also comment on my first few days of developing for
FirefoxOS.

I first started using Firefox OS way back when
the ZTE Open[0] became available in early 2013. I fell in love with
the idea of Firefox OS, most likely because it was so in step with my
“compute free or die” attitude (if you sidestep the issue of mobile
phones having proprietary media codecs and proprietary baseband
systems). Sadly, the ZTE-Open was only my daily driver phone for a
week or two because the hardware/software (Firefox OS v1.0) required
too much handholding for me at the time. I was missing important
calls/texts/emails due to software bugs and hard resets, and for quite
a while I had a notification that I could never clear and a
notification tray that I could not open. Because of that, the ZTE-Open
got regulated to a shelf in my shop where I would occasionally pull it
out and putter around developing for it, but it never made it back
into my pocket for longer than a week or so. I did talk to Bob Call[1]
who was also using a ZTE-Open, but he didn’t seem to have the same
issues that I was (probably because he is used to working on things
like the ZTE-Open)

I saw the announcement of the Flame developer reference phone, but
didn’t pre-order one because of my experience with the
ZTE-Open. It was only after I
heard Christian Heilmann[2] speak at IoTCon 2014 in Berlin, Germany (I
attended both of his talks) that I decided to get a Flame
phone. Christian’s first talk was about the “Mobile Web” and how it
can be a common platform across many devices. His second talk was
specifically about Firefox OS and its current state.

I was once again hooked.

I ordered a Flame phone the day that I got home, and have been
using and abusing it since it arrived a few days later.
My Flame came with Firefox OS v1.3 on it. The improvements over
v1.2 (which I was able to compile and flash onto the ZTE-Open
myself) were phenomenal. I wasn’t missing calls, texts, or emails
and with the exception of a PumpIO [7] client, there were apps for
everything that I wanted. The Flame replaced a Nexus 5 and met the
standard of reliablity that the Nexus had set. My wife started using
the Nexus 5, so now I had to be careful about hacking too deep on the
Flame because there was no going back.

The Software
————
I flashed the Firefox OS v2.0 base image later that
first week and was once again blown away by the software. In v2.0,
the homescreen scrolls vertically and scrolling horizontally
switches between open apps. Just as the change from iOS to Android
made me love the paradigm of the back button (I know, I used to be
an iOS guy), this switch to the crazy Firefox OS scrolling has me
convinced that it is a better user experience. The only part of
this new scrolling experience that still strikes me as weird is
that when browsing the internet, opening a link in a new tab both
creates the new tab as a new horizontal scrolling target and
pushes me to it. I don’t mind the new scrolling target, but I wish
that there was an option to not automatically navigate me to the
new tab (there may be, but I haven’t found it).

I then flashed a nightly build and set the phone to do OTA updates
from the nightly build tree. This was pretty scary for the first
few days since I had no other phone to fall back to (other than
the ZTE-Open of course) but now I sleep easy knowing that the
morning’s update will be just fine.

The only outstanding software issue that is really annoying is
that sometimes when I receive a call, when I answer the call the
vibration and ringing stop. But then as soon as I hang up (1 or 30
minutes later) the phone keeps vibrating as if I am receiving a
call. Everything else works just fine at these times – I can use
apps, send texts, whatever, but the phone is just constantly
vibrating. Putting the phone to sleep doesn’t stop the vibration,
but restarting it does. This doesn’t happen every call, maybe only
about one in seven, but it still pretty annoying.

The Hardware
————
The ZTE-Open hardware always felt cheat to me. The Flame is billed
as[3] “representative of the mid-tier phone hardware Mozilla and its
partners are targeting over the coming year”. I think that if the
Flame is “mid-tier” I think that if there is ever a “high-end” device,
it it going to blow the competition out of the water. The phone has
enough weight to it that it doesn’t feel cheap and skimpy. I have
never seen it get bogged down and sluggish and it has weathered many
tumbles off of my workbench without so much as a scratch.

The back of the case is a smooth rubber-ish/matte material that
seems to attract sawdust, pocket lint, and dust, but it may just
be that I am often covered in those things myself.
The screen is a 4.5in screen (FWVGA 854×480 pixels) and is quite
useable in direct sunlight. The screen also feels very responsive
to touch events with is a wonderful improvement over the ZTE-Open
where I often felt like I had to really press hard to get events
to register.

The Development Ecosystem
————————-
I haven’t made any Firefox OS apps that are more than a few steps
above trivial, but I really like the
ecosystem. The App Manager[4] is very impressive. It uses adb to
connect to the Flame and provides a nice place to modify the app’s
manifest, install the app on the phone, and debug the app on the
phone. The App Manager is being replaced with the WebIDE from Firefox
34 on, but as I only use GNU Icecat and Debian Iceweasel, I haven’t
tried it out yet.
Because Firefox OS apps are just HTML5 apps, developers are free
to use whatever tooling they so choose. And because apps are just
JS, CSS, and some HTML, any tool set is very easy to set
up. Personally I use Emacs + Grunt as my web development tool
set. Granted, I use Emacs + whatever as my tool set for any
development. Mozilla has a bunch of reference apps[5] where you can
see various techniques for using the web API present in Firefox OS,
and there is a decent tutorial[6] if reading code doesn’t do much for
you.

I have begun work on a non-trivial open web app that I intend on
running (and using) on my Flame phone – an HTML5 Emacs clone. So
far, it is going well and I will surely humblebrag/post about it
once it has a minimal feature set. I am sure that I will also have
a post specifically about developing for Firefox OS.

Final Thoughts
————–
Do I like the Flame? Yes
Knowing what I know now, would I get one again? Yes
Would I reccomend that others get one? Eh, maybe. If you aren’t
getting a Flame to hack on, then it would behoove you to look at
the Firefox Marketplace and see if there are apps there for
everything that you want.
I really like the Flame, and barring any catastrophes, I expect
that it will be my daily drive phone for a long long time.

[0]
https://developer.mozilla.org/en-US/Firefox_OS/Developer_phone_guide/ZTE_OPEN
[1] http://fossetcon.org/2014/speakers/robert-call
[2] http://christianheilmann.com/
[3] https://hacks.mozilla.org/2014/05/flame-firefox-os-developer-phone/
[4] https://developer.mozilla.org/en-US/Firefox_OS/Using_the_App_Manager
[5] https://developer.mozilla.org/en-US/Apps/Reference_apps
[6] https://developer.mozilla.org/en-US/Apps/Quickstart
[7] http://pump.io