Java Code Examples for android.view.View.getContentDescription()

The following are Jave code examples for showing how to use getContentDescription() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: MainActivity.java   View Source Code Vote up 6 votes
private void showHeadView(){
    headerLayout.setTranslationY(0);
    View underView = rightMenu.findChildViewUnder(headerView.getX(),0);
    if(underView!=null && underView.getContentDescription()!=null){
        int position = Integer.parseInt(underView.getContentDescription().toString());
        DishMenu menu = rightAdapter.getMenuOfMenuByPosition(position+1);
        headMenu = menu;
        headerView.setText(headMenu.getMenuName());
        for (int i = 0; i < dishMenuList.size(); i++) {
            if (dishMenuList.get(i) == headMenu) {
                leftAdapter.setSelectedNum(i);
                break;
            }
        }
    }
}
 
Example 2
Project: ChimpCheck   File: SwipeActivity.java   View Source Code Vote up 6 votes
@Override
protected void onResume(){
    super.onResume();
    View root = this.getWindow().getDecorView();

    for(View v : TreeIterables.breadthFirstViewTraversal(root)){
        if(v.getId() != -1) {
            System.out.println("View: " + v.getResources().getResourceEntryName(v.getId()) + " " + v.isClickable());
        } else if(v.getContentDescription() != null){
            System.out.println("View: " + v.getContentDescription().toString() + " " + v.isClickable());
        } else{
            System.out.println("View: " + v.toString() + " No Des, No Id " + v.isClickable());
        }

    }
}
 
Example 3
Project: microMathematics   File: ViewUtils.java   View Source Code Vote up 6 votes
/**
 * Procedure hows toast that contains description of the given button
 */
@SuppressLint("RtlHardcoded")
public static boolean showButtonDescription(Context context, View button)
{
    CharSequence contentDesc = button.getContentDescription();
    if (contentDesc != null && contentDesc.length() > 0)
    {
        int[] pos = new int[2];
        button.getLocationOnScreen(pos);

        Toast t = Toast.makeText(context, contentDesc, Toast.LENGTH_SHORT);
        t.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0);
        t.getView().measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        final int x = pos[0] + button.getMeasuredWidth() / 2 - (t.getView().getMeasuredWidth() / 2);
        final int y = pos[1] - button.getMeasuredHeight() / 2 - t.getView().getMeasuredHeight()
                - context.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin);
        t.setGravity(Gravity.TOP | Gravity.LEFT, x, y);
        t.show();
        return true;
    }
    return false;
}
 
Example 4
Project: Bigbang   File: XposedUniversalCopyHandler.java   View Source Code Vote up 5 votes
private ArrayList<CopyNode> traverseNode(View nodeInfo, int screenWidth, int scerrnHeight) {
    ArrayList nodeList = new ArrayList();
    if(nodeInfo != null ) {
        if (!nodeInfo.isShown()){
            return nodeList;
        }
        if (nodeInfo instanceof ViewGroup){
            ViewGroup viewGroup = (ViewGroup) nodeInfo;
            for(int var4 = 0; var4 < viewGroup.getChildCount(); ++var4) {
                nodeList.addAll(this.traverseNode(viewGroup.getChildAt(var4), screenWidth, scerrnHeight));
            }
        }
        if(nodeInfo.getClass().getName() != null && nodeInfo.getClass().getName().equals("android.webkit.WebView")) {
            return nodeList;
        } else {
            String content = null;
            String description = content;
            if(nodeInfo.getContentDescription() != null) {
                description = content;
                if(!"".equals(nodeInfo.getContentDescription())) {
                    description = nodeInfo.getContentDescription().toString();
                }
            }

            content = description;
            String text=getTextInFilters(nodeInfo,mFilters);
            if(text != null) {
                content = description;
                if(!"".equals(text)) {
                    content = text.toString();
                }
            }

            if(content != null) {
                Rect var8 = new Rect();
                nodeInfo.getGlobalVisibleRect(var8);
                if(checkBound(var8, screenWidth, scerrnHeight)) {
                    nodeList.add(new CopyNode(var8, content));
                }
            }

            return nodeList;
        }
    } else {
        return nodeList;
    }
}
 
Example 5
Project: ChimpCheck   File: ActivityManager.java   View Source Code Vote up 5 votes
protected static String getResName(View v){
    if(v == null) return "";
    if(v.getId() == -1){
        if(v.getContentDescription() != null) {
            return v.getContentDescription().toString();
        } else {
            return "";
        }
    }else {
        return v.getResources().getResourceEntryName(v.getId());
    }
}
 
Example 6
Project: foco   File: SelectionToolbarUtils.java   View Source Code Vote up 5 votes
@Override
public boolean onLongClick(View v) {
    CharSequence description = v.getContentDescription();
    if (!TextUtils.isEmpty(description)) {
        Toast.makeText(mContext, description, Toast.LENGTH_SHORT).show();
    }
    return true;
}