Skip to content

Commit

Permalink
Merge pull request #207 from GuoXiCheng/dev-c
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
GuoXiCheng authored Aug 24, 2024
2 parents 7e02e24 + 0377082 commit 8fd37fa
Show file tree
Hide file tree
Showing 7 changed files with 338 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ data class NodeChildSchema(
val top: Int,
val right: Int,
val bottom: Int,
val isClickable: Boolean,
var className: String? = null,
var text: String? = null,
var viewIdResourceName: String? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.android.skip.dataclass

data class NodeRootSchema(
val uuid: String,
val appName: String,
val packageName: String,
val className: String,
val activityName: String,
val screenHeight: Int,
val screenWidth: Int,
val createTime: Long,
val nodes: MutableList<NodeChildSchema>
)
15 changes: 13 additions & 2 deletions app/src/main/java/com/android/skip/utils/LayoutInspectUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object LayoutInspectUtils {

CoroutineScope(Dispatchers.IO).launch {
repeat(3) { index ->
delay( 3000)
delay(3000)
val zipFile = File(SKIPApp.context.filesDir, "$filename.zip")
if (FileUtils.isFileExists(zipFile)) return@repeat

Expand Down Expand Up @@ -143,10 +143,13 @@ object LayoutInspectUtils {
}

val nodeRootSchema = NodeRootSchema(
filename.toString(),
InstalledAppUtils.getAppInfoByPackageName(root.packageName.toString()).name,
root.packageName.toString(),
activityName.toString(),
ScreenUtils.getScreenHeight(),
ScreenUtils.getScreenWidth(),
System.currentTimeMillis(),
nodeChildSchemaList
)

Expand All @@ -166,7 +169,15 @@ object LayoutInspectUtils {
val rect = Rect()
node.getBoundsInScreen(rect)
val myNodeChild = NodeChildSchema(
depth, node.childCount, parentId, nodeId, rect.left, rect.top, rect.right, rect.bottom
depth,
node.childCount,
parentId,
nodeId,
rect.left,
rect.top,
rect.right,
rect.bottom,
node.isClickable
)

node.className?.let {
Expand Down
122 changes: 66 additions & 56 deletions docs/inspect/InspectContainer.vue
Original file line number Diff line number Diff line change
@@ -1,77 +1,87 @@
<template>
<el-row class="h-screen">
<el-col :span="6">
<NodePic v-if="rawData" :raw-data="rawData" :img-src="imgSrc" :current-node-key="currentNodeKey"
@handle-img-node-click="handleImgNodeClick" />
</el-col>
<el-col :span="9" class="h-full overflow-y-auto">
<NodeTree v-if="treeData" :tree-data="treeData" :current-node-key="currentNodeKey"
@handle-tree-node-click="handleTreeNodeClick" />
</el-col>
<el-col :span="9">
<NodeTable :node-data="nodeData" />
</el-col>
</el-row>
<el-row class="h-screen">
<el-col :span="6">
<NodePic
:raw-data="rawData"
:img-src="imgSrc"
:current-node-key="currentNodeKey"
@handle-img-node-click="handleImgNodeClick"
v-if="rawData"
/>
</el-col>
<el-col :span="9" class="h-full overflow-y-auto">
<NodeTree
:tree-data="treeData"
:current-node-key="currentNodeKey"
@handle-tree-node-click="handleTreeNodeClick"
v-if="treeData"
/>
</el-col>
<el-col :span="9">
<NodeTable :node-data="nodeData" :raw-data="rawData" v-if="rawData" />
</el-col>
</el-row>
</template>

<script lang="ts" setup>
import NodeTree from './NodeTree.vue';
import NodeTable from './NodeTable.vue';
import NodePic from './NodePic.vue';
import { ref, onMounted } from 'vue';
import { AccessibilityNode, AccessibilityNodeTree, AccessibilityWindow } from './types';
import JSZip from 'jszip';
import NodeTree from "./NodeTree.vue";
import NodeTable from "./NodeTable.vue";
import NodePic from "./NodePic.vue";
import { ref, onMounted } from "vue";
import { AccessibilityNode, AccessibilityNodeTree, AccessibilityWindow } from "./types";
import JSZip from "jszip";
const treeData = ref<AccessibilityNodeTree[]>([]);
const nodeData = ref<AccessibilityNode | null>(null);
const rawData = ref<AccessibilityWindow | null>(null);
const currentNodeKey = ref<number>(-1);
const imgSrc = ref<string>('');
const imgSrc = ref<string>("");
onMounted(async () => {
const response = await fetch('/1724297451246.zip');
const arrayBuffer = await response.arrayBuffer();
const zip = await JSZip.loadAsync(arrayBuffer);
const response = await fetch("/94e04ea4-2502-4c24-a7f1-7574270fa921.zip");
const arrayBuffer = await response.arrayBuffer();
const zip = await JSZip.loadAsync(arrayBuffer);
const pngFile = zip.filter((relativePath, file) => relativePath.endsWith('.png'));
const blob = await pngFile[0].async('blob');
const imgUrl = URL.createObjectURL(blob);
imgSrc.value = imgUrl;
const pngFile = zip.filter((relativePath, file) => relativePath.endsWith(".png"));
const blob = await pngFile[0].async("blob");
const imgUrl = URL.createObjectURL(blob);
imgSrc.value = imgUrl;
const jsonFile = zip.filter((relativePath, file) => relativePath.endsWith('.json'));
const jsonText = await jsonFile[0].async('text');
const data = JSON.parse(jsonText) as AccessibilityWindow;
rawData.value = data;
treeData.value = buildTree(data.nodes, -1);
const jsonFile = zip.filter((relativePath, file) => relativePath.endsWith(".json"));
const jsonText = await jsonFile[0].async("text");
const data = JSON.parse(jsonText) as AccessibilityWindow;
rawData.value = data;
treeData.value = buildTree(data.nodes, -1);
});
function buildTree(data: AccessibilityNode[], parentId: number): AccessibilityNodeTree[] {
const children = data.filter(node => node.parentId === parentId);
return children.map(node => {
const { childCount, className, nodeId, text, viewIdResourceName, left, top, right, bottom } = node;
return {
label: childCount === 0 ? className : `${className} [${childCount}]`,
children: buildTree(data, nodeId),
text,
className,
childCount,
viewIdResourceName,
left,
top,
right,
bottom,
nodeId
}
})
const children = data.filter((node) => node.parentId === parentId);
return children.map((node) => {
const { childCount, className, nodeId, text, viewIdResourceName, left, top, right, bottom, isClickable } = node;
return {
label: childCount === 0 ? className : `${className} [${childCount}]`,
children: buildTree(data, nodeId),
text,
className,
childCount,
viewIdResourceName,
left,
top,
right,
bottom,
nodeId,
isClickable,
};
});
}
const handleTreeNodeClick = (data: AccessibilityNode) => {
nodeData.value = data;
currentNodeKey.value = data.nodeId;
}
nodeData.value = data;
currentNodeKey.value = data.nodeId;
};
const handleImgNodeClick = (data: AccessibilityNode) => {
nodeData.value = data;
currentNodeKey.value = data.nodeId;
}
</script>
nodeData.value = data;
currentNodeKey.value = data.nodeId;
};
</script>
Loading

0 comments on commit 8fd37fa

Please sign in to comment.