List of usage examples for android.view ViewConfiguration get
public static ViewConfiguration get(Context context)
From source file:android.support.v7.app.AppCompatDelegateImplV7.java
private void reopenMenu(MenuBuilder menu, boolean toggleMenuMode) { if (mDecorContentParent != null && mDecorContentParent.canShowOverflowMenu() && (!ViewConfigurationCompat.hasPermanentMenuKey(ViewConfiguration.get(mContext)) || mDecorContentParent.isOverflowMenuShowPending())) { final Window.Callback cb = getWindowCallback(); if (!mDecorContentParent.isOverflowMenuShowing() || !toggleMenuMode) { if (cb != null && !isDestroyed()) { // If we have a menu invalidation pending, do it now. if (mInvalidatePanelMenuPosted && (mInvalidatePanelMenuFeatures & (1 << FEATURE_OPTIONS_PANEL)) != 0) { mWindowDecor.removeCallbacks(mInvalidatePanelMenuRunnable); mInvalidatePanelMenuRunnable.run(); }//from w w w . j a v a 2 s.c o m final PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, true); // If we don't have a menu or we're waiting for a full content refresh, // forget it. This is a lingering event that no longer matters. if (st.menu != null && !st.refreshMenuContent && cb.onPreparePanel(FEATURE_OPTIONS_PANEL, st.createdPanelView, st.menu)) { cb.onMenuOpened(FEATURE_ACTION_BAR, st.menu); mDecorContentParent.showOverflowMenu(); } } } else { mDecorContentParent.hideOverflowMenu(); if (!isDestroyed()) { final PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, true); cb.onPanelClosed(FEATURE_ACTION_BAR, st.menu); } } return; } PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, true); st.refreshDecorView = true; closePanel(st, false); openPanel(st, null); }
From source file:com.android.launcher3.folder.FolderIcon.java
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); }
From source file:com.android.volley.ui.PhotoView.java
/** * Initializes the header and any static values *///from w ww . ja v a2s.c o m private void initialize() { Context context = getContext(); if (!sInitialized) { sInitialized = true; Resources resources = context.getApplicationContext().getResources(); sCropSize = resources.getDimensionPixelSize(R.dimen.photo_crop_width); sCropDimPaint = new Paint(); sCropDimPaint.setAntiAlias(true); sCropDimPaint.setColor(resources.getColor(R.color.photo_crop_dim_color)); sCropDimPaint.setStyle(Style.FILL); sCropPaint = new Paint(); sCropPaint.setAntiAlias(true); sCropPaint.setColor(resources.getColor(R.color.photo_crop_highlight_color)); sCropPaint.setStyle(Style.STROKE); sCropPaint.setStrokeWidth(resources.getDimension(R.dimen.photo_crop_stroke_width)); final ViewConfiguration configuration = ViewConfiguration.get(context); final int touchSlop = configuration.getScaledTouchSlop(); sTouchSlopSquare = touchSlop * touchSlop; } mGestureDetector = new GestureDetectorCompat(context, this, null); mScaleGetureDetector = new ScaleGestureDetector(context, this); mQuickScaleEnabled = ScaleGestureDetectorCompat.isQuickScaleEnabled(mScaleGetureDetector); mScaleRunnable = new ScaleRunnable(this); mTranslateRunnable = new TranslateRunnable(this); mSnapRunnable = new SnapRunnable(this); mRotateRunnable = new RotateRunnable(this); }
From source file:cl.monsoon.s1next.widget.PhotoView.java
/** * Initializes the header and any static values *///from ww w .j a va 2 s . com private void initialize() { Context context = getContext(); if (!sInitialized) { sInitialized = true; Resources resources = context.getResources(); sCropSize = resources.getDimensionPixelSize(R.dimen.photo_view_crop_width); sCropDimPaint = new Paint(); sCropDimPaint.setAntiAlias(true); sCropDimPaint.setColor(ContextCompat.getColor(context, R.color.photo_view_crop_dim_color)); sCropDimPaint.setStyle(Style.FILL); sCropPaint = new Paint(); sCropPaint.setAntiAlias(true); sCropPaint.setColor(ContextCompat.getColor(context, R.color.photo_view_crop_dim_color)); sCropPaint.setStyle(Style.STROKE); sCropPaint.setStrokeWidth(resources.getDimension(R.dimen.photo_view_crop_stroke_width)); final ViewConfiguration configuration = ViewConfiguration.get(context); final int touchSlop = configuration.getScaledTouchSlop(); sTouchSlopSquare = touchSlop * touchSlop; } mGestureDetector = new GestureDetectorCompat(context, this, null); scaleGestureDetector = new ScaleGestureDetector(context, this); mQuickScaleEnabled = ScaleGestureDetectorCompat.isQuickScaleEnabled(scaleGestureDetector); mScaleRunnable = new ScaleRunnable(this); mTranslateRunnable = new TranslateRunnable(this); mSnapRunnable = new SnapRunnable(this); mRotateRunnable = new RotateRunnable(this); }
From source file:com.android.contacts.activities.DialtactsActivity.java
private void prepareOptionsMenuInSearchMode(Menu menu) { // get references to menu items final MenuItem searchMenuItem = menu.findItem(R.id.search_on_action_bar); final MenuItem filterOptionMenuItem = menu.findItem(R.id.filter_option); final MenuItem addContactOptionMenuItem = menu.findItem(R.id.add_contact); final MenuItem callSettingsMenuItem = menu.findItem(R.id.menu_call_settings); final MenuItem emptyRightMenuItem = menu.findItem(R.id.empty_right_menu_item); // prepare the menu items searchMenuItem.setVisible(false);//w ww . j av a 2 s. co m filterOptionMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey()); addContactOptionMenuItem.setVisible(false); callSettingsMenuItem.setVisible(false); emptyRightMenuItem.setVisible(false); }
From source file:org.cryptsecure.Utility.java
/** * Force overflow menu buttons. Typically these are only available for * phones without a hardware context-menu key. * //from w w w . j a v a2 s. co m * @param context * the context */ public static void forceOverflowMenuButtons(Context context) { // ========================= // how-to-force-use-of-overflow-menu-on-devices-with-menu-button try { ViewConfiguration config = ViewConfiguration.get(context); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } // ========================= }
From source file:com.android.contacts.activities.DialtactsActivity.java
private void prepareOptionsMenuForDialerTab(Menu menu) { if (DEBUG) {/*from w w w .ja v a 2 s . co m*/ Log.d(TAG, "onPrepareOptionsMenu(dialer). swipe: " + mDuringSwipe + ", user tab click: " + mUserTabClick); } // get references to menu items final MenuItem searchMenuItem = menu.findItem(R.id.search_on_action_bar); final MenuItem filterOptionMenuItem = menu.findItem(R.id.filter_option); final MenuItem addContactOptionMenuItem = menu.findItem(R.id.add_contact); final MenuItem callSettingsMenuItem = menu.findItem(R.id.menu_call_settings); final MenuItem emptyRightMenuItem = menu.findItem(R.id.empty_right_menu_item); // prepare the menu items filterOptionMenuItem.setVisible(false); addContactOptionMenuItem.setVisible(false); if (mDuringSwipe || mUserTabClick) { // During horizontal movement, the real ActionBar menu items are shown searchMenuItem.setVisible(true); callSettingsMenuItem.setVisible(true); // When there is a permanent menu key, there is no overflow icon on the right of // the action bar which would force the search menu item (if it is visible) to the // left. This is the purpose of showing the emptyRightMenuItem. emptyRightMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey()); } else { // This is when the user is looking at the dialer pad. In this case, the real // ActionBar is hidden and fake menu items are shown. // Except in landscape, in which case the real search menu item is shown. searchMenuItem.setVisible(ContactsUtils.isLandscape(this)); // If a permanent menu key is available, then we need to show the call settings item // so that the call settings item can be invoked by the permanent menu key. callSettingsMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey()); emptyRightMenuItem.setVisible(false); } }
From source file:com.android.contacts.activities.DialtactsActivity.java
private void prepareOptionsMenuForCallLogTab(Menu menu) { // get references to menu items final MenuItem searchMenuItem = menu.findItem(R.id.search_on_action_bar); final MenuItem filterOptionMenuItem = menu.findItem(R.id.filter_option); final MenuItem addContactOptionMenuItem = menu.findItem(R.id.add_contact); final MenuItem callSettingsMenuItem = menu.findItem(R.id.menu_call_settings); final MenuItem emptyRightMenuItem = menu.findItem(R.id.empty_right_menu_item); // prepare the menu items searchMenuItem.setVisible(true);/*from w w w . j a v a 2 s . c o m*/ filterOptionMenuItem.setVisible(false); addContactOptionMenuItem.setVisible(false); callSettingsMenuItem.setVisible(true); emptyRightMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey()); }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
private void getOverflowMenu() { try {//from w w w.j av a 2s. c o m ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception e) { e.printStackTrace(); } }
From source file:cn.ismartv.tvrecyclerview.widget.RecyclerView.java
/** * Configure the scrolling touch slop for a specific use case. * * Set up the RecyclerView's scrolling motion threshold based on common usages. * Valid arguments are {@link #TOUCH_SLOP_DEFAULT} and {@link #TOUCH_SLOP_PAGING}. * * @param slopConstant One of the <code>TOUCH_SLOP_</code> constants representing * the intended usage of this RecyclerView *//* w ww .j ava 2 s .c o m*/ public void setScrollingTouchSlop(int slopConstant) { final ViewConfiguration vc = ViewConfiguration.get(getContext()); switch (slopConstant) { default: Log.w(TAG, "setScrollingTouchSlop(): bad argument constant " + slopConstant + "; using default value"); // fall-through case TOUCH_SLOP_DEFAULT: mTouchSlop = vc.getScaledTouchSlop(); break; case TOUCH_SLOP_PAGING: mTouchSlop = vc.getScaledPagingTouchSlop(); break; } }