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

Commit

Permalink
Merge branch 'main' into fix-issue-3473
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigomatosc authored Sep 9, 2024
2 parents 6066070 + 485b6d4 commit c8e6aed
Show file tree
Hide file tree
Showing 135 changed files with 2,674 additions and 2,592 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automatic_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Create a Pull Request
uses: peter-evans/create-pull-request@v6
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Automatic release: v${{ env.NEW_VERSION_NAME }} (${{ env.NEW_VERSION_CODE }})"
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ dependencies {
implementation(projects.shared.data.core)
implementation(projects.shared.domain)
implementation(projects.shared.ui.navigation)
implementation(projects.shared.ui.core)
implementation(projects.temp.legacyCode)
implementation(projects.temp.oldDesign)
implementation(projects.widget.addTransaction)
Expand Down
34 changes: 28 additions & 6 deletions app/src/main/java/com/ivy/wallet/RootActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,22 @@ import com.google.android.material.timepicker.MaterialTimePicker
import com.google.android.material.timepicker.TimeFormat
import com.google.android.play.core.review.ReviewManagerFactory
import com.ivy.IvyNavGraph
import com.ivy.base.time.TimeConverter
import com.ivy.base.time.TimeProvider
import com.ivy.design.api.IvyUI
import com.ivy.domain.RootScreen
import com.ivy.home.customerjourney.CustomerJourneyCardsProvider
import com.ivy.legacy.Constants
import com.ivy.legacy.IvyWalletCtx
import com.ivy.legacy.appDesign
import com.ivy.legacy.utils.activityForResultLauncher
import com.ivy.legacy.utils.convertLocalToUTC
import com.ivy.legacy.utils.sendToCrashlytics
import com.ivy.legacy.utils.simpleActivityForResultLauncher
import com.ivy.legacy.utils.timeNowLocal
import com.ivy.navigation.Navigation
import com.ivy.navigation.NavigationRoot
import com.ivy.ui.R
import com.ivy.ui.time.TimeFormatter
import com.ivy.ui.time.impl.DateTimePicker
import com.ivy.wallet.ui.applocked.AppLockedScreen
import com.ivy.widget.balance.WalletBalanceWidgetReceiver
import com.ivy.widget.transaction.AddTransactionWidget
Expand All @@ -66,6 +68,18 @@ class RootActivity : AppCompatActivity(), RootScreen {
@Inject
lateinit var customerJourneyLogic: CustomerJourneyCardsProvider

@Inject
lateinit var timeConverter: TimeConverter

@Inject
lateinit var timeProvider: TimeProvider

@Inject
lateinit var timeFormatter: TimeFormatter

@Inject
lateinit var dateTimePicker: DateTimePicker

private lateinit var createFileLauncher: ActivityResultLauncher<String>
private lateinit var onFileCreated: (fileUri: Uri) -> Unit

Expand Down Expand Up @@ -110,7 +124,10 @@ class RootActivity : AppCompatActivity(), RootScreen {

true -> {
IvyUI(
design = appDesign(ivyContext)
design = appDesign(ivyContext),
timeConverter = timeConverter,
timeProvider = timeProvider,
timeFormatter = timeFormatter,
) {
AppLockedScreen(
onShowOSBiometricsModal = {
Expand All @@ -129,13 +146,18 @@ class RootActivity : AppCompatActivity(), RootScreen {
NavigationRoot(navigation = navigation) { screen ->
IvyUI(
design = appDesign(ivyContext),
includeSurface = screen?.isLegacy ?: true
includeSurface = screen?.isLegacy ?: true,
timeConverter = timeConverter,
timeProvider = timeProvider,
timeFormatter = timeFormatter,
) {
IvyNavGraph(screen)
}
}
}
}

dateTimePicker.Content()
}
}

Expand Down Expand Up @@ -186,7 +208,7 @@ class RootActivity : AppCompatActivity(), RootScreen {
private fun setupTimePicker() {
ivyContext.onShowTimePicker = { initialTime,
onTimePicked ->
val nowLocal = initialTime ?: timeNowLocal().toLocalTime()
val nowLocal = initialTime ?: timeProvider.localTimeNow()
val is24Hour = android.text.format.DateFormat.is24HourFormat(this)
val timeFormat = if (is24Hour) TimeFormat.CLOCK_24H else TimeFormat.CLOCK_12H

Expand All @@ -199,7 +221,7 @@ class RootActivity : AppCompatActivity(), RootScreen {
picker.show(supportFragmentManager, "timePicker")
picker.addOnPositiveButtonClickListener {
onTimePicked(
LocalTime.of(picker.hour, picker.minute).convertLocalToUTC().withSecond(0)
LocalTime.of(picker.hour, picker.minute).withSecond(0)
)
}
}
Expand Down
20 changes: 10 additions & 10 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlin = "2.0.0"
kotlin = "2.0.20"
kotlin-coroutines = "1.8.1"
ktor = "2.3.12"
arrow = "1.2.4"
Expand All @@ -8,25 +8,25 @@ kotest = "5.9.1"
compose = "1.6.8"
compose-material3 = "1.2.1"
glance = "1.1.0"
hilt = "2.51.1"
hilt = "2.52"
room = "2.6.1"
androidx-work = "2.9.0"
androidx-work = "2.9.1"
kotlinx-collections = "0.3.7"
paparazzi = "1.3.3"

# Android
min-sdk = "28"
compile-sdk = "34"
version-name = "2024.08.25"
version-code = "195"
version-name = "2024.09.08"
version-code = "197"
jvm-target = "17"


# Linters
detekt = "1.23.6" # https://detekt.dev/docs/gettingstarted/gradle/

[libraries]
android-gradle-plugin = { module = "com.android.tools.build:gradle", version = "8.5.1" }
android-gradle-plugin = { module = "com.android.tools.build:gradle", version = "8.5.2" }

# Kotlin
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
Expand Down Expand Up @@ -65,7 +65,7 @@ paparazzi = { module = "app.cash.paparazzi:paparazzi", version.ref = "paparazzi"
google-testparameterinjector = { module = "com.google.testparameterinjector:test-parameter-injector", version = "1.16" }

# Integartion (Android) testing
androidx-test-runner = { module = "androidx.test:runner", version = "1.6.1" }
androidx-test-runner = { module = "androidx.test:runner", version = "1.6.2" }
androidx-test-core = { module = "androidx.test:core-ktx", version = "1.6.1" }
androidx-test-ext = { module = "androidx.test.ext:junit-ktx", version = "1.2.1" }
mockk-android = { module = "io.mockk:mockk-android", version = "1.13.12" }
Expand Down Expand Up @@ -129,18 +129,18 @@ timber = { module = "com.jakewharton.timber:timber", version = "5.0.1" }
# Legacy
keval = { module = "com.notkamui.libs:keval", version = "1.1.1" }
opencsv-csv = { module = "com.opencsv:opencsv", version = "5.9" }
opencsv-apache-commons = { module = "org.apache.commons:commons-lang3", version = "3.15.0" }
opencsv-apache-commons = { module = "org.apache.commons:commons-lang3", version = "3.16.0" }

# Linters
detekt-gradle-plugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
detekt-ruleset-compiler = { module = "com.braisgabin.detekt:kotlin-compiler-wrapper", version = "0.0.4" }
detekt-ruleset-ktlint = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
detekt-ruleset-compose = { module = "io.nlopez.compose.rules:detekt", version = "0.4.5" }
detekt-ruleset-compose = { module = "io.nlopez.compose.rules:detekt", version = "0.4.10" }
detekt-ruleset-ivy-explicit = { module = "com.github.Ivy-Apps:detekt-explicit", version = "v0.0.8" }
slack-lint-compose = { module = "com.slack.lint.compose:compose-lint-checks", version = "1.3.1" }

# KSP
ksp-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version = "2.0.0-1.0.23" }
ksp-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version = "2.0.20-1.0.24" }

# Modules Graph
module-graph-plugin = { module = "com.jraska.module.graph.assertion:plugin", version = "2.6.0" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ data class AccountsState(
val totalBalanceWithoutExcluded: String,
val totalBalanceWithoutExcludedText: String,
val reorderVisible: Boolean,
val compactAccountsModeEnabled: Boolean
val compactAccountsModeEnabled: Boolean,
val hideTotalBalance: Boolean,
)
9 changes: 6 additions & 3 deletions screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ private fun BoxWithConstraintsScope.UI(
incomeLabel = stringResource(id = R.string.total_balance),
income = state.totalBalanceWithoutExcluded.toDoubleOrNull() ?: 0.00,
expensesLabel = stringResource(id = R.string.total_balance_excluded),
expenses = state.totalBalanceWithExcluded.toDoubleOrNull() ?: 0.00
expenses = state.totalBalanceWithExcluded.toDoubleOrNull() ?: 0.00,
hiddenMode = state.hideTotalBalance
)
}
Spacer(Modifier.height(16.dp))
Expand Down Expand Up @@ -413,7 +414,8 @@ private fun PreviewAccountsTabCompactModeDisabled(theme: Theme = Theme.LIGHT) {
totalBalanceWithoutExcluded = "25.54",
totalBalanceWithoutExcludedText = "BGN 25.54",
reorderVisible = false,
compactAccountsModeEnabled = false
compactAccountsModeEnabled = false,
hideTotalBalance = false
)
UI(state = state)
}
Expand Down Expand Up @@ -499,7 +501,8 @@ private fun PreviewAccountsTabCompactModeEnabled(theme: Theme = Theme.LIGHT) {
totalBalanceWithoutExcluded = "25.54",
totalBalanceWithoutExcludedText = "BGN 25.54",
reorderVisible = false,
compactAccountsModeEnabled = true
compactAccountsModeEnabled = true,
hideTotalBalance = false
)
UI(state = state)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.base.legacy.SharedPrefs
import com.ivy.base.time.TimeConverter
import com.ivy.base.time.TimeProvider
import com.ivy.data.DataObserver
import com.ivy.data.DataWriteEvent
import com.ivy.data.repository.AccountRepository
Expand Down Expand Up @@ -45,6 +47,8 @@ class AccountsViewModel @Inject constructor(
private val accountRepository: AccountRepository,
private val dataObserver: DataObserver,
private val features: Features,
private val timeProvider: TimeProvider,
private val timeConverter: TimeConverter,
) : ComposeViewModel<AccountsState, AccountsEvent>() {
private val baseCurrency = mutableStateOf("")
private val accountsData = mutableStateOf(listOf<AccountData>())
Expand Down Expand Up @@ -84,10 +88,16 @@ class AccountsViewModel @Inject constructor(
totalBalanceWithoutExcluded = getTotalBalanceWithoutExcluded(),
totalBalanceWithoutExcludedText = getTotalBalanceWithoutExcludedText(),
reorderVisible = getReorderVisible(),
compactAccountsModeEnabled = getCompactAccountsMode()
compactAccountsModeEnabled = getCompactAccountsMode(),
hideTotalBalance = getHideTotalBalance()
)
}

@Composable
private fun getHideTotalBalance(): Boolean {
return features.hideTotalBalance.asEnabledState()
}

@Composable
private fun getBaseCurrency(): String {
return baseCurrency.value
Expand Down Expand Up @@ -157,7 +167,7 @@ class AccountsViewModel @Inject constructor(
val period = com.ivy.legacy.data.model.TimePeriod.currentMonth(
startDayOfMonth = ivyContext.startDayOfMonth
) // this must be monthly
val range = period.toRange(ivyContext.startDayOfMonth)
val range = period.toRange(ivyContext.startDayOfMonth, timeConverter, timeProvider)

val baseCurrencyCode = baseCurrencyAct(Unit)
val accounts = accountRepository.findAll().toImmutableList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fun IncomeExpensesRow(
dividerColor: Color = UI.colors.medium,
incomeLabel: String = stringResource(R.string.income_uppercase),
expensesLabel: String = stringResource(R.string.expenses_uppercase),
hiddenMode: Boolean = false,
center: Boolean = true,
dividerSpacer: Dp? = null,
) {
Expand All @@ -47,7 +48,8 @@ fun IncomeExpensesRow(
label = incomeLabel,
amount = income,
currency = currency,
center = center
center = center,
hiddenMode = hiddenMode
)

if (center) {
Expand Down Expand Up @@ -79,7 +81,8 @@ fun IncomeExpensesRow(
label = expensesLabel,
amount = expenses,
currency = currency,
center = center
center = center,
hiddenMode = hiddenMode
)

if (center) {
Expand All @@ -94,7 +97,8 @@ private fun LabelAmountColumn(
amount: Double,
currency: String,
textColor: Color,
center: Boolean
center: Boolean,
hiddenMode: Boolean
) {
Column(
horizontalAlignment = if (center) Alignment.CenterHorizontally else Alignment.Start
Expand All @@ -115,7 +119,8 @@ private fun LabelAmountColumn(
AmountCurrencyB1(
textColor = textColor,
amount = amount,
currency = currency
currency = currency,
hideIncome = hiddenMode
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.base.time.TimeConverter
import com.ivy.base.time.TimeProvider
import com.ivy.ui.ComposeViewModel
import com.ivy.legacy.data.model.TimePeriod
import com.ivy.legacy.utils.ioThread
Expand All @@ -23,7 +25,9 @@ class BalanceViewModel @Inject constructor(
private val plannedPaymentsLogic: PlannedPaymentsLogic,
private val ivyContext: com.ivy.legacy.IvyWalletCtx,
private val baseCurrencyAct: BaseCurrencyAct,
private val calcWalletBalanceAct: CalcWalletBalanceAct
private val calcWalletBalanceAct: CalcWalletBalanceAct,
private val timeProvider: TimeProvider,
private val timeConverter: TimeConverter,
) : ComposeViewModel<BalanceState, BalanceEvent>() {

private val period = mutableStateOf(ivyContext.selectedPeriod)
Expand Down Expand Up @@ -69,7 +73,7 @@ class BalanceViewModel @Inject constructor(

plannedPaymentsAmount.doubleValue = ioThread {
plannedPaymentsLogic.plannedPaymentsAmountFor(
timePeriod.toRange(ivyContext.startDayOfMonth)
timePeriod.toRange(ivyContext.startDayOfMonth, timeConverter, timeProvider)
// + positive if Income > Expenses else - negative
) * if (numberOfMonthsAhead.intValue >= 0) {
numberOfMonthsAhead.intValue.toDouble()
Expand Down
Loading

0 comments on commit c8e6aed

Please sign in to comment.