Skip to content

Commit

Permalink
Merge branch 'main' into export-tests-results-kiwi
Browse files Browse the repository at this point in the history
  • Loading branch information
acosta434 authored Dec 4, 2023
2 parents 18b7a0d + 40aaeb9 commit 9135bc1
Show file tree
Hide file tree
Showing 63 changed files with 1,135 additions and 469 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.fragment:fragment-ktx:1.4.1'
// Provides ARCore Session and related resources.
Expand Down Expand Up @@ -105,6 +105,7 @@ dependencies {
implementation "androidx.navigation:navigation-fragment-ktx:2.4.1"
implementation "androidx.navigation:navigation-ui-ktx:2.4.1"

implementation 'com.vmadalin:easypermissions-ktx:1.0.0'

implementation 'com.jakewharton.timber:timber:5.0.1'
implementation 'com.google.firebase:firebase-analytics:20.1.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.willowtree.vocable.presets.PresetCategories
import com.willowtree.vocable.utils.VocableSharedPreferences
import com.willowtree.vocable.utils.locale.LocalesWithText
import kotlinx.coroutines.test.runTest
import org.junit.Assert
import org.junit.Assert.assertEquals
Expand Down Expand Up @@ -322,15 +323,15 @@ class MigrationTest {
"custom",
0L,
null,
mapOf("english" to "custom"),
LocalesWithText( mapOf("english" to "custom")),
false,
7
),
CategoryDto(
"recents",
0L,
null,
mapOf("english" to "recents"),
LocalesWithText( mapOf("english" to "recents")),
false,
8
)
Expand All @@ -346,7 +347,7 @@ class MigrationTest {
"custom",
0L,
0L,
mapOf("english" to "hi"),
LocalesWithText( mapOf("english" to "hi")),
0
)
), customPhrases
Expand All @@ -358,7 +359,7 @@ class MigrationTest {
"recents",
0L,
0L,
mapOf("english" to "hi"),
LocalesWithText( mapOf("english" to "hi")),
0
)
), recentPhrases
Expand Down
29 changes: 18 additions & 11 deletions app/src/main/java/com/willowtree/vocable/AppKoinModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.willowtree.vocable

import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import com.willowtree.vocable.facetracking.FaceTrackingViewModel
import com.willowtree.vocable.presets.IPresetsRepository
import com.willowtree.vocable.presets.PresetCategoriesRepository
import com.willowtree.vocable.presets.PresetsRepository
Expand All @@ -12,27 +13,31 @@ import com.willowtree.vocable.room.StoredCategoriesRepository
import com.willowtree.vocable.settings.AddUpdateCategoryViewModel
import com.willowtree.vocable.settings.EditCategoriesViewModel
import com.willowtree.vocable.settings.EditCategoryMenuViewModel
import com.willowtree.vocable.utils.DateProvider
import com.willowtree.vocable.utils.ILocalizedResourceUtility
import com.willowtree.vocable.utils.JavaDateProvider
import com.willowtree.vocable.utils.JavaLocaleProvider
import com.willowtree.vocable.utils.LocaleProvider
import com.willowtree.vocable.utils.LocalizedResourceUtility
import com.willowtree.vocable.utils.RandomUUIDProvider
import com.willowtree.vocable.utils.UUIDProvider
import com.willowtree.vocable.utils.VocableSharedPreferences
import com.willowtree.vocable.settings.selectionmode.SelectionModeViewModel
import com.willowtree.vocable.utils.*
import com.willowtree.vocable.utils.locale.JavaLocaleProvider
import com.willowtree.vocable.utils.locale.LocaleProvider
import com.willowtree.vocable.utils.locale.LocalizedResourceUtility
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.bind
import org.koin.dsl.module

object AppKoinModule {

fun getModule() = module {
single { VocableSharedPreferences() }

scope<MainActivity> {
scoped {
FaceTrackingManager(get(), get())
}
}

single { FaceTrackingPermissions(get()) } bind IFaceTrackingPermissions::class
single { VocableSharedPreferences() } bind IVocableSharedPreferences::class
single { PresetsRepository(get()) } bind IPresetsRepository::class
single { Moshi.Builder().add(KotlinJsonAdapterFactory()).build() }
single { LocalizedResourceUtility() } bind ILocalizedResourceUtility::class
single { CategoriesUseCase(get(), get(), get(), get(), get(), get()) } bind ICategoriesUseCase::class
single { CategoriesUseCase(get(), get(), get(), get(), get()) } bind ICategoriesUseCase::class
single { PhrasesUseCase(get(), get()) }
single { RandomUUIDProvider() } bind UUIDProvider::class
single { JavaDateProvider() } bind DateProvider::class
Expand All @@ -43,5 +48,7 @@ object AppKoinModule {
viewModel { EditCategoriesViewModel(get(), get(), get()) }
viewModel { AddUpdateCategoryViewModel(get(), get(), get()) }
viewModel { EditCategoryMenuViewModel(get(), get()) }
viewModel { SelectionModeViewModel(get()) }
viewModel { FaceTrackingViewModel() }
}
}
15 changes: 6 additions & 9 deletions app/src/main/java/com/willowtree/vocable/CategoriesUseCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ import com.willowtree.vocable.presets.Category
import com.willowtree.vocable.presets.IPresetsRepository
import com.willowtree.vocable.presets.PresetCategoriesRepository
import com.willowtree.vocable.presets.asCategory
import com.willowtree.vocable.room.CategoryDto
import com.willowtree.vocable.room.CategorySortOrder
import com.willowtree.vocable.room.StoredCategoriesRepository
import com.willowtree.vocable.utils.DateProvider
import com.willowtree.vocable.utils.LocaleProvider
import com.willowtree.vocable.utils.UUIDProvider
import com.willowtree.vocable.utils.locale.LocaleProvider
import com.willowtree.vocable.utils.locale.LocalesWithText
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class CategoriesUseCase(
private val presetsRepository: IPresetsRepository,
private val uuidProvider: UUIDProvider,
private val dateProvider: DateProvider,
private val localeProvider: LocaleProvider,
private val storedCategoriesRepository: StoredCategoriesRepository,
private val presetCategoriesRepository: PresetCategoriesRepository
Expand All @@ -34,7 +32,7 @@ class CategoriesUseCase(

override suspend fun updateCategoryName(
categoryId: String,
localizedName: Map<String, String>
localizedName: LocalesWithText
) {
presetsRepository.updateCategoryName(categoryId, localizedName)
}
Expand All @@ -48,12 +46,11 @@ class CategoriesUseCase(
}

override suspend fun addCategory(categoryName: String, sortOrder: Int) {
presetsRepository.addCategory(
CategoryDto(
storedCategoriesRepository.addCategory(
Category.StoredCategory(
uuidProvider.randomUUIDString(),
dateProvider.currentTimeMillis(),
null,
mapOf(Pair(localeProvider.getDefaultLocaleString(), categoryName)),
LocalesWithText(mapOf(Pair(localeProvider.getDefaultLocaleString(), categoryName))),
false,
sortOrder
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package com.willowtree.vocable

import com.willowtree.vocable.presets.Category
import com.willowtree.vocable.room.CategorySortOrder
import com.willowtree.vocable.utils.locale.LocalesWithText
import kotlinx.coroutines.flow.Flow

interface ICategoriesUseCase {
fun categories(): Flow<List<Category>>
suspend fun updateCategoryName(categoryId: String, localizedName: Map<String, String>)
suspend fun updateCategoryName(categoryId: String, localizedName: LocalesWithText)
suspend fun addCategory(categoryName: String, sortOrder: Int)
suspend fun updateCategorySortOrders(categorySortOrders: List<CategorySortOrder>)
}
Loading

0 comments on commit 9135bc1

Please sign in to comment.