building


More With Less
           with android bootstrap
tweet tweet @donnfelker
Building More With Less
agenda



         open source
         libraries
         examples
         bootstrap
Pay with Square   GitHub   Gaug.es
tons of open source


tons of integration work
open source

              roboguice
              action bar sherlock
              http-request
              gson
              view pager indicator
              robotium
              maven
              android maven plugin
              fragments
roboguice.org




roboguice
dependency injection
for android
roboguice.org




class RoboWay extends RoboActivity {
    @InjectView(R.id.name)             TextView name;
    @InjectView(R.id.thumbnail)        ImageView thumbnail;
    @InjectResource(R.drawable.icon)   Drawable icon;
    @InjectResource(R.string.app_name) String myName;
    @Inject                            LocationManager loc;

        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            name.setText( "Hello, " + myName );
        }
}
roboguice.org




        User Interface


        Service Layer
                                                         ed a string
                                           wha t if I ne          e?
                                                       d  own her
                                            r esource

     Persistence Layer




service layer: goo.gl/7NQVZ   persistence layer: goo.gl/j5u74
roboguice.org




public class UserRepository {

    @InjectResource(R.string.public_key) String publicKey;

    public void saveProfile(UserProfile profile) {
        // user publicKey to do some encryption
        // Now, save the encrypted profile to db/api/etc
    }
}
roboguice.org




public class UserRepository {

    @InjectResource(R.string.public_key) String publicKey;
    @Inject protected AuthService authService;

    public   void saveProfile(UserProfile profile) {
        //   Get auth token from auth service then save
        //   user publicKey to do some encryption
        //   Now, save the encrypted profile to api
    }
}
roboguice.org




must extend



              RoboActivity
              RoboListActivity
              RoboFragmentActivity
              RoboListFragmentActivity
              ...
roboguice.org
actionbarsherlock.com




action bar sherlock
action bar support for pre 3.x
actionbarsherlock.com



Pay with Square   GitHub                 Gaug.es
actionbarsherlock.com
actionbarsherlock.com




usage


        getSupportActionBar()

        native calls

        supports theming

        must use Sherlock themes
        as parent
actionbarsherlock.com




must extend



              SherlockActivity
              SherlockListActivity
              SherlockFragmentActivity
              SherlockListFragmentActivity
              ...
actionbarsherlock.com




                 ruh roh.
roboguice and actionbarsherlock must both extend activity
github.com/rtyley/roboguice-sherlock




roboguice-sherlock
 combines roboguice and sherlock
github.com/rtyley/roboguice-sherlock




public class CarouselActivity extends RoboSherlockFragmentActivity {

    @InjectView(id.tpi_header) private TitlePageIndicator indicator;
    @InjectView(id.vp_pages) private ViewPager pager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.carousel_view);

        pager.setAdapter(new BootstrapPagerAdapter(getResources(), getSupportFragmentManager()));

        indicator.setViewPager(pager);
        pager.setCurrentItem(1);
    }


}
github.com/rtyley/roboguice-sherlock
kevinsawicki.github.com/http-request/




      http-request
A simple convenience library for using a HttpURLConnection to
          make requests and access the response.
kevinsawicki.github.com/http-request/
kevinsawicki.github.com/http-request/
kevinsawicki.github.com/http-request/
code.google.com/p/google-gson/




       gson
a library for working with json
code.google.com/p/google-gson/
a pojo
  class BagOfPrimitives {
    private int value1 = 1;
    private String value2 = "abc";
    private transient int value3 = 3;
    BagOfPrimitives() {
      // no-args constructor
   }
  }




serialization
  BagOfPrimitives obj = new BagOfPrimitives();
  Gson gson = new Gson();
  String json = gson.toJson(obj); 



deserialization
   BagOfPrimitives obj2 = gson.fromJson(json, BagOfPrimitives.class);
code.google.com/p/google-gson/
a pojo
  class BagOfPrimitives {
    private int value1 = 1;
    private String value2 = "abc";
    private transient int value3 = 3;
    BagOfPrimitives() {
      // no-args constructor
   }
  }




serialization
  BagOfPrimitives obj = new BagOfPrimitives();
  Gson gson = new Gson();
  String json = gson.toJson(obj); 



deserialization
   BagOfPrimitives obj2 = gson.fromJson(json, BagOfPrimitives.class);
code.google.com/p/google-gson/




woohoo! no more manual json parsing
code.google.com/p/google-gson/
viewpagerindicator.com




view pager indicator
viewpagerindicator.com
viewpagerindicator.com
viewpagerindicator.com
code.google.com/p/maven-android-plugin/




 android-maven-plugin
an easy to use maven plugin for android
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>android-bootstrap</artifactId>
    <packaging>apk</packaging>
    <name>Android Bootstrap app</name>
    <url>https://github.com/donnfelker/android-bootstrap</url>

    <parent>
        <version>1.0</version>
        <groupId>com.donnfelker.android.bootstrap</groupId>
        <artifactId>android-bootstrap-parent</artifactId>
    </parent>

    <properties>
        <abs.version>4.1.0</abs.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <scope>provided</scope>
            <version>${android.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>com.github.rtyley</groupId>
            <artifactId>roboguice-sherlock</artifactId>
            <version>1.4</version>
        </dependency>
code.google.com/p/maven-android-plugin/




build process easier to manage
code.google.com/p/maven-android-plugin/




resources




            google group

            ch14 of sonatype book
            goo.gl/3Waf5
code.google.com/p/maven-android-plugin/
fragments android support library
download from android sdk
code.google.com/p/robotium




“its like selenium, but for android”
code.google.com/p/robotium
public class EditorTest extends
                ActivityInstrumentationTestCase2<EditorActivity> {

  private Solo solo;

    public EditorTest() {
                  super("com.test.editor",
                                  EditorActivity.class);
    }

    public void setUp() throws Exception {
          solo = new Solo(getInstrumentation(), getActivity());
    }
 
    public void testPreferenceIsSaved() throws Exception {
 
                                solo.sendKey(Solo.MENU);
                                solo.clickOnText("More");
                                solo.clickOnText("Preferences");
                                solo.clickOnText("Edit File Extensions");
                                Assert.assertTrue(solo.searchText("rtf"));
                             
                                solo.clickOnText("txt");
                                solo.clearEditText(2);
                                solo.enterText(2, "robotium");
                                solo.clickOnButton("Save");
                                solo.goBack();
                                solo.clickOnText("Edit File Extensions");
                                Assert.assertTrue(solo.searchText("application/robotium"));
                             
    }

     @Override
     public void tearDown() throws Exception {
          solo.finishOpenedActivities();
    }
}
code.google.com/p/robotium
androidbootstrap.com
androidbootstrap.com



influences github and github gauges

           GitHub          Gaug.es
androidbootstrap.com
includes
           roboguice
           action bar sherlock
           http-request
           gson
           view pager indicator
           robotium
           maven
           android maven plugin
           fragments
           api consumption
           image downloading
           image caching
           cache mechanism
           pojo support
                                        ahhhhhh yeah
           and more...
androidbootstrap.com




uses



       template for your next project
       use as a reference
       a how to tutorial
       project MVP bootstrap
androidbootstrap.com




code
Thank You.
questions? tweet @donnfelker

Android Bootstrap