Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #934 from ILIYANGERMANOV/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ILIYANGERMANOV authored May 23, 2022
2 parents 8f25efd + 80c5b8e commit 754935b
Show file tree
Hide file tree
Showing 166 changed files with 1,794 additions and 1,225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ import androidx.test.platform.app.InstrumentationRegistry
import androidx.work.Configuration
import androidx.work.impl.utils.SynchronousExecutor
import androidx.work.testing.WorkManagerTestInitHelper
import com.ivy.design.navigation.Navigation
import com.ivy.frp.test.TestIdlingResource
import com.ivy.frp.test.TestingContext
import com.ivy.frp.view.navigation.Navigation
import com.ivy.wallet.io.network.IvySession
import com.ivy.wallet.io.persistence.IvyRoomDatabase
import com.ivy.wallet.io.persistence.SharedPrefs
import com.ivy.wallet.ui.IvyWalletCtx
import com.ivy.wallet.ui.RootActivity
import com.ivy.wallet.utils.*
import com.ivy.wallet.utils.timeNowUTC
import com.ivy.wallet.utils.toEpochMilli
import com.ivy.wallet.utils.toEpochSeconds
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import kotlinx.coroutines.test.runTest
Expand Down
42 changes: 41 additions & 1 deletion app/src/main/java/com/ivy/wallet/AppModuleDI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.ivy.wallet
import android.content.Context
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.ivy.design.navigation.Navigation
import com.ivy.frp.view.navigation.Navigation
import com.ivy.wallet.android.billing.IvyBilling
import com.ivy.wallet.android.notification.NotificationService
import com.ivy.wallet.domain.deprecated.logic.*
Expand All @@ -21,6 +21,9 @@ import com.ivy.wallet.domain.deprecated.sync.uploader.*
import com.ivy.wallet.domain.pure.data.WalletDAOs
import com.ivy.wallet.io.network.*
import com.ivy.wallet.io.network.error.ErrorCode
import com.ivy.wallet.io.network.error.NetworkError
import com.ivy.wallet.io.network.error.RestError
import com.ivy.wallet.io.network.service.ExpImagesService
import com.ivy.wallet.io.persistence.IvyRoomDatabase
import com.ivy.wallet.io.persistence.SharedPrefs
import com.ivy.wallet.io.persistence.dao.*
Expand All @@ -30,8 +33,10 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.delay
import java.time.LocalDateTime
import javax.inject.Singleton
import kotlin.random.Random

@Module
@InstallIn(SingletonComponent::class)
Expand Down Expand Up @@ -734,4 +739,39 @@ object AppModuleDI {
sharedPrefs
)
}

@Provides
fun provideExpImagesService(): ExpImagesService = object : ExpImagesService {
override suspend fun fetchImages(): List<String> {
val randDelay = Random.nextLong(from = 300, until = 1500)
delay(randDelay)

val success = Random.nextBoolean()
return if (success) {
val res = mutableListOf<String>()

val images = listOf(
"https://stimg.cardekho.com/images/carexteriorimages/930x620/Lamborghini/Aventador/6721/Lamborghini-Aventador-SVJ/1621849426405/front-left-side-47.jpg",
"https://scuffedentertainment.com/wp-content/uploads/2021/11/what-car-suits-you-best-quiz.jpg",
"malformed_url",
"https://maserati.scene7.com/is/image/maserati/maserati/regional/us/models/my22/levante/22_LV_Trofeo_PS_T1_HomePage_1920x1080.jpg?\$1920x2000\$&fit=constrain",
"https://i.ytimg.com/vi/dip_8dmrcaU/maxresdefault.jpg",
"https://img.poki.com/cdn-cgi/image/quality=78,width=600,height=600,fit=cover,f=auto/94945631828bfdcf32a8ad0b79978913.png",
"https://pixelmedia.bg/wp-content/uploads/2021/08/Apple-Car.jpeg",
"https://www.teslarati.com/wp-content/uploads/2021/12/apple-car-patent.jpeg"
)

for (i in 0..50) {
res.addAll(images)
}

res
} else {
throw NetworkError(
restError = RestError(ErrorCode.UNKNOWN, "Random error")
)
}
}

}
}
2 changes: 2 additions & 0 deletions app/src/main/java/com/ivy/wallet/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ object Constants {
const val SWIPE_DOWN_THRESHOLD_OPEN_MORE_MENU = 200

const val SWIPE_UP_EXPANDED_THRESHOLD = 200

const val SUPPORT_EMAIL = "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ivy.wallet.domain.action.account

import com.ivy.fp.action.FPAction
import com.ivy.fp.action.thenMap
import com.ivy.frp.action.FPAction
import com.ivy.frp.action.thenMap
import com.ivy.wallet.domain.data.core.Transaction
import com.ivy.wallet.domain.pure.data.ClosedTimeRange
import com.ivy.wallet.io.persistence.dao.TransactionDao
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ivy.wallet.domain.action.account

import com.ivy.fp.action.FPAction
import com.ivy.fp.action.then
import com.ivy.frp.action.FPAction
import com.ivy.frp.then
import com.ivy.wallet.domain.data.core.Account
import com.ivy.wallet.io.persistence.dao.AccountDao
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ivy.wallet.domain.action.account

import com.ivy.fp.action.FPAction
import com.ivy.frp.action.FPAction
import com.ivy.wallet.domain.data.core.Account
import com.ivy.wallet.io.persistence.dao.AccountDao
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.ivy.wallet.domain.action.account

import arrow.core.nonEmptyListOf
import com.ivy.fp.action.FPAction
import com.ivy.fp.action.then
import com.ivy.frp.action.FPAction
import com.ivy.frp.then
import com.ivy.wallet.domain.data.core.Account
import com.ivy.wallet.domain.pure.data.ClosedTimeRange
import com.ivy.wallet.domain.pure.transaction.AccountValueFunctions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.ivy.wallet.domain.action.account

import arrow.core.nonEmptyListOf
import com.ivy.fp.action.FPAction
import com.ivy.fp.action.then
import com.ivy.frp.action.FPAction
import com.ivy.frp.then
import com.ivy.wallet.domain.data.core.Account
import com.ivy.wallet.domain.pure.data.ClosedTimeRange
import com.ivy.wallet.domain.pure.data.IncomeExpensePair
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ivy.wallet.domain.action.budget

import com.ivy.fp.action.FPAction
import com.ivy.fp.action.thenMap
import com.ivy.frp.action.FPAction
import com.ivy.frp.action.thenMap
import com.ivy.wallet.domain.data.core.Budget
import com.ivy.wallet.io.persistence.dao.BudgetDao
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ivy.wallet.domain.action.category

import com.ivy.fp.action.FPAction
import com.ivy.fp.action.thenMap
import com.ivy.frp.action.FPAction
import com.ivy.frp.action.thenMap
import com.ivy.wallet.domain.data.core.Category
import com.ivy.wallet.io.persistence.dao.CategoryDao
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ivy.wallet.domain.action.category

import com.ivy.fp.action.FPAction
import com.ivy.frp.action.FPAction
import com.ivy.wallet.domain.data.core.Category
import com.ivy.wallet.io.persistence.dao.CategoryDao
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ivy.wallet.domain.action.category

import com.ivy.fp.action.FPAction
import com.ivy.fp.action.then
import com.ivy.frp.action.FPAction
import com.ivy.frp.then
import com.ivy.wallet.domain.action.transaction.CalcTrnsIncomeExpenseAct
import com.ivy.wallet.domain.data.core.Account
import com.ivy.wallet.domain.data.core.Category
Expand All @@ -13,7 +13,7 @@ class CategoryIncomeWithAccountFiltersAct @Inject constructor(
private val calcTrnsIncomeExpenseAct: CalcTrnsIncomeExpenseAct
) : FPAction<CategoryIncomeWithAccountFiltersAct.Input, IncomeExpenseTransferPair>() {

override suspend fun Input.compose(): suspend () -> IncomeExpenseTransferPair = {
override suspend fun Input.compose(): suspend () -> IncomeExpenseTransferPair = suspend {
val accountFilterSet = accountFilterList.map { it.id }.toHashSet()
transactions.filter {
it.categoryId == category?.id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ivy.wallet.domain.action.category

import com.ivy.fp.action.FPAction
import com.ivy.fp.action.thenMap
import com.ivy.frp.action.FPAction
import com.ivy.frp.action.thenMap
import com.ivy.wallet.domain.data.core.Transaction
import com.ivy.wallet.domain.pure.data.ClosedTimeRange
import com.ivy.wallet.io.persistence.dao.TransactionDao
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ivy.wallet.domain.action.charts

import com.ivy.fp.action.FPAction
import com.ivy.frp.action.FPAction
import com.ivy.wallet.domain.action.wallet.CalcWalletBalanceAct
import com.ivy.wallet.domain.pure.charts.ChartPeriod
import com.ivy.wallet.domain.pure.charts.SingleChartPoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.ivy.wallet.domain.action.charts

import androidx.compose.ui.graphics.toArgb
import com.ivy.fp.Pure
import com.ivy.fp.SideEffect
import com.ivy.fp.action.FPAction
import com.ivy.fp.action.then
import com.ivy.fp.action.thenFilter
import com.ivy.fp.action.thenMap
import com.ivy.frp.Pure
import com.ivy.frp.SideEffect
import com.ivy.frp.action.FPAction
import com.ivy.frp.action.thenFilter
import com.ivy.frp.action.thenMap
import com.ivy.frp.then
import com.ivy.wallet.R
import com.ivy.wallet.domain.action.account.AccountsAct
import com.ivy.wallet.domain.action.category.CategoriesAct
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.ivy.wallet.domain.action.exchange

import arrow.core.Option
import com.ivy.fp.action.FPAction
import com.ivy.fp.then
import com.ivy.frp.action.FPAction
import com.ivy.frp.then
import com.ivy.wallet.domain.pure.exchange.ExchangeData
import com.ivy.wallet.domain.pure.exchange.exchange
import com.ivy.wallet.io.persistence.dao.ExchangeRateDao
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ivy.wallet.domain.action.global

import com.ivy.frp.action.FPAction
import com.ivy.frp.then
import com.ivy.wallet.io.persistence.SharedPrefs
import com.ivy.wallet.ui.IvyWalletCtx
import javax.inject.Inject

class StartDayOfMonthAct @Inject constructor(
private val sharedPrefs: SharedPrefs,
private val ivyWalletCtx: IvyWalletCtx
) : FPAction<Unit, Int>() {

override suspend fun Unit.compose(): suspend () -> Int = suspend {
sharedPrefs.getInt(SharedPrefs.START_DATE_OF_MONTH, 1)
} then { startDay ->
ivyWalletCtx.setStartDayOfMonth(startDay)
startDay
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.ivy.wallet.domain.action.global

import com.ivy.frp.action.FPAction
import com.ivy.frp.monad.Res
import com.ivy.frp.monad.thenIfSuccess
import com.ivy.wallet.io.persistence.SharedPrefs
import com.ivy.wallet.ui.IvyWalletCtx
import javax.inject.Inject

class UpdateStartDayOfMonthAct @Inject constructor(
private val sharedPrefs: SharedPrefs,
private val ivyWalletCtx: IvyWalletCtx
) : FPAction<Int, Res<String, Int>>() {

override suspend fun Int.compose(): suspend () -> Res<String, Int> = suspend {
val startDay = this

if (startDay in 1..31) {
Res.Ok(startDay)
} else {
Res.Err("Invalid start day $startDay. Start date must be between 1 and 31.")
}
} thenIfSuccess { startDay ->
sharedPrefs.putInt(SharedPrefs.START_DATE_OF_MONTH, startDay)
ivyWalletCtx.setStartDayOfMonth(startDay)
Res.Ok(startDay)
} thenIfSuccess { startDay ->
ivyWalletCtx.initSelectedPeriodInMemory(
startDayOfMonth = startDay,
forceReinitialize = true
)
Res.Ok(startDay)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ivy.wallet.domain.action.loan

import com.ivy.fp.action.FPAction
import com.ivy.frp.action.FPAction
import com.ivy.wallet.domain.data.core.Loan
import com.ivy.wallet.io.persistence.dao.LoanDao
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ivy.wallet.domain.action.loan

import com.ivy.fp.action.FPAction
import com.ivy.fp.action.thenMap
import com.ivy.frp.action.FPAction
import com.ivy.frp.action.thenMap
import com.ivy.wallet.domain.data.core.Loan
import com.ivy.wallet.io.persistence.dao.LoanDao
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ivy.wallet.domain.action.settings

import com.ivy.fp.action.FPAction
import com.ivy.frp.action.FPAction
import com.ivy.wallet.io.persistence.dao.SettingsDao
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ivy.wallet.domain.action.settings

import com.ivy.fp.action.FPAction
import com.ivy.frp.action.FPAction
import java.math.BigDecimal
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ivy.wallet.domain.action.settings

import com.ivy.fp.action.FPAction
import com.ivy.fp.action.then
import com.ivy.frp.action.FPAction
import com.ivy.frp.then
import com.ivy.wallet.domain.data.core.Settings
import com.ivy.wallet.io.persistence.dao.SettingsDao
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.ivy.wallet.domain.action.settings

import com.ivy.frp.action.FPAction
import com.ivy.wallet.domain.data.core.Settings
import com.ivy.wallet.io.persistence.dao.SettingsDao
import javax.inject.Inject

class UpdateSettingsAct @Inject constructor(
private val settingsDao: SettingsDao
) : FPAction<Settings, Settings>() {
override suspend fun Settings.compose(): suspend () -> Settings = suspend {
settingsDao.save(this.toEntity())
this
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ivy.wallet.domain.action.transaction

import com.ivy.fp.action.FPAction
import com.ivy.fp.action.thenMap
import com.ivy.frp.action.FPAction
import com.ivy.frp.action.thenMap
import com.ivy.wallet.domain.data.core.Transaction
import com.ivy.wallet.io.persistence.dao.TransactionDao
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.ivy.wallet.domain.action.transaction

import arrow.core.nonEmptyListOf
import com.ivy.fp.action.FPAction
import com.ivy.fp.action.then
import com.ivy.fp.then
import com.ivy.frp.action.FPAction
import com.ivy.frp.then
import com.ivy.wallet.domain.action.exchange.ExchangeAct
import com.ivy.wallet.domain.action.exchange.actInput
import com.ivy.wallet.domain.data.core.Account
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ivy.wallet.domain.action.transaction

import com.ivy.fp.action.FPAction
import com.ivy.fp.action.thenMap
import com.ivy.frp.action.FPAction
import com.ivy.frp.action.thenMap
import com.ivy.wallet.domain.data.core.Transaction
import com.ivy.wallet.domain.pure.data.ClosedTimeRange
import com.ivy.wallet.io.persistence.dao.TransactionDao
Expand Down
Loading

0 comments on commit 754935b

Please sign in to comment.