当前位置: 首页>>代码示例>>Java>>正文


Java AccessibilityNodeInfo.getContentDescription方法代码示例

本文整理汇总了Java中android.view.accessibility.AccessibilityNodeInfo.getContentDescription方法的典型用法代码示例。如果您正苦于以下问题:Java AccessibilityNodeInfo.getContentDescription方法的具体用法?Java AccessibilityNodeInfo.getContentDescription怎么用?Java AccessibilityNodeInfo.getContentDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.accessibility.AccessibilityNodeInfo的用法示例。


在下文中一共展示了AccessibilityNodeInfo.getContentDescription方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: serialize

import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public static SerializedAccessibilityNodeInfo serialize(AccessibilityNodeInfo node){
    SerializedAccessibilityNodeInfo serializedNode = new SerializedAccessibilityNodeInfo();
    Rect boundsInScreen = new Rect(), boundsInParent = new Rect();
    if(node == null){
        return null;
    }
    if(node.getClassName() != null)
        serializedNode.className = node.getClassName().toString();
    node.getBoundsInScreen(boundsInScreen);
    node.getBoundsInParent(boundsInParent);

    serializedNode.boundsInScreen = boundsInScreen.flattenToString();
    serializedNode.boundsInParent = boundsInParent.flattenToString();

    if(node.getContentDescription() != null)
        serializedNode.contentDescription = node.getContentDescription().toString();

    if(node.getText() != null){
        serializedNode.text = node.getText().toString();
    }

    if(node.getViewIdResourceName() != null)
        serializedNode.viewId = node.getViewIdResourceName();

    int childCount = node.getChildCount();
    for(int i = 0; i < childCount; i ++){
        if(node.getChild(i) != null){
            serializedNode.children.add(serialize(node.getChild(i)));
        }
    }

    return serializedNode;
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:34,代码来源:AccessibilityUtils.java

示例2: getRedSenderInfo

import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public static String getRedSenderInfo(AccessibilityNodeInfo node) {
    AccessibilityNodeInfo nodeParent = node.getParent();
    if ("android.widget.ListView".equals(nodeParent)) return null;
    if (!TextUtils.isEmpty(nodeParent.getChild(0).getText()))
        content = nodeParent.getChild(0).getText().toString();//get content
    nodeParent = nodeParent.getParent();
    if (null==nodeParent)return null;
    if (!TextUtils.isEmpty(nodeParent.getChild(0).getText()))
        sendTime = nodeParent.getChild(0).getText().toString();//get Time
    for (int i = 0; i < nodeParent.getChildCount(); i++) {
        AccessibilityNodeInfo nodeChild = nodeParent.getChild(i);
        if ("android.widget.ImageView".equals(nodeChild.getClassName())) {
            CharSequence contentDescription = nodeChild.getContentDescription();
            if (null != contentDescription)
                sender = contentDescription.toString().replaceAll("头像$", ""); //get sender
        }
    }
    Log.e("LSeven", " red info===>" + sender + " " + content + " " + sendTime);
    return sender+"|"+content+"|"+sendTime;
}
 
开发者ID:WanAndroid,项目名称:GetRedPackets,代码行数:21,代码来源:SelfUtil.java

示例3: watchList

import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private boolean watchList(AccessibilityEvent event) {
    if (mListMutex) return false;
    mListMutex = true;
    AccessibilityNodeInfo eventSource = event.getSource();
    // Not a message
    if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED || eventSource == null)
        return false;

    List<AccessibilityNodeInfo> nodes = eventSource.findAccessibilityNodeInfosByText(WECHAT_NOTIFICATION_TIP);
    //增加条件判断currentActivityName.contains(WECHAT_LUCKMONEY_GENERAL_ACTIVITY)
    //避免当订阅号中出现标题为“[微信红包]拜年红包”(其实并非红包)的信息时误判
    if (!nodes.isEmpty() && currentActivityName.contains(WECHAT_LUCKMONEY_GENERAL_ACTIVITY)) {
        AccessibilityNodeInfo nodeToClick = nodes.get(0);
        if (nodeToClick == null) return false;
        CharSequence contentDescription = nodeToClick.getContentDescription();
        if (contentDescription != null && !signature.getContentDescription().equals(contentDescription)) {
            nodeToClick.performAction(AccessibilityNodeInfo.ACTION_CLICK);
            signature.setContentDescription(contentDescription.toString());
            return true;
        }
    }
    return false;
}
 
开发者ID:KoreHuang,项目名称:WeChatLuckyMoney,代码行数:24,代码来源:HongbaoService.java

示例4: clickLastMsg

import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/** 点最新消息 */
private boolean clickLastMsg(AccessibilityNodeInfo nodeInfo) {
    boolean isClick = false;
    AccessibilityNodeInfo item = AccessibilityUtils.findNodeInfosByIdLast(nodeInfo, ID_LIST_CHAT_ITEM);
    if(item != null){
        CharSequence desc = item.getContentDescription();
        if(TextUtils.isEmpty(desc)){
            return isClick;
        }
        isClick = clickRedPacket(nodeInfo, item, desc);
    }
    return isClick;
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:14,代码来源:QQAccessibilityJob.java

示例5: getSenderContentDescriptionFromNode

import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private String[] getSenderContentDescriptionFromNode(AccessibilityNodeInfo node) {
    int count = node.getChildCount();
    String[] result = {"unknownSender", "unknownTime"};
    for (int i = 0; i < count; i++) {
        AccessibilityNodeInfo thisNode = node.getChild(i);
        if ("android.widget.ImageView".equals(thisNode.getClassName()) && "unknownSender".equals(result[0])) {
            CharSequence contentDescription = thisNode.getContentDescription();
            if (contentDescription != null) result[0] = contentDescription.toString().replaceAll("头像$", "");
        } else if ("android.widget.TextView".equals(thisNode.getClassName()) && "unknownTime".equals(result[1])) {
            CharSequence thisNodeText = thisNode.getText();
            if (thisNodeText != null) result[1] = thisNodeText.toString();
        }
    }
    return result;
}
 
开发者ID:KoreHuang,项目名称:WeChatLuckyMoney,代码行数:16,代码来源:HongbaoSignature.java

示例6: findEditText

import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private boolean findEditText(AccessibilityNodeInfo rootNode, String content)
   {
       int count = rootNode.getChildCount();

    //   android.util.Log.d("maptrix", "root class=" + rootNode.getClassName() + "," + rootNode.getText() + "," + count);
       for (int i = 0; i < count; i++)
{
           AccessibilityNodeInfo nodeInfo = rootNode.getChild(i);
           if (nodeInfo == null)
    {
    //           android.util.Log.d("maptrix", "nodeinfo = null");
               continue;
           }

     //      android.util.Log.d("maptrix", "class=" + nodeInfo.getClassName());
   //        android.util.Log.e("maptrix", "ds=" + nodeInfo.getContentDescription());
           if (nodeInfo.getContentDescription() != null)
    {
               int nindex = nodeInfo.getContentDescription().toString().indexOf(name);
               int cindex = nodeInfo.getContentDescription().toString().indexOf(scontent);
     //          android.util.Log.e("maptrix", "nindex=" + nindex + " cindex=" + cindex);
               if (nindex != -1)
	{
                   itemNodeinfo = nodeInfo;
                  // android.util.Log.i("maptrix", "find node info");
               }
           }
           if ("android.widget.EditText".equals(nodeInfo.getClassName()))
    {
    //           android.util.Log.i("maptrix", "==================");
               Bundle arguments = new Bundle();
               arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
			 AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD);
               arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
			     true);
               nodeInfo.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
			       arguments);
               nodeInfo.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
               ClipData clip = ClipData.newPlainText("label", content);
               ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
               clipboardManager.setPrimaryClip(clip);
               nodeInfo.performAction(AccessibilityNodeInfo.ACTION_PASTE);
               return true;
           }

           if (findEditText(nodeInfo, content))
    {
               return true;
           }
       }

       return false;
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:54,代码来源:AppCompatDlalog.java

示例7: windowContentEvent

import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/** 窗口内容变化 */
private void windowContentEvent(AccessibilityEvent event) {
    if(mCurrentWindow != WINDOW_SPLASH){ // //不在聊天界面或聊天列表,不处理
        return;
    }

    AccessibilityNodeInfo nodeInfo = mService.getRootInActiveWindow();
    if(nodeInfo == null){
        return;
    }

    // 获取MsgBox
    AccessibilityNodeInfo msgBox = AccessibilityUtils.findNodeInfosById(nodeInfo, ID_MSG_BOX);
    if(msgBox != null){
        CharSequence text = msgBox.getText();
        if(!TextUtils.isEmpty(text)){
            String value = text.toString();
            int index = value.lastIndexOf(":");
            if(index != -1) {
                value = value.substring(index + 1);
            }
            if(value.startsWith(KEY)) {
                AccessibilityUtils.performClick(msgBox);
                return;
            }
        }
    }

    // 直接去获取当前会话的最后一条Item, 不为null, 则是当前会话列表
    AccessibilityNodeInfo item = AccessibilityUtils.findNodeInfosByIdLast(nodeInfo, ID_LIST_CHAT_ITEM);
    if(item != null){
        CharSequence desc = item.getContentDescription();
        if(TextUtils.isEmpty(desc)){
            return;
        }
        clickRedPacket(nodeInfo, item, desc);
        return;
    }

    // 聊天记录的 ID_LIST_MSG_LABEL 是 View, 具体不知道怎么获取消息值
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:42,代码来源:QQAccessibilityJob.java

示例8: findEditText

import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/**
 * 通过rootNode 填充内容
 * @param rootNode
 * @param content
 * @return
 */
private boolean findEditText(AccessibilityNodeInfo rootNode, String content) {
    int count = rootNode.getChildCount();

    for (int i = 0; i < count; i++) {
        AccessibilityNodeInfo nodeInfo = rootNode.getChild(i);
        if (nodeInfo == null) {
            continue;
        }
        if(nodeInfo.getContentDescription() != null){
            int nindex = nodeInfo.getContentDescription().toString().indexOf(name);
            int cindex = nodeInfo.getContentDescription().toString().indexOf(scontent);
            if(nindex != -1){
                itemNodeinfo = nodeInfo;
            }
        }
        if ("android.widget.EditText".equals(nodeInfo.getClassName())) {
            Bundle arguments = new Bundle();
            arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
                    AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD);
            arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN,
                    true);
            nodeInfo.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
                    arguments);
            nodeInfo.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
            // 创建一个剪贴数据集,把content数据集放进去
            ClipData clip = ClipData.newPlainText("label", content);
            // 获取系统剪贴板
            ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            // 把数据集设置(复制)到剪贴板
            clipboardManager.setPrimaryClip(clip);
            nodeInfo.performAction(AccessibilityNodeInfo.ACTION_PASTE);
            return true;
        }

        if (findEditText(nodeInfo, content)) {
            return true;
        }
    }

    return false;
}
 
开发者ID:xmlxin,项目名称:ReplyMessage,代码行数:48,代码来源:AutoReplyService.java


注:本文中的android.view.accessibility.AccessibilityNodeInfo.getContentDescription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。