|
20 | 20 | import static android.content.ConfigurationProto.DENSITY_DPI;
|
21 | 21 | import static android.content.ConfigurationProto.FONT_SCALE;
|
22 | 22 | import static android.content.ConfigurationProto.FONT_WEIGHT_ADJUSTMENT;
|
| 23 | +import static android.content.ConfigurationProto.GRAMMATICAL_GENDER; |
23 | 24 | import static android.content.ConfigurationProto.HARD_KEYBOARD_HIDDEN;
|
24 | 25 | import static android.content.ConfigurationProto.KEYBOARD;
|
25 | 26 | import static android.content.ConfigurationProto.KEYBOARD_HIDDEN;
|
@@ -167,19 +168,19 @@ public final class Configuration implements Parcelable, Comparable<Configuration
|
167 | 168 | * Constant for grammatical gender: to indicate the terms of address the user
|
168 | 169 | * preferred in an application is neuter.
|
169 | 170 | */
|
170 |
| - public static final int GRAMMATICAL_GENDER_NEUTRAL = 2; |
| 171 | + public static final int GRAMMATICAL_GENDER_NEUTRAL = 1; |
171 | 172 |
|
172 | 173 | /**
|
173 | 174 | * Constant for grammatical gender: to indicate the terms of address the user
|
174 | 175 | * preferred in an application is feminine.
|
175 | 176 | */
|
176 |
| - public static final int GRAMMATICAL_GENDER_FEMININE = 3; |
| 177 | + public static final int GRAMMATICAL_GENDER_FEMININE = 2; |
177 | 178 |
|
178 | 179 | /**
|
179 | 180 | * Constant for grammatical gender: to indicate the terms of address the user
|
180 | 181 | * preferred in an application is masculine.
|
181 | 182 | */
|
182 |
| - public static final int GRAMMATICAL_GENDER_MASCULINE = 4; |
| 183 | + public static final int GRAMMATICAL_GENDER_MASCULINE = 3; |
183 | 184 |
|
184 | 185 | /** Constant for {@link #colorMode}: bits that encode whether the screen is wide gamut. */
|
185 | 186 | public static final int COLOR_MODE_WIDE_COLOR_GAMUT_MASK = 0x3;
|
@@ -529,15 +530,10 @@ public static String configurationDiffToString(int diff) {
|
529 | 530 | if ((diff & ActivityInfo.CONFIG_FONT_WEIGHT_ADJUSTMENT) != 0) {
|
530 | 531 | list.add("CONFIG_AUTO_BOLD_TEXT");
|
531 | 532 | }
|
532 |
| - StringBuilder builder = new StringBuilder("{"); |
533 |
| - for (int i = 0, n = list.size(); i < n; i++) { |
534 |
| - builder.append(list.get(i)); |
535 |
| - if (i != n - 1) { |
536 |
| - builder.append(", "); |
537 |
| - } |
| 533 | + if ((diff & ActivityInfo.CONFIG_GRAMMATICAL_GENDER) != 0) { |
| 534 | + list.add("CONFIG_GRAMMATICAL_GENDER"); |
538 | 535 | }
|
539 |
| - builder.append("}"); |
540 |
| - return builder.toString(); |
| 536 | + return "{" + TextUtils.join(", ", list) + "}"; |
541 | 537 | }
|
542 | 538 |
|
543 | 539 | /**
|
@@ -970,6 +966,7 @@ public boolean isLayoutSizeAtLeast(int size) {
|
970 | 966 | NATIVE_CONFIG_SMALLEST_SCREEN_SIZE,
|
971 | 967 | NATIVE_CONFIG_LAYOUTDIR,
|
972 | 968 | NATIVE_CONFIG_COLOR_MODE,
|
| 969 | + NATIVE_CONFIG_GRAMMATICAL_GENDER, |
973 | 970 | })
|
974 | 971 | @Retention(RetentionPolicy.SOURCE)
|
975 | 972 | public @interface NativeConfig {}
|
@@ -1008,6 +1005,9 @@ public boolean isLayoutSizeAtLeast(int size) {
|
1008 | 1005 | public static final int NATIVE_CONFIG_LAYOUTDIR = 0x4000;
|
1009 | 1006 | /** @hide Native-specific bit mask for COLOR_MODE config ; DO NOT USE UNLESS YOU ARE SURE.*/
|
1010 | 1007 | public static final int NATIVE_CONFIG_COLOR_MODE = 0x10000;
|
| 1008 | + /** @hide Native-specific bit mask for GRAMMATICAL_GENDER config; DO NOT USE UNLESS YOU |
| 1009 | + * ARE SURE.*/ |
| 1010 | + public static final int NATIVE_CONFIG_GRAMMATICAL_GENDER = 0x20000; |
1011 | 1011 |
|
1012 | 1012 | /**
|
1013 | 1013 | * <p>Construct an invalid Configuration. This state is only suitable for constructing a
|
@@ -1112,6 +1112,14 @@ public String toString() {
|
1112 | 1112 | } else {
|
1113 | 1113 | sb.append(" ?localeList");
|
1114 | 1114 | }
|
| 1115 | + if (mGrammaticalGender != 0) { |
| 1116 | + switch (mGrammaticalGender) { |
| 1117 | + case GRAMMATICAL_GENDER_NEUTRAL: sb.append(" neuter"); break; |
| 1118 | + case GRAMMATICAL_GENDER_FEMININE: sb.append(" feminine"); break; |
| 1119 | + case GRAMMATICAL_GENDER_MASCULINE: sb.append(" masculine"); break; |
| 1120 | + case GRAMMATICAL_GENDER_NOT_SPECIFIED: sb.append(" ?grgend"); break; |
| 1121 | + } |
| 1122 | + } |
1115 | 1123 | int layoutDir = (screenLayout&SCREENLAYOUT_LAYOUTDIR_MASK);
|
1116 | 1124 | switch (layoutDir) {
|
1117 | 1125 | case SCREENLAYOUT_LAYOUTDIR_UNDEFINED: sb.append(" ?layoutDir"); break;
|
@@ -1292,6 +1300,7 @@ public void dumpDebug(ProtoOutputStream protoOutputStream, long fieldId, boolean
|
1292 | 1300 | protoOutputStream.write(ORIENTATION, orientation);
|
1293 | 1301 | protoOutputStream.write(SCREEN_WIDTH_DP, screenWidthDp);
|
1294 | 1302 | protoOutputStream.write(SCREEN_HEIGHT_DP, screenHeightDp);
|
| 1303 | + protoOutputStream.write(GRAMMATICAL_GENDER, mGrammaticalGender); |
1295 | 1304 | protoOutputStream.end(token);
|
1296 | 1305 | }
|
1297 | 1306 |
|
@@ -1454,6 +1463,9 @@ public void readFromProto(ProtoInputStream protoInputStream, long fieldId) throw
|
1454 | 1463 | case (int) FONT_WEIGHT_ADJUSTMENT:
|
1455 | 1464 | fontWeightAdjustment = protoInputStream.readInt(FONT_WEIGHT_ADJUSTMENT);
|
1456 | 1465 | break;
|
| 1466 | + case (int) GRAMMATICAL_GENDER: |
| 1467 | + mGrammaticalGender = protoInputStream.readInt(GRAMMATICAL_GENDER); |
| 1468 | + break; |
1457 | 1469 | }
|
1458 | 1470 | }
|
1459 | 1471 | } finally {
|
@@ -1839,6 +1851,9 @@ public void setTo(@NonNull Configuration delta, @Config int mask,
|
1839 | 1851 | if ((mask & ActivityInfo.CONFIG_FONT_WEIGHT_ADJUSTMENT) != 0) {
|
1840 | 1852 | fontWeightAdjustment = delta.fontWeightAdjustment;
|
1841 | 1853 | }
|
| 1854 | + if ((mask & ActivityInfo.CONFIG_GRAMMATICAL_GENDER) != 0) { |
| 1855 | + mGrammaticalGender = delta.mGrammaticalGender; |
| 1856 | + } |
1842 | 1857 | }
|
1843 | 1858 |
|
1844 | 1859 | /**
|
@@ -1975,7 +1990,7 @@ && getScreenLayoutNoDirection(screenLayout) !=
|
1975 | 1990 | changed |= ActivityInfo.CONFIG_FONT_WEIGHT_ADJUSTMENT;
|
1976 | 1991 | }
|
1977 | 1992 |
|
1978 |
| - if (!publicOnly&& mGrammaticalGender != delta.mGrammaticalGender) { |
| 1993 | + if (!publicOnly && mGrammaticalGender != delta.mGrammaticalGender) { |
1979 | 1994 | changed |= ActivityInfo.CONFIG_GRAMMATICAL_GENDER;
|
1980 | 1995 | }
|
1981 | 1996 | return changed;
|
@@ -2172,6 +2187,8 @@ public int compareTo(Configuration that) {
|
2172 | 2187 | if (n != 0) return n;
|
2173 | 2188 | }
|
2174 | 2189 |
|
| 2190 | + n = this.mGrammaticalGender - that.mGrammaticalGender; |
| 2191 | + if (n != 0) return n; |
2175 | 2192 | n = this.touchscreen - that.touchscreen;
|
2176 | 2193 | if (n != 0) return n;
|
2177 | 2194 | n = this.keyboard - that.keyboard;
|
@@ -2205,11 +2222,6 @@ public int compareTo(Configuration that) {
|
2205 | 2222 | n = windowConfiguration.compareTo(that.windowConfiguration);
|
2206 | 2223 | if (n != 0) return n;
|
2207 | 2224 | n = this.fontWeightAdjustment - that.fontWeightAdjustment;
|
2208 |
| - if (n != 0) return n; |
2209 |
| - n = this.mGrammaticalGender - that.mGrammaticalGender; |
2210 |
| - if (n != 0) return n; |
2211 |
| - |
2212 |
| - // if (n != 0) return n; |
2213 | 2225 | return n;
|
2214 | 2226 | }
|
2215 | 2227 |
|
@@ -2482,6 +2494,20 @@ public static String resourceQualifierString(Configuration config, DisplayMetric
|
2482 | 2494 | }
|
2483 | 2495 | }
|
2484 | 2496 |
|
| 2497 | + switch (config.mGrammaticalGender) { |
| 2498 | + case Configuration.GRAMMATICAL_GENDER_NEUTRAL: |
| 2499 | + parts.add("neuter"); |
| 2500 | + break; |
| 2501 | + case Configuration.GRAMMATICAL_GENDER_FEMININE: |
| 2502 | + parts.add("feminine"); |
| 2503 | + break; |
| 2504 | + case Configuration.GRAMMATICAL_GENDER_MASCULINE: |
| 2505 | + parts.add("masculine"); |
| 2506 | + break; |
| 2507 | + default: |
| 2508 | + break; |
| 2509 | + } |
| 2510 | + |
2485 | 2511 | switch (config.screenLayout & Configuration.SCREENLAYOUT_LAYOUTDIR_MASK) {
|
2486 | 2512 | case Configuration.SCREENLAYOUT_LAYOUTDIR_LTR:
|
2487 | 2513 | parts.add("ldltr");
|
@@ -2768,6 +2794,10 @@ public static Configuration generateDelta(
|
2768 | 2794 | delta.locale = change.locale;
|
2769 | 2795 | }
|
2770 | 2796 |
|
| 2797 | + if (base.mGrammaticalGender != change.mGrammaticalGender) { |
| 2798 | + delta.mGrammaticalGender = change.mGrammaticalGender; |
| 2799 | + } |
| 2800 | + |
2771 | 2801 | if (base.touchscreen != change.touchscreen) {
|
2772 | 2802 | delta.touchscreen = change.touchscreen;
|
2773 | 2803 | }
|
@@ -2881,6 +2911,7 @@ public static Configuration generateDelta(
|
2881 | 2911 | private static final String XML_ATTR_DENSITY = "density";
|
2882 | 2912 | private static final String XML_ATTR_APP_BOUNDS = "app_bounds";
|
2883 | 2913 | private static final String XML_ATTR_FONT_WEIGHT_ADJUSTMENT = "fontWeightAdjustment";
|
| 2914 | + private static final String XML_ATTR_GRAMMATICAL_GENDER = "grammaticalGender"; |
2884 | 2915 |
|
2885 | 2916 | /**
|
2886 | 2917 | * Reads the attributes corresponding to Configuration member fields from the Xml parser.
|
@@ -2932,6 +2963,8 @@ public static void readXmlAttrs(XmlPullParser parser, Configuration configOut)
|
2932 | 2963 | DENSITY_DPI_UNDEFINED);
|
2933 | 2964 | configOut.fontWeightAdjustment = XmlUtils.readIntAttribute(parser,
|
2934 | 2965 | XML_ATTR_FONT_WEIGHT_ADJUSTMENT, FONT_WEIGHT_ADJUSTMENT_UNDEFINED);
|
| 2966 | + configOut.mGrammaticalGender = XmlUtils.readIntAttribute(parser, |
| 2967 | + XML_ATTR_GRAMMATICAL_GENDER, GRAMMATICAL_GENDER_NOT_SPECIFIED); |
2935 | 2968 |
|
2936 | 2969 | // For persistence, we don't care about assetsSeq and WindowConfiguration, so do not read it
|
2937 | 2970 | // out.
|
|
0 commit comments