Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hitherejoe committed Oct 24, 2015
0 parents commit bdca119
Show file tree
Hide file tree
Showing 82 changed files with 3,949 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.gradle
/local.properties
/.idea/workspace.xml
.DS_Store
/build
.idea/
*iml
*.iml
*/build
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: android
android:
components:
- platform-tools
- tools

# The BuildTools version used by your project
- build-tools-23.0.1
- android-23
- extra-android-m2repository
- extra-google-m2repository
- extra-android-support
- extra-google-google_play_services

before_script:
- chmod +x gradlew
#Build, and run tests
script: "./gradlew build testDebug"
sudo: false
596 changes: 596 additions & 0 deletions License.md

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Android Boilerplate [![Build Status](https://travis-ci.org/hitherejoe/Android-Boilerplate.svg?branch=master)](https://travis-ci.org/hitherejoe/Android-Boilerplate)
===================

<p align="center">
<img src="images/ic_web.png" alt="Web Launcher"/>
</p>


A simple boilerplate application which demonstrates the downloading, persisting and syncing of data - displayed with a common layout used amongst applications. It features the use of the Design Support library, data caching and the new Test Modules, separating the functional tests from production code.

The project is setup using:

- Functional test Module with [Espresso](https://code.google.com/p/android-test-kit/wiki/Espresso)
- Unit tests with [Robolectric](http://robolectric.org/)
- [RxJava](https://github.com/ReactiveX/RxJava) and [RxAndroid](https://github.com/ReactiveX/RxAndroid)
- [Retrofit](http://square.github.io/retrofit/) and [OkHttp](https://github.com/square/okhttp)
- [Dagger 2](http://google.github.io/dagger/)
- [SqlBrite](https://github.com/square/sqlbrite)
- [EasyAdapter](https://github.com/ribot/easy-adapter)
- [Butterknife](https://github.com/JakeWharton/butterknife)
- [Timber] (https://github.com/JakeWharton/timber)
- [Mockito](http://mockito.org/)
- [Glide](https://github.com/bumptech/glide)

<p align="center">
<img src="images/device.png" alt="Web Launcher"/>
</p>


Requirements
------------

- [Android SDK](http://developer.android.com/sdk/index.html).
- Android [5.1 (API 22) ](http://developer.android.com/tools/revisions/platforms.html#5.1).
- Android SDK Tools
- Android SDK Build tools 23.0.0.0 rc3
- Android Support Repository
- Android Support library

Building
--------

To build, install and run a debug version, run this from the root of the project:

./gradlew installRunDebug

Testing
--------

For Android Studio to use syntax highlighting for Automated tests and Unit tests you **must** switch the Build Variant to the desired mode.

To run **unit** tests on your machine using [Robolectric] (http://robolectric.org/):

./gradlew testDebug

To run **automated** tests on connected devices:

./gradlew connectedAndroidTest

Thanks
--------

Thanks to the following for contributions!

[ivacf] (https://github.com/ivacf)
[Jawnnypoo] (https://github.com/Jawnnypoo)

Attributions
------------

Thanks to the following for use of icons off of Noun Project:

[Iconoci](https://thenounproject.com/iconoci)
4 changes: 4 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/build
*iml
*.iml
.idea
84 changes: 84 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
publishNonDefault true

defaultConfig {
applicationId "com.hitherejoe.androidboilerplate"
minSdkVersion 16
targetSdkVersion 23
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
}

lintOptions {
abortOnError false
}

}

dependencies {
final SUPPORT_LIBRARY_VERSION = '23.1.0'
final DAGGER_VERSION = '2.0.1'
final HAMCREST_VERSION = '1.3'
final MOCKITO_VERSION = '1.10.19'

compile fileTree(dir: 'libs', include: ['*.jar'])

compile "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"

compile 'com.squareup.sqlbrite:sqlbrite:0.4.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup:otto:1.3.8'

compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.jakewharton.timber:timber:4.1.0'
compile 'uk.co.ribot:easyadapter:1.5.0@aar'

compile "com.google.dagger:dagger:$DAGGER_VERSION"
apt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
provided 'org.glassfish:javax.annotation:10.0-b28'

testCompile 'junit:junit:4.12'
testCompile "org.hamcrest:hamcrest-core:$HAMCREST_VERSION"
testCompile "org.hamcrest:hamcrest-library:$HAMCREST_VERSION"
testCompile "org.hamcrest:hamcrest-integration:$HAMCREST_VERSION"
testCompile "org.mockito:mockito-core:$MOCKITO_VERSION"
testCompile('org.robolectric:robolectric:3.0') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}

androidTestApt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/hitherejoe/Android Studio.app/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
45 changes: 45 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hitherejoe.androidboilerplate" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:name=".AndroidBoilerplateApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".ui.activity.MainActivity"
android:label="@string/label_main"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<service android:name="com.hitherejoe.androidboilerplate.data.SyncService"/>

<receiver
android:name="com.hitherejoe.androidboilerplate.data.SyncService$SyncOnConnectionAvailable"
android:enabled="false">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>

<activity
android:name=".ui.activity.DetailActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"/>
<activity
android:name=".ui.activity.CharacterActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.hitherejoe.androidboilerplate;

import android.app.Application;
import android.content.Context;

import com.hitherejoe.androidboilerplate.injection.component.ApplicationComponent;
import com.hitherejoe.androidboilerplate.injection.component.DaggerApplicationComponent;
import com.hitherejoe.androidboilerplate.injection.module.ApplicationModule;

import timber.log.Timber;

public class AndroidBoilerplateApplication extends Application {

ApplicationComponent mApplicationComponent;

@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());

mApplicationComponent = DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(this))
.build();
}

public static AndroidBoilerplateApplication get(Context context) {
return (AndroidBoilerplateApplication) context.getApplicationContext();
}

public ApplicationComponent getComponent() {
return mApplicationComponent;
}

// Needed to replace the component with a test specific one
public void setComponent(ApplicationComponent applicationComponent) {
mApplicationComponent = applicationComponent;
}
}
Loading

0 comments on commit bdca119

Please sign in to comment.