ec 脚本运行中通过悬浮窗交互获取数据

main.js
function main() {
    //开始再这里编写代码了!!
    toast("Hello World");

    let p = floaty.requestFloatViewPermission(1000)
    logd("是否有浮窗权限: "+p);
    sleep(1000)
    floaty.close("123")
    sleep(1000);
    let view = floaty.showFloatXml("123","dialog3.xml",0,500);
    if (view) {
        // 从悬浮窗中查找视图tag=web的对象 (例子)
        let btn1 = view.findViewWithTag("btn1");
        ui.setViewValue(btn1,"确定执行那个流程")
        logd (ui.getViewValue(btn1))
        ui.setEvent(btn1,"click",function () {
            logd('@@@');
            logd(ui.getViewValue(view.findViewWithTag('r1')))
            logd(ui.getViewValue(view.findViewWithTag('r2')))
            floaty.close("123");
        })
    }
    sleep(20*1000);
    floaty.touchable(123,true)

    /*var p = {
        "title": "沙雕确认",
        "msg": "你是沙雕吗?",
        "cancelable": false,
        "cancelText": "不是",
        "okText": "我是"
    };
    let result=''
    ui.inputDialog(p,
        function (dialog, v, text) {
            //text 是输入的文字
            logd("ok btn click  : " + text)
            //让对话消失掉
            result = text+'';
            logd(result)
            dialog.doDismiss();
            return true;
        },
        function (dialog, v, text) {
            logd("cancel btn click " + text)
            //让对话消失掉
            result = text+'';
            logd(result)
            dialog.doDismiss();
            return true;
        },
        function () {
            //result = text+'';
            logd("mission btn click ")
            return true;
    });
    while (!result){
        sleep(1000);

    }
    logd(result)
    console.log('end')*/

  /*  importPackage(android.widget)
    // var textView = new TextView(ui.getContext());
    // textView.setText("sdfasfsad");
    // 使用xml解析出来的控件
    var textView = ui.parseView("dialog3.xml");
    ui.setEvent(textView.btn1, "click", function (view) {
        logd('v.btn1')
    });
    ui.customDialog({
            "fullScreen": false,
            "cancelable": true
        },
        textView,
        function (dialog, v) {
            logd(v)
            logd(ui.getViewValue(textView.cb1))

            ui.setEvent(textView.btn1, "click", function (view) {
                logd('v.btn1')
            });
            //这里面可以拿到视图对象,然后进行设置各种事件
        }, function () {
            logd(ui.getViewValue(textView.cb1))

            logd("dsssss")
        })
*/
  /*  while (true){
        sleep(1000)
    }*/


}

function autoServiceStart(time) {
    for (var i = 0; i < time; i++) {
        if (isServiceOk()) {
            return true;
        }
        var started = startEnv();
        logd("第" + (i + 1) + "次启动服务结果: " + started);
        if (isServiceOk()) {
            return true;
        }
    }
    return isServiceOk();
}

main();

dialog3.xml

<?xml version="1.0" encoding="UTF-8" ?>
<LinearLayout
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xsi:noNamespaceSchemaLocation="layout.xsd"
        android:layout_height="match_parent"
        android:layout_width="match_parent">
    <LinearLayout
            android:layout_height="wrap_parent"
            android:layout_width="wrap_content"
            android:layout_marginTop="0dp"
            android:orientation="vertical"
            android:padding="20dp"
            android:background="#0ff">
      <!--  <CheckBox android:layout_height="wrap_parent"
                  android:layout_width="wrap_parent"
                  android:tag="cb1"
                  android:text="关注"
                  android:textColor="#000"
                  android:textSize="14dp"
                  android:gravity="center_vertical"
                  android:checked="true"

        />
        <CheckBox android:layout_height="wrap_parent"
                  android:layout_width="wrap_parent"
                  android:tag="cb2"
                  android:text="养号"
                  android:textColor="#000"
                  android:textSize="14dp"
                  android:gravity="center_vertical"
                  android:checked="true"

        />-->
        <RadioGroup android:layout_width="match_parent"
                    android:layout_marginTop="10dp"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

            <RadioButton   android:layout_height="wrap_content"
                           android:layout_width="wrap_content"
                           android:text="r1"
                           android:tag="r1"
                           android:gravity="center"/>
            <RadioButton    android:layout_height="wrap_content"
                            android:layout_width="wrap_content"
                            android:text="r2"
                            android:gravity="center"
                            android:tag="r2"/>
        </RadioGroup>

        <Button android:layout_height="wrap_parent"
                android:layout_width="match_parent"
                android:tag="btn1"
                android:text="按钮"
                android:textColor="#669999"
                android:textSize="14dp"
                android:gravity="center"
        />
    </LinearLayout>


    <!--    <WebView android:layout_height="wrap_parent"-->
    <!--             android:layout_width="match_parent"-->
    <!--             android:url="http://jd.com"-->
    <!--    />-->
</LinearLayout>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值