Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47f71a69 authored by Roozbeh Pournader's avatar Roozbeh Pournader
Browse files

Use the full locale list in resourceQualifierString().

Previously, only the first locale was dumped to the output in
android.content.res.Configuration#resourceQualifierString(). Now the full
locale list is part of the output.

Change-Id: I5d4b73738a14d48533ee96c38dbc6c4b204ea998
parent b444afc0
Loading
Loading
Loading
Loading
+22 −17
Original line number Diff line number Diff line
@@ -1505,14 +1505,19 @@ public final class Configuration implements Parcelable, Comparable<Configuration
     *
     * @hide
     */
    public static String localeToResourceQualifier(Locale loc) {
    public static String localesToResourceQualifier(LocaleList locs) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < locs.size(); i++) {
            Locale loc = locs.get(i);
            boolean l = (loc.getLanguage().length() != 0);
            boolean c = (loc.getCountry().length() != 0);
            boolean s = (loc.getScript().length() != 0);
            boolean v = (loc.getVariant().length() != 0);
            // TODO: take script and extensions into account
            if (l) {
                if (sb.length() != 0) {
                    sb.append(",");
                }
                sb.append(loc.getLanguage());
                if (c) {
                    sb.append("-r").append(loc.getCountry());
@@ -1524,6 +1529,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
                    }
                }
            }
        }
        return sb.toString();
    }

@@ -1544,9 +1550,8 @@ public final class Configuration implements Parcelable, Comparable<Configuration
            }
        }

        // TODO: send the whole locale list
        if (config.locale != null && !config.locale.getLanguage().isEmpty()) {
            parts.add(localeToResourceQualifier(config.locale));
        if (!config.mLocaleList.isEmpty()) {
            parts.add(localesToResourceQualifier(config.mLocaleList));
        }

        switch (config.screenLayout & Configuration.SCREENLAYOUT_LAYOUTDIR_MASK) {