From 06b046c1293cbcdc3d5f20f10480e9c3f664ff41 Mon Sep 17 00:00:00 2001 From: starry-shivam Date: Wed, 22 May 2024 13:02:38 +0530 Subject: [PATCH] Remove fullstop from duration text in widgets Signed-off-by: starry-shivam --- .idea/misc.xml | 2 +- .../java/com/starry/greenstash/widget/GoalWidget.kt | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 9f71c83d..0ad17cbd 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + 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 6b3aac89..1c24fb3a 100644 --- a/app/src/main/java/com/starry/greenstash/widget/GoalWidget.kt +++ b/app/src/main/java/com/starry/greenstash/widget/GoalWidget.kt @@ -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) @@ -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) } @@ -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) }