diff options
author | Xavier Ducrohet <xav@android.com> | 2011-06-09 14:07:57 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-06-09 14:23:18 -0700 |
commit | 65d2312eb7cb092b5db7c871231817bd56628d42 (patch) | |
tree | e0169ddbf2cd2ddf78516526628ed78ae89d561e /eclipse | |
parent | c1b76da1654a96eafd17f8cdb79feeef5b9f5177 (diff) | |
download | sdk-65d2312eb7cb092b5db7c871231817bd56628d42.zip sdk-65d2312eb7cb092b5db7c871231817bd56628d42.tar.gz sdk-65d2312eb7cb092b5db7c871231817bd56628d42.tar.bz2 |
Add support for the new width/height resource qualifiers.
Also add Television to the dock mode (which is really UI Mode).
Change-Id: I97e3fbea1806a32d8267d8e462211add2b122ed0
Diffstat (limited to 'eclipse')
4 files changed, 213 insertions, 1 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptParser.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptParser.java index 2a2f0d0..01cdde0 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptParser.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/AaptParser.java @@ -192,7 +192,12 @@ public final class AaptParser { * @return true if the parsing failed, false if success. */ public static boolean parseOutput(List<String> results, IProject project) { - return parseOutput(results.toArray(new String[results.size()]), project); + int size = results.size(); + if (size > 0) { + return parseOutput(results.toArray(new String[size]), project); + } + + return true; } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigEditDialog.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigEditDialog.java index d9b3911..86b8cd5 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigEditDialog.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigEditDialog.java @@ -131,6 +131,7 @@ public class ConfigEditDialog extends GridDialog { public void getConfig(FolderConfiguration config) { config.set(mConfig); + config.updateScreenWidthAndHeight(); } @Override diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/LayoutDeviceHandler.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/LayoutDeviceHandler.java index 3ad4e61..eb3853a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/LayoutDeviceHandler.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/LayoutDeviceHandler.java @@ -120,6 +120,7 @@ class LayoutDeviceHandler extends DefaultHandler { mCurrentDevice = null; mDefaultConfig = null; } else if (LayoutDevicesXsd.NODE_CONFIG.equals(localName)) { + mCurrentConfig.updateScreenWidthAndHeight(); mCurrentConfig = null; } else if (LayoutDevicesXsd.NODE_COUNTRY_CODE.equals(localName)) { CountryCodeQualifier ccq = new CountryCodeQualifier( 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 74120fd..ffef837 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 @@ -30,9 +30,12 @@ import com.android.ide.common.resources.configuration.PixelDensityQualifier; import com.android.ide.common.resources.configuration.RegionQualifier; import com.android.ide.common.resources.configuration.ResourceQualifier; import com.android.ide.common.resources.configuration.ScreenDimensionQualifier; +import com.android.ide.common.resources.configuration.ScreenHeightQualifier; import com.android.ide.common.resources.configuration.ScreenOrientationQualifier; import com.android.ide.common.resources.configuration.ScreenRatioQualifier; import com.android.ide.common.resources.configuration.ScreenSizeQualifier; +import com.android.ide.common.resources.configuration.ScreenWidthQualifier; +import com.android.ide.common.resources.configuration.SmallestScreenWidthQualifier; import com.android.ide.common.resources.configuration.TextInputMethodQualifier; import com.android.ide.common.resources.configuration.TouchScreenQualifier; import com.android.ide.common.resources.configuration.VersionQualifier; @@ -422,6 +425,10 @@ 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(SmallestScreenWidthQualifier.class, + new SmallestScreenWidthEdit(mQualifierEditParent)); + mUiMap.put(ScreenWidthQualifier.class, new ScreenWidthEdit(mQualifierEditParent)); + mUiMap.put(ScreenHeightQualifier.class, new ScreenHeightEdit(mQualifierEditParent)); mUiMap.put(ScreenSizeQualifier.class, new ScreenSizeEdit(mQualifierEditParent)); mUiMap.put(ScreenRatioQualifier.class, new ScreenRatioEdit(mQualifierEditParent)); mUiMap.put(ScreenOrientationQualifier.class, new OrientationEdit(mQualifierEditParent)); @@ -966,6 +973,204 @@ public class ConfigurationSelector extends Composite { } /** + * Edit widget for {@link SmallestScreenWidthQualifier}. + */ + private class SmallestScreenWidthEdit extends QualifierEditBase { + + private Text mSize; + + public SmallestScreenWidthEdit(Composite parent) { + super(parent, SmallestScreenWidthQualifier.NAME); + + ModifyListener modifyListener = new ModifyListener() { + public void modifyText(ModifyEvent e) { + onSizeChange(); + } + }; + + FocusAdapter focusListener = new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + onSizeChange(); + } + }; + + mSize = new Text(this, SWT.BORDER); + mSize.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + mSize.addVerifyListener(new DimensionVerifier()); + mSize.addModifyListener(modifyListener); + mSize.addFocusListener(focusListener); + } + + private void onSizeChange() { + // update the current config + String size = mSize.getText(); + + if (size.length() == 0) { + // if one of the strings is empty, reset to 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.setSmallestScreenWidthQualifier( + new SmallestScreenWidthQualifier()); + } else { + SmallestScreenWidthQualifier qualifier = SmallestScreenWidthQualifier.getQualifier( + size); + + if (qualifier != null) { + mSelectedConfiguration.setSmallestScreenWidthQualifier(qualifier); + } else { + // Failure! Looks like the value is wrong, reset the 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.setSmallestScreenWidthQualifier( + new SmallestScreenWidthQualifier()); + } + } + + // notify of change + onChange(true /* keepSelection */); + } + + @Override + public void setQualifier(ResourceQualifier qualifier) { + SmallestScreenWidthQualifier q = (SmallestScreenWidthQualifier)qualifier; + + mSize.setText(Integer.toString(q.getValue())); + } + } + + /** + * Edit widget for {@link ScreenWidthQualifier}. + */ + private class ScreenWidthEdit extends QualifierEditBase { + + private Text mSize; + + public ScreenWidthEdit(Composite parent) { + super(parent, ScreenWidthQualifier.NAME); + + ModifyListener modifyListener = new ModifyListener() { + public void modifyText(ModifyEvent e) { + onSizeChange(); + } + }; + + FocusAdapter focusListener = new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + onSizeChange(); + } + }; + + mSize = new Text(this, SWT.BORDER); + mSize.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + mSize.addVerifyListener(new DimensionVerifier()); + mSize.addModifyListener(modifyListener); + mSize.addFocusListener(focusListener); + } + + private void onSizeChange() { + // update the current config + String size = mSize.getText(); + + if (size.length() == 0) { + // if one of the strings is empty, reset to 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.setScreenWidthQualifier(new ScreenWidthQualifier()); + } else { + ScreenWidthQualifier qualifier = ScreenWidthQualifier.getQualifier(size); + + if (qualifier != null) { + mSelectedConfiguration.setScreenWidthQualifier(qualifier); + } else { + // Failure! Looks like the value is wrong, reset the 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.setScreenWidthQualifier( + new ScreenWidthQualifier()); + } + } + + // notify of change + onChange(true /* keepSelection */); + } + + @Override + public void setQualifier(ResourceQualifier qualifier) { + ScreenWidthQualifier q = (ScreenWidthQualifier)qualifier; + + mSize.setText(Integer.toString(q.getValue())); + } + } + + /** + * Edit widget for {@link ScreenHeightQualifier}. + */ + private class ScreenHeightEdit extends QualifierEditBase { + + private Text mSize; + + public ScreenHeightEdit(Composite parent) { + super(parent, ScreenHeightQualifier.NAME); + + ModifyListener modifyListener = new ModifyListener() { + public void modifyText(ModifyEvent e) { + onSizeChange(); + } + }; + + FocusAdapter focusListener = new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + onSizeChange(); + } + }; + + mSize = new Text(this, SWT.BORDER); + mSize.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + mSize.addVerifyListener(new DimensionVerifier()); + mSize.addModifyListener(modifyListener); + mSize.addFocusListener(focusListener); + } + + private void onSizeChange() { + // update the current config + String size = mSize.getText(); + + if (size.length() == 0) { + // if one of the strings is empty, reset to 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.setScreenHeightQualifier(new ScreenHeightQualifier()); + } else { + ScreenHeightQualifier qualifier = ScreenHeightQualifier.getQualifier(size); + + if (qualifier != null) { + mSelectedConfiguration.setScreenHeightQualifier(qualifier); + } else { + // Failure! Looks like the value is wrong, reset the 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.setScreenHeightQualifier( + new ScreenHeightQualifier()); + } + } + + // notify of change + onChange(true /* keepSelection */); + } + + @Override + public void setQualifier(ResourceQualifier qualifier) { + ScreenHeightQualifier q = (ScreenHeightQualifier)qualifier; + + mSize.setText(Integer.toString(q.getValue())); + } + } + + + /** * Edit widget for {@link ScreenSizeQualifier}. */ private class ScreenSizeEdit extends QualifierEditBase { |