/**
 * Copyright (C) 2005-2012 XELOG AG
 */
package ch.spherIC.recurvebowsight.utilities;

import android.content.Context;

import android.content.res.Configuration;

import android.os.Build;


/**
 * @author  FC Smilari
 */
public class CompatibilityUtil {

    private static final int VERSION_CODES_HONEYCOMB = 11;

    /**
     * Get the current Android API level.
     */
    public static int getSdkVersion() {
        return Build.VERSION.SDK_INT;
    }

    /**
     * Determine if the device is running API level 8 or higher.
     */
    public static boolean isFroyo() {
        return getSdkVersion() >= Build.VERSION_CODES.FROYO;
    }

    /**
     * Determine if the device is running API level 11 or higher.
     */
    public static boolean isHoneycomb() {
        return getSdkVersion() >= VERSION_CODES_HONEYCOMB;
    }

    /**
     * Determine if the device is a tablet (i.e. it has a large screen).
     *
     * @param  context  The calling context.
     */
    public static boolean isTablet(final Context context) {
        return (context.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK)
               >= Configuration.SCREENLAYOUT_SIZE_LARGE;
    }

    /**
     * Determine if the device is a HoneyComb tablet.
     *
     * @param  context  The calling context.
     */
    public static boolean isHoneycombTablet(final Context context) {
        return isHoneycomb() && isTablet(context);
    }

    /**
     * This class can't be instantiated.
     */
    private CompatibilityUtil() { }
}
