com.android.sdklib.devices.State Java Examples

The following examples show how to use com.android.sdklib.devices.State. 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: AvdHwProfile.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private List<State> generateStates(Hardware hardware) {
    List<State> states = Lists.newArrayListWithExpectedSize(4);

    if (portrait.isSelected()) {
        states.add(createState(ScreenOrientation.PORTRAIT, hardware, false));
    }

    if (landscape.isSelected()) {
        states.add(createState(ScreenOrientation.LANDSCAPE, hardware, false));
    }

    if (hwKeyb.isSelected()) {
        if (portrait.isSelected()) {
            states.add(createState(ScreenOrientation.PORTRAIT, hardware, true));
        }

        if (landscape.isSelected()) {
            states.add(createState(ScreenOrientation.LANDSCAPE, hardware, true));
        }
    }

    // We've added states in the order of most common to least common, so let's mark the first one as default
    states.get(0).setDefaultState(true);
    return states;
}
 
Example #2
Source File: DeviceConfigHelper.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a {@link FolderConfiguration} based on the given state
 *
 * @param state
 *            The {@link State} of the {@link Device} to base the
 *            {@link FolderConfiguration} on. Can be null.
 * @return A {@link FolderConfiguration} based on the given {@link State}.
 *         If the given {@link State} is null, the result is also null;
 */
@Nullable
public static FolderConfiguration getFolderConfig(@Nullable State state) {
    if (state == null) {
        return null;
    }

    Hardware hw = state.getHardware();

    FolderConfiguration config = new FolderConfiguration();
    config.createDefault();
    Screen screen = hw.getScreen();
    config.setDensityQualifier(new DensityQualifier(screen.getPixelDensity()));
    config.setNavigationMethodQualifier(new NavigationMethodQualifier(hw.getNav()));
    ScreenDimensionQualifier sdq;
    if (screen.getXDimension() > screen.getYDimension()) {
        sdq = new ScreenDimensionQualifier(screen.getXDimension(), screen.getYDimension());
    } else {
        sdq = new ScreenDimensionQualifier(screen.getYDimension(), screen.getXDimension());
    }
    config.setScreenDimensionQualifier(sdq);
    config.setScreenRatioQualifier(new ScreenRatioQualifier(screen.getRatio()));
    config.setScreenSizeQualifier(new ScreenSizeQualifier(screen.getSize()));
    config.setTextInputMethodQualifier(new TextInputMethodQualifier(hw.getKeyboard()));
    config.setTouchTypeQualifier(new TouchScreenQualifier(screen.getMechanism()));

    config.setKeyboardStateQualifier(new KeyboardStateQualifier(state.getKeyState()));
    config.setNavigationStateQualifier(new NavigationStateQualifier(state.getNavState()));
    config.setScreenOrientationQualifier(
        new ScreenOrientationQualifier(state.getOrientation()));

    config.updateScreenWidthAndHeight();

    // Setup some default qualifiers
    config.setUiModeQualifier(new UiModeQualifier(UiMode.NORMAL));
    config.setNightModeQualifier(new NightModeQualifier(NightMode.NOTNIGHT));
    config.setCountryCodeQualifier(new CountryCodeQualifier());
    config.setLanguageQualifier(new LanguageQualifier());
    config.setLayoutDirectionQualifier(new LayoutDirectionQualifier());
    config.setNetworkCodeQualifier(new NetworkCodeQualifier());
    config.setRegionQualifier(new RegionQualifier());
    config.setVersionQualifier(new VersionQualifier());

    return config;
}
 
Example #3
Source File: DeviceConfigHelper.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns a {@link FolderConfiguration} based on the given state
 *
 * @param state
 *            The {@link State} of the {@link Device} to base the
 *            {@link FolderConfiguration} on. Can be null.
 * @return A {@link FolderConfiguration} based on the given {@link State}.
 *         If the given {@link State} is null, the result is also null;
 */
@Nullable
public static FolderConfiguration getFolderConfig(@Nullable State state) {
    if (state == null) {
        return null;
    }

    Hardware hw = state.getHardware();

    FolderConfiguration config = new FolderConfiguration();
    config.createDefault();
    Screen screen = hw.getScreen();
    config.setDensityQualifier(new DensityQualifier(screen.getPixelDensity()));
    config.setNavigationMethodQualifier(new NavigationMethodQualifier(hw.getNav()));
    ScreenDimensionQualifier sdq;
    if (screen.getXDimension() > screen.getYDimension()) {
        sdq = new ScreenDimensionQualifier(screen.getXDimension(), screen.getYDimension());
    } else {
        sdq = new ScreenDimensionQualifier(screen.getYDimension(), screen.getXDimension());
    }
    config.setScreenDimensionQualifier(sdq);
    config.setScreenRatioQualifier(new ScreenRatioQualifier(screen.getRatio()));
    config.setScreenSizeQualifier(new ScreenSizeQualifier(screen.getSize()));
    config.setTextInputMethodQualifier(new TextInputMethodQualifier(hw.getKeyboard()));
    config.setTouchTypeQualifier(new TouchScreenQualifier(screen.getMechanism()));
    ScreenRound screenRound = screen.getScreenRound();
    if (screenRound == null) {
        // The default is not round.
        screenRound = ScreenRound.NOTROUND;
    }
    config.setScreenRoundQualifier(new ScreenRoundQualifier(screenRound));

    config.setKeyboardStateQualifier(new KeyboardStateQualifier(state.getKeyState()));
    config.setNavigationStateQualifier(new NavigationStateQualifier(state.getNavState()));
    config.setScreenOrientationQualifier(
        new ScreenOrientationQualifier(state.getOrientation()));

    config.updateScreenWidthAndHeight();

    // Setup some default qualifiers
    config.setUiModeQualifier(new UiModeQualifier(UiMode.NORMAL));
    config.setNightModeQualifier(new NightModeQualifier(NightMode.NOTNIGHT));
    config.setCountryCodeQualifier(new CountryCodeQualifier());
    config.setLocaleQualifier(new LocaleQualifier());
    config.setLayoutDirectionQualifier(new LayoutDirectionQualifier());
    config.setNetworkCodeQualifier(new NetworkCodeQualifier());
    config.setVersionQualifier(new VersionQualifier());

    return config;
}
 
Example #4
Source File: AvdHwProfile.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
/**
 * Creates new form AvdHwProfile
 */
public AvdHwProfile(Device device, DeviceManager deviceManager,boolean edit) {
    this.deviceManager = deviceManager;
    this.edit=edit;
    initComponents();
    deviceType.setModel(new DefaultComboBoxModel<>(DeviceType.values()));
    if (device != null) {
         String tagId = device.getTagId();
        initBootProperties(device);
        if (tagId == null) {
            deviceType.setSelectedItem(DeviceType.MOBILE);
        } else if (DeviceType.TV.id.equals(tagId)) {
            deviceType.setSelectedItem(DeviceType.TV);
        } else if (DeviceType.WEAR.id.equals(tagId)) {
            deviceType.setSelectedItem(DeviceType.WEAR);
        }
        if (edit) {
            deviceName.setText(device.getDisplayName());
            deviceName.setEditable(false);
        }else{
            deviceName.setText(String.format("%s (Edited)", device.getDisplayName()));
        }
        if (CreateAvdVisualPanel1.isTv(device)) {
            deviceType.setSelectedItem(DeviceType.TV);
        } else if (HardwareConfigHelper.isWear(device)) {
            deviceType.setSelectedItem(DeviceType.WEAR);
        } else {
            deviceType.setSelectedItem(DeviceType.MOBILE);
        }
        screenSize.setValue(device.getDefaultHardware().getScreen().getDiagonalLength());
        Dimension dimension = device.getScreenSize(device.getDefaultState().getOrientation());
        resolutionX.setValue(dimension.width);
        resolutionY.setValue(dimension.height);
        round.setSelected(device.isScreenRound());
        ram.setValue(device.getDefaultHardware().getRam().getSizeAsUnit(Storage.Unit.MiB));
        hwButt.setSelected(device.getDefaultHardware().getButtonType() == ButtonType.HARD);
        hwKeyb.setSelected(device.getDefaultHardware().getKeyboard() != Keyboard.NOKEY);
        List<State> states = device.getAllStates();
        portrait.setSelected(false);
        landscape.setSelected(false);
        for (State state : states) {
            if (state.getOrientation().equals(ScreenOrientation.PORTRAIT)) {
                portrait.setSelected(true);
            }
            if (state.getOrientation().equals(ScreenOrientation.LANDSCAPE)) {
                landscape.setSelected(true);
            }
        }
        Navigation nav = device.getDefaultHardware().getNav();
        switch (nav) {
            case NONAV:
                navigationStyle.setSelectedIndex(0);
                break;
            case DPAD:
                navigationStyle.setSelectedIndex(1);
                break;
            case TRACKBALL:
                navigationStyle.setSelectedIndex(2);
                break;
            case WHEEL:
                navigationStyle.setSelectedIndex(3);
                break;
        }
        cameraFront.setSelected(device.getDefaultHardware().getCamera(CameraLocation.FRONT) != null);
        cameraBack.setSelected(device.getDefaultHardware().getCamera(CameraLocation.BACK) != null);
        accelerometer.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.ACCELEROMETER));
        gyroscope.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.GYROSCOPE));
        gps.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.GPS));
        proximity.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.PROXIMITY_SENSOR));
        File skinFile = device.getDefaultHardware().getSkinFile();
        AndroidSdk defaultSdk = AndroidSdkProvider.getDefaultSdk();
        if (defaultSdk != null) {
            String skinPath = defaultSdk.getSdkPath() + File.separator + "skins";
            skin.setModel(new SkinsComboboxModel(new File(skinPath)));
        }
        skin.setSelectedItem(skinFile);
        playstore.setSelected(device.hasPlayStore());
    } else {
        deviceType.setSelectedItem(DeviceType.MOBILE);
        navigationStyle.setSelectedIndex(0);
        deviceName.setText(getUniqueId(null));
    }
    skin.setRenderer(new BasicComboBoxRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
            if ((component instanceof JLabel) && (value instanceof File)) {
                ((JLabel) component).setText(((File) value).getName());
            }
            return component;
        }

    });
}