Example usage for android.view ViewConfiguration get

List of usage examples for android.view ViewConfiguration get

Introduction

In this page you can find the example usage for android.view ViewConfiguration get.

Prototype

public static ViewConfiguration get(Context context) 

Source Link

Document

Returns a configuration for the specified context.

Usage

From source file:Main.java

private static boolean hasNavigationBar(Context context) {
    return !ViewConfiguration.get(context).hasPermanentMenuKey();
}

From source file:Main.java

private static boolean hasSoftNavigation(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        return !ViewConfiguration.get(context).hasPermanentMenuKey();
    }/* w  ww.  java  2  s.  c o m*/
    return false;
}

From source file:Main.java

public static boolean hasHardwareMenuKey(Context context) {
    boolean flag = false;
    if (Build.VERSION.SDK_INT < 11)
        flag = true;/*w  w w  .  jav a  2s.co m*/
    else if (Build.VERSION.SDK_INT >= 14) {
        flag = ViewConfiguration.get(context).hasPermanentMenuKey();
    } else
        flag = false;
    return flag;
}

From source file:Main.java

public static boolean hasHardwareMenu(Context context, int currentVersion) {
    if (currentVersion < 11) {
        return true;
    } else if (currentVersion >= 11 && currentVersion <= 13) {
        return false;
    }//from  ww  w.j  a v  a 2s.c  o m

    return ViewConfiguration.get(context).hasPermanentMenuKey();
}

From source file:Main.java

public static boolean isThereASettingsButton(Context context) {
    return Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR2
            || (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2)
                    && ViewConfiguration.get(context).hasPermanentMenuKey();
}

From source file:Main.java

public static boolean hasHardwareMenuKey(Context getContext) {
    boolean flag = false;
    if (PRE_HC)//from   www.  jav  a  2 s. c  om
        flag = true;
    else if (GTE_ICS) {
        flag = ViewConfiguration.get(getContext).hasPermanentMenuKey();
    } else
        flag = false;
    return flag;
}

From source file:Main.java

/**
 * Force overflow menu in samsung devices
 *
 * @param context The activity context.//  w  w  w.j a v a2s . c o m
 */
public static void forceOverFlowMenu(Context context) {
    try {
        ViewConfiguration config = ViewConfiguration.get(context);
        Field menuKeyFields = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");

        if (menuKeyFields != null) {
            menuKeyFields.setAccessible(true);
            menuKeyFields.setBoolean(config, false);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static int getNavigationBarHeight(Context c) {
    int result = 0;
    boolean hasMenuKey = ViewConfiguration.get(c).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);

    if (!hasMenuKey && !hasBackKey) {
        //The device has a navigation bar
        Resources resources = c.getResources();

        int orientation = resources.getConfiguration().orientation;
        int resourceId;
        if (isTablet(c)) {
            resourceId = resources/*w w w .j a va  2s  .  c o m*/
                    .getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height"
                            : "navigation_bar_height_landscape", "dimen", "android");
        } else {
            resourceId = resources
                    .getIdentifier(orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height"
                            : "navigation_bar_width", "dimen", "android");
        }

        if (resourceId > 0) {
            return resources.getDimensionPixelSize(resourceId);
        }
    }
    return result;
}

From source file:Main.java

/**
 * Create a rectangle based on touch point as center point and touch slop as half side.
 *
 * @param context android context/*www .  j a  va2 s.  c  om*/
 * @param x       axis x of touch point
 * @param y       axis y of touch point
 * @return rectangle for touch point
 */
public static Rect createTouchSquare(Context context, int x, int y) {
    int touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    return new Rect(x - touchSlop, y - touchSlop, x + touchSlop, y + touchSlop);
}

From source file:Main.java

public static boolean hasVirtualSoftKey(Context context) {
    return ViewConfiguration.get(context).hasPermanentMenuKey();
}