Search in sources :

Example 1 with Device

use of com.android.sdklib.devices.Device in project android by JetBrains.

the class AvdDisplayList method getScreenSize.

/**
   * @return the device screen size of this AVD
   */
@VisibleForTesting
static Dimension getScreenSize(@NotNull AvdInfo info) {
    DeviceManagerConnection deviceManager = DeviceManagerConnection.getDefaultDeviceManagerConnection();
    Device device = deviceManager.getDevice(info.getDeviceName(), info.getDeviceManufacturer());
    if (device == null) {
        return null;
    }
    return device.getScreenSize(device.getDefaultState().getOrientation());
}
Also used : Device(com.android.sdklib.devices.Device) VisibleForTesting(com.android.annotations.VisibleForTesting)

Example 2 with Device

use of com.android.sdklib.devices.Device in project android by JetBrains.

the class ConfigureDeviceModel method handleFinished.

@Override
protected void handleFinished() {
    Device device = buildDevice();
    DeviceManagerConnection.getDefaultDeviceManagerConnection().createOrEditDevice(device);
    myProvider.refreshDevices();
    myProvider.setDevice(device);
}
Also used : Device(com.android.sdklib.devices.Device)

Example 3 with Device

use of com.android.sdklib.devices.Device in project android by JetBrains.

the class DeviceDefinitionList method refreshDeviceProfiles.

private void refreshDeviceProfiles() {
    myDevices = DeviceManagerConnection.getDefaultDeviceManagerConnection().getDevices();
    myDeviceCategoryMap.clear();
    for (Device d : myDevices) {
        String category = getCategory(d);
        if (!myDeviceCategoryMap.containsKey(category)) {
            myDeviceCategoryMap.put(category, new ArrayList<Device>(1));
        }
        myDeviceCategoryMap.get(category).add(d);
    }
    Set<String> categories = myDeviceCategoryMap.keySet();
    String[] categoryArray = ArrayUtil.toStringArray(categories);
    myCategoryModel.setItems(Lists.newArrayList(categoryArray));
}
Also used : Device(com.android.sdklib.devices.Device)

Example 4 with Device

use of com.android.sdklib.devices.Device in project android by JetBrains.

the class DeviceDefinitionPreview method onCategorySelectionChanged.

@Override
public void onCategorySelectionChanged(@Nullable String category, @Nullable List<Device> devices) {
    if (devices == null) {
        myMaxOutlineWidth = 0;
        myMinOutlineWidthIn = 0;
    } else {
        double maxWidth = 0;
        double minWidth = Double.MAX_VALUE;
        for (Device d : devices) {
            Dimension pixelSize = d.getScreenSize(d.getDefaultState().getOrientation());
            if (pixelSize == null) {
                continue;
            }
            double diagonal = d.getDefaultHardware().getScreen().getDiagonalLength();
            double sideRatio = pixelSize.getHeight() / pixelSize.getWidth();
            double widthIn = diagonal / Math.sqrt(1 + sideRatio * sideRatio);
            maxWidth = Math.max(maxWidth, widthIn);
            minWidth = Math.min(minWidth, widthIn);
        }
        myMaxOutlineWidth = maxWidth;
        myMinOutlineWidthIn = minWidth;
    }
}
Also used : Device(com.android.sdklib.devices.Device)

Example 5 with Device

use of com.android.sdklib.devices.Device in project android by JetBrains.

the class DeleteDeviceAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Device device = myProvider.getDevice();
    int result = Messages.showYesNoDialog((Project) null, "Do you really want to delete Device " + device.getDisplayName() + "?", "Confirm Deletion", AllIcons.General.QuestionDialog);
    if (result == Messages.YES) {
        DeviceManagerConnection.getDefaultDeviceManagerConnection().deleteDevice(device);
        myProvider.refreshDevices();
        myProvider.selectDefaultDevice();
    }
}
Also used : Device(com.android.sdklib.devices.Device)

Aggregations

Device (com.android.sdklib.devices.Device)61 State (com.android.sdklib.devices.State)20 Nullable (org.jetbrains.annotations.Nullable)16 IAndroidTarget (com.android.sdklib.IAndroidTarget)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 NotNull (org.jetbrains.annotations.NotNull)9 File (java.io.File)8 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)8 Configuration (com.android.tools.idea.configurations.Configuration)7 Module (com.intellij.openapi.module.Module)6 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)5 IOException (java.io.IOException)5 Density (com.android.resources.Density)4 Project (com.intellij.openapi.project.Project)4 LayoutLibrary (com.android.ide.common.rendering.LayoutLibrary)3 ScreenOrientation (com.android.resources.ScreenOrientation)3 ISystemImage (com.android.sdklib.ISystemImage)3 Screen (com.android.sdklib.devices.Screen)3 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)3 AvdManager (com.android.sdklib.internal.avd.AvdManager)3