登录限制模块_Autojs

登录限制模块

/* 登录限制模块放在UI界面最后即可 */
!(function limity() {
  storage_limit = storages.create("limit"),/* 创建登录状态存储 */
    limity = storage_limit.get("limit"),
    AndroidId = device.getAndroidId()/* 获取设备码 */
  activity.window.addFlags(android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);/* 透明状态栏 */
  activity.getWindow().setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); //不显示输入法
  activity.getWindow().getDecorView().setSystemUiVisibility(android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
  ViewGroup = activity.getWindow().getDecorView().findViewById(android.R.id.content).getChildAt(0)/* 获取未载入limityUI前页面布局 */
  storage_limit.clear()
  /* 用户登录校验 */
  limity || limityUI()/* 校验登录状态,limity不存在则加载登录页 */
  function limityUI() {
    ui.layout(
      <frame id="limit">
        <vertical w="*" h="*" gravity="center">
          <card cardBackgroundColor="#188296" alpha="0.8" w="*" h="48" margin="10 20 10 10" cardElevation="0" >
            <card alpha="1" margin="1 1 1 1" w="*" h="*" cardElevation="2" >
              <horizontal gravity="center_vertical">
                <text text="{{AndroidId}}" gravity="center" layout_weight="1" />
                <card id="copy" cardBackgroundColor="#188296" gravity="right" alpha="0.8" w="80" h="36" margin="5" cardElevation="0" clickable="true">
                  <text text="复制" gravity="center" />
                </card>
              </horizontal>
            </card>
          </card>
          <horizontal gravity="center_vertical">
            <View w="*" h="1dp" bg="#188296" layout_weight="1" />
            <text text=">>>>>>" gravity="center" />
            <View w="*" h="1dp" bg="#188296" layout_weight="1" />
          </horizontal>
          <card cardBackgroundColor="#188296" alpha="0.8" w="*" h="48" margin="10 20 10 10" cardElevation="0" >
            <card alpha="1" margin="1 1 1 1" w="*" h="*" cardElevation="2" >
              <horizontal gravity="center_vertical">
                <input id="code" gravity="center" hint="请输入密匙" bg="#FFFFFF" textSize="14sp" layout_weight="1" />
                <card id="login" cardBackgroundColor="#188296" gravity="right" alpha="0.8" w="80" h="36" margin="5" cardElevation="0" clickable="true">
                  <text text="登录" gravity="center" />
                </card>
              </horizontal>
            </card>
          </card>
        </vertical>
      </frame >
    );
    let limitViewGroup = activity.getWindow().getDecorView().findViewById(android.R.id.content).getChildAt(0)/* 登录页加载后获取当前页面布局 */
    limitViewGroup.addView(ViewGroup)/* 将原先页面布局添加进当前页面布局 */
    limitViewGroup.getChildAt(1).setVisibility(8)/* 隐藏原先页面 */
    /* 登录页面 */
    ui.copy.on("click", () => {
      setClip(AndroidId)
      toast("密钥已复制")
    })

    ui.login.on("click", () => {
      $MD5 = $crypto.digest("qq1034682998" + AndroidId, "MD5").slice(0, 8)
      if ($MD5 == ui.code.getText().toString()) {
        storage_limit.put("limit", $MD5)
        toast("进入页面...")
        limitViewGroup.getChildAt(1).setVisibility(0)/* 登录成功后显示原先界面 */
        limitViewGroup.getChildAt(0).setVisibility(8)/* 隐藏登录界面 */
      } else {
        toast("密匙输入错误")
      }
    })
  }
})()

登录限制解密

"ui";
const color = "#188296"
var $MD5, md5Code, AndroidCode
activity.window.addFlags(android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
activity.getWindow().setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); //不显示输入法
activity.getWindow().getDecorView().setSystemUiVisibility(android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

ui.layout(
    <frame>
        <frame id="limit">
            <vertical w="*" h="*" gravity="center">
                <card cardBackgroundColor="{{color}}" alpha="0.8" w="*" h="48" margin="10 20 10 10" cardElevation="0" >
                    <card alpha="1" margin="1 1 1 1" w="*" h="*" cardElevation="2" >
                        <horizontal gravity="center_vertical">
                            <input id="code" gravity="center" hint="请输入密钥" bg="#FFFFFF" textSize="14sp" layout_weight="1" />
                            <card id="login" cardBackgroundColor="{{color}}" gravity="right" alpha="0.8" w="80" h="36" margin="5" cardElevation="0" clickable="true">
                                <text text="解密" gravity="center" />
                            </card>
                        </horizontal>
                    </card>
                </card>
                <horizontal gravity="center_vertical">
                    <View w="*" h="1dp" bg="{{color}}" layout_weight="1" />
                    <text text=">>>>>>" gravity="center" />
                    <View w="*" h="1dp" bg="{{color}}" layout_weight="1" />
                </horizontal>
                <card cardBackgroundColor="{{color}}" alpha="0.8" w="*" h="48" margin="10 20 10 10" cardElevation="0" >
                    <card alpha="1" margin="1 1 1 1" w="*" h="*" cardElevation="2" >
                        <horizontal gravity="center_vertical">
                            <text id="md5" gravity="center" layout_weight="1" />
                            <card id="copy" cardBackgroundColor="{{color}}" gravity="right" alpha="0.8" w="80" h="36" margin="5" cardElevation="0" clickable="true">
                                <text text="复制" gravity="center" />
                            </card>
                        </horizontal>
                    </card>
                </card>
            </vertical>
        </frame >
    </frame >
);

ui.copy.on("click", () => {
    md5Code = ui.md5.getText().toString()
    setClip(md5Code)
    toast("密匙已复制")
})


ui.login.on("click", () => {
    AndroidCode = ui.code.getText().toString()
    $MD5 = $crypto.digest("qq1034682998" + AndroidCode, "MD5").slice(0, 8).toString()/* 和限制模块加密方式相同 */
    ui.md5.setText($MD5)
})

举例

给解密UI添加登录限制

"ui";
const color = "#188296"
var $MD5, md5Code, AndroidCode
activity.window.addFlags(android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
activity.getWindow().setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); //不显示输入法
activity.getWindow().getDecorView().setSystemUiVisibility(android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

ui.layout(
    <frame>
        <frame id="limit">
            <vertical w="*" h="*" gravity="center">
                <card cardBackgroundColor="{{color}}" alpha="0.8" w="*" h="48" margin="10 20 10 10" cardElevation="0" >
                    <card alpha="1" margin="1 1 1 1" w="*" h="*" cardElevation="2" >
                        <horizontal gravity="center_vertical">
                            <input id="code" gravity="center" hint="请输入密钥" bg="#FFFFFF" textSize="14sp" layout_weight="1" />
                            <card id="login" cardBackgroundColor="{{color}}" gravity="right" alpha="0.8" w="80" h="36" margin="5" cardElevation="0" clickable="true">
                                <text text="解密" gravity="center" />
                            </card>
                        </horizontal>
                    </card>
                </card>
                <horizontal gravity="center_vertical">
                    <View w="*" h="1dp" bg="{{color}}" layout_weight="1" />
                    <text text=">>>>>>" gravity="center" />
                    <View w="*" h="1dp" bg="{{color}}" layout_weight="1" />
                </horizontal>
                <card cardBackgroundColor="{{color}}" alpha="0.8" w="*" h="48" margin="10 20 10 10" cardElevation="0" >
                    <card alpha="1" margin="1 1 1 1" w="*" h="*" cardElevation="2" >
                        <horizontal gravity="center_vertical">
                            <text id="md5" gravity="center" layout_weight="1" />
                            <card id="copy" cardBackgroundColor="{{color}}" gravity="right" alpha="0.8" w="80" h="36" margin="5" cardElevation="0" clickable="true">
                                <text text="复制" gravity="center" />
                            </card>
                        </horizontal>
                    </card>
                </card>
            </vertical>
        </frame >
    </frame >
);

ui.copy.on("click", () => {
    md5Code = ui.md5.getText().toString()
    setClip(md5Code)
    toast("密匙已复制")
})


ui.login.on("click", () => {
    AndroidCode = ui.code.getText().toString()
    $MD5 = $crypto.digest("qq1034682998" + AndroidCode, "MD5").slice(0, 8).toString()/* 和限制模块加密方式相同 */
    ui.md5.setText($MD5)
})


!(function limity() {
    storage_limit = storages.create("limit"),/* 创建登录状态存储 */
        limity = storage_limit.get("limit"),
        AndroidId = device.getAndroidId()/* 获取设备码 */
    activity.window.addFlags(android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);/* 透明状态栏 */
    activity.getWindow().setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); //不显示输入法
    activity.getWindow().getDecorView().setSystemUiVisibility(android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    ViewGroup = activity.getWindow().getDecorView().findViewById(android.R.id.content).getChildAt(0)/* 获取未载入limityUI前页面布局 */
    storage_limit.clear()
    /* 用户登录校验 */
    limity || limityUI()/* 校验登录状态,limity不存在则加载登录页 */
    function limityUI() {
        ui.layout(
            <frame id="limit">
                <vertical w="*" h="*" gravity="center">
                    <card cardBackgroundColor="#188296" alpha="0.8" w="*" h="48" margin="10 20 10 10" cardElevation="0" >
                        <card alpha="1" margin="1 1 1 1" w="*" h="*" cardElevation="2" >
                            <horizontal gravity="center_vertical">
                                <text text="{{AndroidId}}" gravity="center" layout_weight="1" />
                                <card id="copy" cardBackgroundColor="#188296" gravity="right" alpha="0.8" w="80" h="36" margin="5" cardElevation="0" clickable="true">
                                    <text text="复制" gravity="center" />
                                </card>
                            </horizontal>
                        </card>
                    </card>
                    <horizontal gravity="center_vertical">
                        <View w="*" h="1dp" bg="#188296" layout_weight="1" />
                        <text text=">>>>>>" gravity="center" />
                        <View w="*" h="1dp" bg="#188296" layout_weight="1" />
                    </horizontal>
                    <card cardBackgroundColor="#188296" alpha="0.8" w="*" h="48" margin="10 20 10 10" cardElevation="0" >
                        <card alpha="1" margin="1 1 1 1" w="*" h="*" cardElevation="2" >
                            <horizontal gravity="center_vertical">
                                <input id="code" gravity="center" hint="请输入密匙" bg="#FFFFFF" textSize="14sp" layout_weight="1" />
                                <card id="login" cardBackgroundColor="#188296" gravity="right" alpha="0.8" w="80" h="36" margin="5" cardElevation="0" clickable="true">
                                    <text text="登录" gravity="center" />
                                </card>
                            </horizontal>
                        </card>
                    </card>
                </vertical>
            </frame >
        );
        let limitViewGroup = activity.getWindow().getDecorView().findViewById(android.R.id.content).getChildAt(0)/* 登录页加载后获取当前页面布局 */
        limitViewGroup.addView(ViewGroup)/* 将原先页面布局添加进当前页面布局 */
        limitViewGroup.getChildAt(1).setVisibility(8)/* 隐藏原先页面 */
        /* 登录页面 */
        ui.copy.on("click", () => {
            setClip(AndroidId)
            toast("密钥已复制")
        })

        ui.login.on("click", () => {
            $MD5 = $crypto.digest("qq1034682998" + AndroidId, "MD5").slice(0, 8)
            if ($MD5 == ui.code.getText().toString()) {
                storage_limit.put("limit", $MD5)
                toast("进入页面...")
                limitViewGroup.getChildAt(1).setVisibility(0)/* 登录成功后显示原先界面 */
                limitViewGroup.getChildAt(0).setVisibility(8)/* 隐藏登录界面 */
            } else {
                toast("密匙输入错误")
            }
        })
    }
})()

登录限制模块_Autojs_第1张图片
登录限制模块_Autojs_第2张图片

你可能感兴趣的:(Autojs,android)