feat(res): support grammar inflection flag in res config (#2270)

This commit is contained in:
Skylot
2024-09-08 21:49:13 +01:00
parent 3f9aa34057
commit 5d1f0b8cae
3 changed files with 25 additions and 5 deletions
@@ -547,7 +547,7 @@ public class ResTableBinaryParser extends CommonBinaryParser implements IResTabl
byte keyboard = (byte) is.readInt8();
byte navigation = (byte) is.readInt8();
byte inputFlags = (byte) is.readInt8();
is.readInt8(); // inputPad0
byte grammaticalInflection = (byte) is.readInt8();
short screenWidth = (short) is.readInt16();
short screenHeight = (short) is.readInt16();
@@ -590,7 +590,7 @@ public class ResTableBinaryParser extends CommonBinaryParser implements IResTabl
return new EntryConfig(mcc, mnc, language, country,
orientation, touchscreen, density, keyboard, navigation,
inputFlags, screenWidth, screenHeight, sdkVersion,
inputFlags, grammaticalInflection, screenWidth, screenHeight, sdkVersion,
screenLayout, uiMode, smallestScreenWidthDp, screenWidthDp,
screenHeightDp, localeScript, localeVariant, screenLayout2,
colorMode, false, size);
@@ -27,6 +27,8 @@ import org.slf4j.LoggerFactory;
*/
public class EntryConfig {
private static final Logger LOG = LoggerFactory.getLogger(EntryConfig.class);
public final short mcc;
public final short mnc;
@@ -40,6 +42,7 @@ public class EntryConfig {
public final byte keyboard;
public final byte navigation;
public final byte inputFlags;
public final byte grammaticalInflection;
public final short screenWidth;
public final short screenHeight;
@@ -68,7 +71,7 @@ public class EntryConfig {
public EntryConfig(short mcc, short mnc, char[] language,
char[] region, byte orientation,
byte touchscreen, int density, byte keyboard, byte navigation,
byte inputFlags, short screenWidth, short screenHeight,
byte inputFlags, byte grammaticalInflection, short screenWidth, short screenHeight,
short sdkVersion, byte screenLayout, byte uiMode,
short smallestScreenWidthDp, short screenWidthDp,
short screenHeightDp, char[] localeScript, char[] localeVariant,
@@ -125,6 +128,7 @@ public class EntryConfig {
this.keyboard = keyboard;
this.navigation = navigation;
this.inputFlags = inputFlags;
this.grammaticalInflection = grammaticalInflection;
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
this.sdkVersion = sdkVersion;
@@ -173,6 +177,18 @@ public class EntryConfig {
}
ret.append(getLocaleString());
switch (grammaticalInflection) {
case GRAMMATICAL_GENDER_NEUTER:
ret.append("-neuter");
break;
case GRAMMATICAL_GENDER_FEMININE:
ret.append("-feminine");
break;
case GRAMMATICAL_GENDER_MASCULINE:
ret.append("-masculine");
break;
}
switch (screenLayout & MASK_LAYOUTDIR) {
case SCREENLAYOUT_LAYOUTDIR_RTL:
ret.append("-ldrtl");
@@ -620,5 +636,8 @@ public class EntryConfig {
public static final byte COLOR_WIDE_YES = 0x2;
public static final byte COLOR_WIDE_MASK = 0x3;
private static final Logger LOG = LoggerFactory.getLogger(EntryConfig.class);
public static final byte GRAMMATICAL_GENDER_ANY = 0;
public static final byte GRAMMATICAL_GENDER_NEUTER = 1;
public static final byte GRAMMATICAL_GENDER_FEMININE = 2;
public static final byte GRAMMATICAL_GENDER_MASCULINE = 3;
}
@@ -111,6 +111,7 @@ public class CommonProtoParser extends ParserConstants {
byte screenLayout2 = (byte) (c.getLayoutDirectionValue() | c.getScreenRoundValue());
byte navigation = (byte) c.getNavigationValue();
byte inputFlags = (byte) (c.getKeysHiddenValue() | c.getNavHiddenValue());
byte grammaticalInflection = (byte) c.getGrammaticalGenderValue();
int size = c.getSerializedSize();
byte uiMode = (byte) (c.getUiModeNightValue() | c.getUiModeTypeValue());
@@ -119,7 +120,7 @@ public class CommonProtoParser extends ParserConstants {
return new EntryConfig(mcc, mnc, language, new char[] { '\00' },
orientation, touchscreen, density, keyboard, navigation,
inputFlags, screenWidth, screenHeight, sdkVersion,
inputFlags, grammaticalInflection, screenWidth, screenHeight, sdkVersion,
screenLayout, uiMode, smallestScreenWidthDp, screenWidthDp,
screenHeightDp, new char[] { '\00' }, new char[] { '\00' }, screenLayout2,
colorMode, false, size).getQualifiers();