List of usage examples for android.view View isLongClickable
public boolean isLongClickable()
From source file:com.google.android.apps.common.testing.accessibility.framework.ViewAccessibilityUtils.java
/** * Determines if the supplied {@link View} is actionable for accessibility purposes. * * @param view The {@link View} to evaluate * @return {@code true} if {@code view} is considered actionable for accessibility *//* ww w .j a va 2s. com*/ public static boolean isActionableForAccessibility(View view) { if (view == null) { return false; } return (view.isClickable() || view.isLongClickable() || view.isFocusable()); }
From source file:android.support.v7.widget.ForwardingListener.java
private void onLongPress() { clearCallbacks();//from w w w. j ava 2 s .c o m final View src = mSrc; if (!src.isEnabled() || src.isLongClickable()) { // Ignore long-press if the view is disabled or has its own // handler. return; } if (!onForwardingStarted()) { return; } // Don't let the parent intercept our events. src.getParent().requestDisallowInterceptTouchEvent(true); // Make sure we cancel any ongoing source event stream. final long now = SystemClock.uptimeMillis(); final MotionEvent e = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0, 0, 0); src.onTouchEvent(e); e.recycle(); mForwarding = true; }
From source file:com.facebook.litho.MountItem.java
void init(Component<?> component, ComponentHost host, Object content, NodeInfo nodeInfo, ViewNodeInfo viewNodeInfo, DisplayListDrawable displayListDrawable, int flags, int importantForAccessibility) { mComponent = component;/*w ww . j a va 2s.co m*/ mContent = content; mHost = host; mFlags = flags; mImportantForAccessibility = importantForAccessibility; mDisplayListDrawable = displayListDrawable; if (mNodeInfo != null) { mNodeInfo.release(); mNodeInfo = null; } if (nodeInfo != null) { mNodeInfo = nodeInfo.acquireRef(); } if (mViewNodeInfo != null) { mViewNodeInfo.release(); mViewNodeInfo = null; } if (viewNodeInfo != null) { mViewNodeInfo = viewNodeInfo.acquireRef(); } if (mContent instanceof View) { final View view = (View) mContent; if (view.isClickable()) { mFlags |= FLAG_VIEW_CLICKABLE; } if (view.isLongClickable()) { mFlags |= FLAG_VIEW_LONG_CLICKABLE; } if (view.isFocusable()) { mFlags |= FLAG_VIEW_FOCUSABLE; } } }
From source file:android.support.car.app.CarFragmentActivity.java
private static String viewToString(View view) { StringBuilder out = new StringBuilder(128); out.append(view.getClass().getName()); out.append('{'); out.append(Integer.toHexString(System.identityHashCode(view))); out.append(' '); switch (view.getVisibility()) { case View.VISIBLE: out.append('V'); break;// ww w.j av a 2 s . com case View.INVISIBLE: out.append('I'); break; case View.GONE: out.append('G'); break; default: out.append('.'); break; } out.append(view.isFocusable() ? 'F' : '.'); out.append(view.isEnabled() ? 'E' : '.'); out.append(view.willNotDraw() ? '.' : 'D'); out.append(view.isHorizontalScrollBarEnabled() ? 'H' : '.'); out.append(view.isVerticalScrollBarEnabled() ? 'V' : '.'); out.append(view.isClickable() ? 'C' : '.'); out.append(view.isLongClickable() ? 'L' : '.'); out.append(' '); out.append(view.isFocused() ? 'F' : '.'); out.append(view.isSelected() ? 'S' : '.'); out.append(view.isPressed() ? 'P' : '.'); out.append(' '); out.append(view.getLeft()); out.append(','); out.append(view.getTop()); out.append('-'); out.append(view.getRight()); out.append(','); out.append(view.getBottom()); final int id = view.getId(); if (id != View.NO_ID) { out.append(" #"); out.append(Integer.toHexString(id)); final Resources r = view.getResources(); if (id != 0 && r != null) { try { String pkgname; switch (id & 0xff000000) { case 0x7f000000: pkgname = "app"; break; case 0x01000000: pkgname = "android"; break; default: pkgname = r.getResourcePackageName(id); break; } String typename = r.getResourceTypeName(id); String entryname = r.getResourceEntryName(id); out.append(" "); out.append(pkgname); out.append(":"); out.append(typename); out.append("/"); out.append(entryname); } catch (Resources.NotFoundException e) { } } } out.append("}"); return out.toString(); }
From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java
ViewHierarchyElement(int id, @Nullable ViewHierarchyElement parent, View fromView) { // Bookkeeping this.id = id; this.parentId = (parent != null) ? parent.getId() : null; // API 16+ properties this.scrollable = AT_16 ? fromView.isScrollContainer() : null; // API 11+ properties this.backgroundDrawableColor = (AT_11 && (fromView != null) && (fromView.getBackground() instanceof ColorDrawable)) ? ((ColorDrawable) fromView.getBackground()).getColor() : null;// w ww.ja va 2s. co m // Base properties this.visibleToUser = ViewAccessibilityUtils.isVisibleToUser(fromView); this.className = fromView.getClass().getName(); this.accessibilityClassName = null; this.packageName = fromView.getContext().getPackageName(); this.resourceName = (fromView.getId() != View.NO_ID) ? ViewAccessibilityUtils.getResourceNameForView(fromView) : null; this.contentDescription = SpannableString.valueOf(fromView.getContentDescription()); this.enabled = fromView.isEnabled(); if (fromView instanceof TextView) { TextView textView = (TextView) fromView; // Hint text takes precedence if no text is present. CharSequence text = textView.getText(); if (TextUtils.isEmpty(text)) { text = textView.getHint(); } this.text = SpannableString.valueOf(text); this.textSize = textView.getTextSize(); this.textColor = textView.getCurrentTextColor(); this.typefaceStyle = (textView.getTypeface() != null) ? textView.getTypeface().getStyle() : null; } else { this.text = null; this.textSize = null; this.textColor = null; this.typefaceStyle = null; } this.importantForAccessibility = ViewAccessibilityUtils.isImportantForAccessibility(fromView); this.clickable = fromView.isClickable(); this.longClickable = fromView.isLongClickable(); this.focusable = fromView.isFocusable(); this.editable = ViewAccessibilityUtils.isViewEditable(fromView); this.canScrollForward = (ViewCompat.canScrollVertically(fromView, 1) || ViewCompat.canScrollHorizontally(fromView, 1)); this.canScrollBackward = (ViewCompat.canScrollVertically(fromView, -1) || ViewCompat.canScrollHorizontally(fromView, -1)); this.checkable = (fromView instanceof Checkable); this.checked = (fromView instanceof Checkable) ? ((Checkable) fromView).isChecked() : null; this.hasTouchDelegate = (fromView.getTouchDelegate() != null); // There may be subtle differences between the bounds from a View instance compared to that of // its AccessibilityNodeInfo. The latter uses a @hide getBoundsOnScreen method, which clips to // parent bounds. android.graphics.Rect tempRect = new android.graphics.Rect(); if (fromView.getGlobalVisibleRect(tempRect)) { this.boundsInScreen = new Rect(tempRect); } else { this.boundsInScreen = null; } this.nonclippedHeight = fromView.getHeight(); this.nonclippedWidth = fromView.getWidth(); }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
public void setOnClicks(int... ids) { for (int id : ids) if (findViewById(id) != null) { View v = findViewById(id); if (v.isLongClickable()) v.setOnLongClickListener(this); v.setOnClickListener(this); }/*from w ww . ja v a 2s . c o m*/ }