Example usage for com.liferay.portal.kernel.mobile.device Device getScreenPhysicalSize

List of usage examples for com.liferay.portal.kernel.mobile.device Device getScreenPhysicalSize

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.mobile.device Device getScreenPhysicalSize.

Prototype

public Dimensions getScreenPhysicalSize();

Source Link

Usage

From source file:com.liferay.mobile.device.rules.rule.group.rule.SimpleRuleHandler.java

License:Open Source License

@Override
public boolean evaluateRule(MDRRule mdrRule, ThemeDisplay themeDisplay) {
    Device device = themeDisplay.getDevice();

    if (device == null) {
        if (_log.isDebugEnabled()) {
            _log.debug("Rule evaluation is not possible because the information "
                    + "about the device is not available");
        }/*  w w w  .j  a  v  a  2  s. com*/

        return false;
    }

    if (!isValidMultiValue(mdrRule, PROPERTY_OS, device.getOS())) {
        return false;
    }

    if (!isValidBooleanValue(mdrRule, PROPERTY_TABLET, device.isTablet())) {
        return false;
    }

    Dimensions screenPhysicalSize = device.getScreenPhysicalSize();

    if (!isValidRangeValue(mdrRule, PROPERTY_SCREEN_PHYSICAL_HEIGHT_MAX, PROPERTY_SCREEN_PHYSICAL_HEIGHT_MIN,
            screenPhysicalSize.getHeight())) {

        return false;
    }

    if (!isValidRangeValue(mdrRule, PROPERTY_SCREEN_PHYSICAL_WIDTH_MAX, PROPERTY_SCREEN_PHYSICAL_WIDTH_MIN,
            screenPhysicalSize.getWidth())) {

        return false;
    }

    Dimensions screenResolution = device.getScreenResolution();

    if (!isValidRangeValue(mdrRule, PROPERTY_SCREEN_RESOLUTION_HEIGHT_MAX,
            PROPERTY_SCREEN_RESOLUTION_HEIGHT_MIN, screenResolution.getHeight())) {

        return false;
    }

    if (!isValidRangeValue(mdrRule, PROPERTY_SCREEN_RESOLUTION_WIDTH_MAX, PROPERTY_SCREEN_RESOLUTION_WIDTH_MIN,
            screenResolution.getWidth())) {

        return false;
    }

    return true;
}