From 3fc982f41fda1f254bfbc35490d81cd82a0ed90a Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 30 Mar 2011 16:20:26 -0700 Subject: Add new resource configurations for screen width/height in "dp". You can now specify resource configuration variants "wNNNdp" and "hNNNdp". These are the minimum screen width/height in "dp" units. This allows you to do things like have your app adjust its layout based only on the about of horizontal space available. This introduces a new configuration change flag for screen size. Note that this configuration change happens each time the orientation changes. Applications often say they handle the orientation change to avoid being restarted at a screen rotation, and this will now cause them to be restarted. To address this, we assume the app can handle this new config change if its target SDK version is < ICS. Change-Id: I22f8afa136b4f274423978c570fa7c9855040496 --- libs/utils/ResourceTypes.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'libs') diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp index 7197ad7..ac9cdf9 100644 --- a/libs/utils/ResourceTypes.cpp +++ b/libs/utils/ResourceTypes.cpp @@ -2424,7 +2424,7 @@ void ResTable::setParameters(const ResTable_config* params) { mLock.lock(); TABLE_GETENTRY(LOGI("Setting parameters: imsi:%d/%d lang:%c%c cnt:%c%c " - "orien:%d touch:%d density:%d key:%d inp:%d nav:%d w:%d h:%d\n", + "orien:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d %ddp x %ddp\n", params->mcc, params->mnc, params->language[0] ? params->language[0] : '-', params->language[1] ? params->language[1] : '-', @@ -2437,7 +2437,9 @@ void ResTable::setParameters(const ResTable_config* params) params->inputFlags, params->navigation, params->screenWidth, - params->screenHeight)); + params->screenHeight, + params->screenWidthDp, + params->screenHeightDp)); mParams = *params; for (size_t i=0; iconfig); - TABLE_GETENTRY(LOGI("Match entry 0x%x in type 0x%x (sz 0x%x): imsi:%d/%d=%d/%d lang:%c%c=%c%c cnt:%c%c=%c%c " - "orien:%d=%d touch:%d=%d density:%d=%d key:%d=%d inp:%d=%d nav:%d=%d w:%d=%d h:%d=%d\n", + TABLE_GETENTRY(LOGI("Match entry 0x%x in type 0x%x (sz 0x%x): imsi:%d/%d=%d/%d " + "lang:%c%c=%c%c cnt:%c%c=%c%c orien:%d=%d touch:%d=%d " + "density:%d=%d key:%d=%d inp:%d=%d nav:%d=%d w:%d=%d h:%d=%d " + "wdp:%d=%d hdp:%d=%d\n", entryIndex, typeIndex+1, dtohl(thisType->config.size), thisConfig.mcc, thisConfig.mnc, config ? config->mcc : 0, config ? config->mnc : 0, @@ -3786,7 +3790,11 @@ ssize_t ResTable::getEntry( thisConfig.screenWidth, config ? config->screenWidth : 0, thisConfig.screenHeight, - config ? config->screenHeight : 0)); + config ? config->screenHeight : 0, + thisConfig.screenWidthDp, + config ? config->screenWidthDp : 0, + thisConfig.screenHeightDp, + config ? config->screenHeightDp : 0)); // Check to make sure this one is valid for the current parameters. if (config && !thisConfig.match(*config)) { @@ -4067,7 +4075,8 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, ResTable_config thisConfig; thisConfig.copyFromDtoH(type->config); LOGI("Adding config to type %d: imsi:%d/%d lang:%c%c cnt:%c%c " - "orien:%d touch:%d density:%d key:%d inp:%d nav:%d w:%d h:%d\n", + "orien:%d touch:%d density:%d key:%d inp:%d nav:%d w:%d h:%d " + "wdp:%d hdp:%d\n", type->id, thisConfig.mcc, thisConfig.mnc, thisConfig.language[0] ? thisConfig.language[0] : '-', @@ -4081,7 +4090,9 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, thisConfig.inputFlags, thisConfig.navigation, thisConfig.screenWidth, - thisConfig.screenHeight)); + thisConfig.screenHeight, + thisConfig.screenWidthDp, + thisConfig.screenHeightDp)); t->configs.add(type); } else { status_t err = validate_chunk(chunk, sizeof(ResChunk_header), @@ -4444,6 +4455,12 @@ void ResTable::print(bool inclValues) const if (type->config.screenHeight != 0) { printf(" h=%d", dtohs(type->config.screenHeight)); } + if (type->config.screenWidthDp != 0) { + printf(" wdp=%d", dtohs(type->config.screenWidthDp)); + } + if (type->config.screenHeightDp != 0) { + printf(" hdp=%d", dtohs(type->config.screenHeightDp)); + } if (type->config.sdkVersion != 0) { printf(" sdk=%d", dtohs(type->config.sdkVersion)); } -- cgit v1.1