Merge branch 'xatom' of https://gitee.com/fanghoo/fuzhu into xatom

This commit is contained in:
2021-10-26 15:45:07 +08:00
5 changed files with 94 additions and 20 deletions

View File

@@ -376,7 +376,7 @@ public class AblViewUtil {
new float[]{x, y},
new float[]{x, y},
100,
50,
100,
null
);
}

View File

@@ -309,7 +309,7 @@ public class MainActivity extends BaseActivity implements InfoMessage {
.setFindViewMillisInFuture(10000)//寻找界面超时时间
.setFindViewCountDownInterval(200)//寻找界面间隔时间
.build().init();
AblStepHandler.getInstance().initStepClass(new TestAblStep0(), new TestAblStep1(), new TestAblStep2(), new TestAblStep8(), new TestAblStep9(), new TestAblStep10(), new TestAblStep12(), new TestAblStep13(), new TestAblStep18(), new TestAblStep19(), new TestAblStep23(), new TestAblStep25(), new TestAblStep26(), new TestAblStep27(), new TestAblStep28(), new TestAblStep29(), new TestAblStep31(), new TestAblStep32(), new TestAblStep33() , new AblStep1());
AblStepHandler.getInstance().initStepClass(new TestAblStep0(), new TestAblStep1(), new TestAblStep2(), new TestAblStep8(), new TestAblStep9(), new TestAblStep10(), new TestAblStep12(), new TestAblStep13(), new TestAblStep18(), new TestAblStep19(), new TestAblStep23(), new TestAblStep25(), new TestAblStep26(), new TestAblStep27(), new TestAblStep28(), new TestAblStep29(), new TestAblStep31(), new TestAblStep32(), new TestAblStep33());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int hasWriteContactsPermission = checkSelfPermission(Manifest.permission.READ_CONTACTS);
if (hasWriteContactsPermission != PackageManager.PERMISSION_GRANTED) {

View File

@@ -1,6 +1,7 @@
package com.fisherbone.fuzhu.quzan;
import android.os.Message;
import android.view.accessibility.AccessibilityNodeInfo;
import com.fisherbone.fuzhu.abllib.AblService;
import com.fisherbone.fuzhu.abllib.AblStepHandler;
@@ -8,6 +9,9 @@ import com.fisherbone.fuzhu.abllib.AblSteps;
import com.fisherbone.fuzhu.abllib.BaseAblStep;
import com.fisherbone.fuzhu.abllib.utils.AblViewUtil;
import java.util.Collections;
import java.util.List;
public class AblStep1 extends BaseAblStep {
int i = 0;
int j = 0;
@@ -17,17 +21,17 @@ public class AblStep1 extends BaseAblStep {
switch ( step ){
case AblSteps.STEP_260:
AblViewUtil.startApplication();
AblViewUtil.mySleep(8);
AblViewUtil.mySleep(5);
AblStepHandler.sendMsg(AblSteps.STEP_261);
break;
case AblSteps.STEP_261:
AblService instance = AblService.getInstance();
AblViewUtil.mySleep(4);
AblViewUtil.mySleep(2);
myClick();
AblStepHandler.sendMsg(AblSteps.STEP_262);
break;
case AblSteps.STEP_262:
AblViewUtil.clickScreen(12,12);
findAndPerformActionTextView("喜欢");
AblStepHandler.sendMsg(AblSteps.STEP_263);
break;
case AblSteps.STEP_263:
@@ -35,15 +39,61 @@ public class AblStep1 extends BaseAblStep {
AblStepHandler.sendMsg(AblSteps.STEP_264);
break;
case AblSteps.STEP_264:
AblViewUtil.clickScreen(18,11);
AblStepHandler.sendMsg(AblSteps.STEP_265);
findAndPerformActionLike();
AblViewUtil.scrollVertical(15,2);
AblViewUtil.mySleep(1);
AblStepHandler.sendMsg(AblSteps.STEP_264);
break;
case AblSteps.STEP_265:
AblViewUtil.scrollVertical(15,2);
AblStepHandler.sendMsg(AblSteps.STEP_264);
break;
default:
}
}
public void findAndPerformActionTextView(String text) {
if (AblService.getInstance().getRootInActiveWindow() == null) {
return;
}
List node = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText(text);
for ( int i = 0; i < node.size(); i++ ){
AccessibilityNodeInfo nodeInfo = (AccessibilityNodeInfo) node.get(i);
if (nodeInfo != null && nodeInfo.isEnabled()){
performViewClick(nodeInfo);
}
}
}
/**
* 模拟点击事件,如果该node不能点击则点击父node将点击事件一直向父级传递直至到根node或者找到一个可以点击的node
*
* @param nodeInfo nodeInfo
*/
public void performViewClick(AccessibilityNodeInfo nodeInfo) {
if (nodeInfo == null) {
return;
} else {
while (nodeInfo != null) {
if (nodeInfo.isClickable()) {
nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
break;
}
nodeInfo = nodeInfo.getParent();
}
}
}
public void findAndPerformActionLike() {
if (AblService.getInstance().getRootInActiveWindow() == null) {
return;
}
List node = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText("已选中,喜欢");
for ( int i = 0; i < node.size(); i++ ){
AccessibilityNodeInfo nodeInfo = (AccessibilityNodeInfo) node.get(i);
if (nodeInfo != null && nodeInfo.isEnabled()){
nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}
}
}