Category Archives: android

Learning more about Android development

From Tuesday: I spent most of the long weekend learning about Android development by working on the MobileOrg for Android open source project. When it comes to learning new technologies, I like working on existing projects more than starting from scratch. There’s plenty of sample code to draw on, and there’s enough functionality to inspire me to think about how to tweak it to fit my needs.

The first two days were really slow in terms of progress. It took me a while to figure out how to build both MobileOrg and MobileOrgNG, and I blogged the instructions in case someone else needs them in the future. After I figured that out, I started fiddling with the settings menu. I made the system more consistent, updated the look and feel to the latest design guidelines, and learned a little more about how everything tied together.

I’m starting to feel more comfortable with Android development. There are still tons of things to learn, of course, but I’m getting the hang of where things are, what things are called, and how things flow together. It’s an amazing thing, feeling the concepts click into place. As you learn more things, the possibilities grow combinatorically.

I should take care of a few other tasks before I move on to the next steps. I have to prepare a presentation for the Quantified Self conference in September. It’ll be an Ignite-style presentation, which is good – clear constraints make it easier to put something together. I also want to do an annual review in preparation for my birthday on Sunday.

After I finish those tasks, what do I want to do next in terms of Android development?

  • I’d like to build a better browsing interface for MobileOrg. I like the way MobileOrgNG makes it easy to browse the Org file’s hierarchy.
  • I want to be able to capture information from other applications.
  • It would be awesome to be able to handle attachments, too.
  • Tasker integration for automatically capturing information, perhaps?
  • Org-contacts would be great.

If I have a year of days like this, I think I’ll be able to learn and do a lot.

How to build MobileOrgNG for Android

MobileOrgNG is kvj’s fork of matburt’s MobileOrg for Android. It has a better layout for large devices and a useful outline view, but doesn’t have some of the other features in the main branch. Here’s how you can build it in Eclipse.

In order to be able to get all the libraries you’ll need, install the Subversive SVN plugin for Eclipse.

  1. In Eclipse, click Help – Install New Software.
  2. Click on the dropdown for Work with and choose the update site for your Eclipse version (ex: Juno).
  3. When the packages load, type in Subversive to filter the list.
  4. Choose Subversive SVN Team Provider. You can choose other plugins as well.
  5. Click Next and proceed through the installation process.

Now you can check out the MobileOrgNG source code and other modules. MobileOrgNG is set up as an Eclipse project, so importing it is easier than importing the original MobileOrg. Here’s how to get MobileOrgNG:

  1. Copy the Git repository URI (ex: git://github.com/kvj/mobileorg-android.git)
  2. In Eclipse, click File – Import – Git – Projects from Git.
  3. Choose URI.
  4. The URI may automatically be detected from the clipboard. If it isn’t, paste it in.
  5. Click Next.
  6. Click Next again.
  7. Click Next.
  8. You should now be at the dialog called Select a wizard to use for importing projects. Choose Import existing projects and click Next.
  9. It should have detected the mobile-org project. Click Finish.

In addition to MobileOrgNG, you will also need the android-actionbar and android-file-dialog libraries. Here’s how to get android-actionbar:

  1. Go to https://github.com/kvj/android-actionbar and copy the Git repository URL (ex: git://github.com/kvj/android-actionbar.git).
  2. In Eclipse, click File – Import – Git – Projects from Git.
  3. Choose URI.
  4. The URI may automatically be detected from the clipboard. If it isn’t, paste it in.
  5. Click Next.
  6. Click Next again.
  7. In the Local destination dialog, change Initial branch to honeycomb-support. Click Next.
  8. You should now be at the dialog called Select a wizard to use for importing projects. Click Cancel.
  9. Click File – Import – Android – Existing Android Code Into Workspace.
  10. Click Browse and choose the android-actionbar directory in your workspace. You can deselect the actionbar example if you wish.
  11. Click Finish.

Here’s how to get android-file-dialog.

  1. Go to http://code.google.com/p/android-file-dialog/source/checkout and copy the SVN URI (ex: http://android-file-dialog.googlecode.com/svn/trunk/).
  2. In Eclipse, click on File – Import – SVN – Project from SVN.
  3. Paste in the URI.
  4. Click Next.
  5. Eclipse should prompt you to normalize the URL. Click Yes.
  6. Click Browse. Choose trunk and click OK.
  7. Click Finish.
  8. Choose Find projects in the children of the selected resource. Click Finish.
  9. Make sure that Check out as a projects into workspace is selected. Click Finish.

Confirm that the libraries are detected.

  1. Right-click on the mobileorg-android project and choose Properties.
  2. Click Android and confirm that both libraries are detected. If not, you may need to remove and re-add them.

The Dropbox API key isn’t part of the source code, so you’ll need to apply for your own at https://www.dropbox.com/developers/start . After you get the API key, add it to your project:

  1. Create a new Android XML Values file. I called mine secrets.xml.
  2. Right-click on the file and choose Team – Ignore.
  3. Add a string with the key dropbox_consumer_key and the value from the Dropbox webpage.
  4. Add another string with the key dropbox_consumer_secret and the value from the Dropbox webpage.

MobileOrgNG should now compile without errors.

Building MobileOrg for Android

If you want to use your Android device to work with your Org-mode files, there’s MobileOrg and there’s MobileOrg NG. MobileOrg seems to have more recent activity and more contributors, but NG has a more tablet-optimized layout and better support for navigating large files, so it would be good to apply some of the ideas from NG to the main MobileOrg project. Might be a useful way for me to learn more about mobile development.

Here’s how to build MobileOrg (the matburt version).

  1. Copy the URI to the Git repository (ex: git://github.com/matburt/mobileorg-android.git).
  2. In Eclipse, click on File – Import – Projects from Git – URI. This may autodetect the URI. If not, paste in the URI. Click Next.
  3. You should now see a list of branches. You can leave them all selected. Click Next.
  4. Check the box for Clone Submodules. This will make sure that the project’s dependencies are also checked out. Click Next.
  5. When you see the dialog called Select a wizard to use for importing projects, click on Cancel.

Because the .project file hasn’t been set up, you’ll need to import the project using a different wizard. However, there’s an Eclipse bug that can make this a bit of a hassle, so this is what you should do to get the projects set up in your system.

  1. Close Eclipse.
  2. Move the mobileorg-android subdirectory from your Eclipse workspace directory to a different directory that is not in your workspace.
  3. Start Eclipse again.
  4. Click on File – Import – Existing Android Code Into Workspace. Click Browse and choose the mobileorg-android folder.
  5. Click on Deselect All.Reselect the following:
    • com.matburt.mobileorg.Gui.OutlineActivity
    • library
    • com.twofortyfouram.locale.MarketActivity
  6. Click on Finish.

Now you should have a bunch of projects in your system. You may need to adjust the libraries and build paths.

  1. Right-click on the com.matburt.mobileorg.Gui.OutlineActivity project and choose Properties.
  2. Click on Android and confirm that both libraries are detected. If not, you may need to remove and re-add them.
  3. Wait for the libraries to be built. If you notice that the compiled JARs don’t have classes, doublecheck that the src folder has loaded the sources. Right-click on the src folder and choose Refresh in order to get the sources recognized by Eclipse.

Re-detect the Git connection by doing the following:

  1. Right-click on the com.matburt.mobileorg.Gui.OutlineActivity project and choose Team – Share Project.
  2. Choose Git.
  3. Check the Use or create repository in parent folder of project.
  4. Check the .git directory you’re using.
  5. Click on Finish.

I also had to remove some code from AndroidManifest.xml because you’re apparently not supposed to have more than one action in an intent-filter:

diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 01c4f1e..9fc3eb1 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -64,14 +64,11 @@
             android:name=".Gui.OutlineActivity"
             android:label="MobileOrg"
             android:theme="@style/Theme.MobileOrgActionbar" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
-
                 <category android:name="android.intent.category.LAUNCHER" />
-
-                <action android:name="com.matburt.mobileorg.Synchronizer.action.SYNC_UPDATE" />
             </intent-filter>
         </activity>
         <activity
             android:name=".Gui.NodeViewActivity"
             android:label="Org View"

(StackOverflow)

Hope that helps!

Tablet adventures: Using my TF700 as a second monitor with AirDisplay

UPDATE 2012-07-29: Hmm, I’m getting some weird mouse behaviour after disconnecting from AirDisplay. I’ll look into this some more tomorrow.

Multiple monitors are great for productivity. You can see more of what you’re working on. You don’t have to switch between applications. You don’t have to remember snippets as you move from window to window. I want to work with multiple monitors, but I don’t want to be confined to the desktop downstairs, or to take up valuable kitchen table space with an LCD.

At 1920×1200, the Asus Infinity TF700 tablet has a higher resolution than my laptop (Lenovo X220 tablet, 1366×768). The Air Display app ($4.99 in Google Play) makes it easy to set up a tablet as a second monitor for your Mac or Windows computer if they’re on the same wireless network.

I installed the app on my tablet, installed the PC version on my laptop, restarted my computer, and set up the connection. Now I can drag windows over or use keyboard shortcuts to move my windows to the tablet. I can touch the tablet to interact with my computer, although the hardware keyboard on my dock doesn’t work. The display has some lag, but it’s useful enough for reading references or checking websites.

Air Display sets my laptop’s graphics scheme to Windows Basic, which removes a lot of the fancy visual effects that Windows uses to make things prettier. It’s a small price to pay for the ease and portability of having a second monitor.

DSC_3376image

Air Display (Android, $9.99 $4.99)  – Looks like they increased the price!
Air Display from the App Store ($9.99) – for the iPad

Waking up with barcodes

I’d been looking for a wake-up alarm that was good at getting me up and out of bed. It turned out that I can solve a sequence of two-digit addition problems while half-asleep, so my previous alarm clock app still tempted me to snooze.

For the past two weeks, I’ve been trying a different alarm clock app. Morning Routine requires you to scan a barcode or a series of barcodes in order to turn off the alarm. After reading a Lifehacker post that mentioned it, I downloaded the app and set it up on my phone. I configured Morning Routine to require the barcode of a tub of cream cheese from the fridge. It turns out that the process of stumbling out of bed, stepping around the cats in the hallway, and opening the fridge is enough to wake me up and get me to start making breakfast.

The app doesn’t have a snooze button, so I can either wake up properly or shut down my phone. So far, I’ve been good at not shutting down my phone.

The developer’s blog post describes an even more fleshed out routine that involves barcodes in several rooms, with timers to get through the process. My morning wake-up-and-get-out-the-door routine typically takes an hour, but it might be interesting to set timers for the different components, or do a low-level time study of it. Hmmm.

Morning Routine is an Android app, and it’s currently available for free. Check it out in the Google Play store!

Quantified Awesome: How I’m starting to use Tap Log for Android

At Rails Pub Nite the other week, Andrew Louis showed me his timestamped-based self-tracker inspired by Your Flowing Data and similar semi-structured text entry systems. He had a year of data in his system, and had built a fascinating dashboard. 

Nudged by the idea, I moved from using Time Recording to capturing timestamped data, and started using Tap Log for data entry because it lets me set up categories for quick entry.

I wanted to use Tap Log to capture the following types of data:

  • activities (work, sleep, etc.) so that I can do weekly and long-term time analysis
  • meals, so that I can get a sense of what I eat and when
  • thoughts, so that I can jot quick ideas, keep track of things I need to follow up on, and copy information into other systems
  • moods / feelings

screenshot_11I’ve set up my Tap Log to start with high-level categories. From this screen, I can quickly enter text or choose an activity.

The “Text” button is in yellow, which means that the next screen will have a text entry screen. “Sleep” is in red, which means that it needs no additional input – it creates a log entry, and that’s it. Entries like “Discretionary” lead to other menus, which are set up similarly.

For example, if I’m planning to write, I’d start by tapping “Discretionary”, then “Writing”, and I’d add a note about writing for my blog. 

screenshot_20You can have up to three levels of categories. Timestamped entries can be associated with numbers, ratings (1-5), or text. You can review log entries in the application itself, or you can export the log as a CSV and process it yourself.

The CSV will give you the following data:

  • latitude, longitude, altitude, accuracy, gpstime, street, city, state, country, zip
  • samples, _id
  • timestamp, DayOfYear, DayOfMonth, DayOfWeek, TimeOfDay
  • catOne, catTwo, catThree
  • number, rating, note

For my use, I focus on _id (for updates), timestamp, catOne, catTwo, catThree, number, and note. I usually keep GPS off on my Google Nexus One in order to save battery. Besides, GPS performance on that phone isn’t very good. W- wins our GPS battles all the time thanks to his trusty N8. You might find the GPS tagging handy, though.

Because I’m interested in activity tracking, I need to infer ending timestamps from the data. Some of my records are associated with activities. Some of them capture other data, such as thoughts. Here’s the basic idea behind my code:

  • Read each timestamp and copy it into my database, updating the record if it already exists
  • Re-sort the records by timestamp
  • Delete time records for this period
  • For each timestamp in the updated period:
    • If this is an activity (based on the category)
      • Close the last activity and save it as an activity record
      • Set the last activity to the current activity

I also added some text analysis to look for notes tagged with !memory, !todo, !private, and other tags I’m starting to find handy.

Tada! http://quantifiedawesome.com/tap_log_records:

image

and activity graphs at http://quantifiedawesome.com/time/graph:

image

Observations: I like the ability to capture text and ratings quickly, and I look forward to taking advantage of that. I’ve been tracking activities just as much as I did on Time Recording, so the lack of on-phone activity summaries hasn’t gotten in my way.

What would make this even better? I’d like built-in time tracking, although that might mean that people would need to indicate which buttons correspond to activities. I’d like to have full Tasker integration so that I can automatically create entries based on different events, but I can get around that by logging the information separately and then merging it based on time. Sometimes I wish I could have four or five levels of categories, but I can use text for now. Mostly, I just need to keep adding to the analysis tools I’ve been building on Quantified Awesome: tags, activities, summaries, paging, and so on.

So that’s where I am. Let’s see where this helps me go!