From dfb2163d29f4b05ae674b704380160f7357afba4 Mon Sep 17 00:00:00 2001 From: Joaquim Ley Date: Sun, 14 Oct 2018 00:43:11 +0200 Subject: [PATCH] Scaffold sharedpreferences module (#77) * Scaffold sharedpreferences module - Attach to store implemetnation - Mock data currently being returned Some housekeeping. * Small configurations for CI Still not working, wanted to make mock work with debug but variants still compain. * Test removing ViewModelModule * Ci why you no work? * Fix lints on CI * Working stuff for CI * housekeeping mobile-ui/build.gradle Had to make some changtes while debuging CI fails. This change still makes sense IMO. #69 * Rename data package to include project name #69 * Remove unecessary .gitignore from other packages Maintenece commit, not really related to this branch feature. * Manifest cleanup and format --- .gitignore | 4 +- .../data-sharedpreferences/build.gradle | 107 ++++++++++++++++++ .../data-sharedpreferences/proguard-rules.pro | 21 ++++ .../ExampleInstrumentedTest.java | 26 +++++ .../src/main/AndroidManifest.xml | 2 + .../FrameworkLocalStorageImpl.kt | 8 +- .../mapper/SharedPrefMapper.kt | 6 + .../model/SharedPrefTransport.kt | 6 + .../src/main/res/values/strings.xml | 3 + .../sharedpreferences/ExampleUnitTest.java | 17 +++ transport-eta-android/data/build.gradle | 1 - .../data/FavoritesRepositoryImpl.kt | 6 +- .../data/TransportRepositoryImpl.kt | 6 +- .../data/executor/ThreadExecutorImpl.kt | 2 +- .../data/mapper/DataTransportMapper.kt | 4 +- .../data/model/TransportEntity.kt | 2 +- .../data/source/FrameworkLocalStorage.kt | 4 +- .../data/store/TransportDataStore.kt | 4 +- .../data/store/TransportDataStoreImpl.kt | 6 +- .../data/FavoritesRepositoryTest.kt | 12 +- .../data/TransportRepositoryTest.kt | 12 +- .../data/factory/DataFactory.kt | 2 +- .../data/factory/TransportFactory.kt | 8 +- .../data/mapper/DataTransportMapperTest.kt | 6 +- .../data/store/TransportDataStoreTest.kt | 17 ++- transport-eta-android/presentation/.gitignore | 1 - .../presentation/build.gradle | 6 - .../presentation/src/main/AndroidManifest.xml | 3 +- transport-eta-android/settings.gradle | 2 +- transport-eta-android/sms/.gitignore | 1 - transport-eta-android/sms/build.gradle | 20 ++-- .../transporteta/sms/SmsControllerImpl.kt | 5 + transport-eta-android/ui-mobile/build.gradle | 29 ++++- .../ui/di/module/TestActivityBindingModule.kt | 2 +- .../di/module/TestFavoriteFragmentModule.kt | 4 +- .../ui/di/module/ActivityBindingModule.kt | 6 +- .../transporteta/ui/di/module/AppModule.kt | 2 +- .../ui/di/module/DataSourceModule.kt | 4 +- .../ui/di/module/DataStoreModule.kt | 6 +- ... => HomeActivityFragmentBuildersModule.kt} | 6 +- .../ui/di/module/HomeActivityModule.kt | 8 +- .../ui/di/module/HomeViewModelModule.kt | 8 -- .../transporteta/ui/di/module/MapperModule.kt | 2 +- .../ui/di/module/RepositoryModule.kt | 8 +- .../ui/home/favorite/FavoritesAdapter.kt | 4 +- .../ui/home/favorite/FavoritesFragment.kt | 31 ++--- 46 files changed, 327 insertions(+), 123 deletions(-) create mode 100644 transport-eta-android/data-sharedpreferences/build.gradle create mode 100644 transport-eta-android/data-sharedpreferences/proguard-rules.pro create mode 100644 transport-eta-android/data-sharedpreferences/src/androidTest/java/com/joaquimley/transporteta/sharedpreferences/ExampleInstrumentedTest.java create mode 100644 transport-eta-android/data-sharedpreferences/src/main/AndroidManifest.xml rename transport-eta-android/{data/src/main/java/com/joaquimley/data/source => data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences}/FrameworkLocalStorageImpl.kt (68%) create mode 100644 transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/mapper/SharedPrefMapper.kt create mode 100644 transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/model/SharedPrefTransport.kt create mode 100644 transport-eta-android/data-sharedpreferences/src/main/res/values/strings.xml create mode 100644 transport-eta-android/data-sharedpreferences/src/test/java/com/joaquimley/transporteta/sharedpreferences/ExampleUnitTest.java rename transport-eta-android/data/src/main/java/com/joaquimley/{ => transporteta}/data/FavoritesRepositoryImpl.kt (84%) rename transport-eta-android/data/src/main/java/com/joaquimley/{ => transporteta}/data/TransportRepositoryImpl.kt (88%) rename transport-eta-android/data/src/main/java/com/joaquimley/{ => transporteta}/data/executor/ThreadExecutorImpl.kt (97%) rename transport-eta-android/data/src/main/java/com/joaquimley/{ => transporteta}/data/mapper/DataTransportMapper.kt (85%) rename transport-eta-android/data/src/main/java/com/joaquimley/{ => transporteta}/data/model/TransportEntity.kt (79%) rename transport-eta-android/data/src/main/java/com/joaquimley/{ => transporteta}/data/source/FrameworkLocalStorage.kt (77%) rename transport-eta-android/data/src/main/java/com/joaquimley/{ => transporteta}/data/store/TransportDataStore.kt (89%) rename transport-eta-android/data/src/main/java/com/joaquimley/{ => transporteta}/data/store/TransportDataStoreImpl.kt (91%) rename transport-eta-android/data/src/test/java/com/joaquimley/{ => transporteta}/data/FavoritesRepositoryTest.kt (96%) rename transport-eta-android/data/src/test/java/com/joaquimley/{ => transporteta}/data/TransportRepositoryTest.kt (98%) rename transport-eta-android/data/src/test/java/com/joaquimley/{ => transporteta}/data/factory/DataFactory.kt (90%) rename transport-eta-android/data/src/test/java/com/joaquimley/{ => transporteta}/data/factory/TransportFactory.kt (83%) rename transport-eta-android/data/src/test/java/com/joaquimley/{ => transporteta}/data/mapper/DataTransportMapperTest.kt (92%) rename transport-eta-android/data/src/test/java/com/joaquimley/{ => transporteta}/data/store/TransportDataStoreTest.kt (97%) delete mode 100644 transport-eta-android/presentation/.gitignore delete mode 100644 transport-eta-android/sms/.gitignore rename transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/{HomeFragmentBuildersModule.kt => HomeActivityFragmentBuildersModule.kt} (67%) delete mode 100644 transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeViewModelModule.kt diff --git a/.gitignore b/.gitignore index cf44778..8460e67 100644 --- a/.gitignore +++ b/.gitignore @@ -74,4 +74,6 @@ proguard/ *.iml # OS -.DS_Store \ No newline at end of file +.DS_Store +bitrise.yml +gradle.deps diff --git a/transport-eta-android/data-sharedpreferences/build.gradle b/transport-eta-android/data-sharedpreferences/build.gradle new file mode 100644 index 0000000..40a8682 --- /dev/null +++ b/transport-eta-android/data-sharedpreferences/build.gradle @@ -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 == "" + 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 +} \ No newline at end of file diff --git a/transport-eta-android/data-sharedpreferences/proguard-rules.pro b/transport-eta-android/data-sharedpreferences/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/transport-eta-android/data-sharedpreferences/proguard-rules.pro @@ -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 diff --git a/transport-eta-android/data-sharedpreferences/src/androidTest/java/com/joaquimley/transporteta/sharedpreferences/ExampleInstrumentedTest.java b/transport-eta-android/data-sharedpreferences/src/androidTest/java/com/joaquimley/transporteta/sharedpreferences/ExampleInstrumentedTest.java new file mode 100644 index 0000000..521ca2f --- /dev/null +++ b/transport-eta-android/data-sharedpreferences/src/androidTest/java/com/joaquimley/transporteta/sharedpreferences/ExampleInstrumentedTest.java @@ -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 Testing documentation + */ +@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()); + } +} diff --git a/transport-eta-android/data-sharedpreferences/src/main/AndroidManifest.xml b/transport-eta-android/data-sharedpreferences/src/main/AndroidManifest.xml new file mode 100644 index 0000000..80ec3c8 --- /dev/null +++ b/transport-eta-android/data-sharedpreferences/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/transport-eta-android/data/src/main/java/com/joaquimley/data/source/FrameworkLocalStorageImpl.kt b/transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/FrameworkLocalStorageImpl.kt similarity index 68% rename from transport-eta-android/data/src/main/java/com/joaquimley/data/source/FrameworkLocalStorageImpl.kt rename to transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/FrameworkLocalStorageImpl.kt index 75d6d18..6888c68 100644 --- a/transport-eta-android/data/src/main/java/com/joaquimley/data/source/FrameworkLocalStorageImpl.kt +++ b/transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/FrameworkLocalStorageImpl.kt @@ -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 @@ -19,7 +20,8 @@ class FrameworkLocalStorageImpl: FrameworkLocalStorage { override fun getAll(): Single> { val list = mutableListOf() - 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) } diff --git a/transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/mapper/SharedPrefMapper.kt b/transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/mapper/SharedPrefMapper.kt new file mode 100644 index 0000000..cb2d8f8 --- /dev/null +++ b/transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/mapper/SharedPrefMapper.kt @@ -0,0 +1,6 @@ +package com.joaquimley.transporteta.sharedpreferences.mapper + +class SharedPrefMapper { + + // TODO +} \ No newline at end of file diff --git a/transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/model/SharedPrefTransport.kt b/transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/model/SharedPrefTransport.kt new file mode 100644 index 0000000..5630f72 --- /dev/null +++ b/transport-eta-android/data-sharedpreferences/src/main/java/com/joaquimley/transporteta/sharedpreferences/model/SharedPrefTransport.kt @@ -0,0 +1,6 @@ +package com.joaquimley.transporteta.sharedpreferences.model + +class SharedPrefTransport { + + // TODO +} \ No newline at end of file diff --git a/transport-eta-android/data-sharedpreferences/src/main/res/values/strings.xml b/transport-eta-android/data-sharedpreferences/src/main/res/values/strings.xml new file mode 100644 index 0000000..9ae5e05 --- /dev/null +++ b/transport-eta-android/data-sharedpreferences/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + sharedprefernces + diff --git a/transport-eta-android/data-sharedpreferences/src/test/java/com/joaquimley/transporteta/sharedpreferences/ExampleUnitTest.java b/transport-eta-android/data-sharedpreferences/src/test/java/com/joaquimley/transporteta/sharedpreferences/ExampleUnitTest.java new file mode 100644 index 0000000..031e2fa --- /dev/null +++ b/transport-eta-android/data-sharedpreferences/src/test/java/com/joaquimley/transporteta/sharedpreferences/ExampleUnitTest.java @@ -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 Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/transport-eta-android/data/build.gradle b/transport-eta-android/data/build.gradle index 1f65648..4172f0e 100644 --- a/transport-eta-android/data/build.gradle +++ b/transport-eta-android/data/build.gradle @@ -11,7 +11,6 @@ configurations.all { dependencies { // Modules implementation project(':domain') - // Javax implementation deps.javax.inject compileOnly deps.javax.annotation diff --git a/transport-eta-android/data/src/main/java/com/joaquimley/data/FavoritesRepositoryImpl.kt b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/FavoritesRepositoryImpl.kt similarity index 84% rename from transport-eta-android/data/src/main/java/com/joaquimley/data/FavoritesRepositoryImpl.kt rename to transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/FavoritesRepositoryImpl.kt index 7950305..b64e23c 100644 --- a/transport-eta-android/data/src/main/java/com/joaquimley/data/FavoritesRepositoryImpl.kt +++ b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/FavoritesRepositoryImpl.kt @@ -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 diff --git a/transport-eta-android/data/src/main/java/com/joaquimley/data/TransportRepositoryImpl.kt b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/TransportRepositoryImpl.kt similarity index 88% rename from transport-eta-android/data/src/main/java/com/joaquimley/data/TransportRepositoryImpl.kt rename to transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/TransportRepositoryImpl.kt index 4829009..77bbbbd 100644 --- a/transport-eta-android/data/src/main/java/com/joaquimley/data/TransportRepositoryImpl.kt +++ b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/TransportRepositoryImpl.kt @@ -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 diff --git a/transport-eta-android/data/src/main/java/com/joaquimley/data/executor/ThreadExecutorImpl.kt b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/executor/ThreadExecutorImpl.kt similarity index 97% rename from transport-eta-android/data/src/main/java/com/joaquimley/data/executor/ThreadExecutorImpl.kt rename to transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/executor/ThreadExecutorImpl.kt index abc1864..db7bfc7 100644 --- a/transport-eta-android/data/src/main/java/com/joaquimley/data/executor/ThreadExecutorImpl.kt +++ b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/executor/ThreadExecutorImpl.kt @@ -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 diff --git a/transport-eta-android/data/src/main/java/com/joaquimley/data/mapper/DataTransportMapper.kt b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/mapper/DataTransportMapper.kt similarity index 85% rename from transport-eta-android/data/src/main/java/com/joaquimley/data/mapper/DataTransportMapper.kt rename to transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/mapper/DataTransportMapper.kt index e262923..8b4065b 100644 --- a/transport-eta-android/data/src/main/java/com/joaquimley/data/mapper/DataTransportMapper.kt +++ b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/mapper/DataTransportMapper.kt @@ -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 { diff --git a/transport-eta-android/data/src/main/java/com/joaquimley/data/model/TransportEntity.kt b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/model/TransportEntity.kt similarity index 79% rename from transport-eta-android/data/src/main/java/com/joaquimley/data/model/TransportEntity.kt rename to transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/model/TransportEntity.kt index c48dfb5..7e71c36 100644 --- a/transport-eta-android/data/src/main/java/com/joaquimley/data/model/TransportEntity.kt +++ b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/model/TransportEntity.kt @@ -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) diff --git a/transport-eta-android/data/src/main/java/com/joaquimley/data/source/FrameworkLocalStorage.kt b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/source/FrameworkLocalStorage.kt similarity index 77% rename from transport-eta-android/data/src/main/java/com/joaquimley/data/source/FrameworkLocalStorage.kt rename to transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/source/FrameworkLocalStorage.kt index 2353160..c68cc6f 100644 --- a/transport-eta-android/data/src/main/java/com/joaquimley/data/source/FrameworkLocalStorage.kt +++ b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/source/FrameworkLocalStorage.kt @@ -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 diff --git a/transport-eta-android/data/src/main/java/com/joaquimley/data/store/TransportDataStore.kt b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/store/TransportDataStore.kt similarity index 89% rename from transport-eta-android/data/src/main/java/com/joaquimley/data/store/TransportDataStore.kt rename to transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/store/TransportDataStore.kt index b057f34..fbd3400 100644 --- a/transport-eta-android/data/src/main/java/com/joaquimley/data/store/TransportDataStore.kt +++ b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/store/TransportDataStore.kt @@ -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 diff --git a/transport-eta-android/data/src/main/java/com/joaquimley/data/store/TransportDataStoreImpl.kt b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/store/TransportDataStoreImpl.kt similarity index 91% rename from transport-eta-android/data/src/main/java/com/joaquimley/data/store/TransportDataStoreImpl.kt rename to transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/store/TransportDataStoreImpl.kt index a844724..69a1abd 100644 --- a/transport-eta-android/data/src/main/java/com/joaquimley/data/store/TransportDataStoreImpl.kt +++ b/transport-eta-android/data/src/main/java/com/joaquimley/transporteta/data/store/TransportDataStoreImpl.kt @@ -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 diff --git a/transport-eta-android/data/src/test/java/com/joaquimley/data/FavoritesRepositoryTest.kt b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/FavoritesRepositoryTest.kt similarity index 96% rename from transport-eta-android/data/src/test/java/com/joaquimley/data/FavoritesRepositoryTest.kt rename to transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/FavoritesRepositoryTest.kt index 1cd2311..c8232e1 100644 --- a/transport-eta-android/data/src/test/java/com/joaquimley/data/FavoritesRepositoryTest.kt +++ b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/FavoritesRepositoryTest.kt @@ -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.* diff --git a/transport-eta-android/data/src/test/java/com/joaquimley/data/TransportRepositoryTest.kt b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/TransportRepositoryTest.kt similarity index 98% rename from transport-eta-android/data/src/test/java/com/joaquimley/data/TransportRepositoryTest.kt rename to transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/TransportRepositoryTest.kt index 50fbbe3..960e85a 100644 --- a/transport-eta-android/data/src/test/java/com/joaquimley/data/TransportRepositoryTest.kt +++ b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/TransportRepositoryTest.kt @@ -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.* diff --git a/transport-eta-android/data/src/test/java/com/joaquimley/data/factory/DataFactory.kt b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/factory/DataFactory.kt similarity index 90% rename from transport-eta-android/data/src/test/java/com/joaquimley/data/factory/DataFactory.kt rename to transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/factory/DataFactory.kt index b1e18f5..44033b2 100644 --- a/transport-eta-android/data/src/test/java/com/joaquimley/data/factory/DataFactory.kt +++ b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/factory/DataFactory.kt @@ -1,4 +1,4 @@ -package com.joaquimley.data.factory +package com.joaquimley.transporteta.data.factory import java.util.concurrent.ThreadLocalRandom diff --git a/transport-eta-android/data/src/test/java/com/joaquimley/data/factory/TransportFactory.kt b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/factory/TransportFactory.kt similarity index 83% rename from transport-eta-android/data/src/test/java/com/joaquimley/data/factory/TransportFactory.kt rename to transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/factory/TransportFactory.kt index a2d8510..575d89a 100644 --- a/transport-eta-android/data/src/test/java/com/joaquimley/data/factory/TransportFactory.kt +++ b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/factory/TransportFactory.kt @@ -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 /** diff --git a/transport-eta-android/data/src/test/java/com/joaquimley/data/mapper/DataTransportMapperTest.kt b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/mapper/DataTransportMapperTest.kt similarity index 92% rename from transport-eta-android/data/src/test/java/com/joaquimley/data/mapper/DataTransportMapperTest.kt rename to transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/mapper/DataTransportMapperTest.kt index 007805f..d7998c0 100644 --- a/transport-eta-android/data/src/test/java/com/joaquimley/data/mapper/DataTransportMapperTest.kt +++ b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/mapper/DataTransportMapperTest.kt @@ -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 diff --git a/transport-eta-android/data/src/test/java/com/joaquimley/data/store/TransportDataStoreTest.kt b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/store/TransportDataStoreTest.kt similarity index 97% rename from transport-eta-android/data/src/test/java/com/joaquimley/data/store/TransportDataStoreTest.kt rename to transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/store/TransportDataStoreTest.kt index 5d6a00b..3f73d48 100644 --- a/transport-eta-android/data/src/test/java/com/joaquimley/data/store/TransportDataStoreTest.kt +++ b/transport-eta-android/data/src/test/java/com/joaquimley/transporteta/data/store/TransportDataStoreTest.kt @@ -1,12 +1,11 @@ -package com.joaquimley.data.store +package com.joaquimley.transporteta.data.store -import com.joaquimley.data.factory.DataFactory -import com.joaquimley.data.factory.TransportFactory -import com.joaquimley.data.model.TransportEntity -import com.joaquimley.data.source.FrameworkLocalStorage +import com.joaquimley.transporteta.data.factory.DataFactory +import com.joaquimley.transporteta.data.factory.TransportFactory +import com.joaquimley.transporteta.data.model.TransportEntity +import com.joaquimley.transporteta.data.source.FrameworkLocalStorage import com.nhaarman.mockitokotlin2.* import io.reactivex.Completable -import io.reactivex.Flowable import io.reactivex.Single import org.junit.After import org.junit.Before @@ -75,14 +74,14 @@ class TransportDataStoreTest { // TODO: Missing correct data returned test // @Test // fun getAllFavoritesReturnsCorrectData() { - // Assemble + // Assemble // val transportList = TransportFactory.makeTransportList(5, true) // val transportEntityList = TransportFactory.makeTransportEntityList(5, true) // robot.stubTransportMapperToModel(transportEntityList, transportList) // robot.stubDataStoreGetAllFavoritesSuccess(transportEntityList) - // Act + // Act // val returnedData = favoritesRepository.getAll().test() - // Assert + // Assert // returnedData.assertResult(transportList) // } diff --git a/transport-eta-android/presentation/.gitignore b/transport-eta-android/presentation/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/transport-eta-android/presentation/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/transport-eta-android/presentation/build.gradle b/transport-eta-android/presentation/build.gradle index 27527eb..84c7f2b 100644 --- a/transport-eta-android/presentation/build.gradle +++ b/transport-eta-android/presentation/build.gradle @@ -51,10 +51,6 @@ android { prod { dimension "environment" } - - mock { - dimension "environment" - } } /** @@ -79,12 +75,10 @@ androidExtensions { dependencies { // Module implementation project(':domain') - // ACC kapt deps.lifecycle.compiler implementation deps.lifecycle.livedata implementation deps.lifecycle.viewmodel - // Javax implementation deps.javax.inject compileOnly deps.javax.annotation diff --git a/transport-eta-android/presentation/src/main/AndroidManifest.xml b/transport-eta-android/presentation/src/main/AndroidManifest.xml index 1e6da03..be52634 100644 --- a/transport-eta-android/presentation/src/main/AndroidManifest.xml +++ b/transport-eta-android/presentation/src/main/AndroidManifest.xml @@ -1,2 +1 @@ - + diff --git a/transport-eta-android/settings.gradle b/transport-eta-android/settings.gradle index de9fbec..fec347b 100644 --- a/transport-eta-android/settings.gradle +++ b/transport-eta-android/settings.gradle @@ -1 +1 @@ -include ':ui-mobile', ':sms', ':presentation', ':domain', ':data' +include ':ui-mobile', ':sms', ':presentation', ':domain', ':data', ':data-sharedpreferences' diff --git a/transport-eta-android/sms/.gitignore b/transport-eta-android/sms/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/transport-eta-android/sms/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/transport-eta-android/sms/build.gradle b/transport-eta-android/sms/build.gradle index 9a03cad..6da5a6b 100644 --- a/transport-eta-android/sms/build.gradle +++ b/transport-eta-android/sms/build.gradle @@ -32,16 +32,16 @@ android { preDexLibraries true } -// buildTypes { -// debug { -// testCoverageEnabled true -// } -// -// release { -// minifyEnabled true -// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' -// } -// } + buildTypes { + debug { + testCoverageEnabled true + } + + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } flavorDimensions "environment" productFlavors { diff --git a/transport-eta-android/sms/src/mock/java/com/joaquimley/transporteta/sms/SmsControllerImpl.kt b/transport-eta-android/sms/src/mock/java/com/joaquimley/transporteta/sms/SmsControllerImpl.kt index 22bde38..3473a0b 100644 --- a/transport-eta-android/sms/src/mock/java/com/joaquimley/transporteta/sms/SmsControllerImpl.kt +++ b/transport-eta-android/sms/src/mock/java/com/joaquimley/transporteta/sms/SmsControllerImpl.kt @@ -14,6 +14,11 @@ import javax.inject.Singleton @Singleton open class SmsControllerImpl @Inject constructor(private val smsBroadcastReceiver: SmsBroadcastReceiver) : SmsController { + + init { + + } + override fun dispose() { } diff --git a/transport-eta-android/ui-mobile/build.gradle b/transport-eta-android/ui-mobile/build.gradle index b03701c..edbee11 100644 --- a/transport-eta-android/ui-mobile/build.gradle +++ b/transport-eta-android/ui-mobile/build.gradle @@ -23,6 +23,19 @@ android { missingDimensionStrategy 'environment', ['prod', 'mock'] } + /** + * Prevent shipping the mock flavor with release variant + * 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 == "" + if (names.contains("mock") && variant.buildType.name == "release") { + // Gradle ignores any variants that satisfy the conditions above. + setIgnore(true) + } + } + // Always show the result of every unit test, even if it passes. testOptions { execution 'ANDROID_TEST_ORCHESTRATOR' @@ -45,9 +58,15 @@ android { quiet true abortOnError false ignoreWarnings true + checkDependencies true } buildTypes { + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + debug { versionNameSuffix "-dev" applicationIdSuffix ".debug" @@ -55,13 +74,10 @@ android { testCoverageEnabled true } - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } } } + // Module configuration configurations.all { resolutionStrategy { @@ -80,10 +96,11 @@ androidExtensions { dependencies { // Modules + implementation project(':presentation') + implementation project(':domain') implementation project(':sms') implementation project(':data') - implementation project(':domain') - implementation project(':presentation') + implementation project(':data-sharedpreferences') // AndroidX implementation deps.androidx.slice implementation deps.androidx.core_ktx diff --git a/transport-eta-android/ui-mobile/src/androidTest/java/com/joaquimley/transporteta/ui/di/module/TestActivityBindingModule.kt b/transport-eta-android/ui-mobile/src/androidTest/java/com/joaquimley/transporteta/ui/di/module/TestActivityBindingModule.kt index 3ffbeea..403bcf9 100644 --- a/transport-eta-android/ui-mobile/src/androidTest/java/com/joaquimley/transporteta/ui/di/module/TestActivityBindingModule.kt +++ b/transport-eta-android/ui-mobile/src/androidTest/java/com/joaquimley/transporteta/ui/di/module/TestActivityBindingModule.kt @@ -8,7 +8,7 @@ import dagger.android.ContributesAndroidInjector @Module abstract class TestActivityBindingModule { - @PerActivity // HomeFragmentBuildersModule::class + @PerActivity // HomeActivityFragmentBuildersModule::class @ContributesAndroidInjector(modules = [ TestFragmentActivityModule::class, TestFragmentsBuildersModule::class diff --git a/transport-eta-android/ui-mobile/src/androidTest/java/com/joaquimley/transporteta/ui/di/module/TestFavoriteFragmentModule.kt b/transport-eta-android/ui-mobile/src/androidTest/java/com/joaquimley/transporteta/ui/di/module/TestFavoriteFragmentModule.kt index a9ba8a6..cf8c950 100644 --- a/transport-eta-android/ui-mobile/src/androidTest/java/com/joaquimley/transporteta/ui/di/module/TestFavoriteFragmentModule.kt +++ b/transport-eta-android/ui-mobile/src/androidTest/java/com/joaquimley/transporteta/ui/di/module/TestFavoriteFragmentModule.kt @@ -29,8 +29,8 @@ class TestFavoriteFragmentModule { // } @Provides - fun provideFavoritesViewModelFactory(smsController: SmsController): FavoritesViewModelFactory { - return FavoritesViewModelFactoryImpl(smsController) + fun provideFavoritesViewModelFactory(): FavoritesViewModelFactory { + return favoritesViewModelFactory // return favoritesViewModelFactory } diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/ActivityBindingModule.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/ActivityBindingModule.kt index d4e1fcf..9289534 100644 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/ActivityBindingModule.kt +++ b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/ActivityBindingModule.kt @@ -1,7 +1,7 @@ package com.joaquimley.transporteta.ui.di.module -import com.joaquimley.transporteta.ui.home.HomeActivity import com.joaquimley.transporteta.ui.di.scope.PerActivity +import com.joaquimley.transporteta.ui.home.HomeActivity import dagger.Module import dagger.android.ContributesAndroidInjector @@ -10,8 +10,8 @@ abstract class ActivityBindingModule { @PerActivity @ContributesAndroidInjector(modules = [ - HomeActivityModule::class, - HomeFragmentBuildersModule::class + HomeActivityModule::class +// HomeActivityFragmentBuildersModule::class ]) abstract fun bindHomeActivity(): HomeActivity } \ No newline at end of file diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/AppModule.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/AppModule.kt index 3d2cb8c..44bfda9 100644 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/AppModule.kt +++ b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/AppModule.kt @@ -2,7 +2,7 @@ package com.joaquimley.transporteta.ui.di.module import android.app.Application import android.content.Context -import com.joaquimley.data.executor.ThreadExecutorImpl +import com.joaquimley.transporteta.data.executor.ThreadExecutorImpl import com.joaquimley.transporteta.domain.executor.PostExecutionThread import com.joaquimley.transporteta.domain.executor.ThreadExecutor import com.joaquimley.transporteta.ui.UiThread diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/DataSourceModule.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/DataSourceModule.kt index eec217c..7d3e381 100644 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/DataSourceModule.kt +++ b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/DataSourceModule.kt @@ -1,7 +1,7 @@ package com.joaquimley.transporteta.ui.di.module -import com.joaquimley.data.source.FrameworkLocalStorage -import com.joaquimley.data.source.FrameworkLocalStorageImpl +import com.joaquimley.transporteta.data.source.FrameworkLocalStorage +import com.joaquimley.transporteta.sharedpreferences.FrameworkLocalStorageImpl import com.joaquimley.transporteta.ui.di.scope.PerApplication import dagger.Module import dagger.Provides diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/DataStoreModule.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/DataStoreModule.kt index 8352495..496c591 100644 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/DataStoreModule.kt +++ b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/DataStoreModule.kt @@ -1,8 +1,8 @@ package com.joaquimley.transporteta.ui.di.module -import com.joaquimley.data.source.FrameworkLocalStorage -import com.joaquimley.data.store.TransportDataStore -import com.joaquimley.data.store.TransportDataStoreImpl +import com.joaquimley.transporteta.data.source.FrameworkLocalStorage +import com.joaquimley.transporteta.data.store.TransportDataStore +import com.joaquimley.transporteta.data.store.TransportDataStoreImpl import com.joaquimley.transporteta.ui.di.scope.PerApplication import dagger.Module import dagger.Provides diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeFragmentBuildersModule.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeActivityFragmentBuildersModule.kt similarity index 67% rename from transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeFragmentBuildersModule.kt rename to transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeActivityFragmentBuildersModule.kt index e889af3..c079fed 100644 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeFragmentBuildersModule.kt +++ b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeActivityFragmentBuildersModule.kt @@ -5,10 +5,8 @@ import dagger.Module import dagger.android.ContributesAndroidInjector @Module -abstract class HomeFragmentBuildersModule { +abstract class HomeActivityFragmentBuildersModule { - @ContributesAndroidInjector(modules = [ - HomeViewModelModule::class - ]) + @ContributesAndroidInjector abstract fun contributeFavouritesFragment(): FavoritesFragment } diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeActivityModule.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeActivityModule.kt index cd076a2..f68123b 100644 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeActivityModule.kt +++ b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeActivityModule.kt @@ -1,6 +1,12 @@ package com.joaquimley.transporteta.ui.di.module +import com.joaquimley.transporteta.ui.home.favorite.FavoritesFragment import dagger.Module +import dagger.android.ContributesAndroidInjector @Module -class HomeActivityModule \ No newline at end of file +abstract class HomeActivityModule { + + @ContributesAndroidInjector + abstract fun contributeFavouritesFragment(): FavoritesFragment +} \ No newline at end of file diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeViewModelModule.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeViewModelModule.kt deleted file mode 100644 index 08ed6df..0000000 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/HomeViewModelModule.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.joaquimley.transporteta.ui.di.module - -import dagger.Module - -@Module -class HomeViewModelModule { - -} \ No newline at end of file diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/MapperModule.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/MapperModule.kt index 622c556..4092b83 100644 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/MapperModule.kt +++ b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/MapperModule.kt @@ -1,6 +1,6 @@ package com.joaquimley.transporteta.ui.di.module -import com.joaquimley.data.mapper.DataTransportMapper +import com.joaquimley.transporteta.data.mapper.DataTransportMapper import com.joaquimley.transporteta.presentation.mapper.PresentationTransportMapper import dagger.Module import dagger.Provides diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/RepositoryModule.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/RepositoryModule.kt index 574aebe..261b3eb 100644 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/RepositoryModule.kt +++ b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/di/module/RepositoryModule.kt @@ -1,11 +1,11 @@ package com.joaquimley.transporteta.ui.di.module import com.joaquimley.transporteta.domain.repository.FavoritesRepository -import com.joaquimley.data.FavoritesRepositoryImpl +import com.joaquimley.transporteta.data.FavoritesRepositoryImpl import com.joaquimley.transporteta.domain.repository.TransportRepository -import com.joaquimley.data.TransportRepositoryImpl -import com.joaquimley.data.mapper.DataTransportMapper -import com.joaquimley.data.store.TransportDataStore +import com.joaquimley.transporteta.data.TransportRepositoryImpl +import com.joaquimley.transporteta.data.mapper.DataTransportMapper +import com.joaquimley.transporteta.data.store.TransportDataStore import com.joaquimley.transporteta.ui.di.scope.PerApplication import dagger.Module import dagger.Provides diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/home/favorite/FavoritesAdapter.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/home/favorite/FavoritesAdapter.kt index cd8974e..9d6ea11 100644 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/home/favorite/FavoritesAdapter.kt +++ b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/home/favorite/FavoritesAdapter.kt @@ -1,5 +1,6 @@ package com.joaquimley.transporteta.ui.home.favorite +import android.util.Log import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.DiffUtil import android.view.LayoutInflater @@ -40,10 +41,11 @@ class FavoritesAdapter(private val clickListener: (TransportView) -> Unit) } fun setActionEnabledStatus(isEnabled: Boolean) { + Log.e("To remove", "Hi $isEnabled") // for (position in 0 until itemCount) { // getItem(position).isActionEnabled = isEnabled // } - notifyDataSetChanged() +// notifyDataSetChanged() } inner class ProgressViewHolder(view: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(view) diff --git a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/home/favorite/FavoritesFragment.kt b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/home/favorite/FavoritesFragment.kt index 19a87bb..63bf341 100644 --- a/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/home/favorite/FavoritesFragment.kt +++ b/transport-eta-android/ui-mobile/src/main/java/com/joaquimley/transporteta/ui/home/favorite/FavoritesFragment.kt @@ -12,7 +12,10 @@ import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.recyclerview.widget.RecyclerView +import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_INDEFINITE +import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG import com.google.android.material.snackbar.Snackbar +import com.google.android.material.textfield.TextInputEditText import com.joaquimley.transporteta.R import com.joaquimley.transporteta.presentation.data.ResourceState import com.joaquimley.transporteta.presentation.home.favorite.FavoritesViewModelFactory @@ -29,10 +32,8 @@ import javax.inject.Inject */ class FavoritesFragment : Fragment() { - // Inspiration for UI https://www.behance.net/gallery/69860023/Bust-app - @Inject lateinit var viewModelProvider: FavoritesViewModelFactory - private val viewModel by lazy { viewModelProvider.create()} + private val viewModel by lazy { viewModelProvider.create() } private lateinit var adapter: FavoritesAdapter private lateinit var requestingSnackbar: Snackbar @@ -43,6 +44,7 @@ class FavoritesFragment : Fragment() { } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): + // TODO Inspiration for UI https://www.behance.net/gallery/69860023/Bust-app View = inflater.inflate(R.layout.fragment_favourites, container, false) override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -117,15 +119,15 @@ class FavoritesFragment : Fragment() { message_view?.setVisible(true) } else { message?.let { - com.google.android.material.snackbar.Snackbar.make(favorites_fragment_container, it, com.google.android.material.snackbar.Snackbar.LENGTH_LONG) - .setAction(R.string.action_retry) { viewModel.onRefresh() } + com.google.android.material.snackbar.Snackbar.make(favorites_fragment_container, it, LENGTH_LONG) + .setAction(R.string.action_retry) { _ -> viewModel.onRefresh() } .show() } } } private fun setupRequestSnackbar() { - requestingSnackbar = Snackbar.make(favorites_fragment_container, R.string.info_requesting, com.google.android.material.snackbar.Snackbar.LENGTH_INDEFINITE) + requestingSnackbar = Snackbar.make(favorites_fragment_container, R.string.info_requesting, LENGTH_INDEFINITE) requestingSnackbar.setAction(R.string.action_cancel) { viewModel.onEtaRequestCanceled() Toast.makeText(activity?.applicationContext, R.string.info_canceled, Toast.LENGTH_SHORT).show() @@ -165,22 +167,22 @@ class FavoritesFragment : Fragment() { val dialog = builder.create() dialog.show() - val busStopTitleEditText: com.google.android.material.textfield.TextInputEditText? = dialog.findViewById(R.id.favorite_title_edit_text) - val busStopCodeEditText: com.google.android.material.textfield.TextInputEditText? = dialog.findViewById(R.id.favorite_code_edit_text) - busStopCodeEditText?.onChange { - if (!TextUtils.isEmpty(it)) { +// val busStopTitleEditText: com.google.android.material.textfield.TextInputEditText? = dialog.findViewById(R.id.favorite_title_edit_text) + val busStopCodeEditText: TextInputEditText? = dialog.findViewById(R.id.favorite_code_edit_text) + busStopCodeEditText?.onChange { currentText -> + if (!TextUtils.isEmpty(currentText)) { busStopCodeEditText.error = null } } - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { + dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { _ -> if (TextUtils.isEmpty(busStopCodeEditText?.text)) { busStopCodeEditText?.error = getString(R.string.error_create_favorite_code_required) } } - context?.let { ContextCompat.getColor(it, R.color.colorLightGrey) }?.let { dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(it) } - dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener { + context?.let { context -> ContextCompat.getColor(context, R.color.colorLightGrey) }?.let { dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(it) } + dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener { _ -> dialog.dismiss() } @@ -188,7 +190,8 @@ class FavoritesFragment : Fragment() { } companion object { - @JvmStatic fun newInstance(): FavoritesFragment { + @JvmStatic + fun newInstance(): FavoritesFragment { val fragment = FavoritesFragment() // val args = Bundle() // fragment.arguments = args