Learning Android development by hacking MobileOrg

I spent most of Saturday plunging into Android development, starting from the Hello World and Notepad tutorials. It was lots of fun. I wanted to use MobileOrg on Android, but it lacked a lot of things that were in MobileOrg for iPhone, so I taught myself Android development by fixing little things that a newbie like me could do.

First: I wanted the capture form to resize itself when the soft keyboard was displayed, instead of letting the virtual keyboard hide the Save button. Fortunately, I’d come across a solution while reading the technical articles on developer.android.com: resize the activity based on the onscreen input method. I tested it on my system, then reported the issue and the fix through MobileOrg’s github. Within a few hours, the fix was included in the project. Yay! (It took me a while to figure out I could use the back button to hide the keyboard, but it was a productive while.)

Second: The editing interface was functional but not convenient , so I dug into views and layouts and all sorts of niftiness. Before and after:

edit-before   after

(… and it’s all wired up and working, at least for me!)

Mwahaha! Along the way, I ended up learning about org-mobile.el and how to set up a somewhat finicky configuration so that I could synchronize my files over Dropbox onto my SD card and into MobileOrg, and then back over Dropbox and into my computer. It’s not fully automatic, but the pieces are mostly connected now. The relevant parts of my experimental config:

(setq org-mobile-directory "~/dropbox/mobile")
(setq org-mobile-inbox-for-pull "~/personal/mobileorg.org")
(setq default-buffer-file-coding-system 'utf-8)
(setq org-mobile-files '("~/personal/organizer.org" "~/personal/outline.org" "~/personal/test.org"))
(setq org-mobile-agendas '("a"))

Then I used M-x org-mobile-push to sync  things up. There was a bit of a kerfluffle I had to sort out. I moved files around, so I needed to delete the /sdcard/mobileorg database on my Android, and I also needed to download the checksums and other files using Dropbox before loading them in MobileOrg. But things work reasonably well now, I think, and I can browse my Org files and capture some updates. Whee!

 main organizer outline2

… and so on.

Next step: Talk to my manager about open source approvals so that I can share my patches with the community. There’s still plenty more to build on top of MobileOrg, but at least I’ve taken care of the two big things that were getting in my way.

I’ll have to decide whether I’m going to build my other app ideas as separate lightweight apps, or be evil and store as much data as I can into Org… >:) Hmm. Org as grocery list, price tracker, inventory management, and  recipe database? Org as sewing organizer for patterns, notions, fabric, measurements, and projects? Org as a hammer for an unbelievable variety of nails?


(Okay, maybe I’ll build things for SQLite first, but there’ll probably be some kind of .org or CSV eventually…)

  • Phil Hudson

    Thanks for yet another fantastically useful post. One question: what is `org-mobile-agendas’? I don’t find it in org-mobile.el

  • mom

    Is an Android phone something that a non-geek mother of a geek can learn to use?

    • http://sachachua.com Sacha Chua

      You’re probably more an iPhone or regular phone + iPad kind of person… =)

  • Phil Hudson

    Ignore my question, I had an out-of-date org-mode install.

  • prg

    If you’re using emacs instead of the widespread eclipse for android development, I’d really be interested in a blog post about your setup. jde(e)? cedet? android.el? android-mode.el?
    I’m using almost all of the above, but still haven’t worked out some of the quirks…

  • http://sachachua.com Sacha Chua

    I’m still on Eclipse. =) Development on training wheels – one major change at a time. It’s like when I started out with Drupal, too. I started with Eclipse, so I could take advantage of autocompletion and step-by-step debugging. When I got the hang of it and could make reasonable progress on my own, then I switched over to Emacs. That way, I knew enough to tell the difference from a bug in my code from a bug in my setup, and I had the patience to hack away at things that needed figuring out. =)

    I’d love to hear about your setup, though!

  • Victor Calvert

    I use a prepaid cellphone, so I’m not that interested in switching to an Android phone…even though I kinda want to hack on one. Do you know of any Android-powered iPad replacements (i.e. multitouch tablets) that I could hack on, preferably available now? The main reason I haven’t bought an iPad is that you can’t really hack on it….

    I know the WeTab (used to be WePad) launched in Germany sometime in August/September and is available now in Germany, but they aren’t selling them to those of us in the US yet; it’s a MeeGo/Android stack, and the price isn’t bad, but we probably won’t be able to buy them for another 3-6 months (wetab.mobi/en for more detail)

  • http://sachachua.com Sacha Chua

    I’m on an Android without a data plan, because I’m on WiFi pretty much all the time anyway. I use APNdroid to change my details so that my processes don’t get any data over the cellular network. Result: no data charges. It’s good to have the option, just in case I’m out and I _really_ need to look something up. The same setup should work just fine with a prepaid cellphone, if you’re willing to pay cash for your phone.

    In my case, I considered it an investment into personal productivity and software development. That’s working out well for me, too. =) I take more pictures because it’s easy to share them. I can write e-mail on the subway; it just gets queued until I’m back in WiFi land. I use Time Recording to track my activities and Sleep Bot to track my sleep. And then there’s Android development and a rabbit-hole of things to learn and try. The Android experience isn’t as slick as iPod/iPhone, but the apps cover most of the things I want to do.

    An Android tablet might work well for you. I’ve never tried one myself, as I was looking for something I could use to replace my phone + iPod combination. =)

  • http://matburt.net matburt

    Thanks for you contribution to MobileOrg, I like the editing interface that you’ve designed… it would be another welcome addition to the codebase if you feel like having it merged in?

    I’d recommend forking my project on github and once you are done, submit a pull request… this makes it much easier to integrate your changes and will ensure you are properly credited.

  • http://sachachua.com Sacha Chua

    I’ve asked my manager for permission to contribute to open source (ah, yes, big companies and intellectual property). Once that’s sorted out, I’m happy to use github to manage distributed development. I still need to play around with the interface a bit. A full-screen edit box is handy for viewing, although there’s really not much we can do for soft keyboards and editing. It’s going to be a tiny edit box no matter what. Looking into how other notetaking apps handle it. =)

  • Jean Jordaan

    There’s another open source orgmode on Android app on the block :)

  • Joseph

    Thank you for numerous contributions you made. Such efforts always deserves an appreciation. I have a quick question about what after pulling operation. I setup MobileOrg on Android tablet and local Org mode in Win8.1. After I made changes in mobile device & synchonized with Dropbox, everything seems right. After I run a pull operation, I expected any changes done in mobile device should be AUTOMATICALLY integrate into my original planner.org file; but I was only presented with new changes vs. original content. An example is below.

    * Heading changed in MobileOrg and on the computer F(edit:heading) [[id:1048bda5-3aa1-4779-aa75-dbe2f8381f9b][review cr card bills & calculate amount to dp]]
    ** Old value
    review cr card bills & calculate amount to dp
    ** New value
    review cr card bills & calculate amount to dp for March
    ** End of edit
    (I also noticed my original planner.org file was stripped of the original heading “review cr card bills & calculate amount to dp”)

    Then comes my question: Can Org mode AUTOMATICALLY integrate the changes into my original file planner.org? Or do I have to incorporate the changes manually?

    Your comments, please? I know for sure I can get an anser here. Thank you.


    • http://sachachua.com sachac

      It seems you’ve changed the entry on both your computer and your mobile device – is that right? If so, yeah, I think MobileOrg wants you to manually resolve that by editing the entry and then maybe using org-refile to put it into the right place.

      I haven’t used MobileOrg in ages. I haven’t needed to refer to my Org file much while away from my computer, and I have a little bit of code that makes it easier for me to pull in quick notes from Evernote. You can find it by searching for Evernote-related stuff in my config at http://sachachua.com/dotemacs . Sorry this wasn’t of much help!