Java Code Examples for com.android.sdklib.devices.Screen#getYDimension()

The following examples show how to use com.android.sdklib.devices.Screen#getYDimension() . 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: 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 2
Source File: HardwareConfigHelper.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates and returns the HardwareConfig object.
 * @return the config
 */
@SuppressWarnings("SuspiciousNameCombination") // Deliberately swapping orientations
@NonNull
public HardwareConfig getConfig() {
    Screen screen = mDevice.getDefaultHardware().getScreen();

    // compute width and height to take orientation into account.
    int x = screen.getXDimension();
    int y = screen.getYDimension();
    int width, height;

    if (x > y) {
        if (mScreenOrientation == ScreenOrientation.LANDSCAPE) {
            width = x;
            height = y;
        } else {
            width = y;
            height = x;
        }
    } else {
        if (mScreenOrientation == ScreenOrientation.LANDSCAPE) {
            width = y;
            height = x;
        } else {
            width = x;
            height = y;
        }
    }

    if (mOverrideRenderHeight != -1) {
        width = mOverrideRenderWidth;
    }

    if (mOverrideRenderHeight != -1) {
        height = mOverrideRenderHeight;
    }

    if (mMaxRenderWidth != -1) {
        width = mMaxRenderWidth;
    }

    if (mMaxRenderHeight != -1) {
        height = mMaxRenderHeight;
    }

    return new HardwareConfig(
            width,
            height,
            screen.getPixelDensity(),
            (float) screen.getXdpi(),
            (float) screen.getYdpi(),
            screen.getSize(),
            mScreenOrientation,
            mDevice.getDefaultHardware().getScreen().getScreenRound(),
            mDevice.getDefaultHardware().getButtonType() == ButtonType.SOFT);
}
 
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;
}