Search in sources :

Example 1 with ScreenSize

use of com.android.resources.ScreenSize in project android_frameworks_base by ResurrectionRemix.

the class RenderAction method getConfiguration.

// VisibleForTesting
public static Configuration getConfiguration(RenderParams params) {
    Configuration config = new Configuration();
    HardwareConfig hardwareConfig = params.getHardwareConfig();
    ScreenSize screenSize = hardwareConfig.getScreenSize();
    if (screenSize != null) {
        switch(screenSize) {
            case SMALL:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_SMALL;
                break;
            case NORMAL:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_NORMAL;
                break;
            case LARGE:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_LARGE;
                break;
            case XLARGE:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_XLARGE;
                break;
        }
    }
    Density density = hardwareConfig.getDensity();
    if (density == null) {
        density = Density.MEDIUM;
    }
    config.screenWidthDp = hardwareConfig.getScreenWidth() / density.getDpiValue();
    config.screenHeightDp = hardwareConfig.getScreenHeight() / density.getDpiValue();
    if (config.screenHeightDp < config.screenWidthDp) {
        //noinspection SuspiciousNameCombination
        config.smallestScreenWidthDp = config.screenHeightDp;
    } else {
        config.smallestScreenWidthDp = config.screenWidthDp;
    }
    config.densityDpi = density.getDpiValue();
    // never run in compat mode:
    config.compatScreenWidthDp = config.screenWidthDp;
    config.compatScreenHeightDp = config.screenHeightDp;
    ScreenOrientation orientation = hardwareConfig.getOrientation();
    if (orientation != null) {
        switch(orientation) {
            case PORTRAIT:
                config.orientation = Configuration.ORIENTATION_PORTRAIT;
                break;
            case LANDSCAPE:
                config.orientation = Configuration.ORIENTATION_LANDSCAPE;
                break;
            case SQUARE:
                //noinspection deprecation
                config.orientation = Configuration.ORIENTATION_SQUARE;
                break;
        }
    } else {
        config.orientation = Configuration.ORIENTATION_UNDEFINED;
    }
    ScreenRound roundness = hardwareConfig.getScreenRoundness();
    if (roundness != null) {
        switch(roundness) {
            case ROUND:
                config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_YES;
                break;
            case NOTROUND:
                config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_NO;
        }
    } else {
        config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_UNDEFINED;
    }
    String locale = params.getLocale();
    if (locale != null && !locale.isEmpty())
        config.locale = new Locale(locale);
    return config;
}
Also used : ScreenOrientation(com.android.resources.ScreenOrientation) Locale(java.util.Locale) HardwareConfig(com.android.ide.common.rendering.api.HardwareConfig) Configuration(android.content.res.Configuration) ScreenSize(com.android.resources.ScreenSize) Density(com.android.resources.Density) ScreenRound(com.android.resources.ScreenRound)

Example 2 with ScreenSize

use of com.android.resources.ScreenSize in project android_frameworks_base by DirtyUnicorns.

the class RenderAction method getConfiguration.

// VisibleForTesting
public static Configuration getConfiguration(RenderParams params) {
    Configuration config = new Configuration();
    HardwareConfig hardwareConfig = params.getHardwareConfig();
    ScreenSize screenSize = hardwareConfig.getScreenSize();
    if (screenSize != null) {
        switch(screenSize) {
            case SMALL:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_SMALL;
                break;
            case NORMAL:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_NORMAL;
                break;
            case LARGE:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_LARGE;
                break;
            case XLARGE:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_XLARGE;
                break;
        }
    }
    Density density = hardwareConfig.getDensity();
    if (density == null) {
        density = Density.MEDIUM;
    }
    config.screenWidthDp = hardwareConfig.getScreenWidth() / density.getDpiValue();
    config.screenHeightDp = hardwareConfig.getScreenHeight() / density.getDpiValue();
    if (config.screenHeightDp < config.screenWidthDp) {
        //noinspection SuspiciousNameCombination
        config.smallestScreenWidthDp = config.screenHeightDp;
    } else {
        config.smallestScreenWidthDp = config.screenWidthDp;
    }
    config.densityDpi = density.getDpiValue();
    // never run in compat mode:
    config.compatScreenWidthDp = config.screenWidthDp;
    config.compatScreenHeightDp = config.screenHeightDp;
    ScreenOrientation orientation = hardwareConfig.getOrientation();
    if (orientation != null) {
        switch(orientation) {
            case PORTRAIT:
                config.orientation = Configuration.ORIENTATION_PORTRAIT;
                break;
            case LANDSCAPE:
                config.orientation = Configuration.ORIENTATION_LANDSCAPE;
                break;
            case SQUARE:
                //noinspection deprecation
                config.orientation = Configuration.ORIENTATION_SQUARE;
                break;
        }
    } else {
        config.orientation = Configuration.ORIENTATION_UNDEFINED;
    }
    ScreenRound roundness = hardwareConfig.getScreenRoundness();
    if (roundness != null) {
        switch(roundness) {
            case ROUND:
                config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_YES;
                break;
            case NOTROUND:
                config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_NO;
        }
    } else {
        config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_UNDEFINED;
    }
    String locale = params.getLocale();
    if (locale != null && !locale.isEmpty())
        config.locale = new Locale(locale);
    return config;
}
Also used : ScreenOrientation(com.android.resources.ScreenOrientation) Locale(java.util.Locale) HardwareConfig(com.android.ide.common.rendering.api.HardwareConfig) Configuration(android.content.res.Configuration) ScreenSize(com.android.resources.ScreenSize) Density(com.android.resources.Density) ScreenRound(com.android.resources.ScreenRound)

Example 3 with ScreenSize

use of com.android.resources.ScreenSize in project android by JetBrains.

the class AvdOptionsModel method calculateInitialVmHeap.

/**
   * Set the initial VM heap size. This is based on the Android CDD minimums for each screen size and density.
   */
@NotNull
private static Storage calculateInitialVmHeap(@NotNull AvdDeviceData deviceData) {
    ScreenSize size = AvdScreenData.getScreenSize(deviceData.diagonalScreenSize().get());
    Density density = AvdScreenData.getScreenDensity(deviceData.isTv().get(), deviceData.screenDpi().get(), deviceData.screenResolutionHeight().get());
    int vmHeapSize = 32;
    if (deviceData.isWear().get()) {
        switch(density) {
            case LOW:
            case ANYDPI:
            case NODPI:
            case MEDIUM:
            case TV:
                vmHeapSize = 32;
                break;
            case HIGH:
            case DPI_280:
                vmHeapSize = 36;
                break;
            case XHIGH:
            case DPI_360:
                vmHeapSize = 48;
                break;
            case DPI_400:
                vmHeapSize = 56;
                break;
            case DPI_420:
                vmHeapSize = 64;
                break;
            case XXHIGH:
                vmHeapSize = 88;
                break;
            case DPI_560:
                vmHeapSize = 112;
                break;
            case XXXHIGH:
                vmHeapSize = 154;
                break;
        }
    } else {
        switch(size) {
            case SMALL:
            case NORMAL:
                switch(density) {
                    case LOW:
                    case ANYDPI:
                    case NODPI:
                    case MEDIUM:
                        vmHeapSize = 32;
                        break;
                    case TV:
                    case HIGH:
                    case DPI_280:
                        vmHeapSize = 48;
                        break;
                    case XHIGH:
                    case DPI_360:
                        vmHeapSize = 80;
                        break;
                    case DPI_400:
                        vmHeapSize = 96;
                        break;
                    case DPI_420:
                        vmHeapSize = 112;
                        break;
                    case XXHIGH:
                        vmHeapSize = 128;
                        break;
                    case DPI_560:
                        vmHeapSize = 192;
                        break;
                    case XXXHIGH:
                        vmHeapSize = 256;
                        break;
                }
                break;
            case LARGE:
                switch(density) {
                    case LOW:
                        vmHeapSize = 32;
                        break;
                    case ANYDPI:
                    case NODPI:
                    case MEDIUM:
                        vmHeapSize = 48;
                        break;
                    case TV:
                    case HIGH:
                        vmHeapSize = 80;
                        break;
                    case DPI_280:
                        vmHeapSize = 96;
                        break;
                    case XHIGH:
                        vmHeapSize = 128;
                        break;
                    case DPI_360:
                        vmHeapSize = 160;
                        break;
                    case DPI_400:
                        vmHeapSize = 192;
                        break;
                    case DPI_420:
                        vmHeapSize = 228;
                        break;
                    case XXHIGH:
                        vmHeapSize = 256;
                        break;
                    case DPI_560:
                        vmHeapSize = 384;
                        break;
                    case XXXHIGH:
                        vmHeapSize = 512;
                        break;
                }
                break;
            case XLARGE:
                switch(density) {
                    case LOW:
                        vmHeapSize = 48;
                        break;
                    case ANYDPI:
                    case NODPI:
                    case MEDIUM:
                        vmHeapSize = 80;
                        break;
                    case TV:
                    case HIGH:
                        vmHeapSize = 96;
                        break;
                    case DPI_280:
                        vmHeapSize = 144;
                        break;
                    case XHIGH:
                        vmHeapSize = 192;
                        break;
                    case DPI_360:
                        vmHeapSize = 240;
                        break;
                    case DPI_400:
                        vmHeapSize = 288;
                        break;
                    case DPI_420:
                        vmHeapSize = 336;
                        break;
                    case XXHIGH:
                        vmHeapSize = 384;
                        break;
                    case DPI_560:
                        vmHeapSize = 576;
                        break;
                    case XXXHIGH:
                        vmHeapSize = 768;
                        break;
                }
                break;
        }
    }
    return new Storage(vmHeapSize, Storage.Unit.MiB);
}
Also used : Storage(com.android.sdklib.devices.Storage) ScreenSize(com.android.resources.ScreenSize) Density(com.android.resources.Density) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ScreenSize

use of com.android.resources.ScreenSize in project android_frameworks_base by crdroidandroid.

the class RenderAction method getConfiguration.

// VisibleForTesting
public static Configuration getConfiguration(RenderParams params) {
    Configuration config = new Configuration();
    HardwareConfig hardwareConfig = params.getHardwareConfig();
    ScreenSize screenSize = hardwareConfig.getScreenSize();
    if (screenSize != null) {
        switch(screenSize) {
            case SMALL:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_SMALL;
                break;
            case NORMAL:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_NORMAL;
                break;
            case LARGE:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_LARGE;
                break;
            case XLARGE:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_XLARGE;
                break;
        }
    }
    Density density = hardwareConfig.getDensity();
    if (density == null) {
        density = Density.MEDIUM;
    }
    config.screenWidthDp = hardwareConfig.getScreenWidth() / density.getDpiValue();
    config.screenHeightDp = hardwareConfig.getScreenHeight() / density.getDpiValue();
    if (config.screenHeightDp < config.screenWidthDp) {
        //noinspection SuspiciousNameCombination
        config.smallestScreenWidthDp = config.screenHeightDp;
    } else {
        config.smallestScreenWidthDp = config.screenWidthDp;
    }
    config.densityDpi = density.getDpiValue();
    // never run in compat mode:
    config.compatScreenWidthDp = config.screenWidthDp;
    config.compatScreenHeightDp = config.screenHeightDp;
    ScreenOrientation orientation = hardwareConfig.getOrientation();
    if (orientation != null) {
        switch(orientation) {
            case PORTRAIT:
                config.orientation = Configuration.ORIENTATION_PORTRAIT;
                break;
            case LANDSCAPE:
                config.orientation = Configuration.ORIENTATION_LANDSCAPE;
                break;
            case SQUARE:
                //noinspection deprecation
                config.orientation = Configuration.ORIENTATION_SQUARE;
                break;
        }
    } else {
        config.orientation = Configuration.ORIENTATION_UNDEFINED;
    }
    ScreenRound roundness = hardwareConfig.getScreenRoundness();
    if (roundness != null) {
        switch(roundness) {
            case ROUND:
                config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_YES;
                break;
            case NOTROUND:
                config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_NO;
        }
    } else {
        config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_UNDEFINED;
    }
    String locale = params.getLocale();
    if (locale != null && !locale.isEmpty())
        config.locale = new Locale(locale);
    return config;
}
Also used : ScreenOrientation(com.android.resources.ScreenOrientation) Locale(java.util.Locale) HardwareConfig(com.android.ide.common.rendering.api.HardwareConfig) Configuration(android.content.res.Configuration) ScreenSize(com.android.resources.ScreenSize) Density(com.android.resources.Density) ScreenRound(com.android.resources.ScreenRound)

Example 5 with ScreenSize

use of com.android.resources.ScreenSize in project android_frameworks_base by ParanoidAndroid.

the class RenderAction method getConfiguration.

private Configuration getConfiguration() {
    Configuration config = new Configuration();
    HardwareConfig hardwareConfig = mParams.getHardwareConfig();
    ScreenSize screenSize = hardwareConfig.getScreenSize();
    if (screenSize != null) {
        switch(screenSize) {
            case SMALL:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_SMALL;
                break;
            case NORMAL:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_NORMAL;
                break;
            case LARGE:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_LARGE;
                break;
            case XLARGE:
                config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_XLARGE;
                break;
        }
    }
    Density density = hardwareConfig.getDensity();
    if (density == null) {
        density = Density.MEDIUM;
    }
    config.screenWidthDp = hardwareConfig.getScreenWidth() / density.getDpiValue();
    config.screenHeightDp = hardwareConfig.getScreenHeight() / density.getDpiValue();
    if (config.screenHeightDp < config.screenWidthDp) {
        config.smallestScreenWidthDp = config.screenHeightDp;
    } else {
        config.smallestScreenWidthDp = config.screenWidthDp;
    }
    config.densityDpi = density.getDpiValue();
    // never run in compat mode:
    config.compatScreenWidthDp = config.screenWidthDp;
    config.compatScreenHeightDp = config.screenHeightDp;
    ScreenOrientation orientation = hardwareConfig.getOrientation();
    if (orientation != null) {
        switch(orientation) {
            case PORTRAIT:
                config.orientation = Configuration.ORIENTATION_PORTRAIT;
                break;
            case LANDSCAPE:
                config.orientation = Configuration.ORIENTATION_LANDSCAPE;
                break;
            case SQUARE:
                config.orientation = Configuration.ORIENTATION_SQUARE;
                break;
        }
    } else {
        config.orientation = Configuration.ORIENTATION_UNDEFINED;
    }
    return config;
}
Also used : ScreenOrientation(com.android.resources.ScreenOrientation) HardwareConfig(com.android.ide.common.rendering.api.HardwareConfig) Configuration(android.content.res.Configuration) ScreenSize(com.android.resources.ScreenSize) Density(com.android.resources.Density)

Aggregations

Density (com.android.resources.Density)8 ScreenSize (com.android.resources.ScreenSize)8 Configuration (android.content.res.Configuration)6 HardwareConfig (com.android.ide.common.rendering.api.HardwareConfig)6 ScreenOrientation (com.android.resources.ScreenOrientation)6 ScreenRound (com.android.resources.ScreenRound)5 Locale (java.util.Locale)5 ScreenRatio (com.android.resources.ScreenRatio)1 Storage (com.android.sdklib.devices.Storage)1 Ellipse2D (java.awt.geom.Ellipse2D)1 Line2D (java.awt.geom.Line2D)1 RoundRectangle2D (java.awt.geom.RoundRectangle2D)1 NotNull (org.jetbrains.annotations.NotNull)1