From dee8a409af439cc9ce3211d745cf97bedf92e07a Mon Sep 17 00:00:00 2001 From: Yekta Sarioglu Date: Sat, 19 Mar 2022 14:26:13 +0300 Subject: [PATCH] Refactor project --- .editorconfig | 11 -- .gitignore | 2 + app/build.gradle.kts | 5 - .../gifit/navigation/NavigationGraph.kt | 2 +- .../theteampotato/gifit/view/MainActivity.kt | 4 + build.gradle.kts | 2 - buildSrc/build.gradle.kts | 8 +- .../src/main/kotlin/CommonModulePlugin.kt | 129 +------------- .../kotlin/CommonModulePluginExtension.kt | 1 - buildSrc/src/main/kotlin/Dependencies.kt | 158 +++--------------- features/favorites/build.gradle.kts | 1 - .../favorites/viewmodel/FavoritesViewModel.kt | 7 +- features/history/build.gradle.kts | 1 - .../gifit/history/view/HistoryScreen.kt | 2 - .../history/viewmodel/HistoryViewModel.kt | 7 +- features/language-selection/build.gradle.kts | 1 - .../gifit/language_selection/Language.kt | 17 ++ .../language_selection/SupportedLanguage.kt | 3 + .../view/LanguageSelectionScreen.kt | 23 +-- features/search/build.gradle.kts | 5 +- .../gifit/home/di/SearchModule.kt | 5 +- .../gifit/home/view/SearchScreen.kt | 2 + features/splash/build.gradle.kts | 5 - .../gifit/splash/SplashViewTest.kt | 32 ---- .../gifit/splash/view/SplashScreen.kt | 16 -- layers/data/build.gradle.kts | 4 - .../theteampotato/gifit/data/DeviceManager.kt | 10 +- .../theteampotato/gifit/data/LocaleManager.kt | 8 +- .../gifit/data/datastore/LocalDataStore.kt | 1 + .../theteampotato/gifit/data/di/KtorModule.kt | 6 +- .../gifit/data/di/RepositoryModule.kt | 14 +- .../theteampotato/gifit/data/di/RoomModule.kt | 3 + .../gifit/data/local/dao/SearchResultDao.kt | 2 + .../data/local/database/GIFitRoomDatabase.kt | 2 + .../data/local/datasource/LocalDataSource.kt | 5 +- .../local/repository/GIFitLocalRepository.kt | 5 +- .../gifit/data/remote/GiphyService.kt | 1 + .../theteampotato/gifit/data/remote/Ktor.kt | 4 +- .../repository/GIFitRemoteRepository.kt | 1 + layers/domain/build.gradle.kts | 4 - .../gifit/domain/di/UseCaseModule.kt | 3 +- .../domain/usecase/AddSearchResultEntry.kt | 1 + .../usecase/AddSearchResultToFavorites.kt | 4 - .../gifit/domain/usecase/BaseUseCase.kt | 2 +- .../usecase/DownloadTranslationModel.kt | 2 + .../domain/usecase/GetSelectedLanguage.kt | 5 +- .../domain/usecase/IsSearchResultExist.kt | 2 + .../gifit/domain/usecase/ReadText.kt | 1 + .../domain/usecase/SetSelectedLanguage.kt | 2 + .../gifit/domain/usecase/TranslateText.kt | 10 +- layers/ui/build.gradle.kts | 7 +- .../theteampotato/gifit/ui/NetworkImage.kt | 43 ----- .../gifit/ui/view/GIFitBottomNavBar.kt | 2 + .../theteampotato/gifit/ui/view/GIFitCards.kt | 2 +- .../theteampotato/gifit/ui/view/GIFitList.kt | 1 + .../gifit/ui/view/GIFitLoaders.kt | 1 + .../theteampotato/gifit/ui/view/InfoTips.kt | 2 - .../gifit/ui/view/ResultCards.kt | 2 +- testing/build.gradle.kts | 11 -- translate/build.gradle.kts | 5 - .../gifit/translate/GoogleMLKitTranslator.kt | 23 +-- .../gifit/translate/ITranslator.kt | 4 - 62 files changed, 150 insertions(+), 504 deletions(-) delete mode 100644 .editorconfig create mode 100644 features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/Language.kt create mode 100644 features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/SupportedLanguage.kt delete mode 100644 features/splash/src/androidTest/kotlin/com/theteampotato/gifit/splash/SplashViewTest.kt delete mode 100644 features/splash/src/main/kotlin/com/theteampotato/gifit/splash/view/SplashScreen.kt delete mode 100644 translate/src/main/java/com/theteampotato/gifit/translate/ITranslator.kt diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 5aa38d4..0000000 --- a/.editorconfig +++ /dev/null @@ -1,11 +0,0 @@ -[*.{kt,kts}] -# possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely) -indent_size=4# true (recommended) / false -insert_final_newline=true# possible values: number (e.g. 120) (package name, imports & comments are ignored), "off" -# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide) -max_line_length=off - -# Comma-separated list of rules to disable (Since 0.34.0) -# Note that rules in any ruleset other than the standard ruleset will need to be prefixed -# by the ruleset identifier. -# https://github.com/pinterest/ktlint/blob/69cc0f7f826e18d7ec20e7a0f05df12d53a3c1e1/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/StandardRuleSetProvider.kt \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2fdfa1e..325912d 100644 --- a/.gitignore +++ b/.gitignore @@ -92,3 +92,5 @@ lint/tmp/ # Android Profiling *.hprof /.idea/ + +.DS_Store diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d5a480a..93db77b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -29,13 +29,8 @@ dependencies { ANDROID_TEST COROUTINES_TEST - LOCAL_TEST_JUNIT5 } kapt { correctErrorTypes = true -} - -moduleConfigurations { - useJUnitRunner5 = true } \ No newline at end of file diff --git a/app/src/main/kotlin/com/theteampotato/gifit/navigation/NavigationGraph.kt b/app/src/main/kotlin/com/theteampotato/gifit/navigation/NavigationGraph.kt index ec720bd..639342c 100644 --- a/app/src/main/kotlin/com/theteampotato/gifit/navigation/NavigationGraph.kt +++ b/app/src/main/kotlin/com/theteampotato/gifit/navigation/NavigationGraph.kt @@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable import androidx.navigation.* import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable + import com.theteampotato.gifit.favorites.view.FavoritesScreen import com.theteampotato.gifit.favorites.viewmodel.FavoritesViewModel import com.theteampotato.gifit.history.view.HistoryScreen @@ -22,7 +23,6 @@ const val LANGUAGE_SELECTION = "language_selection" fun NavigationGraph( navController: NavHostController, startDestination: String = "${BottomNavScreen.SearchNavScreen.route}?searchQuery={${BottomNavScreen.SearchNavScreen.arguments?.first()}}", - //startDestination: String = "language_selection", languageSelectionViewModel: LanguageSelectionViewModel, searchViewModel: SearchViewModel, historyViewModel: HistoryViewModel, diff --git a/app/src/main/kotlin/com/theteampotato/gifit/view/MainActivity.kt b/app/src/main/kotlin/com/theteampotato/gifit/view/MainActivity.kt index 86e5c7f..f185c71 100644 --- a/app/src/main/kotlin/com/theteampotato/gifit/view/MainActivity.kt +++ b/app/src/main/kotlin/com/theteampotato/gifit/view/MainActivity.kt @@ -1,6 +1,7 @@ package com.theteampotato.gifit.view import android.os.Bundle + import androidx.activity.compose.setContent import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity @@ -14,6 +15,7 @@ import androidx.lifecycle.lifecycleScope import androidx.navigation.NavController import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController + import com.theteampotato.gifit.data.LocaleManager import com.theteampotato.gifit.data.datastore.preferencesDataStore import com.theteampotato.gifit.favorites.viewmodel.FavoritesViewModel @@ -26,7 +28,9 @@ import com.theteampotato.gifit.splash.viewmodel.SplashViewModel import com.theteampotato.gifit.ui.BottomNavScreen import com.theteampotato.gifit.ui.GIFitTheme import com.theteampotato.gifit.ui.view.GIFitBottomNavBar + import dagger.hilt.android.AndroidEntryPoint + import kotlinx.coroutines.delay val LocaleActiveManager = compositionLocalOf { error("No locale manager found!") } diff --git a/build.gradle.kts b/build.gradle.kts index 9cfb8f8..a9afa80 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,6 @@ buildscript { google() gradlePluginPortal() mavenCentral() - maven(url = "https://developer.huawei.com/repo/") } dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") @@ -20,7 +19,6 @@ allprojects { google() mavenCentral() maven(url = "https://jitpack.io") - maven(url = "https://developer.huawei.com/repo/") maven(url = "https://oss.sonatype.org/content/repositories/snapshots/") } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 60b9605..e3175fa 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -19,13 +19,9 @@ repositories { } dependencies { - //compileOnly(gradleApi()) - //implementation(kotlin("gradle-plugin")) implementation("com.android.tools.build:gradle:7.1.0") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") - implementation("com.google.dagger:hilt-android-gradle-plugin:2.40.5") - implementation("org.jlleitschuh.gradle:ktlint-gradle:10.2.1") - implementation("org.jetbrains.kotlin:kotlin-serialization:1.4.31") + implementation("com.google.dagger:hilt-android-gradle-plugin:2.41") + implementation("org.jetbrains.kotlin:kotlin-serialization:1.6.10") implementation("io.ktor:ktor-serialization:1.5.1") - implementation("de.mannodermaus.gradle.plugins:android-junit5:1.8.2.0") } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/CommonModulePlugin.kt b/buildSrc/src/main/kotlin/CommonModulePlugin.kt index 0b1f95e..6d6371c 100644 --- a/buildSrc/src/main/kotlin/CommonModulePlugin.kt +++ b/buildSrc/src/main/kotlin/CommonModulePlugin.kt @@ -2,23 +2,16 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension -import org.gradle.api.Action import org.gradle.api.JavaVersion import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.internal.file.impl.DefaultFileMetadata.file import org.gradle.kotlin.dsl.* -import org.jlleitschuh.gradle.ktlint.reporter.ReporterType - import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.jlleitschuh.gradle.ktlint.KtlintExtension -import java.io.File class CommonModulePlugin : Plugin { private val isApplicationModule: Boolean - //get() = defaultConfig is AppExtension get() = moduleName == "app" private lateinit var moduleName: String @@ -32,18 +25,14 @@ class CommonModulePlugin : Plugin { apply("kotlin-android") apply("kotlin-kapt") apply("kotlin-parcelize") - //apply(BuildScript.JUNIT5_PLUGIN) - apply(BuildScript.KTLINT_PLUGIN) if (moduleName == "data") apply("kotlinx-serialization") } - //project.applyKtLintConfigurations() - val androidExtension = project.extensions.getByName("android") as? BaseExtension ?: return - project.applyModuleConfigurations(androidExtension) + project.applyModuleConfigurations() androidExtension.applyAndroidConfigurations() androidExtension.applyProguardConfigurations() @@ -59,81 +48,17 @@ class CommonModulePlugin : Plugin { println("${ASCIIArt.A_GUY_SMASHING_COMPUTER}\n\n\n\t\t\t\t\tBuilding $moduleName module...\n") } - private fun Project.applyKtLintConfigurations() { - val ktLint = project.extensions.getByName("ktlint") - println("ktLint is ${ktLint.javaClass.simpleName}") - - // Run `ktlintCheck` task after each module prebuild - afterEvaluate { - tasks { - val ktLintCheck = tasks.named("ktlintCheck") - /*val assembleDebug = tasks.named(if (isApplicationModule) "assembleGmsDebug" else "assembleDebug") - - assembleDebug { - dependsOn(ktLintCheck) - }*/ - - "preBuild" { - dependsOn(ktLintCheck) - } - } - } - - ktlint { - //version.set("0.38.1") - android.set(true) - coloredOutput.set(true) - //debug.set(true) - enableExperimentalRules.set(true) - verbose.set(true) - ignoreFailures.set(true) - outputToConsole.set(true) - disabledRules.set( - setOf( - "colon-spacing", - "experimental:multiline-if-else", - "no-blank-line-before-rbrace", - "no-wildcard-imports", - "import-ordering" - ) - ) - filter { - exclude("**/generated/**") - include("**/kotlin/**") - } - reporters { - //reporter(ReporterType.PLAIN) - //reporter(ReporterType.CHECKSTYLE) - reporter(ReporterType.HTML) - reporter(ReporterType.JSON) - } - } - } - - private fun Project.applyModuleConfigurations(androidExtension: BaseExtension) { + private fun Project.applyModuleConfigurations() { modulePluginExtension = project.extensions.create( "moduleConfigurations", CommonModulePluginExtension::class ) project.afterEvaluate { - println("useJUnitRunner5 is ${modulePluginExtension?.useJUnitRunner5}") - with(modulePluginExtension!!) { - if (useJUnitRunner5) { - with(androidExtension) { - //project.plugins.apply(BuildScript.JUNIT5_PLUGIN) -// defaultConfig.testInstrumentationRunnerArgument( -// "runnerBuilder", -// "de.mannodermaus.junit5.AndroidJUnit5Builder" -// ) - } - } - if (useRoboelectric) { dependencies.apply { - androidInstrumentationTest(useJUnitRunner5, useRoboelectric) - roboelectricTest() + androidInstrumentationTest() } tasks { @@ -158,30 +83,10 @@ class CommonModulePlugin : Plugin { versionCode = AppConfig.VERSION_CODE versionName = AppConfig.VERSION_NAME - minSdkVersion(AppConfig.MINIMUM_SDK) - targetSdkVersion(AppConfig.TARGET_SDK) + minSdk = AppConfig.MINIMUM_SDK + targetSdk = AppConfig.TARGET_SDK testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - //testInstrumentationRunnerArgument("runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder") - } - - if (isApplicationModule) { - println("$moduleName - Creating build variants") - - flavorDimensions("platform") - productFlavors { - create("gms") { dimension("platform") } - create("hms") { dimension("platform") } - } - } - - signingConfigs { - /*create("releaseConfig") { - keyAlias = "key0" - keyPassword = "123456" - storeFile = File("key.jks") - storePassword = "123456" - }*/ } sourceSets { @@ -207,19 +112,6 @@ class CommonModulePlugin : Plugin { add("META-INF/AL2.0") add("META-INF/LGPL2.1") } - - /*pickFirst("META-INF/DEPENDENCIES") - pickFirst("META-INF/ASL2.0")*/ - - //exclude("META-INF/DEPENDENCIES") - /*exclude("META-INF/LICENSE") - exclude("META-INF/LICENSE.txt") - exclude("META-INF/license.txt") - exclude("META-INF/NOTICE") - exclude("META-INF/NOTICE.txt") - exclude("META-INF/notice.txt")*/ - //exclude("META-INF/ASL2.0") - //exclude("META-INF/*.kotlin_module") } } @@ -231,7 +123,6 @@ class CommonModulePlugin : Plugin { when (this) { is AppExtension -> buildTypes { getByName("debug") { - //signingConfig = signingConfigs.getByName("releaseConfig") isDebuggable = true } getByName("release") { @@ -241,7 +132,6 @@ class CommonModulePlugin : Plugin { getDefaultProguardFile("proguard-android-optimize.txt"), proguardFile ) - //signingConfig = signingConfigs.getByName("releaseConfig") } } is LibraryExtension -> defaultConfig { consumerProguardFiles(proguardFile) } @@ -256,9 +146,7 @@ class CommonModulePlugin : Plugin { project.tasks.withType().configureEach { kotlinOptions { - //freeCompilerArgs = listOf("-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check") jvmTarget = "1.8" - //useIR = true } } } @@ -272,17 +160,10 @@ class CommonModulePlugin : Plugin { project.tasks.withType().configureEach { kotlinOptions { jvmTarget = "11" - //useIR = true } } } - /** - * Configures the [ktlint][org.jlleitschuh.gradle.ktlint.KtlintExtension] extension. - */ - private fun Project.`ktlint`(configure: Action): Unit = - (this as org.gradle.api.plugins.ExtensionAware).extensions.configure("ktlint", configure) - companion object { var modulePluginExtension: CommonModulePluginExtension? = null } diff --git a/buildSrc/src/main/kotlin/CommonModulePluginExtension.kt b/buildSrc/src/main/kotlin/CommonModulePluginExtension.kt index bffff61..8f7ded2 100644 --- a/buildSrc/src/main/kotlin/CommonModulePluginExtension.kt +++ b/buildSrc/src/main/kotlin/CommonModulePluginExtension.kt @@ -1,4 +1,3 @@ open class CommonModulePluginExtension { - var useJUnitRunner5: Boolean = false var useRoboelectric: Boolean = false } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 8a6d497..8d7816c 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -7,22 +7,8 @@ const val DAGGER_HILT_ANDROID_PLUGIN = "dagger.hilt.android.plugin" const val COMMON_MODULE_PLUGIN = "common-module-plugin" object BuildScript { - private const val ANDROID_GRADLE_VERSION = "7.0.0-alpha05" - private const val ANDROID_HILT_GRADLE_VERSION = "2.31.2-alpha" - private const val APP_GALLERY_CONNECT_VERSION = "1.4.2.301" - private const val KOTLIN_VERSION = "1.4.30" - - const val KTLINT_PLUGIN_VERSION = "10.2.1" const val VERSIONS_PLUGIN_VERSION = "0.36.0" - const val JUNIT5_PLUGIN = "de.mannodermaus.android-junit5" - const val KTLINT_PLUGIN = "org.jlleitschuh.gradle.ktlint" const val VERSIONS_PLUGIN = "com.github.ben-manes.versions" - - const val ANDROID_GRADLE_PLUGIN = "com.android.tools.build:gradle:$ANDROID_GRADLE_VERSION" - const val ANDROID_HILT_GRADLE_PLUGIN = - "com.google.dagger:hilt-android-gradle-plugin:$ANDROID_HILT_GRADLE_VERSION" - const val APP_GALLERY_CONNECT_PLUGIN = "com.huawei.agconnect:agcp:$APP_GALLERY_CONNECT_VERSION" - const val KOTLIN_GRADLE_PLUGIN = "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION" } object Modules { @@ -48,19 +34,11 @@ object Modules { object Libraries { private const val COIL_VERSION = "1.4.0" private const val MATERIAL_DESIGN_VERSION = "1.5.0" - private const val PERMISSION_DISPATCHER_VERSION = "4.8.0" - private const val SHOWKASE_VERSION = "1.0.0-beta12" private const val TIMBER_VERSION = "5.0.1" const val COIL_COMPOSE = "io.coil-kt:coil-compose:$COIL_VERSION" const val COIL_GIF = "io.coil-kt:coil-gif:$COIL_VERSION" const val MATERIAL_DESIGN = "com.google.android.material:material:$MATERIAL_DESIGN_VERSION" - const val PERMISSION_DISPATCHER = - "org.permissionsdispatcher:permissionsdispatcher:$PERMISSION_DISPATCHER_VERSION" - const val PERMISSION_DISPATCHER_PROCESSOR = - "org.permissionsdispatcher:permissionsdispatcher-processor:$PERMISSION_DISPATCHER_VERSION" - const val SHOWKASE = "com.airbnb.android:showkase:$SHOWKASE_VERSION" - const val SHOWKASE_COMPILER = "com.airbnb.android:showkase-processor:$SHOWKASE_VERSION" const val TIMBER = "com.jakewharton.timber:timber:$TIMBER_VERSION" object AndroidX { @@ -69,7 +47,6 @@ object Libraries { private const val DATASTORE_VERSION = "1.0.0" private const val FRAGMENT_KTX_VERSION = "1.4.1" private const val MULTIDEX_VERSION = "2.0.1" - private const val NAVIGATION_COMPONENT_VERSION = "2.4.1" private const val LIFECYCLE_VERSION = "2.2.0" private const val ROOM_VERSION = "2.4.1" private const val SPLASH_API_VERSION = "1.0.0-beta01" @@ -81,10 +58,6 @@ object Libraries { const val DATASTORE = "androidx.datastore:datastore-preferences:$DATASTORE_VERSION" const val FRAGMENT_KTX = "androidx.fragment:fragment-ktx:$FRAGMENT_KTX_VERSION" const val MULTIDEX = "androidx.multidex:multidex:$MULTIDEX_VERSION" - const val NAVIGATION_COMPONENT = - "androidx.navigation:navigation-fragment-ktx:$NAVIGATION_COMPONENT_VERSION" - const val NAVIGATION_COMPONENT_UI = - "androidx.navigation:navigation-ui-ktx:$NAVIGATION_COMPONENT_VERSION" const val LIFECYCLE_EXTENSIONS = "androidx.lifecycle:lifecycle-extensions:$LIFECYCLE_VERSION" const val LIFECYCLE_EXTENSIONS_LIVEDATA = @@ -143,20 +116,6 @@ object Libraries { } } - object HMS { - const val HWID_VERSION = "5.1.0.302" - const val OCR_VERSION = "2.0.5.300" - - const val HWID = "com.huawei.hms:hwid:$HWID_VERSION" - const val TEXT_RECOGNITION = "com.huawei.hms:ml-computer-vision-ocr:$OCR_VERSION" - const val TEXT_RECOGNITION_LATIN = - "com.huawei.hms:ml-computer-vision-ocr-latin-model:$OCR_VERSION" - const val TEXT_RECOGNITION_CHINESE_ENGLISH = - "com.huawei.hms:ml-computer-vision-ocr-cn-model:$OCR_VERSION" - const val TEXT_RECOGNITION_JAPANESE_KOREAN = - "com.huawei.hms:ml-computer-vision-ocr-jk-model:$OCR_VERSION" - } - object Kotlin { private const val VERSION = "1.6.10" @@ -165,9 +124,6 @@ object Libraries { object Coroutines { private const val COROUTINES_ANDROID_VERSION = "1.6.0" - const val COROUTINES_ANDROID = - "org.jetbrains.kotlinx:kotlinx-coroutines-android:$COROUTINES_ANDROID_VERSION" - object Test { const val TEST = "org.jetbrains.kotlinx:kotlinx-coroutines-test:$COROUTINES_ANDROID_VERSION" @@ -196,15 +152,10 @@ object Libraries { } object Hilt { - private const val HILT_VERSION = "2.40.5" - private const val HILT_LIFECYCLE_VIEWMODEL_VERSION = "1.0.0-alpha03" - private const val HILT_COMPILER_VERSION = "1.0.0-alpha03" + private const val HILT_VERSION = "2.41" const val HILT_ANDROID = "com.google.dagger:hilt-android:$HILT_VERSION" const val HILT_ANDROID_COMPILER = "com.google.dagger:hilt-compiler:$HILT_VERSION" - const val HILT_LIFECYCLE_VIEWMODEL = - "androidx.hilt:hilt-lifecycle-viewmodel:$HILT_LIFECYCLE_VIEWMODEL_VERSION" - const val HILT_COMPILER = "androidx.hilt:hilt-compiler:$HILT_COMPILER_VERSION" object Test { const val TESTING = "com.google.dagger:hilt-android-testing:$HILT_VERSION" @@ -212,26 +163,13 @@ object Libraries { } object Test { - private const val HAMCREST_VERSION = "1.3" private const val JUNIT_VERSION = "4.13.2" - private const val KOTLINX_COROUTINES_VERSION = "1.4.2" - private const val MOCKITO_CORE_VERSION = "2.21.0" - private const val MOCKITO_INLINE_VERSION = "3.3.3" - private const val MOCKITO_KOTLIN_VERSION = "2.2.0" private const val MOCKK_VERSION = "1.10.6" private const val TRUTH_VERSION = "1.1.2" const val JUNIT = "junit:junit:$JUNIT_VERSION" const val MOCKK = "io.mockk:mockk:$MOCKK_VERSION" - const val MOCKK_ANDROID = "io.mockk:mockk-android:$MOCKK_VERSION" - const val MOCKITO_INLINE = "org.mockito:mockito-inline:$MOCKITO_INLINE_VERSION" - const val MOCKITO_KOTLIN = - "com.nhaarman.mockitokotlin2:mockito-kotlin:$MOCKITO_KOTLIN_VERSION" const val TRUTH = "com.google.truth:truth:$TRUTH_VERSION" - const val MOCKITO_CORE = "org.mockito:mockito-core:$MOCKITO_CORE_VERSION" - const val KOTLINX_COROUTINES_TEST = - "org.jetbrains.kotlinx:kotlinx-coroutines-test:$KOTLINX_COROUTINES_VERSION" - const val HAMCREST = "org.hamcrest:hamcrest-all:$HAMCREST_VERSION" object AndroidX { private const val ARCH_VERSION = "2.1.0" @@ -244,12 +182,6 @@ object Libraries { const val JUNIT_RUNNER = "androidx.test:runner:$JUNIT_VERSION" const val JUNIT_RULES = "androidx.test:rules:$JUNIT_VERSION" } - - object UI { - private const val COMPOSE_UI_TEST_JUNIT4_VERSION = "1.0.0-alpha10" - const val COMPOSE_UI_TEST_JUNIT4 = - "androidx.compose.ui:ui-test-junit4:$COMPOSE_UI_TEST_JUNIT4_VERSION" - } } } @@ -315,9 +247,6 @@ val DependencyHandler.COMPOSE_VIEWMODEL val DependencyHandler.COMPOSE_HILT_NAVIGATION get() = implementation(Libraries.Compose.HILT_NAVIGATION) -val DependencyHandler.COROUTINES - get() = coroutines() - val DependencyHandler.DAGGER_HILT get() = hilt() @@ -333,18 +262,27 @@ val DependencyHandler.KTOR val DependencyHandler.KOTLINX_SERIALIZATION get() = kotlinxSerialization() +val DependencyHandler.LOTTIE_COMPOSE + get() = implementation("com.airbnb.android:lottie-compose:5.0.3") + val DependencyHandler.MATERIAL_DESIGN get() = implementation(Libraries.MATERIAL_DESIGN) +val DependencyHandler.NAVIGATION_COMMON_KTX + get() = implementation("androidx.navigation:navigation-common-ktx:2.4.1") + val DependencyHandler.ROOM get() = room() -val DependencyHandler.SHOWKASE - get() = showkase() +val DependencyHandler.TURBINE + get() = { + androidTestImplementation("app.cash.turbine:turbine:0.7.0") + testImplementation("app.cash.turbine:turbine:0.7.0") + } // Test val DependencyHandler.ANDROID_TEST - get() = androidInstrumentationTest(useJUnit5 = true) + get() = androidInstrumentationTest() val DependencyHandler.COMPOSE_UI_TEST get() = uiTest() @@ -353,10 +291,7 @@ val DependencyHandler.COROUTINES_TEST get() = coroutinesTest() val DependencyHandler.LOCAL_TEST - get() = test(useJUnit5 = false) - -val DependencyHandler.LOCAL_TEST_JUNIT5 - get() = test(useJUnit5 = true) + get() = test() val DependencyHandler.DAGGER_HILT_TEST get() = hiltTest() @@ -364,9 +299,6 @@ val DependencyHandler.DAGGER_HILT_TEST val DependencyHandler.DAGGER_HILT_ANDROID_TEST get() = hiltAndroidTest() -val DependencyHandler.ROBOELECTRIC_TEST - get() = roboelectricTest() - private fun DependencyHandler.accompanist() { implementation(Libraries.COIL_COMPOSE) implementation(Libraries.COIL_GIF) @@ -404,15 +336,9 @@ private fun DependencyHandler.compose() { implementation(Libraries.Compose.UI_TOOLING) } -private fun DependencyHandler.coroutines() { - implementation(Libraries.Kotlin.Coroutines.COROUTINES_ANDROID) -} - private fun DependencyHandler.hilt() { implementation(Libraries.Hilt.HILT_ANDROID) - //implementation(Libraries.Hilt.HILT_LIFECYCLE_VIEWMODEL) kapt(Libraries.Hilt.HILT_ANDROID_COMPILER) - //kapt(Libraries.Hilt.HILT_COMPILER) } private fun DependencyHandler.ktor() { @@ -421,55 +347,26 @@ private fun DependencyHandler.ktor() { api(Libraries.Ktor.KTOR_ANDROID_CLIENT) implementation(Libraries.Ktor.KTOR_CLIENT_CIO) implementation(Libraries.Ktor.KTOR_CLIENT_LOGGING) - //implementation(Libraries.Ktor.KTOR_KOTLINX_SERIALIZATION) + implementation(Libraries.Ktor.KTOR_KOTLINX_SERIALIZATION) implementation(Libraries.Ktor.KTOR_SERIALIZATION_JVM) - - //implementation(Libraries.Ktor.KTOR_SERIALIZATION) } private fun DependencyHandler.kotlinxSerialization() { implementation(Libraries.KotlinxSerialization.KOTLINX_SERIALIZATION_JSON) } -private fun DependencyHandler.test(useJUnit5: Boolean) { - if (useJUnit5) { - testImplementation("org.junit.jupiter:junit-jupiter-api:5.3.2") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.3.2") - testImplementation("org.junit.jupiter:junit-jupiter-params:5.3.2") - testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.3.2") - } else { - testImplementation(Libraries.Test.JUNIT) - } - - //testImplementation(Libraries.Test.MOCKK) +private fun DependencyHandler.test() { + testImplementation(Libraries.Test.JUNIT) testImplementation(Libraries.Test.TRUTH) androidTestImplementation(Libraries.Test.TRUTH) } -fun DependencyHandler.androidInstrumentationTest( - useJUnit5: Boolean, - useRoboelectric: Boolean = false -) { - if (useJUnit5) { - androidTestImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") - androidTestImplementation("de.mannodermaus.junit5:android-test-core:1.3.0") - androidTestRuntimeOnly("de.mannodermaus.junit5:android-test-runner:1.3.0") - } - - if (!useRoboelectric) { - androidTestImplementation(Libraries.Test.AndroidX.ARCH) - androidTestImplementation(Libraries.Test.AndroidX.CORE) - androidTestImplementation(Libraries.Test.AndroidX.JUNIT_KTX) - androidTestImplementation(Libraries.Test.AndroidX.JUNIT_RUNNER) - androidTestImplementation(Libraries.Test.AndroidX.JUNIT_RULES) - //androidTestImplementation(Libraries.Test.MOCKK_ANDROID) - } else { - testImplementation(Libraries.Test.AndroidX.ARCH) - testImplementation(Libraries.Test.AndroidX.CORE) - testImplementation(Libraries.Test.AndroidX.JUNIT_KTX) - testImplementation(Libraries.Test.AndroidX.JUNIT_RUNNER) - testImplementation(Libraries.Test.AndroidX.JUNIT_RULES) - } +fun DependencyHandler.androidInstrumentationTest() { + testImplementation(Libraries.Test.AndroidX.ARCH) + testImplementation(Libraries.Test.AndroidX.CORE) + testImplementation(Libraries.Test.AndroidX.JUNIT_KTX) + testImplementation(Libraries.Test.AndroidX.JUNIT_RUNNER) + testImplementation(Libraries.Test.AndroidX.JUNIT_RULES) } private fun DependencyHandler.coroutinesTest() { @@ -490,21 +387,12 @@ private fun DependencyHandler.uiTest() { androidTestImplementation(Libraries.Compose.Test.UI_TEST) } -fun DependencyHandler.roboelectricTest() { - testImplementation("org.robolectric:robolectric:4.5") -} - private fun DependencyHandler.room() { implementation(Libraries.AndroidX.ROOM) implementation(Libraries.AndroidX.ROOM_KTX) kapt(Libraries.AndroidX.ROOM_COMPILER) } -private fun DependencyHandler.showkase() { - implementation(Libraries.SHOWKASE) - kapt(Libraries.SHOWKASE_COMPILER) -} - private fun DependencyHandler.implementation(depName: Any) { add("implementation", depName) } diff --git a/features/favorites/build.gradle.kts b/features/favorites/build.gradle.kts index 5575d5f..7f80a2b 100644 --- a/features/favorites/build.gradle.kts +++ b/features/favorites/build.gradle.kts @@ -52,6 +52,5 @@ kapt { } moduleConfigurations { - //useJUnitRunner5 = true useRoboelectric = true } diff --git a/features/favorites/src/main/java/com/theteampotato/gifit/favorites/viewmodel/FavoritesViewModel.kt b/features/favorites/src/main/java/com/theteampotato/gifit/favorites/viewmodel/FavoritesViewModel.kt index bd66404..668d026 100644 --- a/features/favorites/src/main/java/com/theteampotato/gifit/favorites/viewmodel/FavoritesViewModel.kt +++ b/features/favorites/src/main/java/com/theteampotato/gifit/favorites/viewmodel/FavoritesViewModel.kt @@ -11,12 +11,15 @@ import com.theteampotato.gifit.domain.usecase.DeleteSearchResultsFromLocalDb import com.theteampotato.gifit.testing.DispatcherProvider import dagger.hilt.android.lifecycle.HiltViewModel + +import javax.inject.Inject + import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch -import timber.log.Timber -import javax.inject.Inject import kotlin.coroutines.EmptyCoroutineContext +import timber.log.Timber + @HiltViewModel class FavoritesViewModel @Inject constructor( private val dispatcherProvider: DispatcherProvider? = null, diff --git a/features/history/build.gradle.kts b/features/history/build.gradle.kts index 5575d5f..7f80a2b 100644 --- a/features/history/build.gradle.kts +++ b/features/history/build.gradle.kts @@ -52,6 +52,5 @@ kapt { } moduleConfigurations { - //useJUnitRunner5 = true useRoboelectric = true } diff --git a/features/history/src/main/java/com/theteampotato/gifit/history/view/HistoryScreen.kt b/features/history/src/main/java/com/theteampotato/gifit/history/view/HistoryScreen.kt index 6db2bec..6a24e89 100644 --- a/features/history/src/main/java/com/theteampotato/gifit/history/view/HistoryScreen.kt +++ b/features/history/src/main/java/com/theteampotato/gifit/history/view/HistoryScreen.kt @@ -7,11 +7,9 @@ import androidx.compose.material.icons.filled.Delete import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateListOf import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ColorFilter -import androidx.hilt.navigation.compose.hiltViewModel import com.theteampotato.gifit.history.viewmodel.HistoryViewModel import com.theteampotato.gifit.ui.view.GIFitCard diff --git a/features/history/src/main/java/com/theteampotato/gifit/history/viewmodel/HistoryViewModel.kt b/features/history/src/main/java/com/theteampotato/gifit/history/viewmodel/HistoryViewModel.kt index 0a2ce9d..3f9c441 100644 --- a/features/history/src/main/java/com/theteampotato/gifit/history/viewmodel/HistoryViewModel.kt +++ b/features/history/src/main/java/com/theteampotato/gifit/history/viewmodel/HistoryViewModel.kt @@ -12,12 +12,15 @@ import com.theteampotato.gifit.domain.usecase.RemoveSearchResultFromHistory import com.theteampotato.gifit.testing.DispatcherProvider import dagger.hilt.android.lifecycle.HiltViewModel + +import javax.inject.Inject + import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch -import timber.log.Timber -import javax.inject.Inject import kotlin.coroutines.EmptyCoroutineContext +import timber.log.Timber + @HiltViewModel class HistoryViewModel @Inject constructor( private val dispatcherProvider: DispatcherProvider? = null, diff --git a/features/language-selection/build.gradle.kts b/features/language-selection/build.gradle.kts index 5575d5f..7f80a2b 100644 --- a/features/language-selection/build.gradle.kts +++ b/features/language-selection/build.gradle.kts @@ -52,6 +52,5 @@ kapt { } moduleConfigurations { - //useJUnitRunner5 = true useRoboelectric = true } diff --git a/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/Language.kt b/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/Language.kt new file mode 100644 index 0000000..dd8f987 --- /dev/null +++ b/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/Language.kt @@ -0,0 +1,17 @@ +package com.theteampotato.gifit.language_selection + +enum class Language(val languageCode: String) { + FINNISH("fi"), + CHINESE("zh"), + DANISH("da"), + FRENCH("fr"), + GERMAN("de"), + SPANISH("es"), + TURKISH("tr"), + ITALIAN("it"), + JAPANESE("ja"), + DUTCH("nl"), + NORWEGIAN("no"), + KOREAN("ko"), + SWEDISH("sv") +} \ No newline at end of file diff --git a/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/SupportedLanguage.kt b/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/SupportedLanguage.kt new file mode 100644 index 0000000..d985f44 --- /dev/null +++ b/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/SupportedLanguage.kt @@ -0,0 +1,3 @@ +package com.theteampotato.gifit.language_selection + +data class SupportedLanguage(val name: String, val iconResourceId: Int, val languageCode: String) \ No newline at end of file diff --git a/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/view/LanguageSelectionScreen.kt b/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/view/LanguageSelectionScreen.kt index 8900c20..dac061f 100644 --- a/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/view/LanguageSelectionScreen.kt +++ b/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/view/LanguageSelectionScreen.kt @@ -19,13 +19,18 @@ import androidx.compose.ui.unit.sp import androidx.constraintlayout.compose.ConstraintLayout import androidx.constraintlayout.compose.Dimension import androidx.hilt.navigation.compose.hiltViewModel + import com.theteampotato.gifit.data.LocaleManager +import com.theteampotato.gifit.language_selection.Language import com.theteampotato.gifit.language_selection.R +import com.theteampotato.gifit.language_selection.SupportedLanguage import com.theteampotato.gifit.language_selection.viewmodel.LanguageSelectionViewModel import com.theteampotato.gifit.ui.babyBlue import com.theteampotato.gifit.ui.view.GIFitLanguageCard import com.theteampotato.gifit.ui.view.GIFitTranslateModelLoader + import kotlinx.coroutines.launch + import timber.log.Timber @Composable @@ -140,24 +145,6 @@ fun LanguageSelectionScreen( if (isContinueSelected.value) GIFitTranslateModelLoader() } -data class SupportedLanguage(val name: String, val iconResourceId: Int, val languageCode: String) - -enum class Language(val languageCode: String) { - FINNISH("fi"), - CHINESE("zh"), - DANISH("da"), - FRENCH("fr"), - GERMAN("de"), - SPANISH("es"), - TURKISH("tr"), - ITALIAN("it"), - JAPANESE("ja"), - DUTCH("nl"), - NORWEGIAN("no"), - KOREAN("ko"), - SWEDISH("sv") -} - private fun getSupportedLanguages() = listOf( SupportedLanguage( name = "Finnish", diff --git a/features/search/build.gradle.kts b/features/search/build.gradle.kts index 4c95c68..f7ac4ad 100644 --- a/features/search/build.gradle.kts +++ b/features/search/build.gradle.kts @@ -46,9 +46,7 @@ dependencies { testImplementation(project(Modules.TESTING)) testImplementation(Libraries.Kotlin.Coroutines.Test.TEST) - - androidTestImplementation("app.cash.turbine:turbine:0.7.0") - testImplementation("app.cash.turbine:turbine:0.7.0") + TURBINE } kapt { @@ -56,6 +54,5 @@ kapt { } moduleConfigurations { - //useJUnitRunner5 = true useRoboelectric = true } diff --git a/features/search/src/main/java/com/theteampotato/gifit/home/di/SearchModule.kt b/features/search/src/main/java/com/theteampotato/gifit/home/di/SearchModule.kt index 281afef..7c45a19 100644 --- a/features/search/src/main/java/com/theteampotato/gifit/home/di/SearchModule.kt +++ b/features/search/src/main/java/com/theteampotato/gifit/home/di/SearchModule.kt @@ -1,13 +1,16 @@ package com.theteampotato.gifit.home.di import com.theteampotato.gifit.testing.DispatcherProvider + import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import kotlinx.coroutines.Dispatchers + import javax.inject.Singleton +import kotlinx.coroutines.Dispatchers + @Module @InstallIn(SingletonComponent::class) object SearchModule { diff --git a/features/search/src/main/java/com/theteampotato/gifit/home/view/SearchScreen.kt b/features/search/src/main/java/com/theteampotato/gifit/home/view/SearchScreen.kt index f2c921c..e7f6a15 100644 --- a/features/search/src/main/java/com/theteampotato/gifit/home/view/SearchScreen.kt +++ b/features/search/src/main/java/com/theteampotato/gifit/home/view/SearchScreen.kt @@ -9,11 +9,13 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel + import com.theteampotato.gifit.home.R import com.theteampotato.gifit.home.viewmodel.SearchViewModel import com.theteampotato.gifit.ui.view.GIFitLoader import com.theteampotato.gifit.ui.view.GIFitSearchBar import com.theteampotato.gifit.ui.view.ResultCard + import timber.log.Timber @Composable diff --git a/features/splash/build.gradle.kts b/features/splash/build.gradle.kts index 47ac975..03097ee 100644 --- a/features/splash/build.gradle.kts +++ b/features/splash/build.gradle.kts @@ -27,14 +27,9 @@ dependencies { ANDROID_TEST COMPOSE_UI_TEST COROUTINES_TEST - LOCAL_TEST_JUNIT5 TESTING } kapt { correctErrorTypes = true -} - -moduleConfigurations { - useJUnitRunner5 = true } \ No newline at end of file diff --git a/features/splash/src/androidTest/kotlin/com/theteampotato/gifit/splash/SplashViewTest.kt b/features/splash/src/androidTest/kotlin/com/theteampotato/gifit/splash/SplashViewTest.kt deleted file mode 100644 index be5b2cb..0000000 --- a/features/splash/src/androidTest/kotlin/com/theteampotato/gifit/splash/SplashViewTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.theteampotato.gifit.splash - -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.compose.ui.test.onNodeWithText - -import com.theteampotato.gifit.splash.view.SplashScreen -import com.theteampotato.gifit.ui.GIFitTheme - -import org.junit.Before -import org.junit.Rule -import org.junit.Test - -class SplashViewTest { - - @get:Rule - val composeTestRule = createComposeRule() - - @Before - fun setUp() { - composeTestRule.setContent { - GIFitTheme { - SplashScreen() - } - } - } - - @Test - fun splash_card_contains_app_name() { - composeTestRule.onNodeWithText("GIFit").assertExists() - } - -} \ No newline at end of file diff --git a/features/splash/src/main/kotlin/com/theteampotato/gifit/splash/view/SplashScreen.kt b/features/splash/src/main/kotlin/com/theteampotato/gifit/splash/view/SplashScreen.kt deleted file mode 100644 index 9e768f2..0000000 --- a/features/splash/src/main/kotlin/com/theteampotato/gifit/splash/view/SplashScreen.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.theteampotato.gifit.splash.view - -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier - -import com.theteampotato.gifit.ui.view.GIFitSplashCard - -@Composable -fun SplashScreen() { - Surface(color = MaterialTheme.colors.background, modifier = Modifier.fillMaxSize()) { - GIFitSplashCard() - } -} \ No newline at end of file diff --git a/layers/data/build.gradle.kts b/layers/data/build.gradle.kts index 1d2997e..3a125c4 100644 --- a/layers/data/build.gradle.kts +++ b/layers/data/build.gradle.kts @@ -26,8 +26,4 @@ dependencies { kapt { correctErrorTypes = true -} - -moduleConfigurations { - useJUnitRunner5 = true } \ No newline at end of file diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/DeviceManager.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/DeviceManager.kt index 94c27c1..08dcbe0 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/DeviceManager.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/DeviceManager.kt @@ -1,20 +1,12 @@ package com.theteampotato.gifit.data import android.content.res.Resources -import android.os.Build object DeviceManager { val language: String get() = getDeviceLanguage() - private fun getDeviceLanguage(): String { - val locale = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) - Resources.getSystem().configuration.locale - else - Resources.getSystem().configuration.locales[0] - - return locale.language - } + private fun getDeviceLanguage() = Resources.getSystem().configuration.locales[0].language } \ No newline at end of file diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/LocaleManager.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/LocaleManager.kt index f0aa922..36019a6 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/LocaleManager.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/LocaleManager.kt @@ -2,15 +2,19 @@ package com.theteampotato.gifit.data import android.content.Context import android.content.res.Configuration + import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit + import com.theteampotato.gifit.data.datastore.APP_LANGUAGE -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.flow.map + import java.util.* import javax.inject.Inject +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.map + class LocaleManager @Inject constructor( private val activityContext: Context, private val preferencesDataStore: DataStore diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/datastore/LocalDataStore.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/datastore/LocalDataStore.kt index 713c3a8..df47bc7 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/datastore/LocalDataStore.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/datastore/LocalDataStore.kt @@ -1,6 +1,7 @@ package com.theteampotato.gifit.data.datastore import android.content.Context + import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.stringPreferencesKey diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/di/KtorModule.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/di/KtorModule.kt index 41591a9..df425c0 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/di/KtorModule.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/di/KtorModule.kt @@ -7,14 +7,14 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + import io.ktor.client.* import io.ktor.client.engine.android.* import io.ktor.client.features.json.* import io.ktor.client.features.json.serializer.* import io.ktor.client.features.logging.* -import javax.inject.Singleton - @Module @InstallIn(SingletonComponent::class) object KtorModule { @@ -25,8 +25,6 @@ object KtorModule { engine { connectTimeout = 100_000 socketTimeout = 100_000 - - // proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress("localhost", serverPort)) } install(JsonFeature) { serializer = KotlinxSerializer(json = kotlinx.serialization.json.Json { diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/di/RepositoryModule.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/di/RepositoryModule.kt index aa0ea50..dc08e8b 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/di/RepositoryModule.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/di/RepositoryModule.kt @@ -1,31 +1,25 @@ package com.theteampotato.gifit.data.di import android.content.Context + import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences + import com.theteampotato.gifit.data.LocaleManager import com.theteampotato.gifit.data.datastore.preferencesDataStore + import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent + import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) object RepositoryModule { - /*@Provides - @ViewModelScoped - fun provideGIFitLocalRepository(localDataSource: LocalDataSource): GIFitLocalRepository { - return GIFitLocalRepository(localDataSource) - }*/ - -// @Provides -// @ViewModelScoped -// fun provideGIFitRemoteRepository(giphyService: GiphyService) = GIFitRemoteRepository(giphyService) - @Provides @Singleton fun providesPreferencesDataStore(@ApplicationContext context: Context) = diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/di/RoomModule.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/di/RoomModule.kt index 93f7fc6..7f90034 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/di/RoomModule.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/di/RoomModule.kt @@ -1,12 +1,15 @@ package com.theteampotato.gifit.data.di import android.content.Context + import com.theteampotato.gifit.data.local.database.GIFitRoomDatabase + import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent + import javax.inject.Singleton @Module diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/local/dao/SearchResultDao.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/local/dao/SearchResultDao.kt index 2222182..3521bed 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/local/dao/SearchResultDao.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/local/dao/SearchResultDao.kt @@ -3,7 +3,9 @@ package com.theteampotato.gifit.data.local.dao import androidx.lifecycle.LiveData import androidx.room.Dao import androidx.room.Query + import com.theteampotato.gifit.data.local.entity.SearchResultEntity + import kotlinx.coroutines.flow.Flow @Dao diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/local/database/GIFitRoomDatabase.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/local/database/GIFitRoomDatabase.kt index 6f01a62..07721fc 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/local/database/GIFitRoomDatabase.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/local/database/GIFitRoomDatabase.kt @@ -1,9 +1,11 @@ package com.theteampotato.gifit.data.local.database import android.content.Context + import androidx.room.Database import androidx.room.Room import androidx.room.RoomDatabase + import com.theteampotato.gifit.data.local.dao.SearchResultDao import com.theteampotato.gifit.data.local.entity.SearchResultEntity diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/LocalDataSource.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/LocalDataSource.kt index 986f462..00b3d3b 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/LocalDataSource.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/LocalDataSource.kt @@ -1,11 +1,14 @@ package com.theteampotato.gifit.data.local.datasource import androidx.lifecycle.LiveData + import com.theteampotato.gifit.data.local.dao.SearchResultDao import com.theteampotato.gifit.data.local.entity.SearchResultEntity -import kotlinx.coroutines.flow.Flow + import javax.inject.Inject +import kotlinx.coroutines.flow.Flow + class LocalDataSource @Inject constructor( private val searchResultDao: SearchResultDao ) : ILocalDataSource { diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/GIFitLocalRepository.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/GIFitLocalRepository.kt index 0fda741..f48a092 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/GIFitLocalRepository.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/GIFitLocalRepository.kt @@ -1,11 +1,14 @@ package com.theteampotato.gifit.data.local.repository import androidx.lifecycle.LiveData + import com.theteampotato.gifit.data.local.datasource.LocalDataSource import com.theteampotato.gifit.data.local.entity.SearchResultEntity -import kotlinx.coroutines.flow.Flow + import javax.inject.Inject +import kotlinx.coroutines.flow.Flow + class GIFitLocalRepository @Inject constructor( private val localDataSource: LocalDataSource ) : BaseLocalRepository { diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/remote/GiphyService.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/remote/GiphyService.kt index ebab5d9..dcd40ed 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/remote/GiphyService.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/remote/GiphyService.kt @@ -1,6 +1,7 @@ package com.theteampotato.gifit.data.remote import com.theteampotato.gifit.data.remote.model.GiphyResponse + import javax.inject.Inject private const val BASE_URL = "https://api.giphy.com/v1/gifs" diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/remote/Ktor.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/remote/Ktor.kt index b5e6fca..62c56b6 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/remote/Ktor.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/remote/Ktor.kt @@ -3,11 +3,11 @@ package com.theteampotato.gifit.data.remote import io.ktor.client.* import io.ktor.client.request.* +import javax.inject.Inject + import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext -import javax.inject.Inject - class Ktor @Inject constructor(val client: HttpClient) { suspend inline fun executeGetRequest(urlString: String) = diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/remote/repository/GIFitRemoteRepository.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/remote/repository/GIFitRemoteRepository.kt index 474568d..d217eca 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/remote/repository/GIFitRemoteRepository.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/remote/repository/GIFitRemoteRepository.kt @@ -1,6 +1,7 @@ package com.theteampotato.gifit.data.remote.repository import com.theteampotato.gifit.data.remote.GiphyService + import javax.inject.Inject class GIFitRemoteRepository @Inject constructor(private val giphyService: GiphyService) { diff --git a/layers/domain/build.gradle.kts b/layers/domain/build.gradle.kts index 0e57bd4..8b08265 100644 --- a/layers/domain/build.gradle.kts +++ b/layers/domain/build.gradle.kts @@ -18,8 +18,4 @@ dependencies { kapt { correctErrorTypes = true -} - -moduleConfigurations { - useJUnitRunner5 = true } \ No newline at end of file diff --git a/layers/domain/src/main/java/com/theteampotato/gifit/domain/di/UseCaseModule.kt b/layers/domain/src/main/java/com/theteampotato/gifit/domain/di/UseCaseModule.kt index d0d2764..055f2c2 100644 --- a/layers/domain/src/main/java/com/theteampotato/gifit/domain/di/UseCaseModule.kt +++ b/layers/domain/src/main/java/com/theteampotato/gifit/domain/di/UseCaseModule.kt @@ -1,8 +1,8 @@ package com.theteampotato.gifit.domain.di import android.content.Context + import androidx.datastore.core.DataStore -import androidx.datastore.dataStore import androidx.datastore.preferences.core.Preferences import com.theteampotato.gifit.domain.usecase.DownloadTranslationModel @@ -15,6 +15,7 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent + import javax.inject.Singleton @Module diff --git a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/AddSearchResultEntry.kt b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/AddSearchResultEntry.kt index 41585eb..f970109 100644 --- a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/AddSearchResultEntry.kt +++ b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/AddSearchResultEntry.kt @@ -2,6 +2,7 @@ package com.theteampotato.gifit.domain.usecase import com.theteampotato.gifit.data.local.entity.SearchResultEntity import com.theteampotato.gifit.data.local.repository.GIFitLocalRepository + import javax.inject.Inject class AddSearchResultEntry @Inject constructor( diff --git a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/AddSearchResultToFavorites.kt b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/AddSearchResultToFavorites.kt index 9db2b07..0a25623 100644 --- a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/AddSearchResultToFavorites.kt +++ b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/AddSearchResultToFavorites.kt @@ -1,10 +1,6 @@ package com.theteampotato.gifit.domain.usecase import com.theteampotato.gifit.data.local.repository.GIFitLocalRepository -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext -import timber.log.Timber import javax.inject.Inject class AddSearchResultToFavorites @Inject constructor( diff --git a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/BaseUseCase.kt b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/BaseUseCase.kt index 9c0c7e7..0ebfe01 100644 --- a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/BaseUseCase.kt +++ b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/BaseUseCase.kt @@ -1,9 +1,9 @@ package com.theteampotato.gifit.domain.usecase +import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job -import kotlin.coroutines.CoroutineContext open class BaseUseCase : CoroutineScope { private var parentJob = Job() diff --git a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/DownloadTranslationModel.kt b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/DownloadTranslationModel.kt index 4c5882e..9a40b12 100644 --- a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/DownloadTranslationModel.kt +++ b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/DownloadTranslationModel.kt @@ -1,7 +1,9 @@ package com.theteampotato.gifit.domain.usecase import android.content.Context + import com.theteampotato.gifit.translate.GoogleMLKitTranslator + import java.lang.Exception import javax.inject.Inject diff --git a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/GetSelectedLanguage.kt b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/GetSelectedLanguage.kt index f5b3fd7..580540d 100644 --- a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/GetSelectedLanguage.kt +++ b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/GetSelectedLanguage.kt @@ -2,10 +2,13 @@ package com.theteampotato.gifit.domain.usecase import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences + import com.theteampotato.gifit.data.datastore.SELECTED_LANGUAGE + +import javax.inject.Inject + import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map -import javax.inject.Inject class GetSelectedLanguage @Inject constructor(private val preferencesDataStore: DataStore) { diff --git a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/IsSearchResultExist.kt b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/IsSearchResultExist.kt index c86e51c..ccad514 100644 --- a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/IsSearchResultExist.kt +++ b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/IsSearchResultExist.kt @@ -2,7 +2,9 @@ package com.theteampotato.gifit.domain.usecase import com.theteampotato.gifit.data.local.entity.SearchResultEntity import com.theteampotato.gifit.data.local.repository.GIFitLocalRepository + import javax.inject.Inject + import kotlinx.coroutines.flow.Flow class IsSearchResultExist @Inject constructor( diff --git a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/ReadText.kt b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/ReadText.kt index 0bc4ec9..ecf7ead 100644 --- a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/ReadText.kt +++ b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/ReadText.kt @@ -2,6 +2,7 @@ package com.theteampotato.gifit.domain.usecase import android.content.Context import android.speech.tts.TextToSpeech + import java.util.* import javax.inject.Inject diff --git a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/SetSelectedLanguage.kt b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/SetSelectedLanguage.kt index 65491b5..12943f6 100644 --- a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/SetSelectedLanguage.kt +++ b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/SetSelectedLanguage.kt @@ -3,7 +3,9 @@ package com.theteampotato.gifit.domain.usecase import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit + import com.theteampotato.gifit.data.datastore.SELECTED_LANGUAGE + import javax.inject.Inject class SetSelectedLanguage @Inject constructor(private val preferencesDataStore: DataStore) { diff --git a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/TranslateText.kt b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/TranslateText.kt index 9c57927..72df795 100644 --- a/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/TranslateText.kt +++ b/layers/domain/src/main/java/com/theteampotato/gifit/domain/usecase/TranslateText.kt @@ -3,14 +3,18 @@ package com.theteampotato.gifit.domain.usecase import android.content.Context import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences + import com.theteampotato.gifit.data.datastore.SELECTED_LANGUAGE import com.theteampotato.gifit.translate.GoogleMLKitTranslator -import kotlinx.coroutines.* -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.flow.map + import javax.inject.Inject + import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine +import kotlinx.coroutines.* +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.map + import timber.log.Timber class TranslateText @Inject constructor( diff --git a/layers/ui/build.gradle.kts b/layers/ui/build.gradle.kts index 8a24e9a..dc8dfa3 100644 --- a/layers/ui/build.gradle.kts +++ b/layers/ui/build.gradle.kts @@ -12,17 +12,14 @@ android { } dependencies { - implementation("androidx.navigation:navigation-common-ktx:2.4.1") ACCOMPANIST BASE COMPOSE KOTLIN_STANDARD_LIBRARY + LOTTIE_COMPOSE MATERIAL_DESIGN - SHOWKASE - - api("com.airbnb.android:lottie-compose:5.0.3") + NAVIGATION_COMMON_KTX ANDROID_TEST COROUTINES_TEST - LOCAL_TEST_JUNIT5 } \ No newline at end of file diff --git a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/NetworkImage.kt b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/NetworkImage.kt index e9a4e2f..b1cc956 100644 --- a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/NetworkImage.kt +++ b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/NetworkImage.kt @@ -1,58 +1,15 @@ package com.theteampotato.gifit.ui import android.os.Build.VERSION.SDK_INT -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import coil.ImageLoader import coil.compose.LocalImageLoader -import coil.compose.rememberImagePainter import coil.decode.GifDecoder import coil.decode.ImageDecoderDecoder -import coil.transform.RoundedCornersTransformation -import coil.transform.Transformation - -@Composable -fun NetworkImage( - url: String, - modifier: Modifier = Modifier, - contentScale: ContentScale = ContentScale.Crop, - transformation: Transformation = RoundedCornersTransformation(0f), - placeholderColor: Color? = MaterialTheme.colors.secondary -) { - val painter = rememberImagePainter(url) - - Image( - painter = painter, - contentDescription = null, - modifier = modifier, - contentScale = contentScale, -// fadeIn = true, -// requestBuilder = { -// // transformations(RoundedCornersTransformation(30f)) -// transformations(transformation) -// }, -// loading = { -// if (placeholderColor != null) { -// Spacer( -// modifier = Modifier -// .fillMaxSize() -// .background(placeholderColor) -// ) -// } -// } - ) -} @Composable fun ProvideImageLoader(content: @Composable () -> Unit) { diff --git a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitBottomNavBar.kt b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitBottomNavBar.kt index edb1daf..30d1f32 100644 --- a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitBottomNavBar.kt +++ b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitBottomNavBar.kt @@ -10,8 +10,10 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.navigation.NavDestination import androidx.navigation.NavDestination.Companion.hierarchy + import com.theteampotato.gifit.ui.BottomNavScreen import com.theteampotato.gifit.ui.getBottomNavigationScreenList + import timber.log.Timber @Composable diff --git a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitCards.kt b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitCards.kt index 2dfef1b..57116f7 100644 --- a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitCards.kt +++ b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitCards.kt @@ -1,7 +1,6 @@ package com.theteampotato.gifit.ui.view import androidx.compose.foundation.Image -import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.* @@ -28,6 +27,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp + import com.theteampotato.gifit.ui.babyBlue @Composable diff --git a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitList.kt b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitList.kt index 76ff8d3..da84f87 100644 --- a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitList.kt +++ b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitList.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp + import timber.log.Timber @Composable diff --git a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitLoaders.kt b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitLoaders.kt index 5ce0f0b..85d25b4 100644 --- a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitLoaders.kt +++ b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitLoaders.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp + import com.airbnb.lottie.compose.LottieAnimation import com.airbnb.lottie.compose.LottieCompositionSpec import com.airbnb.lottie.compose.LottieConstants diff --git a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/InfoTips.kt b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/InfoTips.kt index 4aa54b2..b21d6c4 100644 --- a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/InfoTips.kt +++ b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/InfoTips.kt @@ -12,8 +12,6 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.rounded.VolumeUp import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp diff --git a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/ResultCards.kt b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/ResultCards.kt index 147c6f9..9d9db4f 100644 --- a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/ResultCards.kt +++ b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/ResultCards.kt @@ -1,7 +1,6 @@ package com.theteampotato.gifit.ui.view import androidx.compose.foundation.Image -import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.* @@ -18,6 +17,7 @@ import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp + import coil.compose.rememberImagePainter @Composable diff --git a/testing/build.gradle.kts b/testing/build.gradle.kts index 6b58fc9..5fd1dc1 100644 --- a/testing/build.gradle.kts +++ b/testing/build.gradle.kts @@ -19,20 +19,9 @@ dependencies { implementation(Libraries.Test.AndroidX.JUNIT_RULES) implementation(Libraries.Test.JUNIT) - //implementation(Libraries.Test.MOCKK) implementation(Libraries.Test.TRUTH) - - /*implementation("org.junit.jupiter:junit-jupiter-api:5.3.2") - runtimeOnly("org.junit.jupiter:junit-jupiter-engine:5.3.2") - implementation("org.junit.jupiter:junit-jupiter-params:5.3.2") - runtimeOnly("org.junit.vintage:junit-vintage-engine:5.3.2")*/ } kapt { correctErrorTypes = true } - -/* -moduleConfigurations { - useJUnitRunner5 = true -}*/ diff --git a/translate/build.gradle.kts b/translate/build.gradle.kts index df0cdb0..f877c66 100644 --- a/translate/build.gradle.kts +++ b/translate/build.gradle.kts @@ -10,13 +10,8 @@ dependencies { ANDROID_TEST COROUTINES_TEST - LOCAL_TEST_JUNIT5 } kapt { correctErrorTypes = true -} - -moduleConfigurations { - useJUnitRunner5 = true } \ No newline at end of file diff --git a/translate/src/main/java/com/theteampotato/gifit/translate/GoogleMLKitTranslator.kt b/translate/src/main/java/com/theteampotato/gifit/translate/GoogleMLKitTranslator.kt index 5df1a5a..5c21884 100644 --- a/translate/src/main/java/com/theteampotato/gifit/translate/GoogleMLKitTranslator.kt +++ b/translate/src/main/java/com/theteampotato/gifit/translate/GoogleMLKitTranslator.kt @@ -11,7 +11,7 @@ import com.google.mlkit.nl.translate.TranslatorOptions import timber.log.Timber -class GoogleMLKitTranslator: ITranslator { +class GoogleMLKitTranslator { private lateinit var translator: Translator private lateinit var options: TranslatorOptions @@ -43,25 +43,18 @@ class GoogleMLKitTranslator: ITranslator { onSuccess: (String) -> Unit, onFailure: (Exception) -> Unit ) { - //try { - //downloadModels(onSuccess = { - try { - translator.translate(value) - .addOnSuccessListener(onSuccess) - .addOnFailureListener(onFailure) - } catch (e: Exception) { - onFailure(e) - } -// }, onFailure = onFailure) -/* } catch (e: Exception) { - Timber.e("Exception is $e") - }*/ + try { + translator.translate(value) + .addOnSuccessListener(onSuccess) + .addOnFailureListener(onFailure) + } catch (e: Exception) { + onFailure(e) + } } fun destroy() = translator.close() /** - * // TODO: Warn users about this issue in the app * Language models are around 30MB, so don't download them unnecessarily, and * only download them using Wi-Fi unless the user has specified otherwise. You * should also delete unneeded models. diff --git a/translate/src/main/java/com/theteampotato/gifit/translate/ITranslator.kt b/translate/src/main/java/com/theteampotato/gifit/translate/ITranslator.kt deleted file mode 100644 index 382946d..0000000 --- a/translate/src/main/java/com/theteampotato/gifit/translate/ITranslator.kt +++ /dev/null @@ -1,4 +0,0 @@ -package com.theteampotato.gifit.translate - -interface ITranslator { -} \ No newline at end of file