aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-08-13 14:35:44 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-08-13 14:35:44 -0700
commit35451fdd1f27a2cad8337a53f699be75eef9c735 (patch)
treebbace2fa6833c3019e5b1eca21daabaf4a07b892
parente2783fe1e42f9cff6a2cff909ba6ea5f541e2e29 (diff)
parent313aca871dcac3ab687b1fee54846da4eb262aa7 (diff)
downloadsdk-35451fdd1f27a2cad8337a53f699be75eef9c735.zip
sdk-35451fdd1f27a2cad8337a53f699be75eef9c735.tar.gz
sdk-35451fdd1f27a2cad8337a53f699be75eef9c735.tar.bz2
Merge change 21051 into donut
* changes: Add support for the new qualifier in the config selector.
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/VersionQualifier.java7
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java190
4 files changed, 206 insertions, 1 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java
index dda49fc..55857fd 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java
@@ -159,6 +159,11 @@ public class ScreenRatioQualifier extends ResourceQualifier {
@Override
public String getFolderSegment(IAndroidTarget target) {
if (mValue != null) {
+ if (target == null) {
+ // Default behavior (when target==null) is qualifier is supported
+ return mValue.getValue();
+ }
+
AndroidVersion version = target.getVersion();
if (version.getApiLevel() >= 4 ||
(version.getApiLevel() == 3 && "Donut".equals(version.getCodename()))) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java
index 6132193..d148efc 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java
@@ -163,6 +163,11 @@ public class ScreenSizeQualifier extends ResourceQualifier {
@Override
public String getFolderSegment(IAndroidTarget target) {
if (mValue != null) {
+ if (target == null) {
+ // Default behavior (when target==null) is qualifier is supported
+ return mValue.getValue();
+ }
+
AndroidVersion version = target.getVersion();
if (version.getApiLevel() >= 4 ||
(version.getApiLevel() == 3 && "Donut".equals(version.getCodename()))) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/VersionQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/VersionQualifier.java
index c82e7e9..5744fea 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/VersionQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/VersionQualifier.java
@@ -132,6 +132,11 @@ public final class VersionQualifier extends ResourceQualifier {
*/
@Override
public String getFolderSegment(IAndroidTarget target) {
+ if (target == null) {
+ // Default behavior (when target==null) is qualifier is supported
+ return getFolderSegment(mVersion);
+ }
+
AndroidVersion version = target.getVersion();
if (version.getApiLevel() >= 3) {
return getFolderSegment(mVersion);
@@ -143,7 +148,7 @@ public final class VersionQualifier extends ResourceQualifier {
@Override
public String getStringValue() {
if (mVersion != DEFAULT_VERSION) {
- return String.format("v%1$d", mVersion);
+ return String.format("API %1$d", mVersion);
}
return ""; //$NON-NLS-1$
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java
index 34a2391..358b6fd 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java
@@ -27,12 +27,17 @@ import com.android.ide.eclipse.adt.internal.resources.configurations.RegionQuali
import com.android.ide.eclipse.adt.internal.resources.configurations.ResourceQualifier;
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenDimensionQualifier;
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenRatioQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenSizeQualifier;
import com.android.ide.eclipse.adt.internal.resources.configurations.TextInputMethodQualifier;
import com.android.ide.eclipse.adt.internal.resources.configurations.TouchScreenQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.VersionQualifier;
import com.android.ide.eclipse.adt.internal.resources.configurations.KeyboardStateQualifier.KeyboardState;
import com.android.ide.eclipse.adt.internal.resources.configurations.NavigationMethodQualifier.NavigationMethod;
import com.android.ide.eclipse.adt.internal.resources.configurations.PixelDensityQualifier.Density;
import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier.ScreenOrientation;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenRatioQualifier.ScreenRatio;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenSizeQualifier.ScreenSize;
import com.android.ide.eclipse.adt.internal.resources.configurations.TextInputMethodQualifier.TextInputMethod;
import com.android.ide.eclipse.adt.internal.resources.configurations.TouchScreenQualifier.TouchScreenType;
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager;
@@ -357,6 +362,8 @@ public class ConfigurationSelector extends Composite {
mUiMap.put(NetworkCodeQualifier.class, new MNCEdit(mQualifierEditParent));
mUiMap.put(LanguageQualifier.class, new LanguageEdit(mQualifierEditParent));
mUiMap.put(RegionQualifier.class, new RegionEdit(mQualifierEditParent));
+ mUiMap.put(ScreenSizeQualifier.class, new ScreenSizeEdit(mQualifierEditParent));
+ mUiMap.put(ScreenRatioQualifier.class, new ScreenRatioEdit(mQualifierEditParent));
mUiMap.put(ScreenOrientationQualifier.class, new OrientationEdit(mQualifierEditParent));
mUiMap.put(PixelDensityQualifier.class, new PixelDensityEdit(mQualifierEditParent));
mUiMap.put(TouchScreenQualifier.class, new TouchEdit(mQualifierEditParent));
@@ -364,6 +371,7 @@ public class ConfigurationSelector extends Composite {
mUiMap.put(TextInputMethodQualifier.class, new TextInputEdit(mQualifierEditParent));
mUiMap.put(NavigationMethodQualifier.class, new NavigationEdit(mQualifierEditParent));
mUiMap.put(ScreenDimensionQualifier.class, new ScreenDimensionEdit(mQualifierEditParent));
+ mUiMap.put(VersionQualifier.class, new VersionEdit(mQualifierEditParent));
}
/**
@@ -847,6 +855,124 @@ public class ConfigurationSelector extends Composite {
}
/**
+ * Edit widget for {@link ScreenSizeQualifier}.
+ */
+ private class ScreenSizeEdit extends QualifierEditBase {
+
+ private Combo mSize;
+
+ public ScreenSizeEdit(Composite parent) {
+ super(parent, ScreenSizeQualifier.NAME);
+
+ mSize = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
+ ScreenSize[] ssValues = ScreenSize.values();
+ for (ScreenSize value : ssValues) {
+ mSize.add(value.getDisplayValue());
+ }
+
+ mSize.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ mSize.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ onScreenSizeChange();
+ }
+ public void widgetSelected(SelectionEvent e) {
+ onScreenSizeChange();
+ }
+ });
+ }
+
+ protected void onScreenSizeChange() {
+ // update the current config
+ int index = mSize.getSelectionIndex();
+
+ if (index != -1) {
+ mSelectedConfiguration.setScreenSizeQualifier(new ScreenSizeQualifier(
+ ScreenSize.getByIndex(index)));
+ } else {
+ // empty selection, means no qualifier.
+ // Since the qualifier classes are immutable, and we don't want to
+ // remove the qualifier from the configuration, we create a new default one.
+ mSelectedConfiguration.setScreenSizeQualifier(
+ new ScreenSizeQualifier());
+ }
+
+ // notify of change
+ onChange(true /* keepSelection */);
+ }
+
+ @Override
+ public void setQualifier(ResourceQualifier qualifier) {
+ ScreenSizeQualifier q = (ScreenSizeQualifier)qualifier;
+
+ ScreenSize value = q.getValue();
+ if (value == null) {
+ mSize.clearSelection();
+ } else {
+ mSize.select(ScreenSize.getIndex(value));
+ }
+ }
+ }
+
+ /**
+ * Edit widget for {@link ScreenRatioQualifier}.
+ */
+ private class ScreenRatioEdit extends QualifierEditBase {
+
+ private Combo mSize;
+
+ public ScreenRatioEdit(Composite parent) {
+ super(parent, ScreenRatioQualifier.NAME);
+
+ mSize = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
+ ScreenRatio[] srValues = ScreenRatio.values();
+ for (ScreenRatio value : srValues) {
+ mSize.add(value.getDisplayValue());
+ }
+
+ mSize.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ mSize.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ onScreenRatioChange();
+ }
+ public void widgetSelected(SelectionEvent e) {
+ onScreenRatioChange();
+ }
+ });
+ }
+
+ protected void onScreenRatioChange() {
+ // update the current config
+ int index = mSize.getSelectionIndex();
+
+ if (index != -1) {
+ mSelectedConfiguration.setScreenRatioQualifier(new ScreenRatioQualifier(
+ ScreenRatio.getByIndex(index)));
+ } else {
+ // empty selection, means no qualifier.
+ // Since the qualifier classes are immutable, and we don't want to
+ // remove the qualifier from the configuration, we create a new default one.
+ mSelectedConfiguration.setScreenRatioQualifier(
+ new ScreenRatioQualifier());
+ }
+
+ // notify of change
+ onChange(true /* keepSelection */);
+ }
+
+ @Override
+ public void setQualifier(ResourceQualifier qualifier) {
+ ScreenRatioQualifier q = (ScreenRatioQualifier)qualifier;
+
+ ScreenRatio value = q.getValue();
+ if (value == null) {
+ mSize.clearSelection();
+ } else {
+ mSize.select(ScreenRatio.getIndex(value));
+ }
+ }
+ }
+
+ /**
* Edit widget for {@link ScreenOrientationQualifier}.
*/
private class OrientationEdit extends QualifierEditBase {
@@ -1271,4 +1397,68 @@ public class ConfigurationSelector extends Composite {
mSize2.setText(Integer.toString(q.getValue2()));
}
}
+
+ /**
+ * Edit widget for {@link VersionQualifier}.
+ */
+ private class VersionEdit extends QualifierEditBase {
+ private Text mText;
+
+ public VersionEdit(Composite parent) {
+ super(parent, VersionQualifier.NAME);
+
+ mText = new Text(this, SWT.BORDER);
+ mText.addVerifyListener(new MobileCodeVerifier());
+ mText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ onVersionChange();
+ }
+ });
+ mText.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ onVersionChange();
+ }
+ });
+
+ new Label(this, SWT.NONE).setText("(Platform API level)");
+ }
+
+ private void onVersionChange() {
+ String value = mText.getText();
+
+ if (value.length() == 0) {
+ // empty string, means a qualifier with no value.
+ // Since the qualifier classes are immutable, and we don't want to
+ // remove the qualifier from the configuration, we create a new default one.
+ mSelectedConfiguration.setVersionQualifier(new VersionQualifier());
+ } else {
+ try {
+ VersionQualifier qualifier = VersionQualifier.getQualifier(
+ VersionQualifier.getFolderSegment(Integer.parseInt(value)));
+ if (qualifier != null) {
+ mSelectedConfiguration.setVersionQualifier(qualifier);
+ } else {
+ // Failure! Looks like the value is wrong
+ mSelectedConfiguration.setVersionQualifier(new VersionQualifier());
+ }
+ } catch (NumberFormatException nfe) {
+ // Looks like the code is not a number. This should not happen since the text
+ // field has a VerifyListener that prevents it.
+ mSelectedConfiguration.setVersionQualifier(new VersionQualifier());
+ }
+ }
+
+ // notify of change
+ onChange(true /* keepSelection */);
+ }
+
+ @Override
+ public void setQualifier(ResourceQualifier qualifier) {
+ VersionQualifier q = (VersionQualifier)qualifier;
+
+ mText.setText(Integer.toString(q.getVersion()));
+ }
+ }
+
}