]> git.saurik.com Git - android/aapt.git/commitdiff
am 72eb0aca: Merge change 5483 into donut
authorAndroid (Google) Code Review <android-gerrit@google.com>
Mon, 29 Jun 2009 23:37:17 +0000 (16:37 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Mon, 29 Jun 2009 23:37:17 +0000 (16:37 -0700)
Merge commit '72eb0acad5cffc57ce5006f6deab29ee259e461e'

* commit '72eb0acad5cffc57ce5006f6deab29ee259e461e':
  Expand support for different screen sizes.

1  2 
AaptAssets.h
Command.cpp

diff --combined AaptAssets.h
index 3f370696289a9bcf97f6e6fb407fea2ff032438c,3b96412c7c54a7ed8b33f63c3a9a40f46b7b7540..e8c739558a6bdafae088090b6732c3a31e3770e1
@@@ -15,7 -15,7 +15,7 @@@
  #include <utils/String8.h>
  #include <utils/Vector.h>
  #include <utils/RefBase.h>
 -#include <utils/ZipFile.h>
 +#include "ZipFile.h"
  
  #include "Bundle.h"
  #include "SourcePos.h"
@@@ -37,6 -37,7 +37,7 @@@ enum 
      AXIS_KEYBOARD,
      AXIS_NAVIGATION,
      AXIS_SCREENSIZE,
+     AXIS_SCREENLAYOUT,
      AXIS_VERSION
  };
  
@@@ -62,6 -63,7 +63,7 @@@ public
      String8 keyboard;
      String8 navigation;
      String8 screenSize;
+     String8 screenLayout;
      String8 version;
  
      bool initFromDirName(const char* dir, String8* resType);
@@@ -78,6 -80,7 +80,7 @@@
      static bool getKeyboardName(const char* name, ResTable_config* out = NULL);
      static bool getNavigationName(const char* name, ResTable_config* out = NULL);
      static bool getScreenSizeName(const char* name, ResTable_config* out = NULL);
+     static bool getScreenLayoutName(const char* name, ResTable_config* out = NULL);
      static bool getVersionName(const char* name, ResTable_config* out = NULL);
  
      int compare(const AaptGroupEntry& o) const;
@@@ -125,9 -128,7 +128,9 @@@ public
          {
              //printf("new AaptFile created %s\n", (const char*)sourceFile);
          }
 -    virtual ~AaptFile() { }
 +    virtual ~AaptFile() {
 +        free(mData);
 +    }
  
      const String8& getPath() const { return mPath; }
      const AaptGroupEntry& getGroupEntry() const { return mGroupEntry; }
@@@ -443,13 -444,7 +446,13 @@@ private
      AaptSymbolEntry                                 mDefSymbol;
  };
  
 -class ResourceTypeSet;
 +class ResourceTypeSet : public RefBase,
 +                        public KeyedVector<String8,sp<AaptGroup> >
 +{
 +public:
 +    ResourceTypeSet();
 +};
 +
  
  /**
   * Asset hierarchy being operated on.
  class AaptAssets : public AaptDir
  {
  public:
 -    AaptAssets() : AaptDir(String8(), String8()), mHaveIncludedAssets(false) { }
 -    virtual ~AaptAssets() { }
 +    AaptAssets() : AaptDir(String8(), String8()), mHaveIncludedAssets(false), mRes(NULL) { }
 +    virtual ~AaptAssets() { delete mRes; }
  
      const String8& getPackage() const { return mPackage; }
      void setPackage(const String8& package) { mPackage = package; mSymbolsPrivatePackage = package; }
      
      inline KeyedVector<String8, sp<ResourceTypeSet> >* getResources() { return mRes; }
      inline void 
 -        setResources(KeyedVector<String8, sp<ResourceTypeSet> >* res) { mRes = res; }
 +        setResources(KeyedVector<String8, sp<ResourceTypeSet> >* res) { delete mRes; mRes = res; }
  
  private:
      String8 mPackage;
diff --combined Command.cpp
index dcda379c7c18a5f2c031b4e1aa7b9c7ad0e1c61c,e04491d93b863c3949a238bb2049faf5cef3ae42..c0ae592f669269ded8566981800a908fa498bb2d
@@@ -8,10 -8,8 +8,10 @@@
  #include "ResourceTable.h"
  #include "XMLNode.h"
  
 -#include <utils.h>
 -#include <utils/ZipFile.h>
 +#include <utils/Log.h>
 +#include <utils/threads.h>
 +#include <utils/List.h>
 +#include <utils/Errors.h>
  
  #include <fcntl.h>
  #include <errno.h>
@@@ -331,6 -329,9 +331,9 @@@ enum 
      TARGET_SDK_VERSION_ATTR = 0x01010270,
      TEST_ONLY_ATTR = 0x01010272,
      DENSITY_ATTR = 0x0101026c,
+     SMALL_SCREEN_ATTR = 0x01010284,
+     NORMAL_SCREEN_ATTR = 0x01010285,
+     LARGE_SCREEN_ATTR = 0x01010286,
  };
  
  const char *getComponentName(String8 &pkgName, String8 &componentName) {
@@@ -501,6 -502,10 +504,10 @@@ int doDump(Bundle* bundle
              bool isLauncherActivity = false;
              bool withinApplication = false;
              bool withinReceiver = false;
+             int targetSdk = 0;
+             int smallScreen = 1;
+             int normalScreen = 1;
+             int largeScreen = 1;
              String8 pkg;
              String8 activityName;
              String8 activityLabel;
                                          error.string());
                                  goto bail;
                              }
+                             if (name == "Donut") targetSdk = 4;
                              printf("sdkVersion:'%s'\n", name.string());
                          } else if (code != -1) {
+                             targetSdk = code;
                              printf("sdkVersion:'%d'\n", code);
                          }
                          code = getIntegerAttribute(tree, TARGET_SDK_VERSION_ATTR, &error);
                                          error.string());
                                  goto bail;
                              }
+                             if (name == "Donut" && targetSdk < 4) targetSdk = 4;
                              printf("targetSdkVersion:'%s'\n", name.string());
                          } else if (code != -1) {
+                             if (targetSdk < code) {
+                                 targetSdk = code;
+                             }
                              printf("targetSdkVersion:'%d'\n", code);
                          }
                      } else if (tag == "uses-configuration") {
                              goto bail;
                          }
                          printf("supports-density:'%d'\n", dens);
+                     } else if (tag == "supports-screens") {
+                         smallScreen = getIntegerAttribute(tree,
+                                 SMALL_SCREEN_ATTR, NULL, 1);
+                         normalScreen = getIntegerAttribute(tree,
+                                 NORMAL_SCREEN_ATTR, NULL, 1);
+                         largeScreen = getIntegerAttribute(tree,
+                                 LARGE_SCREEN_ATTR, NULL, 1);
                      }
                  } else if (depth == 3 && withinApplication) {
                      withinActivity = false;
                  }
              }
              
+             // Determine default values for any unspecified screen sizes,
+             // based on the target SDK of the package.  As of 4 (donut)
+             // the screen size support was introduced, so all default to
+             // enabled.
+             if (smallScreen > 0) {
+                 smallScreen = targetSdk >= 4 ? -1 : 0;
+             }
+             if (normalScreen > 0) {
+                 normalScreen = -1;
+             }
+             if (largeScreen > 0) {
+                 largeScreen = targetSdk >= 4 ? -1 : 0;
+             }
+             printf("supports-screens:");
+             if (smallScreen != 0) printf(" 'small'");
+             if (normalScreen != 0) printf(" 'normal'");
+             if (largeScreen != 0) printf(" 'large'");
+             printf("\n");
+             
              printf("locales:");
              Vector<String8> locales;
              res.getLocales(&locales);