當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。