Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -9967,6 +9967,7 @@ package android.content.res { method public java.lang.String getQuantityString(int, int, java.lang.Object...) throws android.content.res.Resources.NotFoundException; method public java.lang.String getQuantityString(int, int) throws android.content.res.Resources.NotFoundException; method public java.lang.CharSequence getQuantityText(int, int) throws android.content.res.Resources.NotFoundException; method public java.util.Locale getResolvedLocale(); method public java.lang.String getResourceEntryName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourceName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourcePackageName(int) throws android.content.res.Resources.NotFoundException; api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10328,6 +10328,7 @@ package android.content.res { method public java.lang.String getQuantityString(int, int, java.lang.Object...) throws android.content.res.Resources.NotFoundException; method public java.lang.String getQuantityString(int, int) throws android.content.res.Resources.NotFoundException; method public java.lang.CharSequence getQuantityText(int, int) throws android.content.res.Resources.NotFoundException; method public java.util.Locale getResolvedLocale(); method public java.lang.String getResourceEntryName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourceName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourcePackageName(int) throws android.content.res.Resources.NotFoundException; api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -9967,6 +9967,7 @@ package android.content.res { method public java.lang.String getQuantityString(int, int, java.lang.Object...) throws android.content.res.Resources.NotFoundException; method public java.lang.String getQuantityString(int, int) throws android.content.res.Resources.NotFoundException; method public java.lang.CharSequence getQuantityText(int, int) throws android.content.res.Resources.NotFoundException; method public java.util.Locale getResolvedLocale(); method public java.lang.String getResourceEntryName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourceName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourcePackageName(int) throws android.content.res.Resources.NotFoundException; core/java/android/content/res/Resources.java +23 −7 Original line number Diff line number Diff line Loading @@ -160,6 +160,7 @@ public class Resources { final DisplayMetrics mMetrics = new DisplayMetrics(); private final Configuration mConfiguration = new Configuration(); private Locale mResolvedLocale = null; private PluralRules mPluralRule; private CompatibilityInfo mCompatibilityInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO; Loading Loading @@ -314,6 +315,16 @@ public class Resources { } } /** * Return the Locale resulting from locale negotiation between the Resources and the * Configuration objects used to construct the Resources. The locale is used for retrieving * resources as well as for determining plural rules. */ @NonNull public Locale getResolvedLocale() { return mResolvedLocale; } /** * Return the string value associated with a particular resource ID. The * returned object will be a String if this is a plain string; it will be Loading Loading @@ -378,7 +389,7 @@ public class Resources { private PluralRules getPluralRule() { synchronized (sSync) { if (mPluralRule == null) { mPluralRule = PluralRules.forLocale(mConfiguration.getLocales().getPrimary()); mPluralRule = PluralRules.forLocale(mResolvedLocale); } return mPluralRule; } Loading Loading @@ -441,7 +452,7 @@ public class Resources { @NonNull public String getString(@StringRes int id, Object... formatArgs) throws NotFoundException { final String raw = getString(id); return String.format(mConfiguration.getLocales().getPrimary(), raw, formatArgs); return String.format(mResolvedLocale, raw, formatArgs); } /** Loading Loading @@ -472,7 +483,7 @@ public class Resources { public String getQuantityString(@PluralsRes int id, int quantity, Object... formatArgs) throws NotFoundException { String raw = getQuantityText(id, quantity).toString(); return String.format(mConfiguration.getLocales().getPrimary(), raw, formatArgs); return String.format(mResolvedLocale, raw, formatArgs); } /** Loading Loading @@ -1931,8 +1942,10 @@ public class Resources { mCompatibilityInfo.applyToDisplayMetrics(mMetrics); final int configChanges = calcConfigChanges(config); LocaleList locales = mConfiguration.getLocales(); if (locales.isEmpty()) { final boolean setLocalesToDefault = locales.isEmpty(); if (setLocalesToDefault) { locales = LocaleList.getDefault(); mConfiguration.setLocales(locales); } Loading Loading @@ -1961,9 +1974,12 @@ public class Resources { keyboardHidden = mConfiguration.keyboardHidden; } // TODO: Pass the whole locale list to setConfiguration() if (setLocalesToDefault || mResolvedLocale == null || (configChanges & Configuration.NATIVE_CONFIG_LOCALE) != 0) { mResolvedLocale = locales.getFirstMatch(mAssets.getLocales()); } mAssets.setConfiguration(mConfiguration.mcc, mConfiguration.mnc, adjustLanguageTag(locales.getPrimary().toLanguageTag()), adjustLanguageTag(mResolvedLocale.toLanguageTag()), mConfiguration.orientation, mConfiguration.touchscreen, mConfiguration.densityDpi, mConfiguration.keyboard, Loading @@ -1988,7 +2004,7 @@ public class Resources { } synchronized (sSync) { if (mPluralRule != null) { mPluralRule = PluralRules.forLocale(mConfiguration.getLocales().getPrimary()); mPluralRule = PluralRules.forLocale(mResolvedLocale); } } } Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -9967,6 +9967,7 @@ package android.content.res { method public java.lang.String getQuantityString(int, int, java.lang.Object...) throws android.content.res.Resources.NotFoundException; method public java.lang.String getQuantityString(int, int) throws android.content.res.Resources.NotFoundException; method public java.lang.CharSequence getQuantityText(int, int) throws android.content.res.Resources.NotFoundException; method public java.util.Locale getResolvedLocale(); method public java.lang.String getResourceEntryName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourceName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourcePackageName(int) throws android.content.res.Resources.NotFoundException;
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10328,6 +10328,7 @@ package android.content.res { method public java.lang.String getQuantityString(int, int, java.lang.Object...) throws android.content.res.Resources.NotFoundException; method public java.lang.String getQuantityString(int, int) throws android.content.res.Resources.NotFoundException; method public java.lang.CharSequence getQuantityText(int, int) throws android.content.res.Resources.NotFoundException; method public java.util.Locale getResolvedLocale(); method public java.lang.String getResourceEntryName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourceName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourcePackageName(int) throws android.content.res.Resources.NotFoundException;
api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -9967,6 +9967,7 @@ package android.content.res { method public java.lang.String getQuantityString(int, int, java.lang.Object...) throws android.content.res.Resources.NotFoundException; method public java.lang.String getQuantityString(int, int) throws android.content.res.Resources.NotFoundException; method public java.lang.CharSequence getQuantityText(int, int) throws android.content.res.Resources.NotFoundException; method public java.util.Locale getResolvedLocale(); method public java.lang.String getResourceEntryName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourceName(int) throws android.content.res.Resources.NotFoundException; method public java.lang.String getResourcePackageName(int) throws android.content.res.Resources.NotFoundException;
core/java/android/content/res/Resources.java +23 −7 Original line number Diff line number Diff line Loading @@ -160,6 +160,7 @@ public class Resources { final DisplayMetrics mMetrics = new DisplayMetrics(); private final Configuration mConfiguration = new Configuration(); private Locale mResolvedLocale = null; private PluralRules mPluralRule; private CompatibilityInfo mCompatibilityInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO; Loading Loading @@ -314,6 +315,16 @@ public class Resources { } } /** * Return the Locale resulting from locale negotiation between the Resources and the * Configuration objects used to construct the Resources. The locale is used for retrieving * resources as well as for determining plural rules. */ @NonNull public Locale getResolvedLocale() { return mResolvedLocale; } /** * Return the string value associated with a particular resource ID. The * returned object will be a String if this is a plain string; it will be Loading Loading @@ -378,7 +389,7 @@ public class Resources { private PluralRules getPluralRule() { synchronized (sSync) { if (mPluralRule == null) { mPluralRule = PluralRules.forLocale(mConfiguration.getLocales().getPrimary()); mPluralRule = PluralRules.forLocale(mResolvedLocale); } return mPluralRule; } Loading Loading @@ -441,7 +452,7 @@ public class Resources { @NonNull public String getString(@StringRes int id, Object... formatArgs) throws NotFoundException { final String raw = getString(id); return String.format(mConfiguration.getLocales().getPrimary(), raw, formatArgs); return String.format(mResolvedLocale, raw, formatArgs); } /** Loading Loading @@ -472,7 +483,7 @@ public class Resources { public String getQuantityString(@PluralsRes int id, int quantity, Object... formatArgs) throws NotFoundException { String raw = getQuantityText(id, quantity).toString(); return String.format(mConfiguration.getLocales().getPrimary(), raw, formatArgs); return String.format(mResolvedLocale, raw, formatArgs); } /** Loading Loading @@ -1931,8 +1942,10 @@ public class Resources { mCompatibilityInfo.applyToDisplayMetrics(mMetrics); final int configChanges = calcConfigChanges(config); LocaleList locales = mConfiguration.getLocales(); if (locales.isEmpty()) { final boolean setLocalesToDefault = locales.isEmpty(); if (setLocalesToDefault) { locales = LocaleList.getDefault(); mConfiguration.setLocales(locales); } Loading Loading @@ -1961,9 +1974,12 @@ public class Resources { keyboardHidden = mConfiguration.keyboardHidden; } // TODO: Pass the whole locale list to setConfiguration() if (setLocalesToDefault || mResolvedLocale == null || (configChanges & Configuration.NATIVE_CONFIG_LOCALE) != 0) { mResolvedLocale = locales.getFirstMatch(mAssets.getLocales()); } mAssets.setConfiguration(mConfiguration.mcc, mConfiguration.mnc, adjustLanguageTag(locales.getPrimary().toLanguageTag()), adjustLanguageTag(mResolvedLocale.toLanguageTag()), mConfiguration.orientation, mConfiguration.touchscreen, mConfiguration.densityDpi, mConfiguration.keyboard, Loading @@ -1988,7 +2004,7 @@ public class Resources { } synchronized (sSync) { if (mPluralRule != null) { mPluralRule = PluralRules.forLocale(mConfiguration.getLocales().getPrimary()); mPluralRule = PluralRules.forLocale(mResolvedLocale); } } } Loading