Android Fragment layout

23 Feb

I recently ran into a problem when using a FragmentTranscation to replace a LinearLayout with a Fragment. The Fragment that I was putting into the layout was not filling the view port properly. Luckily it was a fairly easy problem to fix.

FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
trans.replace(R.id.main_fragment, mFragment);
trans.commit();

The code above was creating a layout that had an intermediary FrameLayout that did not have the proper layout parameters. NoSaveStateFrameLayout was set to “wrap_content” so the children were not filling the viewport.

Luckily the fix was just to change the code in onCreateView of the Fragment:

Incorrect:

View layout = inflater.inflate(R.layout.fragment_page_edit, null);

Correct:

View layout = inflater.inflate(R.layout.fragment_page_edit, container, false);

Modifying Amazon’s Kindle app to hide soft keys on Ice Cream Sandwich

3 Feb

Ice Cream Sandwich introduced soft buttons to Android phones, and Google had forethought  enough to allow applications to dim these buttons so that they don’t distract from content like text and video. Sadly Amazon has yet to update their Kindle application to support this feature. Luckily we can take advantage of APK Multi-tool to de-compile, modify, and re-compile and resign applications. Below is a screen shot of how the app should look before and after the modifications.

First we need to create a temporary application so that we can get the Dalvik code that we want to inject into the Kindle application.

Create a test project in eclipse to get the dalvik code and put this into the onCreate method after setting the content.

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);

We can use baksmali that comes with APK Multi-tool to de-compile this new app and find code similar to this:

invoke-virtual {p0}, Lcom/amazon/kcp/reader/ReaderActivity;->getWindow()Landroid/view/Window;
move-result-object v2
invoke-virtual {v2}, Landroid/view/Window;->getDecorView()Landroid/view/View;
move-result-object v2
const/4 v1, 0x1
invoke-virtual {v2, v1}, Landroid/view/View;->setSystemUiVisibility(I)V

Next we need to de-compile the Kindle app.

We want to change the code located in:

com/amazon/kcp/reader/ReaderActivity.smali

Now the code that was generated earlier can be inserted into the Reader activity after line 2027 which should look like this

invoke-virtual {p0, v0}, Lcom/amazon/kcp/reader/ReaderActivity;->setContentView(I)V

Once that is complete smali include with APK Multi-tool can be use to re-compile the modified app. The output can be pushed to an android device with adb and the soft buttons should now auto hide.

Android Kinect Projector Interface w/ System Access

23 Jan

Watch this video on YouTube.

This is a continuation of my work to create a way to interact with Android when it is being displayed on a large scale using a projector.

The setup I’m using consists of a Kinect hooked up to a Windows PC running Simple Kinect Touch. This software processes the input from the Kinect and sends TUIO commands to a Galaxy Nexus running TuioForAndroid. These events get injected into the OS as touch events allowing control over any application. The projector is connected to the Galaxy Nexus with a MHL adapter.

In order to give  TuioForAndroid system access I had to download the AOSP source tree and compile a rom for my Galaxy Nexus.  TuioForAndroid must be signed with the System key so that it can get a system pid to inject the touch events into the OS.

Android Kinect Projector Interface

20 Jan

I’ve been playing around with a way to control an Android device that is hooked up to a projector which will make it great for showing off apps in meetings. The setup I’m using consists of a Galaxy Nexus runninng a TUIO client, a Kinect, projector and a MHL adapter. With an AOSP build of Android the TUIO client app can be signed with the system keys to allow TUIO events across all of Android and not just limited to the TUIO client app.

Watch this video on YouTube.

Github Pull Request Notifier

20 Dec

I recently started working at Ironclad Mobile, they have a workflow that is very similar to what they use at GitHub, GitHub Flow. This method generates enough pull requests that I had to disable email notifications of pull requests as they were quickly filling up my inbox. But I still needed a way to be able to tell if someone had submitted a pull request that didn’t require me to open GitHub just to check. So I decided to write a Chrome extension that takes advantage of the GitHub v3 API that keeps me updated on the latest pulls.

Github Pull Request Notifier

Tags: ,

Automatically generating Android images for different dpi levels

1 Nov

When developing Android apps it can be painful making sure that all you have image assets for every dpi level. I’ve been dealing with this by making all my original images in inkscape and saving them as svg files. I then use a script to scale and save the images for each dpi level.

I’ve put the script up on github:gist here

#!/bin/bash

#Requires ImageMagick to be installed.
#Some builds of ImageMagick on OSX have problems generating the images correctly.

#This script scales and creates images at the correct dpi level for Android.
#It gets placed in a folder called res/drawable/source_images/ in your #Android project along with all your svg files.
#When creating svg files set the image size to the size that you want your hdpi images to be.
#To use simply run the create_images script from its folder and it will generate images for all the svg files.

for f in *.svg;
do
echo "Processing $f"
convert -background none $f ../../drawable-hdpi/${f/.svg}.png
convert -background none $f[66.67%] ../../drawable-mdpi/${f/.svg}.png
convert -background none $f[50%] ../../drawable-ldpi/${f/.svg}.png
done
view raw create_images This Gist brought to you by GitHub.

Xoom dock modified to allow passthrough USB

12 Oct

Last week Motorola finally started allowing Xoom tablets to be sent in for their 4g LTE upgrade. Mine came back today and I was surprised to discover that they had sent it back with a little something extra, a dock. I had been looking at getting one of these since I go the Xoom back in February. The only reason I hadn’t was that there was no passthrough USB so I wouldn’t be able to use it while developing Android applications. Having received one for free I decided to go ahead and see if I could modify it to have USB and make it a little more useful.

Disassembling the dock was actually easier than expected, Motorola opted to use screws instead of the typical snap together casing.

From there it was as simple as desoldering the USB connector in the dock and splicing it to a USB cable that I had laying around. I opted to remove the audio jack from the board inside the dock so that I could route the USB cable out through the existing hole.

I hooked the Xoom up to the dock and my computer to make sure that all the connections had been made correctly and then promptly sealed the dock back up.

Finally a useful dock for the Xoom!

 

On Wall Disc Storage

28 Feb

At the office we have an unreasonable amount of discs that we use frequently. At one point they were kept on thumb tacks on a bulletin board, but they always seems to manage to jump off and end up in the same place where lost socks go.  Luckily I stumbled upon an excellent article on Make, Peel ‘n’ Stick Disc Storage.

It turns out that the CD hubs, that are often found in books, are the perfect solution and cost very little.  I went ahead and ordered some clear ones from Amazon and set them up in the office. So far they get the job done wonderfully, the discs are easy to access and they don’t try to run away anymore.

minus for Android

10 Jan


Yesterday I published minus for Android to the Android marketplace. It is in the same vein as the imgur for Android app that I published in 2010, except it is for the competing service min.us. Minus is organized differently in the fact that images have to be in a gallery to exist, this led to minus for Android having album support from the start. This along with no-nonsense photo uploading makes it a great choice for sharing original content with the internet. If you try it out and have any problems, send me an email from the marketplace and I’ll see what I can do to fix it. Enjoy!

Additional TTS Voices in Android

30 Nov

Text-To-Speech is one of the many great features built into the Android OS. Many users may only use it for the turn by turn navigation, but that still adds up to lots of time listening to a “tinny” robotic voice. Luckily Android 2.2 introduced the ability to install new TTS libraries to change the voice from the default voice. So far there are only two additional voice libraries in the market, one provided by SVOX and the the other by Loquendo. Continue reading 

Switch to our mobile site