Added support for API Level 8 resource qualifiers.

This commit is contained in:
Ryszard Wiśniewski 2010-08-29 17:37:51 +02:00
parent a28f40692a
commit de8bdfacfa
2 changed files with 36 additions and 3 deletions

View File

@ -41,6 +41,7 @@ public class ResConfigFlags {
public final short sdkVersion;
public final byte screenLayout;
public final byte uiMode;
private final String mQualifiers;
@ -59,13 +60,15 @@ public class ResConfigFlags {
screenHeight = 0;
sdkVersion = 0;
screenLayout = SCREENLONG_ANY | SCREENSIZE_ANY;
uiMode = UI_MODE_TYPE_ANY | UI_MODE_NIGHT_ANY;
mQualifiers = "";
}
public ResConfigFlags(short mcc, short mnc, char[] language, char[] country,
byte orientation, byte touchscreen, short density, byte keyboard,
byte navigation, byte inputFlags, short screenWidth,
short screenHeight, short sdkVersion, byte screenLayout) {
short screenHeight, short sdkVersion, byte screenLayout,
byte uiMode) {
this.mcc = mcc;
this.mnc = mnc;
this.language = language;
@ -80,6 +83,7 @@ public class ResConfigFlags {
this.screenHeight = screenHeight;
this.sdkVersion = sdkVersion;
this.screenLayout = screenLayout;
this.uiMode = uiMode;
mQualifiers = generateQualifiers();
}
@ -131,6 +135,22 @@ public class ResConfigFlags {
ret.append("-square");
break;
}
switch (uiMode & MASK_UI_MODE_TYPE) {
case UI_MODE_TYPE_CAR:
ret.append("-car");
break;
case UI_MODE_TYPE_DESK:
ret.append("-desk");
break;
}
switch (uiMode & MASK_UI_MODE_NIGHT) {
case UI_MODE_NIGHT_YES:
ret.append("-night");
break;
case UI_MODE_NIGHT_NO:
ret.append("-notnight");
break;
}
switch (density) {
case DENSITY_DEFAULT:
break;
@ -293,4 +313,15 @@ public class ResConfigFlags {
public final static byte SCREENLONG_ANY = 0x00;
public final static byte SCREENLONG_NO = 0x10;
public final static byte SCREENLONG_YES = 0x20;
public final static byte MASK_UI_MODE_TYPE = 0x0f;
public final static byte UI_MODE_TYPE_ANY = 0x00;
public final static byte UI_MODE_TYPE_NORMAL = 0x01;
public final static byte UI_MODE_TYPE_DESK = 0x02;
public final static byte UI_MODE_TYPE_CAR = 0x03;
public final static byte MASK_UI_MODE_NIGHT = 0x30;
public final static byte UI_MODE_NIGHT_ANY = 0x00;
public final static byte UI_MODE_NIGHT_NO = 0x10;
public final static byte UI_MODE_NIGHT_YES = 0x20;
}

View File

@ -244,9 +244,11 @@ public class ARSCDecoder {
mIn.skipBytes(2);
byte screenLayout = 0;
byte uiMode = 0;
if (size >= 32) {
screenLayout = mIn.readByte();
mIn.skipBytes(3);
uiMode = mIn.readByte();
mIn.skipBytes(2);
}
if (size > 32) {
@ -255,7 +257,7 @@ public class ARSCDecoder {
return new ResConfigFlags(mcc, mnc, language, country, orientation,
touchscreen, density, keyboard, navigation, inputFlags,
screenWidth, screenHeight, sdkVersion, screenLayout);
screenWidth, screenHeight, sdkVersion, screenLayout, uiMode);
}
private void addMissingResSpecs() throws AndrolibException {