Skip to content

Commit

Permalink
[ARCHITECTURE] Let's do some quality (#15)
Browse files Browse the repository at this point in the history
* extract dependencies

* Update test command and add lint

* Move Retrofit into data module and test authentication service

* Implement authorization repository

* Implementation authentication usecase

* Implementation presenter layer

* Remove old session stuff

* Java time backport

* Dependency with dagger
  • Loading branch information
CedrickFlocon authored and balloob committed Nov 10, 2019
1 parent 4789d72 commit 3219504
Show file tree
Hide file tree
Showing 73 changed files with 1,835 additions and 342 deletions.
2 changes: 2 additions & 0 deletions .travis/before_install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -ev

if [ "$TRAVIS_PULL_REQUEST" = "false" ]
then
openssl aes-256-cbc -K $encrypted_6c4fc944fe71_key -iv $encrypted_6c4fc944fe71_iv -in .travis/secrets.tar.enc -out .travis/secrets.tar -d
Expand Down
5 changes: 4 additions & 1 deletion .travis/script.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/bin/bash

set -ev

echo $TRAVIS_COMMIT_MESSAGE > CHANGES.md
export VERSION_CODE=`git rev-list --count HEAD`

./gradlew testReleaseUnitTest
./gradlew test
./gradlew lint

if [ "$TRAVIS_PULL_REQUEST" = "false" ]
then
Expand Down
43 changes: 36 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.firebase.appdistribution'
apply plugin: 'com.github.triplet.play'
apply plugin: 'de.mannodermaus.android-junit5'

buildscript {
repositories {
Expand All @@ -11,15 +13,16 @@ buildscript {
dependencies {
classpath 'com.google.firebase:firebase-appdistribution-gradle:1.1.0'
classpath 'com.github.triplet.gradle:play-publisher:2.5.0'
classpath 'de.mannodermaus.gradle.plugins:android-junit5:1.5.2.0'
}
}

android {
compileSdkVersion 29
compileSdkVersion projectSdkVersion.toInteger()

defaultConfig {
applicationId "io.homeassistant.companion.android"
minSdkVersion 21
minSdkVersion projectMinSdkVersion
targetSdkVersion 29
versionCode "${System.env.VERSION_CODE ?: 1}".toInteger()
versionName "1.0.0"
Expand Down Expand Up @@ -49,20 +52,46 @@ android {
signingConfig signingConfigs.release
}
}

testOptions {
unitTests.returnDefaultValues = true
junitPlatform {
filters {
engines {
include 'spek2'
}
}
}
}
}

play {
serviceAccountCredentials = file("playStorePublishServiceCredentialsFile.json")
}

dependencies {
implementation project(':common')
implementation project(':domain')

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"

implementation "com.google.dagger:dagger:${daggerVersion}"
kapt "com.google.dagger:dagger-compiler:${daggerVersion}"

implementation "androidx.appcompat:appcompat:$appCompatVersion"
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutversion"

implementation("com.jakewharton.threetenabp:threetenabp:$threeTenAbpVersion") {
exclude group: 'org.threeten'
}

implementation "com.squareup.retrofit2:retrofit:2.6.2"
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.2'
implementation "com.squareup.retrofit2:converter-jackson:2.6.2"
testImplementation "org.spekframework.spek2:spek-dsl-jvm:$spek2Version"
testImplementation "org.spekframework.spek2:spek-runner-junit5:$spek2Version"
testImplementation "org.assertj:assertj-core:$assertJVersion"
testImplementation "io.mockk:mockk:$mockkVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
}

apply plugin: 'com.google.gms.google-services'
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
package io.homeassistant.companion.android

import android.app.Application
import io.homeassistant.companion.android.api.Session
import com.jakewharton.threetenabp.AndroidThreeTen
import io.homeassistant.companion.android.common.dagger.AppComponent
import io.homeassistant.companion.android.common.dagger.Graph
import io.homeassistant.companion.android.common.dagger.GraphComponentAccessor

class HomeAssistantApplication : Application() {
class HomeAssistantApplication : Application(), GraphComponentAccessor {

lateinit var graph: Graph

override fun onCreate() {
super.onCreate()

Session.init(this)
AndroidThreeTen.init(this)
graph = Graph(this)
}

override val appComponent: AppComponent
get() = graph.appComponent

override fun urlUpdated() {
graph.urlUpdated()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.homeassistant.companion.android

import dagger.Component
import io.homeassistant.companion.android.common.dagger.AppComponent
import io.homeassistant.companion.android.launch.LaunchActivity
import io.homeassistant.companion.android.onboarding.authentication.AuthenticationFragment
import io.homeassistant.companion.android.onboarding.manual.ManualSetupFragment
import io.homeassistant.companion.android.webview.WebViewActivity

@Component(dependencies = [AppComponent::class], modules = [PresenterModule::class])
interface PresenterComponent {

fun inject(activity: LaunchActivity)

fun inject(fragment: AuthenticationFragment)

fun inject(fragment: ManualSetupFragment)

fun inject(activity: WebViewActivity)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package io.homeassistant.companion.android

import dagger.Binds
import dagger.Module
import dagger.Provides
import io.homeassistant.companion.android.launch.LaunchPresenter
import io.homeassistant.companion.android.launch.LaunchPresenterImpl
import io.homeassistant.companion.android.launch.LaunchView
import io.homeassistant.companion.android.onboarding.authentication.AuthenticationPresenter
import io.homeassistant.companion.android.onboarding.authentication.AuthenticationPresenterImpl
import io.homeassistant.companion.android.onboarding.authentication.AuthenticationView
import io.homeassistant.companion.android.onboarding.manual.ManualSetupPresenter
import io.homeassistant.companion.android.onboarding.manual.ManualSetupPresenterImpl
import io.homeassistant.companion.android.onboarding.manual.ManualSetupView
import io.homeassistant.companion.android.webview.WebView
import io.homeassistant.companion.android.webview.WebViewPresenter
import io.homeassistant.companion.android.webview.WebViewPresenterImpl

@Module(includes = [PresenterModule.Declaration::class])
class PresenterModule {

private lateinit var launchView: LaunchView
private lateinit var authenticationView: AuthenticationView
private lateinit var manualSetupView: ManualSetupView
private lateinit var webView: WebView

constructor(launchView: LaunchView) {
this.launchView = launchView
}

constructor(authenticationView: AuthenticationView) {
this.authenticationView = authenticationView
}

constructor(manualSetupView: ManualSetupView) {
this.manualSetupView = manualSetupView
}

constructor(webView: WebView) {
this.webView = webView
}

@Provides
fun provideLaunchView() = launchView

@Provides
fun provideAuthenticationView() = authenticationView

@Provides
fun provideManualSetupView() = manualSetupView

@Provides
fun provideWebView() = webView

@Module
interface Declaration {

@Binds
fun bindLaunchPresenter(presenter: LaunchPresenterImpl): LaunchPresenter

@Binds
fun bindAuthenticationPresenterImpl(presenter: AuthenticationPresenterImpl): AuthenticationPresenter

@Binds
fun bindManualSetupPresenter(presenter: ManualSetupPresenterImpl): ManualSetupPresenter

@Binds
fun bindWebViewPresenterImpl(presenter: WebViewPresenterImpl): WebViewPresenter


}
}

This file was deleted.

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions app/src/main/java/io/homeassistant/companion/android/api/Token.kt

This file was deleted.

Loading

0 comments on commit 3219504

Please sign in to comment.