@Override public String apply(@Nullable View input) { if (input == null) { return "Provided view was null"; } if (input.getContentDescription() == null) { return String.format( "No content description found, view is %s", getVisibilityString(input.getVisibility())); } return String.format( "Found content description: \"%s\", view is %s", input.getContentDescription(), getVisibilityString(input.getVisibility())); } };
@Override public boolean apply(final View input) { if (input instanceof ComponentHost) { final List<CharSequence> contentDescriptions = ((ComponentHost) input).getContentDescriptions(); return contentDescriptions.contains(contentDescription); } return contentDescription.equals(input.getContentDescription()); } };
static void findViewsWithText(List<View> outViews, ViewGroup parent, String targetDescription) { if (parent == null || TextUtils.isEmpty(targetDescription)) { return; } final int count = parent.getChildCount(); for (int i = 0; i < count; i++) { final View child = parent.getChildAt(i); final CharSequence desc = child.getContentDescription(); if (!TextUtils.isEmpty(desc) && targetDescription.equals(desc.toString())) { outViews.add(child); } else if (child instanceof ViewGroup && child.getVisibility() == View.VISIBLE) { findViewsWithText(outViews, (ViewGroup) child, targetDescription); } } }
public S hasContentDescription(CharSequence contentDescription) { isNotNull(); CharSequence actualContentDescription = actual.getContentDescription(); assertThat(actualContentDescription) // .overridingErrorMessage("Expected content description <%s> but was <%s>", contentDescription, actualContentDescription) // .isEqualTo(contentDescription); return myself; }
public static JSONObject setBasicInfoOfView(View view, JSONObject json) { try { String text = getTextOfView(view); String hint = getHintOfView(view); Object tag = view.getTag(); CharSequence description = view.getContentDescription(); json.put(CLASS_NAME_KEY, view.getClass().getCanonicalName()); json.put(CLASS_TYPE_BITMASK_KEY, getClassTypeBitmask(view)); json.put(ID_KEY, view.getId()); if (!SensitiveUserDataUtils.isSensitiveUserData(view)) { json.put(TEXT_KEY, text); } else { json.put(TEXT_KEY, ""); json.put(IS_USER_INPUT_KEY, true); } json.put(HINT_KEY, hint); if (tag != null) { json.put(TAG_KEY, tag.toString()); } if (description != null) { json.put(DESC_KEY, description.toString()); } JSONObject dimension = getDimensionOfView(view); json.put(DIMENSION_KEY, dimension); } catch (JSONException e) { Utility.logd(TAG, e); } return json; }
& MatchBitmaskType.DESCRIPTION.getValue()) > 0) { String pathDesc = pathElement.description; String targetDesc = targetView.getContentDescription() == null ? "" : String.valueOf(targetView.getContentDescription()); if (!pathDesc.equals(targetDesc)) { return false;
@Test public void testContentDescriptionIsSet() throws Exception { View mediaView = inflate(layout.main); assertThat(mediaView.findViewById(R.id.time).getContentDescription().toString()) .isEqualTo("Howdy"); }
@Override public boolean onLongClick(View view) { return showCheatSheet(view, view.getContentDescription()); } });
final String oldContentDescription = oldView.getContentDescription().toString(); final Drawable oldBackground = oldView.getBackground(); final String newContentDescription = newView.getContentDescription().toString(); final Drawable newBackground = newView.getBackground();
@Override public boolean onLongClick(View view) { return showCheatSheet(view, view.getContentDescription()); } });
@Override public boolean onLongClick(View view) { return showCheatSheet(view, view.getContentDescription()); } });
findViewById(R.id.button_edit).setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { Toast.makeText(context,view.getContentDescription(), Toast.LENGTH_SHORT).show(); return true; } });
textView.setText(yourText.replaceAll("[0-9]","")); textView.setContentDescription(yourText); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String str = ((TextView) v.getContentDescription()).toString(); } });
/** * OnClick handler - Browse URL from content description * @param view view source of click event */ public void browseClickedUrl(View view) { String url = view.getContentDescription().toString(); startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url))); }
public S hasContentDescription(CharSequence contentDescription) { isNotNull(); CharSequence actualContentDescription = actual.getContentDescription(); assertThat(actualContentDescription) // .overridingErrorMessage("Expected content description <%s> but was <%s>", contentDescription, actualContentDescription) // .isEqualTo(contentDescription); return myself; }
@Override public boolean onLongClick(View v) { ClipData imageData = ClipData.newPlainText("name", v.getContentDescription()); return ViewCompat.startDragAndDrop(v, imageData, new DragShadowBuilder(v), null, 0); } };
@Thunk void selectTile(View v) { if (mSelectedTile != null) { mSelectedTile.setSelected(false); mSelectedTile = null; } mSelectedTile = v; v.setSelected(true); mSelectedIndex = mWallpapersView.indexOfChild(v); // TODO: Remove this once the accessibility framework and // services have better support for selection state. v.announceForAccessibility( getContext().getString(R.string.announce_selection, v.getContentDescription())); }
public Element (View view) { ELEMENT = UUID.randomUUID().toString(); cache.put(ELEMENT, view); // Cache the content description as well CharSequence contentDesc = view.getContentDescription(); if (contentDesc != null) { contentDescriptionCache.put(ELEMENT, contentDesc.toString()); } }
@Override public boolean onLongClick(View v) { DynamicHint.show(v, DynamicHint.make(DynamicTheme.getInstance().getContext(), v.getContentDescription(), mActionCustom.getCurrentTextColor(), ((DynamicWidget) v).getColor())); return true; } });
@Override public boolean onLongClick(View v) { DynamicHint.show(v, DynamicHint.make(DynamicTheme.getInstance().getContext(), v.getContentDescription(), mActionCustom.getCurrentTextColor(), ((DynamicWidget) v).getColor())); return true; } });