diff options
author | Tor Norbye <tnorbye@google.com> | 2012-08-06 15:34:49 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-08-06 15:49:27 -0700 |
commit | 5890cb76e4ee5407f7a67f8de79d0f3a7ce1e1ab (patch) | |
tree | 8b025751ed8a96d7224ff59f3ab1298480d06d9d | |
parent | 0920b8eb481295001c85b2023b4ff7c67a7aaf84 (diff) | |
download | sdk-5890cb76e4ee5407f7a67f8de79d0f3a7ce1e1ab.zip sdk-5890cb76e4ee5407f7a67f8de79d0f3a7ce1e1ab.tar.gz sdk-5890cb76e4ee5407f7a67f8de79d0f3a7ce1e1ab.tar.bz2 |
Asset studio fixes
When generating actionbar icons from clipart, do not strip surrounding
space, and do not add extra padding. The clipart images already
contain baked in padding suitable for action bar icons. This CL also
makes sure the UI disables the corresponding options in this mode.
It also renames and moves to the bottom the legacy menu and tab icon
generators, and fixes a file resource leak in the image loading code.
Change-Id: I8a0dd61c97862206cdc71dc591a207a0b6a050f8
7 files changed, 54 insertions, 15 deletions
diff --git a/assetstudio/.classpath b/assetstudio/.classpath index 53a77a1..986bffa 100644 --- a/assetstudio/.classpath +++ b/assetstudio/.classpath @@ -5,5 +5,6 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/common"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> + <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-10.0.1.jar" sourcepath="ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/assetstudio/Android.mk b/assetstudio/Android.mk index a48c3a0..e55ac55 100644 --- a/assetstudio/Android.mk +++ b/assetstudio/Android.mk @@ -21,7 +21,8 @@ LOCAL_JAVA_RESOURCE_DIRS := src # TODO: Replace common with the batik stuff LOCAL_JAVA_LIBRARIES := \ - common + common \ + guava-tools LOCAL_MODULE := assetstudio diff --git a/assetstudio/src/com/android/assetstudiolib/GraphicGenerator.java b/assetstudio/src/com/android/assetstudiolib/GraphicGenerator.java index a88618c..91b2d2e 100644 --- a/assetstudio/src/com/android/assetstudiolib/GraphicGenerator.java +++ b/assetstudio/src/com/android/assetstudiolib/GraphicGenerator.java @@ -17,6 +17,7 @@ package com.android.assetstudiolib; import com.android.resources.Density; +import com.google.common.io.Closeables; import java.awt.image.BufferedImage; import java.io.File; @@ -199,9 +200,14 @@ public abstract class GraphicGenerator { * @return the image, or null * @throws IOException if an unexpected I/O error occurs */ + @SuppressWarnings("resource") // Eclipse doesn't know about Closeables#closeQuietly yet public static BufferedImage getStencilImage(String relativePath) throws IOException { InputStream is = GraphicGenerator.class.getResourceAsStream(relativePath); - return ImageIO.read(is); + try { + return ImageIO.read(is); + } finally { + Closeables.closeQuietly(is); + } } /** @@ -212,10 +218,15 @@ public abstract class GraphicGenerator { * @return the icon image * @throws IOException if the image cannot be loaded */ + @SuppressWarnings("resource") // Eclipse doesn't know about Closeables#closeQuietly yet public static BufferedImage getClipartIcon(String name) throws IOException { InputStream is = GraphicGenerator.class.getResourceAsStream( "/images/clipart/small/" + name); - return ImageIO.read(is); + try { + return ImageIO.read(is); + } finally { + Closeables.closeQuietly(is); + } } /** @@ -226,10 +237,15 @@ public abstract class GraphicGenerator { * @return the clip art image * @throws IOException if the image cannot be loaded */ + @SuppressWarnings("resource") // Eclipse doesn't know about Closeables#closeQuietly yet public static BufferedImage getClipartImage(String name) throws IOException { InputStream is = GraphicGenerator.class.getResourceAsStream( "/images/clipart/big/" + name); - return ImageIO.read(is); + try { + return ImageIO.read(is); + } finally { + Closeables.closeQuietly(is); + } } /** diff --git a/eclipse/dictionary.txt b/eclipse/dictionary.txt index ae582d3..af3d835 100644 --- a/eclipse/dictionary.txt +++ b/eclipse/dictionary.txt @@ -46,6 +46,7 @@ clickable clipart clipboard clipboards +closeables clueless codebase codename diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/AssetType.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/AssetType.java index 58dd332..3e2bd67 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/AssetType.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/AssetType.java @@ -21,19 +21,19 @@ package com.android.ide.eclipse.adt.internal.assetstudio; */ public enum AssetType { /** Launcher icon to be shown in the application list */ - LAUNCHER("Launcher Icons", "ic_launcher"), //$NON-NLS-2$ - - /** Icons shown in menus */ - MENU("Menu Icons", "ic_menu_%s"), //$NON-NLS-2$ + LAUNCHER("Launcher Icons", "ic_launcher"), //$NON-NLS-2$ /** Icons shown in the action bar */ - ACTIONBAR("Action Bar Icons (Android 3.0+)", "ic_action_%s"), //$NON-NLS-2$ + ACTIONBAR("Action Bar and Tab Icons (Android 3.0+)", "ic_action_%s"), //$NON-NLS-2$ + + /** Icons shown in a notification message */ + NOTIFICATION("Notification Icons", "ic_stat_%s"), //$NON-NLS-2$ /** Icons shown as part of tabs */ - TAB("Tab Icons", "ic_tab_%s"), //$NON-NLS-2$ + TAB("Pre-Android 3.0 Tab Icons", "ic_tab_%s"), //$NON-NLS-2$ - /** Icons shown in a notification message */ - NOTIFICATION("Notification Icons", "ic_stat_%s"); //$NON-NLS-2$ + /** Icons shown in menus */ + MENU("Pre-Android 3.0 Menu Icons", "ic_menu_%s"); //$NON-NLS-2$ /** Display name to show to the user in the asset type selection list */ private final String mDisplayName; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/ConfigureAssetSetPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/ConfigureAssetSetPage.java index 457f093..3cc4697 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/ConfigureAssetSetPage.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/ConfigureAssetSetPage.java @@ -538,6 +538,8 @@ public class ConfigureAssetSetPage extends WizardPage implements SelectionListen //updateColor(display, new RGB(0xa4, 0xc6, 0x39), true /*background*/); updateColor(display, mValues.background, true /*background*/); updateColor(display, mValues.foreground, false /*background*/); + + updateTrimOptions(); } finally { mIgnore = false; } @@ -565,6 +567,20 @@ public class ConfigureAssetSetPage extends WizardPage implements SelectionListen } } + private void updateTrimOptions() { + // Trimming and padding is not available for clipart images; padding etc is + // predefined to work well with action bar icons + if (mValues.sourceType == SourceType.CLIPART + && mValues.type == AssetType.ACTIONBAR) { + mTrimCheckBox.setEnabled(false); + mPaddingSlider.setEnabled(false); + mValues.trim = false; + } else if (!mTrimCheckBox.isEnabled()) { + mTrimCheckBox.setEnabled(true); + mPaddingSlider.setEnabled(true); + } + } + private boolean validatePage() { String error = null; //String warning = null; @@ -651,16 +667,19 @@ public class ConfigureAssetSetPage extends WizardPage implements SelectionListen mValues.sourceType = CreateAssetSetWizardState.SourceType.IMAGE; chooseForegroundTab((Button) source, mImageForm); configureAssetType(mValues.type); + updateTrimOptions(); } else if (source == mClipartRadio) { mValues.sourceType = CreateAssetSetWizardState.SourceType.CLIPART; chooseForegroundTab((Button) source, mClipartForm); configureAssetType(mValues.type); + updateTrimOptions(); } else if (source == mTextRadio) { mValues.sourceType = CreateAssetSetWizardState.SourceType.TEXT; updateFontLabel(); chooseForegroundTab((Button) source, mTextForm); configureAssetType(mValues.type); mText.setFocus(); + updateTrimOptions(); } // Choose image file @@ -1043,7 +1062,8 @@ public class ConfigureAssetSetPage extends WizardPage implements SelectionListen try { sourceImage = GraphicGenerator.getClipartImage(mValues.clipartName); - if (trim) { + boolean isActionBar = mValues.type == AssetType.ACTIONBAR; + if (trim && !isActionBar) { sourceImage = ImageUtils.cropBlank(sourceImage, null, TYPE_INT_ARGB); } @@ -1055,7 +1075,7 @@ public class ConfigureAssetSetPage extends WizardPage implements SelectionListen } int padding = mValues.padding; - if (padding != 0) { + if (padding != 0 && !isActionBar) { sourceImage = Util.paddedImage(sourceImage, padding); } } catch (IOException e) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/CreateAssetSetWizardState.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/CreateAssetSetWizardState.java index 94bc4d3..d3a0f42 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/CreateAssetSetWizardState.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/assetstudio/CreateAssetSetWizardState.java @@ -64,7 +64,7 @@ public class CreateAssetSetWizardState implements GraphicGeneratorContext { public IProject project; /** Whether empty space around the source image should be trimmed */ - public boolean trim; + public boolean trim = true; /** The type of source the icon is being created from */ public SourceType sourceType = SourceType.TEXT; |