Skip to content

Commit

Permalink
Merge pull request #29 from fs/refactoring
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
Ilya Eremin authored Mar 10, 2017
2 parents 1053df3 + 8ac898c commit 9d590fa
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 81 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: android
jdk: oraclejdk8
sudo: false
env:
- GRADLE_OPTS='-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'

machine:
environment:
Expand Down Expand Up @@ -29,13 +31,9 @@ before_install:
# - android-wait-for-emulator
# - adb shell input keyevent 82 &

# Robolectric tests
script:
- ./gradlew checkstyle lintProductionRelease testProductionReleaseUnitTest

# Instrument tests
# script: ./gradlew build check connectedCheck

branches:
only:
- master
Expand Down
49 changes: 18 additions & 31 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,25 @@ apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply from: 'checkstyle/checkstyle.gradle'

apply from: '../deps.gradle'

ext {
APPLICATION_ID = "com.flatstack.android"

isTravis = "true".equals(System.getenv("TRAVIS")) // change if use not travis

isCI = "true".equals(System.getenv("CI"))
commitMessage = 'git log -1 --pretty=%B'.execute().text.trim()
}

android {
compileSdkVersion TARGET_SDK_VERSION
buildToolsVersion BUILD_TOOLS_VERSION
compileSdkVersion versions.TARGET_SDK_VERSION
buildToolsVersion versions.BUILD_TOOLS_VERSION

defaultConfig {
minSdkVersion MIN_SDK_VERSION
targetSdkVersion TARGET_SDK_VERSION
minSdkVersion versions.MIN_SDK_VERSION
targetSdkVersion versions.TARGET_SDK_VERSION

applicationId APPLICATION_ID
versionCode 1
versionName '0.1.0'

// TODO uncomment after fix https://code.google.com/p/android/issues/detail?id=202973
// and after annotation processing completed
// jackOptions { enabled true }
versionName '1.0-beta'
}

productFlavors {
Expand Down Expand Up @@ -64,8 +60,8 @@ android {
}

dexOptions {
preDexLibraries = !isTravis
incremental = !isTravis
preDexLibraries = !isCI
incremental = !isCI
}

packagingOptions {
Expand All @@ -77,8 +73,6 @@ android {
lintOptions {
textReport true
textOutput "stdout"
enable 'IconExpectedSize', 'EasterEgg', 'SelectableText', 'StopShip', 'TypographyQuotes', 'UnusedIds'
disable 'InvalidPackage', 'GradleDependency'
lintConfig file("$projectDir/lint.xml")
warningsAsErrors true
}
Expand All @@ -89,30 +83,23 @@ repositories {
}

dependencies {
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
// compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
// compile "com.android.support:gridlayout-v7:$SUPPORT_LIBRARY_VERSION"
// compile "com.android.support:palette-v7:$SUPPORT_LIBRARY_VERSION"
compile supportLibs
compile rxJavaLibs
// compile retrofitLibs
// compile okHttpLibs

compile 'com.jakewharton:butterknife:7.0.0' // view injection
compile 'com.jakewharton.timber:timber:2.5.0' // logging

compile 'com.github.bumptech.glide:glide:3.7.0'

compile 'com.google.code.gson:gson:2.4'

compile 'io.reactivex:rxandroid:1.0.1' // async job and events
compile 'io.reactivex:rxjava:1.0.14'
testCompile unitTestLibs
androidTestCompile androidTestsLibs

testCompile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
testCompile 'junit:junit:4.12'
testCompile 'com.squareup.assertj:assertj-android:1.0.0'
compile 'com.google.code.gson:gson:2.4'
}

configurations {
testCompile.exclude module: 'commons-logging'
testCompile.exclude module: 'httpclient'
}

apply from: "quality.gradle"
apply from: "quality.gradle"
50 changes: 39 additions & 11 deletions app/lint.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="UnusedResources">
<ignore path="src/main/res/values/com_crashlytics_export_strings.xml"/>
</issue>
<issue id="IconExpectedSize" severity="fatal"/>
<issue id="EasterEgg" severity="fatal"/>
<issue id="StopShip" severity="fatal"/>
<issue id="TypographyQuotes" severity="fatal"/>

<issue id="TypographyDashes">
<ignore path="src/main/res/values/com_crashlytics_export_strings.xml"/>
</issue>
<issue id="CommitPrefEdits">
<ignore regexp="build/generated/source/apt/.*"/>
</issue>
<issue id="PrivateResource" severity="ignore" />
<issue id="FieldGetter" severity="ignore" />

<!--lint does not see allowBackup option in manifest for some reason-->
<issue id="AllowBackup" severity="ignore" />
<!-- uncomment if your app has deep links-->
<issue id="GoogleAppIndexingWarning" severity="ignore" />
</lint>

<issue id="IconMissingDensityFolder" severity="ignore">
<ignore path="src/main/res/drawable-xxxdpi"/>
</issue>

<issue id="InvalidPackage" severity="ignore"/>
<issue id="GradleDependency" severity="ignore"/>
<issue id="GradleDynamicVersion" severity="ignore"/>
<issue id="PrivateResource" severity="ignore"/>

<!--I know when I can use compoundDrawables!-->
<issue id="UseCompoundDrawables" severity="ignore"/>

<!--due to retrolambda unused resources work incorrectly-->
<issue id="UnusedResources" severity="ignore"/>

<issue id="ContentDescription" severity="ignore"/>
<!--<issue id="UnusedIds" severity="ignore"/>-->
<!--<issue id="Overdraw" severity="ignore"/>-->
<!--<issue id="RtlSymmetry" severity="ignore"/>-->
<!--<issue id="RtlHardcoded" severity="ignore"/>-->
<!--<issue id="RtlEnabled" severity="ignore"/>-->
<!--<issue id="IconColors" severity="ignore"/>-->
<!--<issue id="RelativeOverlap" severity="ignore"/>-->

<issue id="ClickableViewAccessibility" severity="ignore"/>
<issue id="SelectableText" severity="ignore"/>
<issue id="GoogleAppIndexingWarning" severity="ignore"/>
<issue id="AllowBackup" severity="ignore"/>
<issue id="Typos" severity="ignore"/>
<issue id="ShowToast" severity="ignore"/>
<issue id="Registered" severity="ignore"/>

</lint>
6 changes: 1 addition & 5 deletions app/src/main/java/com/flatstack/android/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

import android.app.Application;

import com.flatstack.android.utils.TimberCrashReportingTree;

import timber.log.Timber;

public class App extends Application {

@Override
public void onCreate() {
super.onCreate();
Timber.plant(BuildConfig.DEBUG ? new Timber.DebugTree() : new TimberCrashReportingTree());
// your super code here
}
}

This file was deleted.

31 changes: 10 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
// project wide version settings for all submodules
ext {
MIN_SDK_VERSION = 14
TARGET_SDK_VERSION = 25
BUILD_TOOLS_VERSION = '25.0.1'
SUPPORT_LIBRARY_VERSION = '25.1.0'
}

buildscript {
repositories {
jcenter()
}
repositories {
jcenter()
}

dependencies {
// android plugin
classpath 'com.android.tools.build:gradle:2.2.3'
// use Java 8 lambdas on android
// TODO replace with jack and jill in near future
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'me.tatarka:gradle-retrolambda:3.2.5' // use Java 8 lambdas on android
}
}

allprojects {
repositories {
jcenter()
}
repositories {
jcenter()
}
}
53 changes: 53 additions & 0 deletions deps.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ext {
versions = [
okHttp : '3.3.1',
support : '25.1.0',
retrofit : '2.0.2',
espressoVersion : '2.2.2',
BUILD_TOOLS_VERSION: '25.0.1',
MIN_SDK_VERSION : 14,
TARGET_SDK_VERSION : 25
]
supportDeps = [
appcompatV7 : "com.android.support:appcompat-v7:$versions.support",
recyclerView : "com.android.support:recyclerview-v7:$versions.support",
supportAnnotation: "com.android.support:support-annotations:$versions.support",
// design : "com.android.support:design:$versions.support",
// gridLayout : "com.android.support:gridlayout-v7:$versions.support"
// cardView : "com.android.support:cardview-v7:$versions.support"
// palette : "com.android.support:palette-v7:$versions.support"
]
rxJava = [
rxJava : 'io.reactivex:rxjava:1.1.6',
rxAndroid: 'io.reactivex:rxandroid:1.2.1'
]
retrofit = [
retrofit : "com.squareup.retrofit2:retrofit:$versions.retrofit",
rxAdapter : "com.squareup.retrofit2:adapter-rxjava:$versions.retrofit",
gsonConverter: "com.squareup.retrofit2:converter-gson:$versions.retrofit"
]
okHttp = [
logger: "com.squareup.okhttp3:logging-interceptor:$versions.okHttp",
self : "com.squareup.okhttp3:okhttp:$versions.okHttp"
]
unitTests = [
supportAnnotation: "com.android.support:support-annotations:$versions.support",
junit : 'junit:junit:4.12',
robolectric : 'org.robolectric:robolectric:3.0',
assertj : 'com.squareup.assertj:assertj-android:1.0.0'
]
androidTests = [
espressoCore : "com.android.support.test.espresso:espresso-core:$versions.espressoVersion",
espressoContrib: "com.android.support.test.espresso:espresso-contrib:$versions.espressoVersion",
espressoIntents: "com.android.support.test.espresso:espresso-intents:$versions.espressoVersion",
testRunner : "com.android.support.test:runner:0.5",
testRules : "com.android.support.test:rules:0.5"
]

supportLibs = supportDeps.values()
retrofitLibs = retrofit.values()
okHttpLibs = okHttp.values()
rxJavaLibs = rxJava.values()
unitTestLibs = unitTests.values()
androidTestsLibs = androidTests.values() + supportLibs
}

0 comments on commit 9d590fa

Please sign in to comment.