Rewrite more plural handling of 'Minutes'

This commit is contained in:
Dr. Tobias Quathamer
2017-02-08 23:25:51 +01:00
parent 4e329adaca
commit 833cbf7302
3 changed files with 7 additions and 6 deletions
@@ -679,7 +679,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
if (minutes == 0) {
value = LocaleController.getString("Disabled", R.string.Disabled);
} else if (minutes < 60) {
value = LocaleController.formatPluralString("Minutes", minutes);
value = ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, minutes, minutes);
} else {
value = LocaleController.formatPluralString("Hours", minutes / 60);
}
@@ -371,9 +371,9 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
if (value == 0) {
return LocaleController.getString("Disabled", R.string.Disabled);
} else if (value == 1) {
return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 1));
return ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, 1, 1);
} else if (value == 2) {
return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 5));
return ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, 5, 5);
} else if (value == 3) {
return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 1));
} else if (value == 4) {
@@ -674,7 +674,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
if (UserConfig.autoLockIn == 0) {
val = LocaleController.formatString("Disabled", R.string.Disabled);
} else if (UserConfig.autoLockIn < 60 * 60) {
val = LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", UserConfig.autoLockIn / 60));
val = ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, UserConfig.autoLockIn / 60, UserConfig.autoLockIn / 60);
} else if (UserConfig.autoLockIn < 60 * 60 * 24) {
val = LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", (int) Math.ceil(UserConfig.autoLockIn / 60.0f / 60)));
} else {
@@ -583,7 +583,8 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
if (delta <= 0) {
val = LocaleController.getString("Enabled", R.string.Enabled);
} else if (delta < 60 * 60) {
val = LocaleController.formatString("WillUnmuteIn", R.string.WillUnmuteIn, LocaleController.formatPluralString("Minutes", delta / 60));
// @TODO: Maybe this should be reworded a bit.
val = mContext.getResources().getQuantityString(R.plurals.Minutes, delta / 60, delta / 60);
} else if (delta < 60 * 60 * 24) {
val = LocaleController.formatString("WillUnmuteIn", R.string.WillUnmuteIn, LocaleController.formatPluralString("Hours", (int) Math.ceil(delta / 60.0f / 60)));
} else if (delta < 60 * 60 * 24 * 365) {
@@ -629,7 +630,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
textCell.setTextAndValue(LocaleController.getString("SmartNotifications", R.string.SmartNotifications), LocaleController.getString("Disabled", R.string.Disabled), true);
} else {
String times = LocaleController.formatPluralString("Times", notifyMaxCount);
String minutes = LocaleController.formatPluralString("Minutes", notifyDelay / 60);
String minutes = ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, notifyDelay / 60, notifyDelay / 60);
textCell.setTextAndValue(LocaleController.getString("SmartNotifications", R.string.SmartNotifications), LocaleController.formatString("SmartNotificationsInfo", R.string.SmartNotificationsInfo, times, minutes), true);
}
}