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());
}
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);
}
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));
}
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;
}
}
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();
}
}
Aggregations