OSDN Git Service

When using prerelease SDK versions, use codename instead of API level
authorTor Norbye <tnorbye@google.com>
Thu, 7 Jul 2011 18:44:18 +0000 (11:44 -0700)
committerTor Norbye <tnorbye@google.com>
Sat, 9 Jul 2011 03:31:02 +0000 (20:31 -0700)
The New Project wizard now automatically fills in the Minimum SDK text
field based on the selection in the SDK target chooser. However, it
was hardcoded to always pick the API level number. That's not correct
when using SDK versions with a code name; for example, when used with
a dev SDK build the minimum SDK version should be "AOSP".

Change-Id: I28273007be7e56f3a34b683f01234d5d1046aa0a

eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectCreationPage.java

index 6b6ade0..3b1b59e 100644 (file)
@@ -31,11 +31,12 @@ import com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper;
 import com.android.ide.eclipse.adt.internal.sdk.Sdk;
 import com.android.ide.eclipse.adt.internal.sdk.Sdk.ITargetChangeListener;
 import com.android.ide.eclipse.adt.internal.wizards.newproject.NewTestProjectCreationPage.TestInfo;
+import com.android.sdklib.AndroidVersion;
 import com.android.sdklib.IAndroidTarget;
 import com.android.sdklib.SdkConstants;
 import com.android.sdklib.internal.project.ProjectProperties;
-import com.android.sdklib.internal.project.ProjectPropertiesWorkingCopy;
 import com.android.sdklib.internal.project.ProjectProperties.PropertyType;
+import com.android.sdklib.internal.project.ProjectPropertiesWorkingCopy;
 import com.android.sdklib.xml.AndroidManifest;
 import com.android.sdklib.xml.ManifestData;
 import com.android.sdklib.xml.ManifestData.Activity;
@@ -1032,7 +1033,8 @@ public class NewProjectCreationPage extends WizardPage {
         // We do if one of two conditions are met:
         if (target != null) {
             boolean setMinSdk = false;
-            int apiLevel = target.getVersion().getApiLevel();
+            AndroidVersion version = target.getVersion();
+            int apiLevel = version.getApiLevel();
             // 1. Has the user not manually edited the SDK field yet? If so, keep
             //    updating it to the selected value.
             if (!mMinSdkModifiedByUser) {
@@ -1053,9 +1055,15 @@ public class NewProjectCreationPage extends WizardPage {
                 }
             }
             if (setMinSdk) {
+                String minSdk;
+                if (version.isPreview()) {
+                    minSdk = version.getCodename();
+                } else {
+                    minSdk = Integer.toString(apiLevel);
+                }
                 try {
                     mInternalMinSdkUpdate = true;
-                    mMinSdkVersionField.setText(Integer.toString(apiLevel));
+                    mMinSdkVersionField.setText(minSdk);
                 } finally {
                     mInternalMinSdkUpdate = false;
                 }