diff --git a/app/build.gradle b/app/build.gradle index e182b715..f8d5dd31 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,12 +11,12 @@ apply plugin: 'com.mikepenz.aboutlibraries.plugin' android { namespace 'com.starry.greenstash' - compileSdk 34 + compileSdk 35 defaultConfig { applicationId "com.starry.greenstash" minSdk 24 - targetSdk 34 + targetSdk 35 versionCode 380 versionName "3.8.0" @@ -86,10 +86,10 @@ dependencies { // Android core components. implementation 'androidx.core:core-ktx:1.13.1' implementation 'androidx.appcompat:appcompat:1.7.0' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.2' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.3' implementation 'androidx.activity:activity-compose:1.9.0' - implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.8.2" - implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.8.2" + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.8.3" + implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3" implementation "androidx.navigation:navigation-compose:2.7.7" // Jetpack compose. implementation "androidx.compose.ui:ui" @@ -138,8 +138,8 @@ dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' // Testing components. testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' androidTestImplementation "androidx.compose.ui:ui-test-junit4" debugImplementation "androidx.compose.ui:ui-tooling" debugImplementation "androidx.compose.ui:ui-test-manifest" diff --git a/app/src/main/java/com/starry/greenstash/reminder/ReminderNotificationSender.kt b/app/src/main/java/com/starry/greenstash/reminder/ReminderNotificationSender.kt index c8a6d77a..e086c7b0 100644 --- a/app/src/main/java/com/starry/greenstash/reminder/ReminderNotificationSender.kt +++ b/app/src/main/java/com/starry/greenstash/reminder/ReminderNotificationSender.kt @@ -37,8 +37,8 @@ import com.starry.greenstash.database.goal.GoalPriority import com.starry.greenstash.reminder.receivers.ReminderDepositReceiver import com.starry.greenstash.reminder.receivers.ReminderDismissReceiver import com.starry.greenstash.utils.GoalTextUtils +import com.starry.greenstash.utils.NumberUtils import com.starry.greenstash.utils.PreferenceUtil -import com.starry.greenstash.utils.Utils /** @@ -94,8 +94,8 @@ class ReminderNotificationSender( notification.addAction( R.drawable.ic_notification_deposit, "${context.getString(R.string.deposit_button)} ${ - Utils.formatCurrency( - amount = Utils.roundDecimal(amountDay), + NumberUtils.formatCurrency( + amount = NumberUtils.roundDecimal(amountDay), currencyCode = defCurrency ) }", @@ -108,8 +108,8 @@ class ReminderNotificationSender( notification.addAction( R.drawable.ic_notification_deposit, "${context.getString(R.string.deposit_button)} ${ - Utils.formatCurrency( - amount = Utils.roundDecimal(amountSemiWeek), + NumberUtils.formatCurrency( + amount = NumberUtils.roundDecimal(amountSemiWeek), currencyCode = defCurrency ) }", @@ -122,8 +122,8 @@ class ReminderNotificationSender( notification.addAction( R.drawable.ic_notification_deposit, "${context.getString(R.string.deposit_button)} ${ - Utils.formatCurrency( - amount = Utils.roundDecimal(amountWeek), + NumberUtils.formatCurrency( + amount = NumberUtils.roundDecimal(amountWeek), currencyCode = defCurrency ) }", @@ -153,7 +153,12 @@ class ReminderNotificationSender( .setContentTitle(context.getString(R.string.notification_deposited_title)) .setContentText( context.getString(R.string.notification_deposited_desc) - .format(Utils.formatCurrency(Utils.roundDecimal(amount), defCurrency!!)) + .format( + NumberUtils.formatCurrency( + NumberUtils.roundDecimal(amount), + defCurrency!! + ) + ) ) .setStyle(NotificationCompat.BigTextStyle()) .setContentIntent(createActivityIntent()) diff --git a/app/src/main/java/com/starry/greenstash/reminder/receivers/ReminderDepositReceiver.kt b/app/src/main/java/com/starry/greenstash/reminder/receivers/ReminderDepositReceiver.kt index 585a6937..e65ff784 100644 --- a/app/src/main/java/com/starry/greenstash/reminder/receivers/ReminderDepositReceiver.kt +++ b/app/src/main/java/com/starry/greenstash/reminder/receivers/ReminderDepositReceiver.kt @@ -36,7 +36,7 @@ import com.starry.greenstash.database.transaction.TransactionDao import com.starry.greenstash.database.transaction.TransactionType import com.starry.greenstash.reminder.ReminderManager import com.starry.greenstash.reminder.ReminderNotificationSender -import com.starry.greenstash.utils.Utils +import com.starry.greenstash.utils.NumberUtils import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -85,7 +85,7 @@ class ReminderDepositReceiver : BroadcastReceiver() { ownerGoalId = it.goal.goalId, type = TransactionType.Deposit, timeStamp = System.currentTimeMillis(), - amount = Utils.roundDecimal(depositAmount), + amount = NumberUtils.roundDecimal(depositAmount), notes = "" ) ) diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/archive/composables/ArchiveScreen.kt b/app/src/main/java/com/starry/greenstash/ui/screens/archive/composables/ArchiveScreen.kt index d2d72a19..b7680f23 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/archive/composables/ArchiveScreen.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/archive/composables/ArchiveScreen.kt @@ -103,7 +103,7 @@ import com.starry.greenstash.ui.theme.greenstashFont import com.starry.greenstash.ui.theme.greenstashNumberFont import com.starry.greenstash.utils.Constants import com.starry.greenstash.utils.ImageUtils -import com.starry.greenstash.utils.Utils +import com.starry.greenstash.utils.NumberUtils import com.starry.greenstash.utils.weakHapticFeedback import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -257,7 +257,7 @@ private fun ArchivedLazyItem( ArchivedGoalItem( title = goalItem.goal.title, icon = goalIcon, - savedAmount = Utils.formatCurrency( + savedAmount = NumberUtils.formatCurrency( goalItem.getCurrentlySavedAmount(), defaultCurrency ), diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/dwscreen/DWViewModel.kt b/app/src/main/java/com/starry/greenstash/ui/screens/dwscreen/DWViewModel.kt index 4c94a1c2..2875e15a 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/dwscreen/DWViewModel.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/dwscreen/DWViewModel.kt @@ -10,6 +10,7 @@ import com.starry.greenstash.database.transaction.Transaction import com.starry.greenstash.database.transaction.TransactionDao import com.starry.greenstash.database.transaction.TransactionType import com.starry.greenstash.ui.screens.settings.DateStyle +import com.starry.greenstash.utils.NumberUtils import com.starry.greenstash.utils.PreferenceUtil import com.starry.greenstash.utils.Utils import dagger.hilt.android.lifecycle.HiltViewModel @@ -111,7 +112,7 @@ class DWViewModel @Inject constructor( } } - private fun amountToDouble(amount: String) = Utils.roundDecimal(amount.toDouble()) + private fun amountToDouble(amount: String) = NumberUtils.roundDecimal(amount.toDouble()) private suspend fun getGoalById(goalId: Long) = goalDao.getGoalById(goalId) diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/dwscreen/composables/DWScreen.kt b/app/src/main/java/com/starry/greenstash/ui/screens/dwscreen/composables/DWScreen.kt index a079230f..f9c59513 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/dwscreen/composables/DWScreen.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/dwscreen/composables/DWScreen.kt @@ -87,7 +87,7 @@ import com.starry.greenstash.ui.navigation.DrawerScreens import com.starry.greenstash.ui.navigation.Screens import com.starry.greenstash.ui.screens.dwscreen.DWViewModel import com.starry.greenstash.ui.theme.greenstashFont -import com.starry.greenstash.utils.Utils +import com.starry.greenstash.utils.NumberUtils import com.starry.greenstash.utils.validateAmount import com.starry.greenstash.utils.weakHapticFeedback import kotlinx.coroutines.CoroutineScope @@ -181,7 +181,7 @@ fun DWScreen(goalId: String, transactionTypeName: String, navController: NavCont notesValue = viewModel.state.notes, onAmountChange = { amount -> viewModel.state = - viewModel.state.copy(amount = Utils.getValidatedNumber(amount)) + viewModel.state.copy(amount = NumberUtils.getValidatedNumber(amount)) }, onNotesChange = { notes -> viewModel.state = viewModel.state.copy(notes = notes) diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/home/composables/GoalLazyItem.kt b/app/src/main/java/com/starry/greenstash/ui/screens/home/composables/GoalLazyItem.kt index 253f46bd..00ef6cc1 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/home/composables/GoalLazyItem.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/home/composables/GoalLazyItem.kt @@ -49,7 +49,7 @@ import com.starry.greenstash.ui.screens.home.HomeViewModel import com.starry.greenstash.utils.Constants import com.starry.greenstash.utils.GoalTextUtils import com.starry.greenstash.utils.ImageUtils -import com.starry.greenstash.utils.Utils +import com.starry.greenstash.utils.NumberUtils import com.starry.greenstash.utils.getActivity import com.starry.greenstash.utils.strongHapticFeedback import com.starry.greenstash.utils.weakHapticFeedback @@ -171,7 +171,7 @@ fun GoalLazyColumnItem( GoalItemCompact( title = item.goal.title, - savedAmount = Utils.formatCurrency( + savedAmount = NumberUtils.formatCurrency( item.getCurrentlySavedAmount(), viewModel.getDefaultCurrency() ), diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/info/InfoViewModel.kt b/app/src/main/java/com/starry/greenstash/ui/screens/info/InfoViewModel.kt index d808853d..63783b43 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/info/InfoViewModel.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/info/InfoViewModel.kt @@ -36,6 +36,7 @@ import com.starry.greenstash.database.transaction.Transaction import com.starry.greenstash.database.transaction.TransactionDao import com.starry.greenstash.database.transaction.TransactionType import com.starry.greenstash.ui.screens.settings.DateStyle +import com.starry.greenstash.utils.NumberUtils import com.starry.greenstash.utils.PreferenceUtil import com.starry.greenstash.utils.Utils import dagger.hilt.android.lifecycle.HiltViewModel @@ -95,7 +96,7 @@ class InfoViewModel @Inject constructor( val newTransaction = transaction.copy( type = TransactionType.valueOf(transactionType), timeStamp = Utils.getEpochTime(transactionTime), - amount = Utils.roundDecimal(editGoalState.amount.toDouble()), + amount = NumberUtils.roundDecimal(editGoalState.amount.toDouble()), notes = editGoalState.notes ) newTransaction.transactionId = transaction.transactionId diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/info/composables/EditTransactionSheet.kt b/app/src/main/java/com/starry/greenstash/ui/screens/info/composables/EditTransactionSheet.kt index 1f0e0a67..395a0cf6 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/info/composables/EditTransactionSheet.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/info/composables/EditTransactionSheet.kt @@ -69,7 +69,7 @@ import com.starry.greenstash.database.transaction.TransactionType import com.starry.greenstash.ui.common.DateTimeCard import com.starry.greenstash.ui.screens.info.InfoViewModel import com.starry.greenstash.ui.theme.greenstashFont -import com.starry.greenstash.utils.Utils +import com.starry.greenstash.utils.NumberUtils import com.starry.greenstash.utils.toToast import com.starry.greenstash.utils.validateAmount import kotlinx.coroutines.delay @@ -198,7 +198,7 @@ fun EditTransactionSheet( onValueChange = { newText -> viewModel.editGoalState = viewModel.editGoalState.copy( - amount = Utils.getValidatedNumber( + amount = NumberUtils.getValidatedNumber( newText ) ) diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/info/composables/GoalInfoScreen.kt b/app/src/main/java/com/starry/greenstash/ui/screens/info/composables/GoalInfoScreen.kt index 9a42ce3d..839c3a58 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/info/composables/GoalInfoScreen.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/info/composables/GoalInfoScreen.kt @@ -99,7 +99,7 @@ import com.starry.greenstash.ui.screens.info.InfoViewModel import com.starry.greenstash.ui.theme.greenstashFont import com.starry.greenstash.ui.theme.greenstashNumberFont import com.starry.greenstash.utils.GoalTextUtils -import com.starry.greenstash.utils.Utils +import com.starry.greenstash.utils.NumberUtils import com.starry.greenstash.utils.weakHapticFeedback import kotlinx.coroutines.delay @@ -238,9 +238,9 @@ fun GoalInfoCard( progress: Float ) { val formattedTargetAmount = - Utils.formatCurrency(Utils.roundDecimal(targetAmount), currencySymbol) + NumberUtils.formatCurrency(NumberUtils.roundDecimal(targetAmount), currencySymbol) val formattedSavedAmount = - Utils.formatCurrency(Utils.roundDecimal(savedAmount), currencySymbol) + NumberUtils.formatCurrency(NumberUtils.roundDecimal(savedAmount), currencySymbol) val animatedProgress = animateFloatAsState(targetValue = progress, label = "progress") Card( diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/input/InputViewModel.kt b/app/src/main/java/com/starry/greenstash/ui/screens/input/InputViewModel.kt index 8baaa51d..a10ef08f 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/input/InputViewModel.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/input/InputViewModel.kt @@ -43,8 +43,8 @@ import com.starry.greenstash.database.goal.GoalPriority import com.starry.greenstash.reminder.ReminderManager import com.starry.greenstash.ui.screens.settings.DateStyle import com.starry.greenstash.utils.ImageUtils +import com.starry.greenstash.utils.NumberUtils import com.starry.greenstash.utils.PreferenceUtil -import com.starry.greenstash.utils.Utils import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -107,7 +107,7 @@ class InputViewModel @Inject constructor( viewModelScope.launch(Dispatchers.IO) { val goal = Goal( title = state.goalTitleText, - targetAmount = Utils.roundDecimal(state.targetAmount.toDouble()), + targetAmount = NumberUtils.roundDecimal(state.targetAmount.toDouble()), deadline = state.deadline, goalImage = if (state.goalImageUri != null) ImageUtils.uriToBitmap( uri = state.goalImageUri!!, context = context, maxSize = 1024 @@ -152,7 +152,7 @@ class InputViewModel @Inject constructor( val goal = goalDao.getGoalById(goalId)!! val newGoal = Goal( title = state.goalTitleText, - targetAmount = Utils.roundDecimal(state.targetAmount.toDouble()), + targetAmount = NumberUtils.roundDecimal(state.targetAmount.toDouble()), deadline = state.deadline, goalImage = if (state.goalImageUri != null) ImageUtils.uriToBitmap( uri = state.goalImageUri!!, context = context, maxSize = 1024 diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/input/composables/InputScreen.kt b/app/src/main/java/com/starry/greenstash/ui/screens/input/composables/InputScreen.kt index 932213b6..144aa0a7 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/input/composables/InputScreen.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/input/composables/InputScreen.kt @@ -144,7 +144,7 @@ import com.starry.greenstash.ui.navigation.DrawerScreens import com.starry.greenstash.ui.screens.input.InputViewModel import com.starry.greenstash.ui.theme.greenstashFont import com.starry.greenstash.utils.ImageUtils -import com.starry.greenstash.utils.Utils +import com.starry.greenstash.utils.NumberUtils import com.starry.greenstash.utils.getActivity import com.starry.greenstash.utils.hasNotificationPermission import com.starry.greenstash.utils.toToast @@ -883,7 +883,7 @@ private fun InputTextFields( OutlinedTextField( value = targetAmount, - onValueChange = { newText -> onAmountChange(Utils.getValidatedNumber(newText)) }, + onValueChange = { newText -> onAmountChange(NumberUtils.getValidatedNumber(newText)) }, modifier = Modifier.fillMaxWidth(0.86f), label = { Text( diff --git a/app/src/main/java/com/starry/greenstash/utils/GoalTextUtils.kt b/app/src/main/java/com/starry/greenstash/utils/GoalTextUtils.kt index 096fffc4..0735a45d 100644 --- a/app/src/main/java/com/starry/greenstash/utils/GoalTextUtils.kt +++ b/app/src/main/java/com/starry/greenstash/utils/GoalTextUtils.kt @@ -87,8 +87,11 @@ object GoalTextUtils { "\n" + context.getString(R.string.currently_saved_complete) } text = text.format( - Utils.formatCurrency(goalItem.getCurrentlySavedAmount(), currencyCode = currencyCode), - Utils.formatCurrency(goalItem.goal.targetAmount, currencyCode = currencyCode) + NumberUtils.formatCurrency( + goalItem.getCurrentlySavedAmount(), + currencyCode = currencyCode + ), + NumberUtils.formatCurrency(goalItem.goal.targetAmount, currencyCode = currencyCode) ) return text } @@ -117,8 +120,8 @@ object GoalTextUtils { .format(calculatedDays.parsedEndDate, calculatedDays.remainingDays) + "\n" if (calculatedDays.remainingDays > 2) { text += context.getString(R.string.goal_approx_saving).format( - Utils.formatCurrency( - Utils.roundDecimal(remainingAmount / calculatedDays.remainingDays), + NumberUtils.formatCurrency( + NumberUtils.roundDecimal(remainingAmount / calculatedDays.remainingDays), currencyCode = currencyCode ) ) @@ -127,8 +130,8 @@ object GoalTextUtils { val weeks = calculatedDays.remainingDays / 7 text = text.dropLast(1) // remove full stop text += ", ${ - Utils.formatCurrency( - Utils.roundDecimal( + NumberUtils.formatCurrency( + NumberUtils.roundDecimal( remainingAmount / weeks ), currencyCode = currencyCode @@ -142,8 +145,8 @@ object GoalTextUtils { val months = calculatedDays.remainingDays / 30 text = text.dropLast(1) // remove full stop text += ", ${ - Utils.formatCurrency( - Utils.roundDecimal( + NumberUtils.formatCurrency( + NumberUtils.roundDecimal( remainingAmount / months ), currencyCode = currencyCode diff --git a/app/src/main/java/com/starry/greenstash/utils/Utils.kt b/app/src/main/java/com/starry/greenstash/utils/Utils.kt index 54ff5e32..842dc707 100644 --- a/app/src/main/java/com/starry/greenstash/utils/Utils.kt +++ b/app/src/main/java/com/starry/greenstash/utils/Utils.kt @@ -46,44 +46,6 @@ import java.util.TimeZone */ object Utils { - /** - * Get validated number from the text. - * - * @param text The text to validate - * @return The validated number - */ - @Deprecated( - "Use NumberUtils.getValidatedNumber instead", - ReplaceWith("NumberUtils.getValidatedNumber(text)") - ) - fun getValidatedNumber(text: String) = NumberUtils.getValidatedNumber(text) - - /** - * Round the decimal number to two decimal places. - * - * @param number The number to round - * @return The rounded number - */ - @Deprecated( - "Use NumberUtils.roundDecimal instead", - ReplaceWith("NumberUtils.roundDecimal(number)") - ) - fun roundDecimal(number: Double) = NumberUtils.roundDecimal(number) - - /** - * Format currency based on the currency code. - * - * @param amount The amount to format - * @param currencyCode The currency code - * @return The formatted currency - */ - @Deprecated( - "Use NumberUtils.formatCurrency instead", - ReplaceWith("NumberUtils.formatCurrency(amount, currencyCode)") - ) - fun formatCurrency(amount: Double, currencyCode: String) = - NumberUtils.formatCurrency(amount, currencyCode) - /** * Retrieves the appropriate authenticators based on the Android version. *