Skip to content

Commit

Permalink
Bump target SDK to v35 (Android 15) (#151)
Browse files Browse the repository at this point in the history
* Bump target SDK to v35 (Android 15)
* Remove some depreciated util function calls
---------
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam authored Jul 20, 2024
1 parent 59a3e41 commit 1d17b95
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 81 deletions.
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


/**
Expand Down Expand Up @@ -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
)
}",
Expand All @@ -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
)
}",
Expand All @@ -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
)
}",
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = ""
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -257,7 +257,7 @@ private fun ArchivedLazyItem(
ArchivedGoalItem(
title = goalItem.goal.title,
icon = goalIcon,
savedAmount = Utils.formatCurrency(
savedAmount = NumberUtils.formatCurrency(
goalItem.getCurrentlySavedAmount(),
defaultCurrency
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -171,7 +171,7 @@ fun GoalLazyColumnItem(

GoalItemCompact(
title = item.goal.title,
savedAmount = Utils.formatCurrency(
savedAmount = NumberUtils.formatCurrency(
item.getCurrentlySavedAmount(),
viewModel.getDefaultCurrency()
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -198,7 +198,7 @@ fun EditTransactionSheet(
onValueChange = { newText ->
viewModel.editGoalState =
viewModel.editGoalState.copy(
amount = Utils.getValidatedNumber(
amount = NumberUtils.getValidatedNumber(
newText
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
19 changes: 11 additions & 8 deletions app/src/main/java/com/starry/greenstash/utils/GoalTextUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
)
)
Expand All @@ -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
Expand All @@ -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
Expand Down
38 changes: 0 additions & 38 deletions app/src/main/java/com/starry/greenstash/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 1d17b95

Please sign in to comment.