2. Who am I?
• Not much of a presentation wiz
• Currently a programmer at Turtle Rock studios
• 7 years of experience in game development for PCs
and console
• Garage Buddy was my first Android application
• Garage Buddy was also my first Java application
• email: brock@non-euclidian.net
3. Why make Garage Buddy?
• We're car guys!
• Wanted to learn about mobile development and
publishing
• Sounded like an easy (spare-time) project
4. What is Garage Buddy?
• It is a multi-tool app for people that work on cars
• Has various calculators and tables
• We have both iOS and Android versions
• Originally written for iOS
• Original iPhone and G1 are both HVGA devices
(320x480), but this has gotten a lot messier
• iPhone table data is in PList files, which is just XML.
• iPhone strings are in a "Localizable.strings" file,
easily converted into a strings.xml file.
5. Splash Screen
• Sends anonymous usage data
to us for demographic tracking
• We track OS version, screen
res, hardware model, and hash
of device ID
• Uploading is slow! So do it in a
thread.
• AsyncTask is a nice way of
offloading work to another
thread
• I was going to pre-load other
data app data here, but it
didn't seem necessary.
6. Main Menu
• We needed a scrollable list that would contain icons
and text, and launch other activities
• The Main Menu is just a list view with an
ArrayList<> back-end
• Doing it this way made the main menu (sort of) data
driven.
• Array is populated like this:
mMainMenuItems.add(
new MainMenuItem(
R.string.ruler_button_label,
R.drawable.ruler_icon,
RulerActivity.class) );
7. Main Menu Items
• Uses the "Class" object, part of Java's support for
Reflection
• Reflection is awesome!
• Code is simple:
public class MainMenuItem
{
int mTitleRes; // resource ID for the menu item string
int mImageRes; // resource ID for the menu item drawable icon
Class mActivity; // the class of the activity we should launch
}
9. Ruler
• In iOS, just a static image
• In Android, numbers and
tick marks placed
programatically.
• Very easy thanks to
Android support for
"dimensions" which include
real-world units (inches,
millimeters)
11. Ruler - RulerView.java
public class RulerView extends View
{
public void onDraw(Canvas canvas)
{
float inchDim = getResources().getDimension(R.dimen.one_inch);
int screenHeight = getHeight();
int inchTicks = screenHeight / inchDim;
int tickWidth = 1;
int tickLength = 50;
Paint paintLargeTick = new Paint(Paint.ANTI_ALIAS_FLAG);
paintLargeTick.setColor(Color.BLACK);
for ( int i = 0; i <= inchTicks; i++ )
{
float xStart = 0;
float yStart = i*inchDim;
canvas.drawRect(
xStart, yStart,
xStart + tickLength, yStart + tickWidth,
paintLargeTick);
}
}
}
12. Tables
• Large tables are slow on low-end devices
• Maybe because a table contains N views, N = ROWs x CELLs
?
• In other words: ROWs x ROWs x COLs
• I couldn't find a way around it:
• Building programatically was slow (even in another thread)
• Putting the entire table in the layout.xml was slow