diff options
| author | Raphael Moll <ralf@android.com> | 2014-05-21 18:02:05 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-05-21 18:02:05 +0000 |
| commit | c289009b3bad2ba3155193fc2d2104c1032231fc (patch) | |
| tree | 25cfa8a9e900c5c3fbdd4472cb16715b7ce09b9c /sdkmanager | |
| parent | 2ecd55922f0e01ccd8835881146e7fcdc23cb57a (diff) | |
| parent | 505355c4d607b1b78633539a66c57f51dc19e41f (diff) | |
| download | platform_tools_swt-c289009b3bad2ba3155193fc2d2104c1032231fc.tar.gz platform_tools_swt-c289009b3bad2ba3155193fc2d2104c1032231fc.tar.bz2 platform_tools_swt-c289009b3bad2ba3155193fc2d2104c1032231fc.zip | |
Merge "AVD Manager: change button order, avd/dev-manager icons." into idea133
Diffstat (limited to 'sdkmanager')
11 files changed, 210 insertions, 93 deletions
diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/ImageFactory.java b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/ImageFactory.java index ab84cc2..3b9733d 100755 --- a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/ImageFactory.java +++ b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/ImageFactory.java @@ -16,6 +16,8 @@ package com.android.sdkuilib.internal.repository.icons; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.sdklib.internal.repository.archives.Archive; import com.android.sdklib.internal.repository.packages.Package; import com.android.sdklib.internal.repository.sources.SdkSource; @@ -42,23 +44,66 @@ public class ImageFactory { private final Display mDisplay; private final Map<String, Image> mImages = new HashMap<String, Image>(); - public ImageFactory(Display display) { + /** + * Filter an image when it's loaded by + * {@link ImageFactory#getImageByName(String, String, Filter)}. + */ + public interface Filter { + /** + * Invoked by {@link ImageFactory#getImageByName(String, String, Filter)} when + * a non-null {@link Image} object has been loaded. The filter should create a + * new image, modifying it as needed. <br/> + * If no modification is necessary, the filter can simply return the source image. <br/> + * The result will be cached and returned by {@link ImageFactory}. + * <p/> + * + * @param source A non-null source image. + * @return Either the source or a new, potentially modified, image. + */ + @NonNull public Image filter(@NonNull Image source); + } + + public ImageFactory(@NonNull Display display) { mDisplay = display; } /** * Loads an image given its filename (with its extension). - * Might return null if the image cannot be loaded. - * The image is cached. Successive calls will return the <em>same</em> object. + * Might return null if the image cannot be loaded. <br/> + * The image is cached. Successive calls will return the <em>same</em> object. <br/> + * The image is automatically disposed when {@link ImageFactory} is disposed. * * @param imageName The filename (with extension) of the image to load. * @return A new or existing {@link Image}. The caller must NOT dispose the image (the * image will disposed by {@link #dispose()}). The returned image can be null if the * expected file is missing. */ - public Image getImageByName(String imageName) { + @Nullable + public Image getImageByName(@NonNull String imageName) { + return getImageByName(imageName, imageName, null); + } + + + /** + * Loads an image given its filename (with its extension), caches it using the given + * {@code KeyName} name and optionally applies a filter to it. + * Might return null if the image cannot be loaded. + * The image is cached. Successive calls using {@code KeyName} will return the <em>same</em> + * object directly (the filter is not re-applied in this case.) <br/> + * The image is automatically disposed when {@link ImageFactory} is disposed. + * <p/> + * + * @param imageName The filename (with extension) of the image to load. + * @return A new or existing {@link Image}. The caller must NOT dispose the image (the + * image will disposed by {@link #dispose()}). The returned image is null if the + * expected file is missing. + */ + @Nullable + public Image getImageByName(@NonNull String imageName, + @NonNull String keyName, + @Nullable Filter filter) { - Image image = mImages.get(imageName); + Image image = mImages.get(keyName); if (image != null) { return image; } @@ -67,6 +112,13 @@ public class ImageFactory { if (stream != null) { try { image = new Image(mDisplay, stream); + if (image != null && filter != null) { + Image image2 = filter.filter(image); + if (image2 != image && !image.isDisposed()) { + image.dispose(); + } + image = image2; + } } catch (SWTException e) { // ignore } catch (IllegalArgumentException e) { @@ -75,7 +127,7 @@ public class ImageFactory { } // Store the image in the hash, even if this failed. If it fails now, it will fail later. - mImages.put(imageName, image); + mImages.put(keyName, image); return image; } @@ -89,7 +141,8 @@ public class ImageFactory { * image will disposed by {@link #dispose()}). The returned image can be null if the * object is of an unknown type. */ - public Image getImageForObject(Object object) { + @Nullable + public Image getImageForObject(@Nullable Object object) { if (object == null) { return null; diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/devman_generic_16.png b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/devman_generic_16.png Binary files differdeleted file mode 100755 index c727351..0000000 --- a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/devman_generic_16.png +++ /dev/null diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/devman_manufacturer_16.png b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/devman_manufacturer_16.png Binary files differdeleted file mode 100755 index c727351..0000000 --- a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/devman_manufacturer_16.png +++ /dev/null diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/devman_user_16.png b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/devman_user_16.png Binary files differdeleted file mode 100755 index 1f4608f..0000000 --- a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/devman_user_16.png +++ /dev/null diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/tag_android-wear_32.png b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/tag_android-wear_32.png Binary files differnew file mode 100755 index 0000000..ecc0f08 --- /dev/null +++ b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/tag_android-wear_32.png diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/tag_default_32.png b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/tag_default_32.png Binary files differnew file mode 100755 index 0000000..5ec2bd3 --- /dev/null +++ b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/tag_default_32.png diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/warning_icon16.png b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/warning_icon16.png Binary files differindex ca3b6ed..a2fcf7c 100755 --- a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/warning_icon16.png +++ b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/icons/warning_icon16.png diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/ui/AvdManagerWindowImpl1.java b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/ui/AvdManagerWindowImpl1.java index 1bea878..4e5d883 100755 --- a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/ui/AvdManagerWindowImpl1.java +++ b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/ui/AvdManagerWindowImpl1.java @@ -58,7 +58,7 @@ import java.io.File; */ public class AvdManagerWindowImpl1 { - private static final String APP_NAME = "Android Virtual Device Manager"; + private static final String APP_NAME = "Android Virtual Device (AVD) Manager"; private static final String APP_NAME_MAC_MENU = "AVD Manager"; private static final String SIZE_POS_PREFIX = "avdman1"; //$NON-NLS-1$ diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/ui/DeviceManagerPage.java b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/ui/DeviceManagerPage.java index 6b0d283..f948de3 100755 --- a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/ui/DeviceManagerPage.java +++ b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/repository/ui/DeviceManagerPage.java @@ -16,6 +16,9 @@ package com.android.sdkuilib.internal.repository.ui; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; +import com.android.sdklib.SystemImage; import com.android.sdklib.devices.Device; import com.android.sdklib.devices.DeviceManager; import com.android.sdklib.devices.DeviceManager.DeviceFilter; @@ -28,6 +31,7 @@ import com.android.sdklib.internal.avd.AvdInfo; import com.android.sdklib.repository.ISdkChangeListener; import com.android.sdkuilib.internal.repository.SwtUpdaterData; import com.android.sdkuilib.internal.repository.icons.ImageFactory; +import com.android.sdkuilib.internal.repository.icons.ImageFactory.Filter; import com.android.sdkuilib.internal.widgets.AvdCreationDialog; import com.android.sdkuilib.internal.widgets.AvdSelector; import com.android.sdkuilib.internal.widgets.DeviceCreationDialog; @@ -47,6 +51,8 @@ import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Resource; import org.eclipse.swt.graphics.TextLayout; @@ -105,11 +111,28 @@ public class DeviceManagerPage extends Composite private Button mRefreshButton; private ImageFactory mImageFactory; private Image mUserImage; - private Image mGenericImage; - private Image mOtherImage; + private Image mDeviceImage; private int mImageWidth; private boolean mDisableRefresh; private IAvdCreatedListener mAvdCreatedListener; + private final Filter mUserColorFilter = new Filter() { + @Override + public Image filter(Image source) { + ImageData srcData = source.getImageData(); + + // swap green and blue + PaletteData p = srcData.palette; + int b = p.blueMask; + p.blueMask = p.greenMask; + p.greenMask = b; + + b = p.blueShift; + p.blueShift = p.greenShift; + p.greenShift = b; + + return new Image(source.getDevice(), srcData); + } + }; /** * Create the composite. @@ -140,12 +163,11 @@ public class DeviceManagerPage extends Composite // get some bitmaps. mImageFactory = new ImageFactory(parent.getDisplay()); - mUserImage = mImageFactory.getImageByName("devman_user_16.png"); - mGenericImage = mImageFactory.getImageByName("devman_generic_16.png"); - mOtherImage = mImageFactory.getImageByName("devman_manufacturer_16.png"); - mImageWidth = Math.max(mGenericImage.getImageData().width, + mUserImage = getTagImage(null /*tag*/, true /*isUser*/); + mDeviceImage = getTagImage(null /*tag*/, false /*isUser*/); + mImageWidth = Math.max(mDeviceImage.getImageData().width, Math.max(mUserImage.getImageData().width, - mOtherImage.getImageData().width)); + mDeviceImage.getImageData().width)); // Layout has 2 columns GridLayoutBuilder.create(parent).columns(2); @@ -169,9 +191,23 @@ public class DeviceManagerPage extends Composite GridDataBuilder.create(buttons).vFill(); buttons.setFont(parent.getFont()); + mNewAvdButton = new Button(buttons, SWT.PUSH | SWT.FLAT); + mNewAvdButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + mNewAvdButton.setText("Create AVD..."); + mNewAvdButton.setToolTipText("Creates a new AVD based on this device definition."); + mNewAvdButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent arg0) { + onCreateAvd(); + } + }); + + @SuppressWarnings("unused") + Label spacing = new Label(buttons, SWT.NONE); + mNewButton = new Button(buttons, SWT.PUSH | SWT.FLAT); mNewButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - mNewButton.setText("New Device..."); + mNewButton.setText("Create Device..."); mNewButton.setToolTipText("Creates a new user device definition."); mNewButton.addSelectionListener(new SelectionAdapter() { @Override @@ -202,20 +238,6 @@ public class DeviceManagerPage extends Composite } }); - @SuppressWarnings("unused") - Label spacing = new Label(buttons, SWT.NONE); - - mNewAvdButton = new Button(buttons, SWT.PUSH | SWT.FLAT); - mNewAvdButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - mNewAvdButton.setText("Create AVD..."); - mNewAvdButton.setToolTipText("Creates a new AVD based on this device definition."); - mNewAvdButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent arg0) { - onCreateAvd(); - } - }); - Composite padding = new Composite(buttons, SWT.NONE); padding.setLayoutData(new GridData(GridData.FILL_VERTICAL)); @@ -239,17 +261,8 @@ public class DeviceManagerPage extends Composite new Label(legend, SWT.NONE).setImage(mUserImage); new Label(legend, SWT.NONE).setText("A user-created device definition."); - new Label(legend, SWT.NONE).setImage(mGenericImage); + new Label(legend, SWT.NONE).setImage(mDeviceImage); new Label(legend, SWT.NONE).setText("A generic device definition."); - Label icon = new Label(legend, SWT.NONE); - icon.setImage(mOtherImage); - Label l = new Label(legend, SWT.NONE); - l.setText("A manufacturer-specific device definition."); - GridData gd; - l.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL)); - gd.horizontalSpan = 3; - icon.setVisible(false); - l.setVisible(false); // create the table columns final TableColumn column0 = new TableColumn(mTable, SWT.NONE); @@ -505,18 +518,13 @@ public class DeviceManagerPage extends Composite int pos1 = sb.length(); String manufacturer = device.getManufacturer(); - String manu = manufacturer; - if (isUser) { - item.setImage(mUserImage); - } else if (GENERIC.equals(manu)) { - item.setImage(mGenericImage); - } else { - item.setImage(mOtherImage); - if (!manufacturer.contains(NEXUS)) { - sb.append(" by ").append(manufacturer); - } + if (!manufacturer.contains(NEXUS)) { + sb.append(" by ").append(manufacturer); } + Image img = getTagImage(device.getTagId(), isUser); + item.setImage(img != null ? img : mDeviceImage); + Hardware hw = device.getDefaultHardware(); Screen screen = hw.getScreen(); sb.append(prefix); @@ -558,9 +566,19 @@ public class DeviceManagerPage extends Composite return disposables; } + @Nullable + private Image getTagImage(@NonNull String tagId, boolean isUser) { + if (tagId == null) { + tagId = SystemImage.DEFAULT_TAG.getId(); + } + + String fname = String.format("tag_%s_32.png", tagId); + String kname = (isUser ? "user_" : "dev_") + fname; + return mImageFactory.getImageByName(fname, kname, isUser ? mUserColorFilter : null); + } + // Constants extracted from DeviceMenuListerner -- TODO refactor somewhere else. private static final String NEXUS = "Nexus"; //$NON-NLS-1$ - private static final String GENERIC = "Generic"; //$NON-NLS-1$ private static Pattern PATTERN = Pattern.compile( "(\\d+\\.?\\d*)(?:in|\") (.+?)( \\(.*Nexus.*\\))?"); //$NON-NLS-1$ /** diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/widgets/AvdSelector.java b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/widgets/AvdSelector.java index da8e84e..94ceaa8 100644 --- a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/widgets/AvdSelector.java +++ b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/widgets/AvdSelector.java @@ -17,27 +17,34 @@ package com.android.sdkuilib.internal.widgets; import com.android.SdkConstants; +import com.android.annotations.NonNull; import com.android.annotations.Nullable; import com.android.prefs.AndroidLocation.AndroidLocationException; import com.android.sdklib.IAndroidTarget; +import com.android.sdklib.SystemImage; import com.android.sdklib.internal.avd.AvdInfo; import com.android.sdklib.internal.avd.AvdInfo.AvdStatus; import com.android.sdklib.internal.avd.AvdManager; import com.android.sdklib.internal.repository.ITask; import com.android.sdklib.internal.repository.ITaskMonitor; import com.android.sdklib.internal.repository.updater.SettingsController; -import com.android.utils.GrabProcessOutput; -import com.android.utils.GrabProcessOutput.IProcessOutput; -import com.android.utils.GrabProcessOutput.Wait; +import com.android.sdklib.repository.descriptors.IdDisplay; import com.android.sdkuilib.internal.repository.icons.ImageFactory; +import com.android.sdkuilib.internal.repository.icons.ImageFactory.Filter; import com.android.sdkuilib.internal.repository.ui.AvdManagerWindowImpl1; import com.android.sdkuilib.internal.tasks.ProgressTask; import com.android.sdkuilib.repository.AvdManagerWindow.AvdInvocationContext; import com.android.sdkuilib.ui.GridDialog; +import com.android.utils.GrabProcessOutput; +import com.android.utils.GrabProcessOutput.IProcessOutput; +import com.android.utils.GrabProcessOutput.Wait; import com.android.utils.ILogger; import com.android.utils.NullLogger; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.DecorationOverlayIcon; +import org.eclipse.jface.viewers.IDecoration; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ControlAdapter; @@ -102,7 +109,6 @@ public final class AvdSelector { private boolean mIsEnabled = true; private ImageFactory mImageFactory; - private Image mOkImage; private Image mBrokenImage; private Image mInvalidImage; @@ -223,8 +229,7 @@ public final class AvdSelector { // get some bitmaps. mImageFactory = new ImageFactory(parent.getDisplay()); - mOkImage = mImageFactory.getImageByName("accept_icon16.png"); - mBrokenImage = mImageFactory.getImageByName("broken_16.png"); + mBrokenImage = mImageFactory.getImageByName("warning_icon16.png"); mInvalidImage = mImageFactory.getImageByName("reject_icon16.png"); // Layout has 2 columns @@ -259,7 +264,7 @@ public final class AvdSelector { if (displayMode == DisplayMode.MANAGER) { mNewButton = new Button(buttons, SWT.PUSH | SWT.FLAT); mNewButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - mNewButton.setText("New..."); + mNewButton.setText("Create..."); mNewButton.setToolTipText("Creates a new AVD."); mNewButton.addSelectionListener(new SelectionAdapter() { @Override @@ -267,7 +272,24 @@ public final class AvdSelector { onNew(); } }); + } + + mStartButton = new Button(buttons, SWT.PUSH | SWT.FLAT); + mStartButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + mStartButton.setText("Start..."); + mStartButton.setToolTipText("Starts the selected AVD."); + mStartButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent arg0) { + onStart(); + } + }); + + @SuppressWarnings("unused") + Label spacing = new Label(buttons, SWT.NONE); + + if (displayMode == DisplayMode.MANAGER) { mEditButton = new Button(buttons, SWT.PUSH | SWT.FLAT); mEditButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mEditButton.setText("Edit..."); @@ -279,17 +301,6 @@ public final class AvdSelector { } }); - mDeleteButton = new Button(buttons, SWT.PUSH | SWT.FLAT); - mDeleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - mDeleteButton.setText("Delete..."); - mDeleteButton.setToolTipText("Deletes the selected AVD."); - mDeleteButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent arg0) { - onDelete(); - } - }); - mRepairButton = new Button(buttons, SWT.PUSH | SWT.FLAT); mRepairButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mRepairButton.setText("Repair..."); @@ -301,8 +312,16 @@ public final class AvdSelector { } }); - Label l = new Label(buttons, SWT.SEPARATOR | SWT.HORIZONTAL); - l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + mDeleteButton = new Button(buttons, SWT.PUSH | SWT.FLAT); + mDeleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + mDeleteButton.setText("Delete..."); + mDeleteButton.setToolTipText("Deletes the selected AVD."); + mDeleteButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent arg0) { + onDelete(); + } + }); } mDetailsButton = new Button(buttons, SWT.PUSH | SWT.FLAT); @@ -316,17 +335,6 @@ public final class AvdSelector { } }); - mStartButton = new Button(buttons, SWT.PUSH | SWT.FLAT); - mStartButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - mStartButton.setText("Start..."); - mStartButton.setToolTipText("Starts the selected AVD."); - mStartButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent arg0) { - onStart(); - } - }); - Composite padding = new Composite(buttons, SWT.NONE); padding.setLayoutData(new GridData(GridData.FILL_VERTICAL)); @@ -360,17 +368,10 @@ public final class AvdSelector { NUM_COL, 1)); legend.setFont(group.getFont()); - new Label(legend, SWT.NONE).setImage(mOkImage); - new Label(legend, SWT.NONE).setText("A valid Android Virtual Device."); new Label(legend, SWT.NONE).setImage(mBrokenImage); - new Label(legend, SWT.NONE).setText( - "A repairable Android Virtual Device."); + new Label(legend, SWT.NONE).setText("A repairable Android Virtual Device."); new Label(legend, SWT.NONE).setImage(mInvalidImage); - Label l = new Label(legend, SWT.NONE); - l.setText("An Android Virtual Device that failed to load. Click 'Details' to see the error."); - GridData gd; - l.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL)); - gd.horizontalSpan = 3; + new Label(legend, SWT.NONE).setText("An Android Virtual Device that failed to load. Click 'Details' to see the error."); } // create the table columns @@ -795,8 +796,13 @@ public final class AvdSelector { item.setText(0, avd.getName()); if (mDisplayMode == DisplayMode.MANAGER) { AvdStatus status = avd.getStatus(); - item.setImage(0, status == AvdStatus.OK ? mOkImage : - isAvdRepairable(status) ? mBrokenImage : mInvalidImage); + + boolean isOk = status == AvdStatus.OK; + boolean isRepair = isAvdRepairable(status); + boolean isInvalid = !isOk && !isRepair; + + Image img = getTagImage(avd.getTag(), isOk, isRepair, isInvalid); + item.setImage(0, img); } IAndroidTarget target = avd.getTarget(); if (target != null) { @@ -829,6 +835,38 @@ public final class AvdSelector { } } + @NonNull + private Image getTagImage(IdDisplay tag, + final boolean isOk, + final boolean isRepair, + final boolean isInvalid) { + if (tag == null) { + tag = SystemImage.DEFAULT_TAG; + } + + String fname = String.format("tag_%s_32.png", tag.getId()); + String kname = String.format("%d%d%d_%s", (isOk ? 1 : 0), + (isRepair ? 1 : 0), + (isInvalid ? 1 : 0), + fname); + return mImageFactory.getImageByName(fname, kname, new Filter() { + @Override + public Image filter(Image source) { + // We don't need an overlay for good AVDs. + if (isOk) { + return source; + } + + Image overlayImg = isRepair ? mBrokenImage : mInvalidImage; + ImageDescriptor overlayDesc = ImageDescriptor.createFromImage(overlayImg); + + DecorationOverlayIcon overlaid = + new DecorationOverlayIcon(source, overlayDesc, IDecoration.BOTTOM_RIGHT); + return overlaid.createImage(); + } + }); + } + /** * Returns the currently selected AVD in the table. * <p/> @@ -895,6 +933,7 @@ public final class AvdSelector { } } + @SuppressWarnings("deprecation") private void onEdit() { AvdInfo avdInfo = getTableSelection(); GridDialog dlg; diff --git a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/widgets/DeviceCreationDialog.java b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/widgets/DeviceCreationDialog.java index 104c598..b153d08 100644 --- a/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/widgets/DeviceCreationDialog.java +++ b/sdkmanager/sdkuilib/src/main/java/com/android/sdkuilib/internal/widgets/DeviceCreationDialog.java @@ -68,6 +68,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import java.util.List; +import java.util.Map; public class DeviceCreationDialog extends GridDialog { @@ -911,6 +912,12 @@ public class DeviceCreationDialog extends GridDialog { Device.Builder builder = new Device.Builder(); builder.setManufacturer("User"); builder.setName(mDeviceName.getText()); + + builder.setTagId(mDevice.getTagId()); + for (Map.Entry<String, String> entry : mDevice.getBootProps().entrySet()) { + builder.addBootProp(entry.getKey(), entry.getValue()); + } + builder.addSoftware(mSoftware); Screen s = mHardware.getScreen(); double diagonal = Double.parseDouble(mDiagonalLength.getText()); |
