
Interactive fiction interpreter for Android released! Look at the code or just grab the package at Market.
Interactive fiction interpreter for Android released! Look at the code or just grab the package at Market.
Android documentation says:
public int ledARGB
The color of the led. The hardware will do its best approximation.
Best approximation my ass. I wanted #fb2a0c
, I got pink. To get the orange color, I needed #080800
, for which orange is most certainly not what I'd call best approximation. It seems that Dreams' drivers just feed the raw RGB values to the hardware without bothering to do any processing on them.
To make it easier to find out which color to feed your device to get the real best approximation of color you want, I made this quick and dirty android LED tester. Just slide the sliders until you're satisfied, note the values and get on with it.
As a note, you might want to only serve the fake colors to devices you tested them on, in case other devices handle this properly and your app would turn out to blink the LED in real #080800
, which is to say, almost black. I do this with if (Build.DEVICE.equals("dream")) color = 0xff080800; else color = 0xfffb2a0c;
obviously if you test on more devices and they're all equally quirky, you need to add more checks.
Making application icons which would fit in style of the original icons on Android isn't at all easy. I've found it's easiest to model icon in 3D and render it. In the best interest of aesthetically-sensitive android users worldwide, I'm making available this android application icon template you can use to make your new beautiful icon.
It's got the camera, lights and whatnot setup just the proper way. It's still a little bit off the original icons—the shadow could be softer, for instance—but works good enough for me after some time struggling with blender's clunky interface. If you can fix it, great—the drop has guest upload enabled, so feel free to share your improved version.
As you may or may not know, 9.png files in compiled android packages have the nine patch metadata info rolled from the image OOB into the PNG file. Following quick and dirty ruby script extracts it back.
#!/usr/bin/env ruby
# Rafał Rzepecki
# public domain
#
# deserializes metadata of 9-patch png file
# optionally writes out png with 9-patch info embedded (needs imagemagick for that)
#
# quick and dirty hack, no error handling, almost no test, YMMV
#
# for format specs see android/platform/frameworks/base/libs/utils/ResourceTypes.cpp
# (in android platform source)
if ARGV.length == 0
print "Usage: #{__FILE__} <serialized nine-patch png file> [optional output png with inline 9-patch info]\n"
exit 1
end
filename = ARGV[0]
png = File.open(filename) { |f|f.read }
index = png.index 'npTc'
data = png[(index+4)..-1]
wasDeserialized, numXDivs, numYDivs, numColors = data[0...4].unpack('C4')
paddings = data[12...(12+16)].unpack('N4') #left right top bottom
data.slice!(0...32)
xDivs = data.unpack("N#{numXDivs}")
data.slice!(0...(4*numXDivs))
yDivs = data.unpack("N#{numYDivs}")
data.slice!(0...(4*numYDivs))
colors = data.unpack("N#{numColors}")
print "was deserialized: #{wasDeserialized}
paddings: #{paddings.join(', ')}
xdivs: #{xDivs.join(', ')}
ydivs: #{yDivs.join(', ')}
colors: #{colors.map{|c| "#%08x"%c}.join(', ')}
"
if ARGV.length == 1
exit 0
end
# quick and dirty
`identify #{filename}` =~ /PNG (\d+)x(\d+)/
w, h = $1.to_i, $2.to_i
`convert #{filename} -bordercolor white -compose Copy -border 1x1 -stroke black \
-draw 'line #{xDivs[0] + 1},0 #{xDivs[1] + 1},0' \
-draw 'line 0,#{yDivs[0] + 1} 0,#{yDivs[1] + 1}' \
-draw 'line #{paddings[0] + 1},#{h + 1} #{w - paddings[1]},#{h+1}' \
-draw 'line #{w+1},#{paddings[2] + 1} #{w+1},#{h - paddings[3]}' \
#{ARGV[1]}`
content://sim/adn
doesn't respect the where
clause when querying it. Just so that someone doesn't spend as much time wondering why the freaking thing wouldn't work as I did.
You have to filter it another way. I did by creating a custom CursorAdapter
to filter it, but your mileage may vary. It might be better to make a cursor wrapper, or something. Or is there something like that in the library already, and I just missed it?
To launch an application programmatically in Android given an ApplicationInfo
, do:
ApplicationInfo ai;
PackageManager pm = getPackageManager();
try {
Intent i = pm.getLaunchIntentForPackage(ai.packageName);
startActivity(i);
} catch (Exception e) {
Toast t = Toast.makeText(this, "Couldn't launch the application.", Toast.LENGTH_SHORT);
t.show();
}
Apparently this was harder pre-1.5, where you had to look for the proper activity yourself.
Google was going to be an interesting case of a large company hiring people both from the embedded world and also the existing Linux development community and then producing an embedded device that was intended to compete with the very best existing platforms. I had high hopes that this combination of factors would result in the Linux community as a whole having a better idea what the constraints and requirements for high-quality power management in the embedded world were, rather than us ending up with another pile of vendor code sitting on an FTP site somewhere in Taiwan that implements its power management by passing tokenised dead mice through a wormhole.
To a certain extent, my hopes were fulfilled. We got a git server in California.