List of usage examples for android.view ViewConfiguration get
public static ViewConfiguration get(Context context)
From source file:Main.java
public static boolean checkDeviceHasNavigationBar(Context context) { boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); if (!hasMenuKey && !hasBackKey) { return true; }//from w w w . j a va2s.co m return false; }
From source file:Main.java
private static int getNavBarHeight(Context context) { boolean hasMenuKey = Build.VERSION.SDK_INT >= 14 && ViewConfiguration.get(context).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); boolean hasNavBar = !hasMenuKey && !hasBackKey; if (hasNavBar) { boolean isPortrait = context.getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; boolean isTablet = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; String key = isPortrait ? "navigation_bar_height" : (isTablet ? "navigation_bar_height_landscape" : null); return key == null ? 0 : getDimenSize(context, key); } else {//from w ww. jav a 2 s . c om return 0; } }
From source file:Main.java
/** * Method that returns if an option menu has to be displayed * * @param ctx The current context/* w w w.jav a 2 s . c om*/ * @return boolean If an option menu has to be displayed */ public static boolean showOptionsMenu(Context ctx) { // Show overflow button? return !ViewConfiguration.get(ctx).hasPermanentMenuKey(); }
From source file:Main.java
/** * initialize method, called inside the Chart.init() method. * * @param context/*from ww w . j av a 2s. c o m*/ */ @SuppressWarnings("deprecation") public static void init(Context context) { if (context == null) { // noinspection deprecation mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity(); // noinspection deprecation mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity(); Log.e("MPChartLib-Utils", "Utils.init(...) PROVIDED CONTEXT OBJECT IS NULL"); } else { ViewConfiguration viewConfiguration = ViewConfiguration.get(context); mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity(); Resources res = context.getResources(); mMetrics = res.getDisplayMetrics(); } }
From source file:Main.java
/** * Check the device whether has soft navigation bar *///ww w. j av a 2s .c om public static boolean hasNavigationBar(Context context) { Resources resources = context.getResources(); int id = resources.getIdentifier("config_showNavigationBar", "bool", "android"); if (id > 0) { return resources.getBoolean(id); } else { // Check for keys boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); return !hasMenuKey && !hasBackKey; } }
From source file:Main.java
/** * Forces the appearance of a menu in the given context. * @param ctx/*ww w. j a va2 s .c o m*/ */ public static void showMenu(Context ctx) { try { ViewConfiguration config = ViewConfiguration.get(ctx); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception e) { } }
From source file:Main.java
/** * Checks if touch event is treat as single tap * * @param context android context/*from www . j av a 2 s. c o m*/ * @param downTime the time when touch down * @param upTime the time when touch up * @param downX axis x of touch down * @param downY axis y of touch down * @param upX axis x of touch up * @param upY axis y of touch up * @return true if it's single tap, otherwise false */ public static boolean isSingleTap(Context context, long downTime, long upTime, float downX, float downY, float upX, float upY) { if (upTime - downTime > ViewConfiguration.getTapTimeout()) { return false; } int touchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); final int deltaX = (int) (downX - upX); final int deltaY = (int) (downY - upY); int distance = (deltaX * deltaX) + (deltaY * deltaY); return distance <= touchSlop * touchSlop; }
From source file:Main.java
@TargetApi(14) public static boolean hasNavigationBar(Context context) { Resources res = context.getResources(); int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android"); if (resourceId != 0) { boolean hasNav = res.getBoolean(resourceId); // check override flag (see static block) if ("1".equals(sNavBarOverride)) { hasNav = false;/*w w w . j ava2 s . c o m*/ } else if ("0".equals(sNavBarOverride)) { hasNav = true; } return hasNav; } else { // fallback return !ViewConfiguration.get(context).hasPermanentMenuKey(); } }
From source file:com.ftinc.kit.widget.TightSwipeRefreshLayout.java
public TightSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); }
From source file:com.dj.hacktor.nshiddenlayout.views.CustomNestedScrollView.java
private void init(Context context) { ViewConfiguration config = ViewConfiguration.get(context); slop = config.getScaledEdgeSlop(); }