Java Code Examples for com.android.sdklib.devices.Device#getDisplayName()

The following examples show how to use com.android.sdklib.devices.Device#getDisplayName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HardwareConfigHelper.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a user-displayable description of the given generic device
 * @param device the device to check
 * @return the label
 * @see #isGeneric(Device)
 */
@NonNull
public static String getGenericLabel(@NonNull Device device) {
    // * Use the same precision for all devices (all but one specify decimals)
    // * Add some leading space such that the dot ends up roughly in the
    //   same space
    // * Add in screen resolution and density
    String name = device.getDisplayName();
    Matcher matcher = GENERIC_PATTERN.matcher(name);
    if (matcher.matches()) {
        String size = matcher.group(1);
        String n = matcher.group(2);
        int dot = size.indexOf('.');
        if (dot == -1) {
            size += ".0";
            dot = size.length() - 2;
        }
        for (int i = 0; i < 2 - dot; i++) {
            size = ' ' + size;
        }
        name = size + "\" " + n;
    }

    return String.format(Locale.US, "%1$s (%2$s)", name,
            getResolutionString(device));
}
 
Example 2
Source File: CreateAvdVisualPanel1.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    Device device = devices.get(rowIndex);
    switch (columnIndex) {
        case 0:
            return device.getDisplayName();
        case 1:
            if (device.hasPlayStore()) {
                return new ImageIcon(ImageUtilities.loadImage("org/netbeans/modules/android/avd/manager/device-play-store.png"));
            }
            return null;
        case 2:
            return getDiagonalSize(device);
        case 3:
            return getDimensionString(device);
        case 4:
            return getDensityString(device);
        default:
            return "Err";
    }
}
 
Example 3
Source File: HardwareConfigHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a user-displayable description of the given Nexus device
 * @param device the device to check
 * @return the label
 * @see #isNexus(com.android.sdklib.devices.Device)
 */
@NonNull
public static String getNexusLabel(@NonNull Device device) {
    String name = device.getDisplayName();
    Screen screen = device.getDefaultHardware().getScreen();
    float length = (float) screen.getDiagonalLength();
    // Round dimensions to the nearest tenth
    length = Math.round(10 * length) / 10.0f;
    return String.format(Locale.US, "%1$s (%3$s\", %2$s)",
            name, getResolutionString(device), Float.toString(length));
}