Skip to content

Commit c1496d2

Browse files
Dianne HackbornRamanan Rajeswaran
authored andcommitted
Add xxhdpi; fix ActivityManager.getLauncherLargeIconSize() etc.
Change-Id: I519d6cdc527a402d93b98df17a64fc1da52ad598
1 parent f11b6fb commit c1496d2

File tree

6 files changed

+38
-11
lines changed

6 files changed

+38
-11
lines changed

api/current.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21388,6 +21388,7 @@ package android.util {
2138821388
field public static final int DENSITY_MEDIUM = 160; // 0xa0
2138921389
field public static final int DENSITY_TV = 213; // 0xd5
2139021390
field public static final int DENSITY_XHIGH = 320; // 0x140
21391+
field public static final int DENSITY_XXHIGH = 480; // 0x1e0
2139121392
field public float density;
2139221393
field public int densityDpi;
2139321394
field public int heightPixels;

core/java/android/app/ActivityManager.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,9 +1442,10 @@ public ConfigurationInfo getDeviceConfigurationInfo() {
14421442
public int getLauncherLargeIconDensity() {
14431443
final Resources res = mContext.getResources();
14441444
final int density = res.getDisplayMetrics().densityDpi;
1445+
final int sw = res.getConfiguration().smallestScreenWidthDp;
14451446

1446-
if ((res.getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
1447-
!= Configuration.SCREENLAYOUT_SIZE_XLARGE) {
1447+
if (sw < 600) {
1448+
// Smaller than approx 7" tablets, use the regular icon size.
14481449
return density;
14491450
}
14501451

@@ -1456,9 +1457,13 @@ public int getLauncherLargeIconDensity() {
14561457
case DisplayMetrics.DENSITY_HIGH:
14571458
return DisplayMetrics.DENSITY_XHIGH;
14581459
case DisplayMetrics.DENSITY_XHIGH:
1459-
return DisplayMetrics.DENSITY_MEDIUM * 2;
1460+
return DisplayMetrics.DENSITY_XXHIGH;
1461+
case DisplayMetrics.DENSITY_XXHIGH:
1462+
return DisplayMetrics.DENSITY_XHIGH * 2;
14601463
default:
1461-
return density;
1464+
// The density is some abnormal value. Return some other
1465+
// abnormal value that is a reasonable scaling of it.
1466+
return (int)(density*1.5f);
14621467
}
14631468
}
14641469

@@ -1471,9 +1476,10 @@ public int getLauncherLargeIconDensity() {
14711476
public int getLauncherLargeIconSize() {
14721477
final Resources res = mContext.getResources();
14731478
final int size = res.getDimensionPixelSize(android.R.dimen.app_icon_size);
1479+
final int sw = res.getConfiguration().smallestScreenWidthDp;
14741480

1475-
if ((res.getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
1476-
!= Configuration.SCREENLAYOUT_SIZE_XLARGE) {
1481+
if (sw < 600) {
1482+
// Smaller than approx 7" tablets, use the regular icon size.
14771483
return size;
14781484
}
14791485

@@ -1487,9 +1493,13 @@ public int getLauncherLargeIconSize() {
14871493
case DisplayMetrics.DENSITY_HIGH:
14881494
return (size * DisplayMetrics.DENSITY_XHIGH) / DisplayMetrics.DENSITY_HIGH;
14891495
case DisplayMetrics.DENSITY_XHIGH:
1490-
return (size * DisplayMetrics.DENSITY_MEDIUM * 2) / DisplayMetrics.DENSITY_XHIGH;
1496+
return (size * DisplayMetrics.DENSITY_XXHIGH) / DisplayMetrics.DENSITY_XHIGH;
1497+
case DisplayMetrics.DENSITY_XXHIGH:
1498+
return (size * DisplayMetrics.DENSITY_XHIGH*2) / DisplayMetrics.DENSITY_XXHIGH;
14911499
default:
1492-
return size;
1500+
// The density is some abnormal value. Return some other
1501+
// abnormal value that is a reasonable scaling of it.
1502+
return (int)(size*1.5f);
14931503
}
14941504
}
14951505

core/java/android/util/DisplayMetrics.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ public class DisplayMetrics {
5656
*/
5757
public static final int DENSITY_XHIGH = 320;
5858

59+
/**
60+
* Standard quantized DPI for extra-extra-high-density screens. Applications
61+
* should not generally worry about this density; relying on XHIGH graphics
62+
* being scaled up to it should be sufficient for almost all cases.
63+
*/
64+
public static final int DENSITY_XXHIGH = 480;
65+
5966
/**
6067
* The reference density used throughout the system.
6168
*/

include/utils/ResourceTypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,8 @@ struct ResTable_config
843843
DENSITY_MEDIUM = ACONFIGURATION_DENSITY_MEDIUM,
844844
DENSITY_TV = ACONFIGURATION_DENSITY_TV,
845845
DENSITY_HIGH = ACONFIGURATION_DENSITY_HIGH,
846+
DENSITY_XHIGH = ACONFIGURATION_DENSITY_XHIGH,
847+
DENSITY_XXHIGH = ACONFIGURATION_DENSITY_XXHIGH,
846848
DENSITY_NONE = ACONFIGURATION_DENSITY_NONE
847849
};
848850

native/include/android/configuration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ enum {
4242
ACONFIGURATION_DENSITY_MEDIUM = 160,
4343
ACONFIGURATION_DENSITY_TV = 213,
4444
ACONFIGURATION_DENSITY_HIGH = 240,
45+
ACONFIGURATION_DENSITY_XHIGH = 320,
46+
ACONFIGURATION_DENSITY_XXHIGH = 480,
4547
ACONFIGURATION_DENSITY_NONE = 0xffff,
4648

4749
ACONFIGURATION_KEYBOARD_ANY = 0x0000,

tools/aapt/AaptAssets.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,12 +1079,17 @@ bool AaptGroupEntry::getDensityName(const char* name,
10791079
if (out) out->density = ResTable_config::DENSITY_HIGH;
10801080
return true;
10811081
}
1082-
1082+
10831083
if (strcmp(name, "xhdpi") == 0) {
1084-
if (out) out->density = ResTable_config::DENSITY_MEDIUM*2;
1084+
if (out) out->density = ResTable_config::DENSITY_XHIGH;
10851085
return true;
10861086
}
1087-
1087+
1088+
if (strcmp(name, "xxhdpi") == 0) {
1089+
if (out) out->density = ResTable_config::DENSITY_XXHIGH;
1090+
return true;
1091+
}
1092+
10881093
char* c = (char*)name;
10891094
while (*c >= '0' && *c <= '9') {
10901095
c++;

0 commit comments

Comments
 (0)