From f96802ce0b6248ae7528e8cc88b3f185fedf4cba Mon Sep 17 00:00:00 2001 From: "Emmanuele (WolfSolver)" Date: Sat, 28 Dec 2024 13:17:35 +0100 Subject: [PATCH] better string for transation --- .../java/com/money/manager/ex/adapter/AllDataAdapter.java | 7 +++++-- .../java/com/money/manager/ex/home/DashboardFragment.java | 5 ++++- app/src/main/res/values-it/strings.xml | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/money/manager/ex/adapter/AllDataAdapter.java b/app/src/main/java/com/money/manager/ex/adapter/AllDataAdapter.java index c7ce61447..73f095cee 100644 --- a/app/src/main/java/com/money/manager/ex/adapter/AllDataAdapter.java +++ b/app/src/main/java/com/money/manager/ex/adapter/AllDataAdapter.java @@ -47,6 +47,7 @@ import androidx.cursoradapter.widget.CursorAdapter; import info.javaperformance.money.Money; import info.javaperformance.money.MoneyFactory; +import timber.log.Timber; /** * Adapter for all_data query. The list of transactions (account/recurring). @@ -392,8 +393,10 @@ private void displayBalanceAmountOrDaysLeft(AllDataViewHolder holder, Cursor cur if (daysLeft == 0) { holder.txtBalance.setText(R.string.due_today); } else { - holder.txtBalance.setText(Math.abs(daysLeft) + " " + - context.getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue)); + boolean hasNumber = context.getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue).indexOf("%d") >= 0; + holder.txtBalance.setText( + String.format((hasNumber ? context.getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue) : "%d " + context.getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue)), + Math.abs(daysLeft))); } holder.txtBalance.setVisibility(View.VISIBLE); } diff --git a/app/src/main/java/com/money/manager/ex/home/DashboardFragment.java b/app/src/main/java/com/money/manager/ex/home/DashboardFragment.java index 55e4c51fd..2d47709b7 100644 --- a/app/src/main/java/com/money/manager/ex/home/DashboardFragment.java +++ b/app/src/main/java/com/money/manager/ex/home/DashboardFragment.java @@ -400,7 +400,10 @@ private View showTableLayoutUpComingTransactions(Cursor cursor) { int daysLeft = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.DAYSLEFT)); long currencyId = cursor.getLong(cursor.getColumnIndex(QueryBillDeposits.CURRENCYID)); String daysLeftText = ""; - daysLeftText = Math.abs(daysLeft) + " " + getString(daysLeft >= 0 ? R.string.days_remaining : R.string.days_overdue); + boolean hasNumber = getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue).indexOf("%d") >= 0; + daysLeftText = String.format( (hasNumber ? getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue) : "%d " + getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue) ), + Math.abs(daysLeft)); + TableRow row = createTableRow(new String[]{"" + payee + "", "" + currencyService.getCurrencyFormatted(currencyId, MoneyFactory.fromDouble(total)) + "", "" + daysLeftText + ""}, new Float[]{1f, null, 1f}, diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index a52ef5927..04d9056b3 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -237,8 +237,8 @@ Non sono state trovate transazioni pianificate. Per crearne una, toccare il pulsante verde piĆ¹. Inattivo Attiva - giorni scaduti! - giorni rimanenti + Scaduta da %d giorni! + %d giorni rimanenti Aggiungi/Modifica Transazione Pianificata Scadenza Prossima Scadenza diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 227bb96f4..3bfb225fa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -264,8 +264,8 @@ No scheduled transactions have been found. To create one, tap the green plus button. Inactive Activates - days overdue! - days remaining + %d days overdue! + %d days remaining New/Edit Scheduled Transaction Due Date Next Occurrence