diff --git a/app/src/main/java/com/starry/greenstash/MainViewModel.kt b/app/src/main/java/com/starry/greenstash/MainViewModel.kt index b2e2e3a..731c346 100644 --- a/app/src/main/java/com/starry/greenstash/MainViewModel.kt +++ b/app/src/main/java/com/starry/greenstash/MainViewModel.kt @@ -131,7 +131,7 @@ class MainViewModel @Inject constructor( }) }.build() - val shortCuts = listOf(newGoalShortcut) + topGoals.map { goal -> + val shortcuts = listOf(newGoalShortcut) + topGoals.map { goal -> val intent = Intent().apply { action = Intent.ACTION_VIEW data = Uri.parse("$LAUNCHER_SHORTCUT_SCHEME://goalId") @@ -145,7 +145,7 @@ class MainViewModel @Inject constructor( }.build() } - withContext(Dispatchers.Main) { onComplete(shortCuts) } + withContext(Dispatchers.Main) { onComplete(shortcuts) } } } diff --git a/app/src/main/java/com/starry/greenstash/widget/GoalWidget.kt b/app/src/main/java/com/starry/greenstash/widget/GoalWidget.kt index 31a1d10..5e11c58 100644 --- a/app/src/main/java/com/starry/greenstash/widget/GoalWidget.kt +++ b/app/src/main/java/com/starry/greenstash/widget/GoalWidget.kt @@ -45,7 +45,6 @@ import dagger.hilt.EntryPoints private const val WIDGET_MANUAL_REFRESH = "widget_manual_refresh" -private const val MAX_AMOUNT_DIGITS = 1000 private const val FULL_WIDGET_MIN_HEIGHT = 110 class GoalWidget : AppWidgetProvider() { @@ -117,14 +116,10 @@ class GoalWidget : AppWidgetProvider() { val datePattern = preferenceUtil.getString(PreferenceUtil.DATE_FORMAT_STR, "")!! val savedAmount = goalItem.getCurrentlySavedAmount().let { - if (it > MAX_AMOUNT_DIGITS) { - "${NumberUtils.getCurrencySymbol(defCurrency)}${NumberUtils.prettyCount(it)}" - } else NumberUtils.formatCurrency(it, defCurrency) + "${NumberUtils.getCurrencySymbol(defCurrency)}${NumberUtils.prettyCount(it)}" } val targetAmount = goalItem.goal.targetAmount.let { - if (it > MAX_AMOUNT_DIGITS) { - "${NumberUtils.getCurrencySymbol(defCurrency)}${NumberUtils.prettyCount(it)}" - } else NumberUtils.formatCurrency(it, defCurrency) + "${NumberUtils.getCurrencySymbol(defCurrency)}${NumberUtils.prettyCount(it)}" } val widgetDesc = context.getString(R.string.goal_widget_desc) .format("$savedAmount / $targetAmount") @@ -177,12 +172,9 @@ class GoalWidget : AppWidgetProvider() { // Calculate amount needed to save per day. val calcPerDayAmount = NumberUtils.roundDecimal(remainingAmount / calculatedDays.remainingDays) - // Build amount per day text by checking if the amount is greater than MAX_AMOUNT_DIGITS, - // if yes, then use prettyCount to format the amount. + // Build amount per day text using prettyCount to format the amount. val amountPerDayText = calcPerDayAmount.let { - if (it > MAX_AMOUNT_DIGITS) { - "${NumberUtils.getCurrencySymbol(defCurrency)}${NumberUtils.prettyCount(it)}" - } else NumberUtils.formatCurrency(it, defCurrency) + "${NumberUtils.getCurrencySymbol(defCurrency)}${NumberUtils.prettyCount(it)}" } + "/${context.getString(R.string.goal_approx_saving_day)}".let { if (localeEnglish) it.dropLast(1) else it } @@ -195,12 +187,9 @@ class GoalWidget : AppWidgetProvider() { // Calculate amount needed to save per week. val calcPerWeekAmount = NumberUtils.roundDecimal(remainingAmount / (calculatedDays.remainingDays / 7)) - // Build amount per week text by checking if the amount is greater than MAX_AMOUNT_DIGITS, - // if yes, then use prettyCount to format the amount. + // Build amount per week text using prettyCount to format the amount. val amountPerWeekText = calcPerWeekAmount.let { - if (it > MAX_AMOUNT_DIGITS) { - "${NumberUtils.getCurrencySymbol(defCurrency)}${NumberUtils.prettyCount(it)}" - } else NumberUtils.formatCurrency(it, defCurrency) + "${NumberUtils.getCurrencySymbol(defCurrency)}${NumberUtils.prettyCount(it)}" } + "/${context.getString(R.string.goal_approx_saving_week)}".let { if (localeEnglish) it.dropLast(1) else it }