Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffold sharedpreferences module #77

Merged
merged 10 commits into from
Oct 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ proguard/
*.iml

# OS
.DS_Store
.DS_Store
bitrise.yml
gradle.deps
107 changes: 107 additions & 0 deletions transport-eta-android/data-sharedpreferences/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion build_versions.target_sdk
defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
testInstrumentationRunner "com.joaquimley.transporteta.ui.test.TestRunner"
}

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

lintOptions {
quiet true
abortOnError false
ignoreWarnings true
disable 'InvalidPackage' //Some libraries have issues with this.
disable 'OldTargetApi'
// Lint gives this warning but SDK 20 would be Android L Beta.
disable 'IconDensities' //For testing purpose. This is safe to remove.
disable 'IconMissingDensityFolder' //For testing purpose. This is safe to remove.
}

dexOptions {
preDexLibraries true
}

buildTypes {
debug {
testCoverageEnabled true
}

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

flavorDimensions "environment"
productFlavors {
mock {
dimension "environment"
}

prod {
dimension "environment"
}
}

/**
* Prevent shipping the mock flavor with release variant
* read more at: https://developer.android.com/studio/build/build-variants.html
*/
variantFilter { variant ->
def names = variant.flavors*.name
// To check for a certain build type, use variant.buildType.name == "<buildType>"
if (names.contains("mock") && variant.buildType.name == "release") {
// Gradle ignores any variants that satisfy the conditions above.
setIgnore(true)
}
}
}

// Module configuration
androidExtensions {
experimental = true
}

dependencies {
// Module
implementation project(':data')
// ACC
kapt deps.lifecycle.compiler
implementation deps.lifecycle.livedata
implementation deps.lifecycle.viewmodel
// Javax
implementation deps.javax.inject
compileOnly deps.javax.annotation
// Rx
implementation deps.rx.java2
implementation deps.rx.android
// Kotlin
implementation deps.kotlin.rx
implementation deps.kotlin.stdlib

/***********
* Testing *
***********/

// Local unit tests
kaptTest deps.dagger.compiler
testImplementation deps.kotlin.junit
testImplementation deps.mockito.kotlin
testImplementation deps.mockito.inline
testImplementation deps.lifecycle.testing
// Resolve conflicts between main and local unit tests
testImplementation deps.androidx.annotation
}
21 changes: 21 additions & 0 deletions transport-eta-android/data-sharedpreferences/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# 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 *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.joaquimley.transporteta.sharedpreferences;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.joaquimley.transporteta.sharedpreferences.test", appContext.getPackageName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest
package="com.joaquimley.transporteta.sharedpreferences"/>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.joaquimley.data.source
package com.joaquimley.transporteta.sharedpreferences

import com.joaquimley.data.model.TransportEntity
import com.joaquimley.transporteta.data.model.TransportEntity
import com.joaquimley.transporteta.data.source.FrameworkLocalStorage
import io.reactivex.Completable
import io.reactivex.Single

Expand All @@ -19,7 +20,8 @@ class FrameworkLocalStorageImpl: FrameworkLocalStorage {

override fun getAll(): Single<List<TransportEntity>> {
val list = mutableListOf<TransportEntity>()
list.add(TransportEntity("hi", "mock",2, "el", true,"bus"))
list.add(TransportEntity("hi", "mock",2, "latestEta 12324", true,"bus"))
list.add(TransportEntity("there", "mock",23, "latestEta 123", true,"bus"))
return Single.just(list)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.joaquimley.transporteta.sharedpreferences.mapper

class SharedPrefMapper {

// TODO
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.joaquimley.transporteta.sharedpreferences.model

class SharedPrefTransport {

// TODO
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">sharedprefernces</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.joaquimley.transporteta.sharedpreferences;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
1 change: 0 additions & 1 deletion transport-eta-android/data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ configurations.all {
dependencies {
// Modules
implementation project(':domain')

// Javax
implementation deps.javax.inject
compileOnly deps.javax.annotation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.joaquimley.data
package com.joaquimley.transporteta.data

import com.joaquimley.data.mapper.DataTransportMapper
import com.joaquimley.data.store.TransportDataStore
import com.joaquimley.transporteta.data.mapper.DataTransportMapper
import com.joaquimley.transporteta.data.store.TransportDataStore
import com.joaquimley.transporteta.domain.model.Transport
import com.joaquimley.transporteta.domain.repository.FavoritesRepository
import io.reactivex.Completable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.joaquimley.data
package com.joaquimley.transporteta.data

import com.joaquimley.data.mapper.DataTransportMapper
import com.joaquimley.data.store.TransportDataStore
import com.joaquimley.transporteta.data.mapper.DataTransportMapper
import com.joaquimley.transporteta.data.store.TransportDataStore
import com.joaquimley.transporteta.domain.model.Transport
import com.joaquimley.transporteta.domain.repository.TransportRepository
import io.reactivex.Completable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.joaquimley.data.executor
package com.joaquimley.transporteta.data.executor

import com.joaquimley.transporteta.domain.executor.ThreadExecutor
import java.util.concurrent.LinkedBlockingQueue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joaquimley.data.mapper
package com.joaquimley.transporteta.data.mapper

import com.joaquimley.data.model.TransportEntity
import com.joaquimley.transporteta.data.model.TransportEntity
import com.joaquimley.transporteta.domain.model.Transport

class DataTransportMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.joaquimley.data.model
package com.joaquimley.transporteta.data.model

data class TransportEntity(val id: String, val name: String, val code: Int, val latestEta: String,
val isFavorite: Boolean = false, val type: String)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joaquimley.data.source
package com.joaquimley.transporteta.data.source

import com.joaquimley.data.model.TransportEntity
import com.joaquimley.transporteta.data.model.TransportEntity
import io.reactivex.Completable
import io.reactivex.Single

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.joaquimley.data.store
package com.joaquimley.transporteta.data.store

import com.joaquimley.data.model.TransportEntity
import com.joaquimley.transporteta.data.model.TransportEntity
import io.reactivex.Completable
import io.reactivex.Flowable
import io.reactivex.Observable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.joaquimley.data.store
package com.joaquimley.transporteta.data.store

import com.joaquimley.data.model.TransportEntity
import com.joaquimley.data.source.FrameworkLocalStorage
import com.joaquimley.transporteta.data.model.TransportEntity
import com.joaquimley.transporteta.data.source.FrameworkLocalStorage
import io.reactivex.Completable
import io.reactivex.Flowable
import io.reactivex.Observable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.joaquimley.data
package com.joaquimley.transporteta.data

import com.joaquimley.data.factory.DataFactory.Factory.randomUuid
import com.joaquimley.data.factory.TransportFactory
import com.joaquimley.data.mapper.DataTransportMapper
import com.joaquimley.data.model.TransportEntity
import com.joaquimley.data.store.TransportDataStore
import com.joaquimley.transporteta.data.factory.DataFactory.Factory.randomUuid
import com.joaquimley.transporteta.data.factory.TransportFactory
import com.joaquimley.transporteta.data.mapper.DataTransportMapper
import com.joaquimley.transporteta.data.model.TransportEntity
import com.joaquimley.transporteta.data.store.TransportDataStore
import com.joaquimley.transporteta.domain.model.Transport
import com.joaquimley.transporteta.domain.repository.FavoritesRepository
import com.nhaarman.mockitokotlin2.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.joaquimley.data
package com.joaquimley.transporteta.data

import com.joaquimley.data.factory.DataFactory
import com.joaquimley.data.factory.TransportFactory
import com.joaquimley.data.mapper.DataTransportMapper
import com.joaquimley.data.model.TransportEntity
import com.joaquimley.data.store.TransportDataStore
import com.joaquimley.transporteta.data.factory.DataFactory
import com.joaquimley.transporteta.data.factory.TransportFactory
import com.joaquimley.transporteta.data.mapper.DataTransportMapper
import com.joaquimley.transporteta.data.model.TransportEntity
import com.joaquimley.transporteta.data.store.TransportDataStore
import com.joaquimley.transporteta.domain.model.Transport
import com.joaquimley.transporteta.domain.repository.TransportRepository
import com.nhaarman.mockitokotlin2.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.joaquimley.data.factory
package com.joaquimley.transporteta.data.factory

import java.util.concurrent.ThreadLocalRandom

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.joaquimley.data.factory
package com.joaquimley.transporteta.data.factory

import com.joaquimley.data.factory.DataFactory.Factory.randomInt
import com.joaquimley.data.factory.DataFactory.Factory.randomUuid
import com.joaquimley.data.model.TransportEntity
import com.joaquimley.transporteta.data.factory.DataFactory.Factory.randomInt
import com.joaquimley.transporteta.data.factory.DataFactory.Factory.randomUuid
import com.joaquimley.transporteta.data.model.TransportEntity
import com.joaquimley.transporteta.domain.model.Transport

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.joaquimley.data.mapper
package com.joaquimley.transporteta.data.mapper

import com.joaquimley.data.factory.TransportFactory
import com.joaquimley.data.model.TransportEntity
import com.joaquimley.transporteta.data.factory.TransportFactory
import com.joaquimley.transporteta.data.model.TransportEntity
import com.joaquimley.transporteta.domain.model.Transport
import org.junit.Before
import org.junit.Test
Expand Down
Loading