From 43bfa791addd433790e0dd6f1817aa889649b7f6 Mon Sep 17 00:00:00 2001 From: vanous Date: Sun, 15 Sep 2019 08:58:38 +0200 Subject: [PATCH] Adds plurals to a string of the Widget. --- .../gadgetbridge/activities/WidgetAlarmsActivity.java | 4 +++- app/src/main/res/values/strings.xml | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetAlarmsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetAlarmsActivity.java index a58924d2a..b7b54a13e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetAlarmsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetAlarmsActivity.java @@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.activities; import android.app.Activity; import android.content.Context; +import android.content.res.Resources; import android.os.Bundle; import android.os.Handler; import android.view.View; @@ -42,7 +43,8 @@ public class WidgetAlarmsActivity extends Activity implements View.OnClickListen int userSleepDuration = new ActivityUser().getSleepDuration(); textView = findViewById(R.id.alarm5); if (userSleepDuration > 0) { - textView.setText(String.format(this.getString(R.string.widget_alarm_target_hours), userSleepDuration)); + Resources res = getResources(); + textView.setText(String.format(res.getQuantityString(R.plurals.widget_alarm_target_hours, userSleepDuration, userSleepDuration))); } else { textView.setVisibility(View.GONE); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52cc533f8..b06e773b2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -733,5 +733,11 @@ 20 minutes 1 hour Icon - %d hours + + %d hour + %d hours + %d hours + %d hours + %d hours + \ No newline at end of file