Skip to content

Commit

Permalink
Remove fullstop from duration text in widgets
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam committed May 22, 2024
1 parent a6725cd commit 06b046c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions app/src/main/java/com/starry/greenstash/widget/GoalWidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ class GoalWidget : AppWidgetProvider() {
datePattern: String
) {
val remainingAmount = (goalItem.goal.targetAmount - goalItem.getCurrentlySavedAmount())
// Check if system locale is english to drop full stop in remaining days or weeks.
val localeEnglish = context.resources.configuration.locales[0].language == "en"

if (remainingAmount > 0f && goalItem.goal.deadline.isNotEmpty()) {
val calculatedDays = GoalTextUtils.calcRemainingDays(goalItem.goal, datePattern)
Expand All @@ -178,7 +180,9 @@ class GoalWidget : AppWidgetProvider() {
amount = Utils.roundDecimal(remainingAmount / calculatedDays.remainingDays),
currencyCode = defCurrency
)
}/${context.getString(R.string.goal_approx_saving_day)}"
}/${context.getString(R.string.goal_approx_saving_day)}".let {
if (localeEnglish) it.dropLast(1) else it
}
views.setCharSequence(R.id.widgetAmountDay, "setText", amountDays)
views.setViewVisibility(R.id.widgetAmountDay, View.VISIBLE)
}
Expand All @@ -189,7 +193,9 @@ class GoalWidget : AppWidgetProvider() {
amount = Utils.roundDecimal(remainingAmount / (calculatedDays.remainingDays / 7)),
currencyCode = defCurrency
)
}/${context.getString(R.string.goal_approx_saving_week)}"
}/${context.getString(R.string.goal_approx_saving_week)}".let {
if (localeEnglish) it.dropLast(1) else it
}
views.setCharSequence(R.id.widgetAmountWeek, "setText", amountWeeks)
views.setViewVisibility(R.id.widgetAmountWeek, View.VISIBLE)
}
Expand Down

0 comments on commit 06b046c

Please sign in to comment.