From 833cbf7302c79994ba4923bea151dbe92bc6acc0 Mon Sep 17 00:00:00 2001 From: "Dr. Tobias Quathamer" Date: Wed, 8 Feb 2017 23:25:51 +0100 Subject: [PATCH] Rewrite more plural handling of 'Minutes' --- .../java/com/b44t/ui/NotificationsSettingsActivity.java | 2 +- .../src/main/java/com/b44t/ui/PasscodeActivity.java | 6 +++--- .../main/java/com/b44t/ui/ProfileNotificationsActivity.java | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/MessengerProj/src/main/java/com/b44t/ui/NotificationsSettingsActivity.java b/MessengerProj/src/main/java/com/b44t/ui/NotificationsSettingsActivity.java index 0880633ae..f0331e5b2 100644 --- a/MessengerProj/src/main/java/com/b44t/ui/NotificationsSettingsActivity.java +++ b/MessengerProj/src/main/java/com/b44t/ui/NotificationsSettingsActivity.java @@ -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); } diff --git a/MessengerProj/src/main/java/com/b44t/ui/PasscodeActivity.java b/MessengerProj/src/main/java/com/b44t/ui/PasscodeActivity.java index 51d261e19..4bdeb4df8 100644 --- a/MessengerProj/src/main/java/com/b44t/ui/PasscodeActivity.java +++ b/MessengerProj/src/main/java/com/b44t/ui/PasscodeActivity.java @@ -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 { diff --git a/MessengerProj/src/main/java/com/b44t/ui/ProfileNotificationsActivity.java b/MessengerProj/src/main/java/com/b44t/ui/ProfileNotificationsActivity.java index b429369ea..524dbdf83 100644 --- a/MessengerProj/src/main/java/com/b44t/ui/ProfileNotificationsActivity.java +++ b/MessengerProj/src/main/java/com/b44t/ui/ProfileNotificationsActivity.java @@ -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); } }