1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-28 11:35:48 +01:00

Adds plurals to a string of the Widget.

This commit is contained in:
vanous 2019-09-15 08:58:38 +02:00 committed by Andreas Shimokawa
parent 80db647692
commit 43bfa791ad
2 changed files with 10 additions and 2 deletions

View File

@ -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);
}

View File

@ -733,5 +733,11 @@
<string name="widget_20_minutes">20 minutes</string>
<string name="widget_1_hour">1 hour</string>
<string name="icon_placeholder" translatable="false">Icon</string>
<string name="widget_alarm_target_hours">%d hours</string>
<plurals name="widget_alarm_target_hours">
<item quantity="one">%d hour</item>
<item quantity="two">%d hours</item>
<item quantity="few">%d hours</item>
<item quantity="many">%d hours</item>
<item quantity="other">%d hours</item>
</plurals>
</resources>