public static int dpToPx(int dp, Context ctx) { Resources r = ctx.getResources(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); } //originally: http://stackoverflow.com/questions/5418510/disable-the-touch-events-for-all-the-views //modified for the needs here public static void enableDisableViewGroup(ViewGroup viewGroup, boolean enabled) { int childCount = viewGroup.getChildCount(); for (int i = 0; i < childCount; i++) { View view = viewGroup.getChildAt(i); if(view.isFocusable()) view.setEnabled(enabled); if (view instanceof ViewGroup) { enableDisableViewGroup((ViewGroup) view, enabled); } else if (view instanceof ListView) { if(view.isFocusable()) view.setEnabled(enabled); ListView listView = (ListView) view; int listChildCount = listView.getChildCount(); for (int j = 0; j < listChildCount; j++) { if(view.isFocusable()) listView.getChildAt(j).setEnabled(false); } } } }
attributes.add(new ViewAttribute<>("Dirty", view.isDirty())); attributes.add(new MutableBooleanViewAttribute("IsFocusable", view.isFocusable()) { @Override protected void mutate(Boolean value) {
public S isFocusable() { isNotNull(); assertThat(actual.isFocusable()) // .overridingErrorMessage("Expected to be focusable but was not") // .isTrue(); return myself; }
public RVHolder(View itemView, String focusViewType, boolean isFocusScaleAnim, boolean isTranslateAnim) { super(itemView); if (itemView.isFocusable() && itemView.isFocusableInTouchMode()) { initView(itemView, focusViewType, isFocusScaleAnim, isTranslateAnim); } else { if (itemView instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) itemView; int count = viewGroup.getChildCount(); View child; for (int i = 0; i < count; i++) { child = viewGroup.getChildAt(i); if (child.isFocusable() && child.isFocusableInTouchMode()) { initView(child, focusViewType, isFocusScaleAnim, isTranslateAnim); } } } } }
public S isNotFocusable() { isNotNull(); assertThat(actual.isFocusable()) // .overridingErrorMessage("Expected to not be focusable but was") // .isFalse(); return myself; }
@Test public void shouldNotBeFocusableByDefault() throws Exception { assertFalse(view.isFocusable()); view.setFocusable(true); assertTrue(view.isFocusable()); }
if (view.isFocusable()) { mMountViewFlags |= FLAG_VIEW_FOCUSABLE;
child, nodeInfo, child.isFocusable(), ViewCompat.getImportantForAccessibility(child)));
//Global Variable.. View v; //beore you hiding the buttons v = getCurrentFocus (); //after you showing the buttons if(null!=v && v. isFocusable ()) v.requestFoucs();
public S isFocusable() { isNotNull(); assertThat(actual.isFocusable()) // .overridingErrorMessage("Expected to be focusable but was not") // .isTrue(); return myself; }
public S isNotFocusable() { isNotNull(); assertThat(actual.isFocusable()) // .overridingErrorMessage("Expected to not be focusable but was") // .isFalse(); return myself; }
private void getFocusableViews(View view, final List<View> focusables) { // Not using addFocusables() or addTouchables() because of concerns with adding ViewGroup // and not getting "clickables." if (!(view instanceof ViewGroup) && (view != null) && (view.isFocusable() || view.isClickable())) { focusables.add(view); } if (view instanceof ViewGroup) { ViewGroup parent = (ViewGroup) view; for (int i = 0; i < parent.getChildCount(); i++) { getFocusableViews(parent.getChildAt(i), focusables); } } } }
/** * 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 */ public static boolean isActionableForAccessibility(View view) { if (view == null) { return false; } return (view.isClickable() || view.isLongClickable() || view.isFocusable()); }
private static View getFirstFocusableIconInReadingOrder(CellLayout cellLayout, boolean isRtl) { View icon; int countX = cellLayout.getCountX(); for (int y = 0; y < cellLayout.getCountY(); y++) { int increment = isRtl ? -1 : 1; for (int x = isRtl ? countX - 1 : 0; 0 <= x && x < countX; x += increment) { if ((icon = cellLayout.getChildAt(x, y)) != null && icon.isFocusable()) { return icon; } } } return null; }
private static View getFirstFocusableIconInReadingOrder(CellLayout cellLayout, boolean isRtl) { View icon; int countX = cellLayout.getCountX(); for (int y = 0; y < cellLayout.getCountY(); y++) { int increment = isRtl ? -1 : 1; for (int x = isRtl ? countX - 1 : 0; 0 <= x && x < countX; x += increment) { if ((icon = cellLayout.getChildAt(x, y)) != null && icon.isFocusable()) { return icon; } } } return null; }
private static View getFirstFocusableIconInReadingOrder(CellLayout cellLayout, boolean isRtl) { View icon; int countX = cellLayout.getCountX(); for (int y = 0; y < cellLayout.getCountY(); y++) { int increment = isRtl ? -1 : 1; for (int x = isRtl ? countX - 1 : 0; 0 <= x && x < countX; x += increment) { if ((icon = cellLayout.getChildAt(x, y)) != null && icon.isFocusable()) { return icon; } } } return null; }
private static View getFirstFocusableIconInReverseReadingOrder(CellLayout cellLayout, boolean isRtl) { View icon; int countX = cellLayout.getCountX(); for (int y = cellLayout.getCountY() - 1; y >= 0; y--) { int increment = isRtl ? 1 : -1; for (int x = isRtl ? 0 : countX - 1; 0 <= x && x < countX; x += increment) { if ((icon = cellLayout.getChildAt(x, y)) != null && icon.isFocusable()) { return icon; } } } return null; } }
private static View getFirstFocusableIconInReverseReadingOrder(CellLayout cellLayout, boolean isRtl) { View icon; int countX = cellLayout.getCountX(); for (int y = cellLayout.getCountY() - 1; y >= 0; y--) { int increment = isRtl ? 1 : -1; for (int x = isRtl ? 0 : countX - 1; 0 <= x && x < countX; x += increment) { if ((icon = cellLayout.getChildAt(x, y)) != null && icon.isFocusable()) { return icon; } } } return null; } }
private static View getFirstFocusableIconInReverseReadingOrder(CellLayout cellLayout, boolean isRtl) { View icon; int countX = cellLayout.getCountX(); for (int y = cellLayout.getCountY() - 1; y >= 0; y--) { int increment = isRtl ? 1 : -1; for (int x = isRtl ? 0 : countX - 1; 0 <= x && x < countX; x += increment) { if ((icon = cellLayout.getChildAt(x, y)) != null && icon.isFocusable()) { return icon; } } } return null; } }
/** * Returns a matrix of size same as the {@link CellLayout} dimension that is initialized with the * index of the child view. */ // TODO: get rid of the dynamic matrix creation public static int[][] createSparseMatrix(CellLayout layout) { ShortcutAndWidgetContainer parent = layout.getShortcutsAndWidgets(); final int m = layout.getCountX(); final int n = layout.getCountY(); final boolean invert = parent.invertLayoutHorizontally(); int[][] matrix = createFullMatrix(m, n); // Iterate thru the children. for (int i = 0; i < parent.getChildCount(); i++ ) { View cell = parent.getChildAt(i); if (!cell.isFocusable()) { continue; } int cx = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellX; int cy = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellY; matrix[invert ? (m - cx - 1) : cx][cy] = i; } return matrix; }