Barra de Español 1.2 is now available!

November 20th, 2009

The newest version of Barra de Español, version 1.2, is now available! See details about what’s new in this version in my post on Babelhut.com.

Simulating a keypress in Firefox

October 27th, 2009

Last night, I was working on Barra de Español and had spent quite a bit of time on Google looking for how to simulate a keypress in Firefox. It’s as simple as creating an event and dispatching it, though how to do so is not exactly intuitive. I needed to be able to do this because inserting accented characters from Barra de Español was not working in the message body textbox in Gmail and other webmail apps.

The way I inserted the characters before was to find the currently focused element, assume it was a textbox, and modify its value using the selectionStart property to know where the cursor was. Once I learned that the message body textbox could not be found using document.commandDispatcher.focusedElement, (that’s what “if(!focused) focused = document.commandDispatcher.focusedWindow.document.activeElement;” is all about) I found that the element used by Gmail for the message body wasn’t even a textbox, and didn’t have a value or selectionStart properties.

So the solution is to create a keypress event and dispatch it, like so:

insertchar: function(ch)
{
    var focused = document.commandDispatcher.focusedElement;
    if(!focused) focused = document.commandDispatcher.focusedWindow.document.activeElement;
    var evt = document.createEvent("KeyboardEvent");
    evt.initKeyEvent("keypress", true, true, null, false, false, false, false, 0, ch);
    focused.dispatchEvent(evt);
}

One important thing to note is that the parameter ch is not a character value, but an integer containing the character code you want to insert. So, for example, to insert the character ‘á’, ch must be the value 225. To find the values I needed I used the wonderful character lookup tool at http://leftlogic.com/lounge/articles/entity-lookup/.

Bonus tip: If you are developing a Firefox extension and are using a text file in your profile’s extension directory to point to the folder where your code is located, and you move your code to another folder, you will discover that Firefox won’t load your extension, even though you edited the text file with the new location. The fix is to find a file in your profile directory called extensions.cache and delete it. This frustrated me for at least an hour last night, and Google failed me on this.

Update on my Android Developer Challenge 2 attempt

September 8th, 2009

So the deadline for the Android Developer Challenge 2 has come and gone, and I did not submit an entry. It wasn’t for a lack of trying though. This was entirely a spare time project and I worked on it 3 to 5 days a week for an hour or more at a time. I’m still not comfortable going into specifics about the project because I think it’s still a viable project. I do still hope to release it to the public at some point.

I will say that I was able to write one of the major features completely, and nearly completed the second major feature. The main reason I didn’t complete the second feature is because it required scraping some data from a web site, and that web site made some of the data difficult to parse by putting it into an image. I didn’t discover this until about 2 nights before the deadline. Without the second feature I didn’t feel the application was compelling enough to enter into the contest, which is too bad. I think I will be able to get the data I need from an alternate source, so I will resume development of this app and hopefully release it to the public later.

I didn’t realize it at the time, but working on this project had increased my stress level quite a bit. I enjoyed working on it, and I’m beginning to appreciate how the Android SDK works, but the deadline was always in the back of my mind. When I decided to call it off, I felt a quite noticeable relief.  I don’t think the stress builds as much for deadlines at my day job, but having to focus my spare time on one project to the exclusion of others was too much for me. I think I need to keep my side projects deadline-free from now on.

Barra de Español has been accepted to Mozilla’s public addon list

August 29th, 2009

I got an email today from the Mozilla Add-ons group that my add-on for Firefox, Barra de Español, has been approved to be in the public listing for Firefox add-ons! This means that it’s no longer listed as “experimental” and no longer requires that users check a box in order to install it.

I was a bit surprised by how long this process took. I nominated it when I released version 1.1 on June 7. 83 days later it was accepted, and during those 83 days I had no feedback as to what was going on. A week or two ago I visited an IRC chat room for add-on developers and was told that 2 or 3 months was pretty common. Recently Mozilla released a statistics dashboard that shows how many add-ons get created or updated daily. I’m not sure how many reviewers Mozilla has, but it makes more sense why it takes as long as it does now that I can see those numbers.

Regardless, I’m happy my little add-on has been accepted and I definitely have plans to enhance it in the future.

My development plan for the Android Developer Challenge 2

July 29th, 2009

I haven’t posted lately about Barra de Español or the Biblefeed Project because my free time has been split among other projects and I have not been able to return to these two for the moment. Barra de Español is still awaiting approval on addons.mozilla.org to be put in the public section, so I don’t want to make further improvements to it until that happens.

Recently I purchased an Android phone, and I love it! It’s everything I wanted a phone to be. It has an excellent web browser, a full QWERTY keyboard, GPS, and it’s hackable! I decided pretty quickly that I wanted to write an app for it, and as I start looking for the documentation on how to write one, I discover that Google is holding a developer contest. This discovery changed my approach to developing this app.

I’m not going to talk about the app I’m working on, but I did want to share how I intend to work on it, because it’s a little different than my normal approach to personal projects. Normally I start with a minimal list of features. These are the features that are most important to me. I work on each one a little at time, slowly improving the pieces until they are functional and working well together. Each piece  that I work usually causes me to improve the other pieces of the program until finally they’re all done at around the same time. At this point the project is probably ugly. I may give it some finishing touches, but not always. The project is for me, so functionality trumps aesthetics.

For this contest I felt that developing an app required a different approach. I made a larger list of features that I felt the app could do that I had not originally planned for, especially features which would take advantage of some of the built-in hardware and software on the Android platform. I then prioritized each feature based on how essential the functionality is to the application, how much the feature took advantage of the platform, and how impressive I thought that the feature could be.

With this prioritized list, I’m going to develop each feature as a whole, one feature at a time. Each feature must be functionally complete and aesthetically pleasing before I move on to the next feature. The reason for this is because if the entry deadline arrives before all of the features are complete, I can still submit an application which is still functional and polished, even if it has fewer features than planned. With my normal development style I could be stuck with an ugly app where only half of the features work by the time the deadline rolls around.

I don’t expect that I will be able to complete all of my planned features for this project by the August 31 deadline, but I hope with this plan I will have a decent app to submit. There is a bit of a learning curve that is slowing me down though. Even though it’s been over five or six years since I’ve worked with Java, the changes to the language are similar to the changes to C# over the same time period. The real learning curve comes from the Android framework. The activities, intents, content providers, etc. are easy enough to understand but I’m still dealing with an API that is brand new to me, and will take time to absorb.

Wish me luck!