Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Garage Buddy
Tips, Hacks, and Lessons Learned
Who am I?
• Not much of a presentation wiz
• Currently a programmer at Turtle Rock studios
• 7 years of experience in game...
Why make Garage Buddy?
• We're car guys!
• Wanted to learn about mobile development and
publishing
• Sounded like an easy ...
What is Garage Buddy?
• It is a multi-tool app for people that work on cars
• Has various calculators and tables
• We have...
Splash Screen
• Sends anonymous usage data
to us for demographic tracking
• We track OS version, screen
res, hardware mode...
Main Menu
• We needed a scrollable list that would contain icons
and text, and launch other activities
• The Main Menu is ...
Main Menu Items
• Uses the "Class" object, part of Java's support for
Reflection
• Reflection is awesome!
• Code is simple...
Menu Item Launching
mMainListView.setOnItemClickListener( new OnItemClickListener() 
{
    public void onItemClick(Adapter...
Ruler
• In iOS, just a static image
• In Android, numbers and
tick marks placed
programatically.
• Very easy thanks to
And...
Ruler - dimens.xml
<resources>
    <dimen name="one_inch">1in</dimen>
    <dimen name="one_millimeter">1mm</dimen>
    <di...
Ruler - RulerView.java
public class RulerView extends View
{
public void onDraw(Canvas canvas)
{
float inchDim = getResour...
Tables
• Large tables are slow on low-end devices 
• Maybe because a table contains N views, N = ROWs x CELLs
?
• In other...
Questions?
 
brock@non-euclidian.net
Upcoming SlideShare
Loading in …5
×

Garage Buddy for Android

978 views

Published on

Overview of things I learned while porting our Garage Buddy application from iOS to Android.

  • Be the first to comment

  • Be the first to like this

Garage Buddy for Android

  1. 1. Garage Buddy Tips, Hacks, and Lessons Learned
  2. 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. 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. 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. 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. 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. 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 }
  8. 8. Menu Item Launching mMainListView.setOnItemClickListener( new OnItemClickListener()  {     public void onItemClick(AdapterView<?> parent, View view, int position, long id)      {         Class activity = mMainMenuItems.get(position).mActivity;         Intent intent = new Intent(                MainMenuActivity.this,                activity );                      MainMenuActivity.this.startActivity(intent);     } }); Being able to store a class type in a variable lets you do some fancy things: Instead of: Intent intent = new Intent(      MainMenuActivity.this,      RulerActivity.class );
  9. 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)
  10. 10. Ruler - dimens.xml <resources>     <dimen name="one_inch">1in</dimen>     <dimen name="one_millimeter">1mm</dimen>     <dimen name="one_centimeter">10mm</dimen> </resources>
  11. 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. 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
  13. 13. Questions?   brock@non-euclidian.net

×