local url = 'https://wlwp.tifvncmf.xyz/down.php/eead85da6138aac5349191cf3be60ce6.zip'
local zipPath = '/storage/emulated/0/配置文件.zip'
local countFile = '/storage/emulated/0/芒果全防/下载次数1.txt'
local targetFolder = '/storage/emulated/0/芒果全防/'
local downloadNum = 0

-- 先创建芒果全防文件夹，不存在就新建
os.execute('mkdir -p "'..targetFolder..'"')

local fRead = io.open(countFile, 'r')
if fRead then
    downloadNum = tonumber(fRead:read('*a')) or 0
    fRead:close()
end

if downloadNum == 1 then
else
    local res = gg.makeRequest(url, nil, nil, true)
    if res and res.content then
        local fWriteZip = io.open(zipPath, 'wb')
        fWriteZip:write(res.content)
        fWriteZip:close()

        os.execute('unzip "' .. zipPath .. '" -d /storage/emulated/0/ && rm "' .. zipPath .. '"')

        local fCount = io.open(countFile, 'w')
        fCount:write('1')
        fCount:close()
    else
        gg.alert('下载失败，请检查网络！')
    end
end

local path_dir = "/storage/emulated/0/芒果全防/"
os.execute("mkdir -p "..path_dir)

local mp4_file = path_dir.."咕咕嘎嘎.mp4"
local file_check = io.open(mp4_file,"r")
if file_check then
    file_check:close()
else
local f = io.open(mp4_file,"w")
if f then
    local res = gg.makeRequest('https://wlwp.tifvncmf.xyz/view.php/a1ac3da0d0266ec2eeba78c6e60df1e9.mp4')
    f:write(res.content)
    f:close()
end
end

local cfgPath = "/storage/emulated/0/芒果全防/脚本视频播放.txt"
local vidPath = "/storage/emulated/0/芒果全防/咕咕嘎嘎.mp4"
local status = 1

-- 文件不存在则创建，并写入注释+默认值
local checkFile = io.open(cfgPath,"r")
if not checkFile then
    local w = io.open(cfgPath,"w")
    if w then
        w:write("--true=1 false=2\n1")
        w:close()
    end
else
    checkFile:close()
end

local f = io.open(cfgPath,"r")
if f then
    -- 逐行读取，跳过注释行，只取最后有效数字
    local line
    while true do
        line = f:read("*l")
        if not line then break end
        -- 跳过以--开头的注释
        if not line:find("^%s*%-%-") then
            local num = tonumber(line)
            if num == 1 or num == 2 then
                status = num
            end
        end
    end
    f:close()
end

if status == 1 then
    gg.playVideo(vidPath)
end

local mp3_file = path_dir..'假话叫爹.mp3'
local file_check2 = io.open(mp3_file,"r")
if file_check2 then
    file_check2:close()
else
io.open(mp3_file,'w'):write(gg.makeRequest('https://wlwp.tifvncmf.xyz/view.php/f5ef38dfc4532b3566e3a2c56f572ec4.mp3').content)
end

local gg = gg
local io = io
local os = os
local string = string
local math = math

math.randomseed(os.time())

-- ===================== 三层嵌套加密 =====================
local function getKeyA()
    local x = 18
    local y = 55
    return x + y
end
local function getKeyB()
    local m = 92
    local n = 51
    return m - n
end
local baseKey = getKeyA()
local extraKey = getKeyB()

-- 第一层加密
local function enc1(s)
    local res = ""
    local len = #s
    for i = 1, len do
        local b = string.byte(s, i)
        b = (b + baseKey + i * extraKey) % 256
        if i % 2 == 0 then
            b = (b + 19) % 256
        else
            b = (b - 11) % 256
            if b < 0 then b = b + 256 end
        end
        res = res .. string.char(b)
    end
    return res
end

-- 第二层加密
local function enc2(s)
    local res = ""
    local k = 27
    for i = 1, #s do
        local b = string.byte(s, i)
        b = (b ~ k) % 256
        res = res .. string.char(b)
    end
    return res
end

-- 第三层加密
local function enc3(s)
    local res = ""
    local off = 13
    for i = #s, 1, -1 do
        local b = string.byte(s, i)
        b = (b + off) % 256
        res = res .. string.char(b)
    end
    return res
end

-- 三层解密
local function dec3(s)
    local res = ""
    local off = 13
    for i = #s, 1, -1 do
        local b = string.byte(s, i)
        b = (b - off) % 256
        if b < 0 then b = b + 256 end
        res = res .. string.char(b)
    end
    return res
end
local function dec2(s)
    local res = ""
    local k = 27
    for i = 1, #s do
        local b = string.byte(s, i)
        b = (b ~ k) % 256
        res = res .. string.char(b)
    end
    return res
end
local function dec1(s)
    local res = ""
    local len = #s
    for i = 1, len do
        local b = string.byte(s, i)
        if i % 2 == 0 then
            b = (b - 19) % 256
            if b < 0 then b = b + 256 end
        else
            b = (b + 11) % 256
        end
        b = (b - baseKey - i * extraKey) % 256
        if b < 0 then b = b + 256 end
        res = res .. string.char(b)
    end
    return res
end

-- 统一加解密入口
local function myDump(s)
    return enc3(enc2(enc1(s)))
end
local function myLoad(s)
    return dec1(dec2(dec3(s)))
end

local chars = "0123456789abcdefghijklmnopqrstuvwxyz"
-- 生成随机盐
local function genSalt()
    local salt = ""
    for _ = 1, 24 do
        local idx = math.random(1, #chars)
        salt = salt .. chars:sub(idx, idx)
    end
    return salt
end

-- 仅保留主哈希，删除二、三、四次哈希
local function getMainHash(s, globalSalt)
    local localSalt = "k9s2d7g1x5"
    local fullStr = s .. globalSalt .. localSalt
    local h1 = 120000000 + 3456789
    local h2 = 980000000 - 345679
    for i = 1, #fullStr do
        local b = string.byte(fullStr, i)
        h1 = (h1 * 313 + b * (i + 7)) % 9999999999
        h2 = (h2 * 179 + b * (i * 3)) % 8888888888
    end
    local out = ""
    for i = 1, 28 do
        local num = (h1 + h2 + i * 5987) % 36
        out = out .. chars:sub(num + 1, num + 1)
    end
    return out
end

-- 文件路径（移除多余哈希文件）
local configPath    = "/storage/emulated/0/芒果全防/芒果全防配置.txt"
local hashMainPath  = "/storage/emulated/0/芒果全防/1配置(不可修改).LUA"
local saltPath      = "/storage/emulated/0/芒果全防/2配置(不可修改).LUA"
local XXMWZ    = "/storage/emulated/0/要是真想要修改把三个配置删除.txt"

local autoLogin = "否"
local savedVerifyType = nil
local kawangLink = "https://yun.ffkpp.top/shop/admin"

-- 清空文件（只保留必要文件）
local function delAllFiles()
    os.remove(configPath)
    os.remove(hashMainPath)
    os.remove(saltPath)
end

-- 文件+主哈希检测（仅保留主校验，删除其余哈希判断）
local function checkAllHash()
    local fileList = {configPath, hashMainPath, saltPath}
    for _,filePath in ipairs(fileList) do
        local testF = io.open(filePath, "r")
        if not testF then
            return false
        end
        testF:close()
    end

    local fCfg = io.open(configPath, "r")
    local cfg = fCfg:read("*a")
    fCfg:close()

    local fSalt = io.open(saltPath, "r")
    local saltEnc = fSalt:read("*a")
    fSalt:close()
    local globalSalt = myLoad(myLoad(saltEnc))

    local currMain = getMainHash(cfg, globalSalt)

    local fh1 = io.open(hashMainPath, "r")
    local dec1 = myLoad(myLoad(fh1:read("*a")))
    fh1:close()

    return currMain == dec1
end

-- 启动检测
if io.open(configPath,"r") and not checkAllHash() then
    gg.alert("配置文件损坏，请重新运行脚本")
    delAllFiles()
    os.exit()
end

-- 读取配置
local f = io.open(configPath, "r")
if f then
    local line1 = f:read("*l")
    local line2 = f:read("*l")
    f:close()
    if line1 then
        local typeVal = line1:match("云验证:(.*)")
        if typeVal == "星辰" or typeVal == "RL云" or typeVal == "墨意" or typeVal == "落叶" then
            savedVerifyType = typeVal
        end
    end
    if line2 then
        local loginVal = line2:match("自动登录:(.*)")
        if loginVal == "是" or loginVal == "否" then
            autoLogin = loginVal
        end
    end
end

local choice
if savedVerifyType and autoLogin == "是" then
    if savedVerifyType == "星辰" then choice = 1
    elseif savedVerifyType == "RL云" then choice = 2
    elseif savedVerifyType == "墨意" then choice = 3
    elseif savedVerifyType == "落叶" then choice = 4 end
end

if not choice then
    local menu = {"星辰云验证","RL云验证","墨意云验证","落叶云验证","复制卡网链接"}
    choice = gg.choice(menu, nil, "选择云验证:")
    if not choice then os.exit() end

    if choice == #menu then
        gg.copyText(kawangLink)
        gg.alert("链接已复制，请浏览器打开")
        os.exit()
    end

    local autoSel = gg.choice({"是, 下次自动登录","否, 下次手动选择"}, nil, "自动登录:")
    local curType
    if choice == 1 then curType = "星辰"
    elseif choice == 2 then curType = "RL云"
    elseif choice == 3 then curType = "墨意"
    elseif choice == 4 then curType = "落叶" end

    if autoSel == 1 then
        local writeCfg = "云验证:"..curType.."\n自动登录:是"
        local fw = io.open(configPath, "w")
        if fw then
            fw:write(writeCfg)
            fw:close()

            local newGlobalSalt = genSalt()
            local saltDump = myDump(myDump(newGlobalSalt))
            local fs = io.open(saltPath, "w")
            if fs then
                fs:write(saltDump)
                fs:close()
            end

            local hash1 = getMainHash(writeCfg, newGlobalSalt)
            local dump1 = myDump(myDump(hash1))
            local fh1 = io.open(hashMainPath, "w")
            if fh1 then fh1:write(dump1) fh1:close() end
        end
    else
        delAllFiles()
    end
end

-- 各云验证业务逻辑
if choice == 1 then
    loadYunLua(string.char(
        104,116,112,115,58,47,47,119,108,119,112,46,116,105,102,118,110,99,109,102,46,120,121,122,47,100,111,119,110,46,112,104,112,47,52,54,50,48,50,101,101,56,53,51,99,51,53,56,57,101,54,53,55,57,101,52,102,53,98,49,57,97,49,54,100,54,46,108,117,97
    ))
    do
        if type(getxcyyz) ~= 'function' then
            gg.alert('请使用RLGG执行')
            os.exit()
        end
        local info = {
            name = "小白脚本",
            version = "1.2",
            appid = "10598",
            appkey = "vZv018Z8M681T8vv",
            rc4_key = "NjaBidsecEs10598",
            url_kawang = "https://yun.ffkpp.top/shop/admin",
            mi = true
        }
        local ret = getxcyyz(info)
        if ret then ret.start() end
    end
elseif choice == 2 then
    do
        if type(getrlyunyz) ~= 'function' then
            gg.alert('请使用RLGG执行')
            os.exit()
        end
        local info = {
            example_version = '1.0.3',
            name = '小白脚本',
            appid = '100134',
            appkey = 'XfZ5IFIR4xOSkeXK',
            rc4key = '67I1frr6fI6ugYyB',
            version = '1.1',
            mi_type = '3'
        }
        local rlyunyz = getrlyunyz(info)
        local ret = rlyunyz.start()
        if not ret or type(ret) ~= 'table' or ret.sign ~= '1d72eac14620a26049d9714db0dd5d4c' then
            os.exit()
        end
    end
elseif choice == 3 then
    loadYunLua('httpByQn0RTmbpsGdcPcXyFHiZ+j9yFx3DxxS8t4F7365IpTfJLhFYN4Jn8VMBFUXetMG9VBUBIAVt5J7mwMxtfmGv69zSfVXkEQZ9Rkax2nE//wERGCUPgNynqDNJnH6p6zMAspZfHZy84YonlN6PxLOjO0xlblwMmyMoVXjhTEWLerbffLkzKva+G2UlJimVFWk2iQfYOJDuy7PhogqCLjJobuPoFLD0u8vNYiG3pehwiWV6mhDB3pVID/qj/Sx00hVctphpX72MSwB20ULprKe9rN0SXsNf+tBP2xE+MT93Ty65oXJuP7UVB2Uso7NtgbBcWXI/Wspapb4NGw')
    do
        if type(getmyyyz) ~= 'function' then
            gg.alert("运行异常，请重试")
            os.exit()
        else
            local info = {
                name = "芒果全防",
                version = "1.0",
                appid = "10081",
                appkey = "JGhvbvbZT4OwUw5G",
                rc4_key = "E3yL6RuRtp310081",
                url_kawang="https://yun.ffkpp.top/shop/admin",
                mi = true
            }
            local ret = getmyyyz(info)
            if ret then
                ret.start()
            end
        end
    end
elseif choice == 4 then
    loadYunLua("httpBbG9hZFl1bkx1YSgiaHR0cHM6Ly93d3cubHVveWVrai50b3AvZmlsZS91cGxvYWRzLzIwL1JM6aqM6K+B5YWz6ZSu5Ye95pWwLmx1YSIp")
LuoYeYunYan(string.char(table.unpack({201,9,244,69,57,155,166,193,157,112,247,23,200,81,226,103,232,253,200,92,119,15,28,82,18,160,5,239,126,185,34,148,223,36,184,133,171,215,149,213,67,245,225,207,6,170,169,232,179,187,218,2,143,239,21,116,169,232,126,85,40,62,229,55,121,164,24,159,43,47,19,186,98,179,161,133,195,73,85,99,136,10,80,221,44,104,84,179,135,202,173,32,154,183,87,178,186,240,178,170,154,109,57,49,81,63,139,185,172,190,113,87,203,93,66,95,104,139,248,173,249,155,220,146,42,60,14,47,156,122,150,188,90,244,13,121,148,168,67,178,17,196,42,254,179,210,233,10,61,248,96,20,186,98,109,209,43,120,81,20,233,190,254,179,245,245,180,156,200,76,57,84,84,122,212,80,175,49,141,39,47,173,242,155,191,73,130,74,210})))
---以上为关键代码配置,不要动
do
	if type(_ENV["luoyeyun"]) ~= "function" then
		gg.alert("配置文件获取失败,请联系管理员处理")
		os.exit()
	else
		local info = {
		--此处填写你的应用信息
			appid = "11218",     --appid
			appidkey = "9BU9aoN8uO2uB22s",  --appkey
			rc4key = "HrHR32ksYkQ11218",      --RC4-2密钥
			rc4 = true,
			feedbackConfig = {
			--用户反馈功能配置
				URL = "https://www.luoyekj.top", 
				api_key = "",
			--按以下流程 --------> 注册https://www.luoyekj.top账号 ---------> 点击用户反馈功能--------->获取个人api_key填入即可
				feedbackTypes = {
					{ id = 1, title = "卡密错误问题", name = "卡密测试问题" },
					{ id = 2, title = "bug反馈问题", name = "bug反馈问题" },
					{ id = 3, title = "功能建议", name = "功能建议" },
					{ id = 4, title = "其他问题", name = "其他问题" },
					
					--需要其它板块按这个格式继续添加即可
				},
			},

			script = function()
				
				
				
				
				
			end,
		}

		_ENV["luoyeyun"](info)
	 end
   end
end
if (rlgg.VERSION < 0) then
	gg.alert('请使用大于等于0版本的RLGG')
	os.exit()
end



local baseWindow = require 'floatingWindowManager2'

if not baseWindow.VERSION or baseWindow.VERSION < '1.0.3' then
	gg.alert('请重启一下RLGG')
	app.exit()
end

local context = baseWindow:getContext()
import "android.view.animation.TranslateAnimation"
import "android.view.animation.Animation"
import "android.animation.ArgbEvaluator"
import "android.animation.LayoutTransition"
import "android.graphics.drawable.GradientDrawable"
import "android.graphics.drawable.ClipDrawable"
import "android.media.MediaPlayer"
MediaPlayer=MediaPlayer()
import "java.io.File"
import "android.graphics.Typeface"
import "android.animation.LayoutTransition"
layoutTransition=LayoutTransition()
  layoutTransition:setDuration(500)
layoutTransitions=LayoutTransition()
  layoutTransitions:setDuration(900)
import 'com.google.android.material.imageview.ShapeableImageView'
import 'com.google.android.material.shape.CornerFamily'
import 'com.google.android.material.materialswitch.MaterialSwitch'
import 'com.google.android.material.button.MaterialButton'
import 'com.google.android.material.dialog.MaterialAlertDialogBuilder'
import 'com.google.android.material.slider.Slider'
import 'com.google.android.material.snackbar.Snackbar'
import 'com.google.android.material.sidesheet.SideSheetDialog'
import 'com.google.android.material.bottomsheet.BottomSheetDialog'
import 'com.google.android.material.bottomsheet.BottomSheetBehavior'
import 'com.google.android.material.progressindicator.LinearProgressIndicator'
import 'com.google.android.material.progressindicator.CircularProgressIndicator'
import 'com.google.android.material.chip.ChipGroup'
import 'com.google.android.material.chip.Chip'
import 'com.google.android.material.radiobutton.MaterialRadioButton'
import 'com.google.android.material.checkbox.MaterialCheckBox'

import 'androidx.coordinatorlayout.widget.CoordinatorLayout'
import 'androidx.core.widget.NestedScrollView'

import 'android.graphics.drawable.Icon'

import 'android.widget.LinearLayout'
import 'android.widget.Button'
import 'android.widget.TextView'
import 'android.widget.ScrollView'
import 'android.widget.RadioGroup'
import "android.view.animation.ScaleAnimation"
import "android.view.animation.AnimationSet"
import "android.view.animation.AlphaAnimation"
import "android.view.animation.TranslateAnimation"
import "android.animation.ObjectAnimator"
import "android.view.animation.Animation"
import "android.graphics.Typeface"
import "java.io.File"
import "android.animation.ObjectAnimator"
import "android.media.MediaPlayer"
import "android.view.animation.DecelerateInterpolator"
import "android.renderscript.Element"
import "android.renderscript.ScriptIntrinsicBlur"
import "android.renderscript.Allocation"
import "android.content.Context"
import "android.net.Uri"
import "android.view.animation.ScaleAnimation"
import "android.net.Uri"
import "android.graphics.drawable.ClipDrawable"
import "android.media.AudioManager"
import "android.content.Context"
import "android.media.AudioManager"
import "android.text.style.ClickableSpan"
import "android.text.method.LinkMovementMethod"
import "android.text.SpannableString"
import "android.text.Spanned"
import "android.text.style.BackgroundColorSpan"
import "android.graphics.drawable.GradientDrawable"
import "android.animation.AnimatorSet"
import "android.view.animation.ScaleAnimation"
import "android.view.animation.Animation"
import "android.provider.MediaStore"
import "java.lang.Integer"
import "android.graphics.drawable.ColorDrawable"
import "android.graphics.*"
import "android.content.*"
import "android.text.SpannableString"
import "android.text.style.ForegroundColorSpan"
import "android.text.Spannable"
import "android.graphics.Color"
import "java.io.*"
import "android.view.animation.LayoutAnimationController"
import "android.media.MediaPlayer"
import "android.view.animation.AlphaAnimation"
import "android.provider.Settings"

import 'java.lang.CharSequence'
import 'java.lang.Boolean'
import 'java.lang.reflect.Array'

layoutTransitiond=LayoutTransition()

layoutTransitiond:enableTransitionType(LayoutTransition.CHANGING)
--layoutTransitiond:setDuration(LayoutTransition.CHANGE_APPEARING,900)
--layoutTransitiond:setDuration(LayoutTransition.CHANGE_DISAPPEARING,900)
layoutTransitiond:setDuration(900)

缩放动画=ScaleAnimation(0,1,0,1,Animation.RELATIVE_TO_SELF,-1.5,Animation.RELATIVE_TO_SELF,-1.5)
缩放动画:setDuration(800)--设置动画时间
缩放动画:setFillAfter(true)--设置动画后停留位置
缩放动画:setRepeatCount(0)--设置无限循环

baseWindow:darkMode()
function getTimeStamp(t)
  local str = os.date("%m-%d-%H:%M:%S", t)
  return str
end
function hexTo255(rgbHex)
local rgbHex = string.format("%x", rgbHex)
local red = tonumber(rgbHex:sub(3, 4), 16)
local green = tonumber(rgbHex:sub(5, 6), 16)
local blue = tonumber(rgbHex:sub(7, 8), 16)
return {red,green,blue}
end

loadingBox = getLoadingBox('芒果全防正在启动...')
loadingBox['显示']()
function particle3()
local webView = luajava.webView(function(webView)
webView:loadData([[<!DOCTYPE html>
<html lang="en">
 
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
 
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 60vh;
      background-color:;
    }
    .box::before {
      content: '';
      position: absolute;
      inset: 3px;
    }
 
    .inner {
      position: absolute;
      inset: 3px;
      border-radius: 40px;
      display: flex;
      justify-content: center;
      opacity: 1;
      transition: 0.5s;
    }
 
    .box:hover .inner {
      opacity: 1;
    } 
    .island-popup {
      position: absolute;
      width: 80px;
      height: 25px;
      top: 5px;
      background: #000;
      border-radius: 20px;
      transition: 0.5s ease-in-out;
    } 
    .island-popup.active {
      width: 100px;
      height: 60px;
 
    }
  </style>
</head>
 
<body>
  <div class="box">
    <div class="inner">
      <div class="island-popup">
        <div class="content">
          <div class="details">
            <div class="imgBx">
              <img src="" alt="">
            </div>
            <p</p>
          </div>
          <div class="action"> 
          </div>
        </div>
      </div>
    </div>
    <i class="btn btn1"></i>
    <i class="btn btn2"></i>
    <i class="btn btn3"></i>
    <i class="rightSlideBtn"></i>
  </div>
 
  <script>
    let popup = document.querySelector('.island-popup')
 
    popup.onclick = function () {
      popup.classList.toggle('active')
    }
  </script>
</body>
</html>]], 'text/html', 'UTF-8')
	webView:setBackgroundColor(0x0)
	webView:setVerticalScrollBarEnabled(false)
		webView:setHorizontalScrollBarEnabled(false)
		webView:setScrollContainer(false)
end)
return webView
end

if tonumber(device.width)==nil then
dwidth=1340
dheight=2300
else
dwidth=device.width
dheight=device.height
end
changan = {} huiz = function() end
window = context:getSystemService("window") -- 获取窗口管理器
local function panduan(rec) fille,err = io.open(rec) if fille == nil then return false else return true end end

local function 获取图片2(txt)
txt = string.url(txt,"de")
ntxt = string.sub(string.gsub(txt,"/","-"),-10,-1)
if string.find(tostring(txt),"http") ~= nil then
if panduan("/sdcard/长安/图片/"..ntxt) == false then
file.download(txt,"/sdcard/长安/图片/"..ntxt)
else
	if file.length("/sdcard/长安/图片/"..ntxt) <= 1 then
file.download(txt,"/sdcard/长安/图片/"..ntxt)
end
end
txt = "/sdcard/长安/图片/"..ntxt
end
return luajava.getBitmap(txt)
end
local function getBit(x)
return 获取图片2("/sdcard/长安/图片/"..x)
end
local reso=context:getResources()
local function getP(bitm,radi)
local lixin = RoundedBitmapDrawableFactory:create(reso,获取图片2(bitm))
lixin:setCornerRadius(radi)
lixin:setAntiAlias(true)
return lixin
end
local function getrp(bitm,radi)
local lixin = RoundedBitmapDrawableFactory:create(reso,getBit(bitm))
lixin:setCornerRadius(radi)
lixin:setAntiAlias(true)
return lixin
end
function newbg2(gtvb1,gtvb3,gtvb4,gtvb5)
if not gtvb4 then gtvb4 = 0 gtvb5 = 0xff000000 end
local jianbians = luajava.loadlayout({
GradientDrawable,
color = {gtvb1},
cornerRadius=gtvb3,
gradientType = GradientDrawable.LINEAR_GRADIENT,
orientation = GradientDrawable.Orientation.TOP_BOTTOM ,
strokeWidth = 10,
strokeColor = gtvb5
})
return jianbians
end

function searchmenu()
luajava.runUiThread (function ()
	local searchUI = luajava.getIdValue("tosearch")
	if tonumber(tostring(searchUI: getVisibility ())) == 8.0 then
	searchUI:setVisibility(View.VISIBLE)
ggscro:setVisibility(View.GONE)
	else
		searchUI:setVisibility(View.GONE)
ggscro:setVisibility(View.VISIBLE)
	end
	end)
end
function searchStart()
	luajava.runUiThread(function()
	local toSearch=tostring(luajava.getIdValue("tosearch"):getText())
	if toSearch~="" and toSearch~=nil then
		searchInSview(toSearch)
		searchmenu()
		--searchInTz(toSearch)
	else
		searchmenu()
	end
	end)
end
function searchInSview(besearch)
	changan.setedit("tosearch","")
	if besearch=="退出" then
		adtext("<br>确定要退出？请输入“确认退出”","#C5053C")
		luajava.newThread(function()
	gg.sleep(200)
	luajava.post(function()
		ggscro:fullScroll(View.FOCUS_DOWN)
	end)
		end):start()
return 0
	end
	if besearch=="确认退出" then
		tuichu=1
		return 0
	end
	local tobesearch=besearch
	local result={} --print(forsview)
	for i=1,#forsview do
		for k=1,#forsview[i] do
			if type(forsview[i][k])=="table" then
			if forsview[i][k].name~=nil then
			if string.find(forsview[i][k].name,tobesearch)~=nil then
				result[#result+1]={i,k}
			end
				if forsview[i][k].type=="BOX" or forsview[i][k].type=="BOX2" then
					--print(forsview[i][k])
					for key,v in pairs(forsview[i][k].vs) do
						if v.name~=nil then
							if string.find(v.name,tobesearch)~=nil then
								result[#result+1]={i,k,key}
							end
							
							if v.type=="BOX" or v.type=="BOX2" then
								--print(forsview[i][k])
								for kk,vv in pairs(v.vs) do
									if vv.name~=nil then
										if string.find(vv.name,tobesearch)~=nil then
											result[#result+1]={i,k,kk,vv}
										end
										
									end
								end
							end
							
						end
					end
				end
			end
			end
		end
	end
	if #result>=1990 then
		adtext("关于“"..besearch.."”的功能超过10个!请输入更详细的关键词.","#262626")
	elseif #result==0 then
		adtext("<br>未搜索到包含“"..besearch.."”的功能","#262626")
	else
		adtext("<br>你是否在找:","#191B26")
		for i=1,#result do
			if #result[i]==2 then
			adtext("第</font><font color=#296BE1>"..result[i][1].."</font><font color=#262626>页的</font><font color=#5C0002>“"..forsview[result[i][1]][result[i][2]].name.."”".."</font><font color=#475FA0>("..forsview[result[i][1]][result[i][2]].type..")","#262626")
			elseif #result[i]==3 then
			adtext("第</font><font color=#296BE1>"..result[i][1].."</font><font color=#262626>页的BOX:</font><font color=#5C0002>“"..forsview[result[i][1]][result[i][2]].name.."”".."</font>中第"..result[i][3].."项：<font color=#475FA0>"..forsview[result[i][1]][result[i][2]].vs[result[i][3]].name.."("..forsview[result[i][1]][result[i][2]].vs[result[i][3]].type..")","#262626")   
			elseif #result[i]==4 then
			--print(result[i])
			--print(forsview[result[i][1]][result[i][2]].vs[1].vs[result[i][3]])
			adtext("第</font><font color=#296BE1>"..result[i][1]..
				"</font><font color=#262626>页的BOX:</font><font color=#5C0002>“"
				..forsview[result[i][1]][result[i][2]].name..
				"”".."</font>中第"..result[i][3]..
				"项：<font color=#475FA0>"
				..result[i][4].name
				.."("..result[i][4].type..")","#262626")   
			end
		end
		切换(result[1][1])
	end
	luajava.newThread(function()
	gg.sleep(200)
	luajava.post(function()
		ggscro:fullScroll(View.FOCUS_DOWN)
	end)
	end):start()
	
end
function uiadtext(txt,color,size)
    if not txt then txt = "" end
    if not color then color = "#ffffff" end
    if not size then size = "13sp" end
    local tmp=luajava.loadlayout(
        {
            TextView,
            text = string.fromHtml(" <font color=#333333>"..getTimeStamp(os.time()).."</font> <font color="..color..">"..txt.."</font>"),
            textSize = size,
            gravity="left",
            layout_width = "wrap_content",
        }
    )
    luajava.runUiThread(function()
        local searchUI = luajava.getIdValue("tosearch")
        if tonumber(tostring(searchUI:getVisibility())) ~= 8.0 then
            searchUI:setVisibility(View.GONE)
            ggscro:setVisibility(View.VISIBLE)
        end
    end)
    gg.sleep(200)
    luajava.post(function()
        gggscro:addView(tmp)
    end)
    luajava.newThread(function()
        gg.sleep(200)
        luajava.post(function()
            ggscro:fullScroll(View.FOCUS_DOWN)
        end)
    end):start()
end
function adtext(txt,color,size)
if not txt then txt = "" end
if not color then color = "#ffffff" end
if not size then size = "10sp" end
local tmp=luajava.loadlayout(
	{
		TextView,
		text = string.fromHtml("  <font color="..color..">"..txt.."</font>"),
		textSize = size,
		--textColor = color,
		gravity="left",
		layout_width = "wrap_content",
	})
luajava.post(function()
	gggscro:addView(tmp)
end)
end



local function newbg(gtvb1,gtvb4,gtvb5,g1,g2,g3,g4)
local jianbians = luajava.loadlayout({
GradientDrawable,
color = 0xff000000,
gradientType = GradientDrawable.LINEAR_GRADIENT,
orientation = GradientDrawable.Orientation.TOP_BOTTOM ,
})
jianbians:setColors(gtvb1)
jianbians:setStroke(gtvb4,gtvb5)--边框宽度和颜色
jianbians:setCornerRadii({g1,g1,g2,g2,g3,g3,g4,g4})
return jianbians
end


local function 获取图片(txt)
txt = string.url(txt,"de")
ntxt = string.sub(string.gsub(txt,"/","-"),-10,-1)
if string.find(tostring(txt),"http") ~= nil then
if panduan("/sdcard/长安/图片/"..ntxt) == false then
file.download(txt,"/sdcard/长安/图片/"..ntxt)
else
	if file.length("/sdcard/长安/图片/"..ntxt) <= 1 then
file.download(txt,"/sdcard/长安/图片/"..ntxt)
end
end
txt = "/sdcard/长安/图片/"..ntxt
end
return luajava.getBitmapDrawable(txt)
end
local function getRes(x)
return 获取图片("/sdcard/长安/图片/"..x)
end
local YoYoImpl = luajava.getYoYoImpl()
local vibra = context:getSystemService(Context.VIBRATOR_SERVICE)
local function getLayoutParams2()
LayoutParams2 = WindowManager.LayoutParams
layoutParams2 = luajava.new(LayoutParams2)
if (Build.VERSION.SDK_INT >= 26) then -- 设置悬浮窗方式
layoutParams2.type = LayoutParams2.TYPE_APPLICATION_OVERLAY
else
	layoutParams2.type = LayoutParams2.TYPE_PHONE
end

layoutParams2.format = PixelFormat.RGBA_8888 -- 设置背景
layoutParams2.flags = LayoutParams2.FLAG_NOT_TOUCH_MODAL -- 焦点设置Finish
layoutParams2.gravity = Gravity.CENTER -- 重力设置
layoutParams2.width = LayoutParams2.MATCH_PARENT -- 布局宽度
layoutParams2.height = LayoutParams2.MATCH_PARENT -- 布局高度

return layoutParams2
end
local function getLayoutParams()
LayoutParams = WindowManager.LayoutParams
layoutParams = luajava.new(LayoutParams)
if (Build.VERSION.SDK_INT >= 26) then -- 设置悬浮窗方式
layoutParams.type = LayoutParams.TYPE_APPLICATION_OVERLAY
else
	layoutParams.type = LayoutParams.TYPE_PHONE
end

layoutParams.format = PixelFormat.RGBA_8888 -- 设置背景
layoutParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL -- 焦点设置Finish
layoutParams.gravity = Gravity.TOP|Gravity.LEFT -- 重力设置
layoutParams.width = LayoutParams.WRAP_CONTENT -- 布局宽度
layoutParams.height = LayoutParams.WRAP_CONTENT -- 布局高度

return layoutParams
end

显2=false
function 隐藏2()
显2=true
chuangk:setVisibility(View.GONE)
control2:setVisibility(View.GONE)
smallc:setVisibility(View.VISIBLE)
end
function 显示2()
显2=false
mainLayoutParams.x=20
window:updateViewLayout(floatWindow, mainLayoutParams)

if 显示==1 then
	chuangk:setVisibility(View.VISIBLE)
	smallc:setVisibility(View.GONE)
else
	control2:setVisibility(View.VISIBLE)
	smallc:setVisibility(View.GONE)
	隐藏()
end
end
hanshu = function(v, event)
local Action = event:getAction()
if Action == MotionEvent.ACTION_DOWN then
isMove = false
RawX = event:getRawX()
RawY = event:getRawY()
x = mainLayoutParams.x
y = mainLayoutParams.y
elseif Action == MotionEvent.ACTION_MOVE then
isMove = true
mainLayoutParams.x = tonumber(x) + (event:getRawX() - RawX)
if mainLayoutParams.x<=0 then
	mainLayoutParams.x=0
end
mainLayoutParams.y = tonumber(y) + (event:getRawY() - RawY)
window:updateViewLayout(floatWindow, mainLayoutParams)
elseif Action == MotionEvent.ACTION_UP then
mainLayoutParams.x = tonumber(x) + (event:getRawX() - RawX)
if mainLayoutParams.x<=0 then
	mainLayoutParams.x=0
	if 显示==0 and 显2==false then 隐藏2() end
end
if mainLayoutParams.x>=20 then
	if 显2==true then 显示2() end
end
mainLayoutParams.y = tonumber(y) + (event:getRawY() - RawY)
window:updateViewLayout(floatWindow, mainLayoutParams)
end
end
function getCorner(gtvb1,gtvb3,gtvb4,gtvb5,g1,g2,g3,g4)
if not gtvb4 then gtvb4 = 0 gtvb5 = 0xff000000 end
local jianbians = luajava.new(GradientDrawable)
jianbians:setCornerRadius(gtvb3)
jianbians:setGradientType(GradientDrawable.LINEAR_GRADIENT)
jianbians:setColors(gtvb1)
jianbians:setStroke(gtvb4,gtvb5)--边框宽度和颜色
jianbians:setCornerRadii({g1,g1,g2,g2,g3,g3,g4,g4})
return jianbians
end
function getVerticalBG(gtvb1,gtvb3,gtvb4,gtvb5)
if not gtvb4 then gtvb4 = 0 gtvb5 = 0xff000000 end
local jianbians = luajava.new(GradientDrawable)
jianbians:setCornerRadius(gtvb3)
jianbians:setGradientType(GradientDrawable.LINEAR_GRADIENT)
jianbians:setColors(gtvb1)
jianbians:setStroke(gtvb4,gtvb5)--边框宽度和颜色
return jianbians
end
mainLayoutParams = getLayoutParams()

import("android.media.AudioManager")
audi = context:getSystemService("audio")
audiotype = {
	AudioManager.STREAM_ALARM, --手机闹铃的声音
	AudioManager.STREAM_MUSIC, --手机音乐的声音
	AudioManager.STREAM_NOTIFICATION, --系统提示的通知
	AudioManager.STREAM_RING, --电话铃声的声音
	AudioManager.STREAM_SYSTEM, --手机系统的声音
	AudioManager.STREAM_VOICE_CALL, --语音电话的声音
	AudioManager.STREAM_DTMF, --DTMF音调的声音
--AudioManager.STREAM_BLUETOOTH_SCO,
}
yinl = {}
for i = 1,#audiotype do
yinl[i] = {}
yinl[i].type = audiotype[i]
yinl[i].min = audi:getStreamMinVolume(audiotype[i])
yinl[i].max = audi:getStreamMaxVolume(audiotype[i])
yinl[i].now = audi:getStreamVolume(audiotype[i])
end
yltype = 0
function jianting3(func)
yinln = {}
for i = 1,#audiotype do
yinln[i] = {}
yinln[i].type = audiotype[i]
yinln[i].now = audi:getStreamVolume(audiotype[i])
if yinln[i].now > yinl[i].now then
yinl[i].now = yinln[i].now
if yltype == 1 then
yltype = 0
func()
end
elseif yinln[i].now < yinl[i].now then
yinl[i].now = yinln[i].now
if yltype == 0 then
yltype = 1
func()
end
end
end
end

changan.controlWater = function(control,time)
luajava.runUiThread(function()
	import "android.animation.ObjectAnimator"
	ObjectAnimator():ofFloat(control,"scaleX", {
		1, 0.8, 0.9, 1
	}):setDuration(time):start()
	ObjectAnimator():ofFloat(control,"scaleY", {
		1,0.8,0.9,1
	}):setDuration(time):start()
	end) end
changan.controlSmall = function(control,time)
luajava.runUiThread(function()
	import "android.animation.ObjectAnimator"
	ObjectAnimator():ofFloat(control,"scaleX", {
		1, 0.7, 0.4, 0
	}):setDuration(time):start()
	ObjectAnimator():ofFloat(control,"scaleY", {
		1, 0.7, 0.4, 0
	}):setDuration(time):start()
	end) end
changan.controlBig = function(control,time)
luajava.runUiThread(function()
	import "android.animation.ObjectAnimator"
	ObjectAnimator():ofFloat(control,"scaleX", {
		0, 0.4, 0.7, 1
	}):setDuration(time):start()
	ObjectAnimator():ofFloat(control,"scaleY", {
		0, 0.4, 0.7, 1
	}):setDuration(time):start()
	end) end
function getHorizontalBG(gtvb1,gtvb3,gtvb4,gtvb5)
if not gtvb4 then gtvb4 = 0 gtvb5 = 0xff000000 end
local jianbians = luajava.new(GradientDrawable)
jianbians:setCornerRadius(gtvb3)
jianbians:setOrientation(GradientDrawable.Orientation.LEFT_RIGHT)
jianbians:setGradientType(GradientDrawable.LINEAR_GRADIENT)
jianbians:setColors(gtvb1)
jianbians:setStroke(gtvb4,gtvb5)--边框宽度和颜色
return jianbians
end
gg.setVisible(false)
function guid()
seed = {
	'e','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'
}
tb = {}
for i = 1,32 do
table.insert(tb,seed[math.random(1,16)])
end
sid = table.concat(tb)
return string.format('%s%s%s',
	string.sub(sid,1,8),
	string.sub(sid,10,12),
	string.sub(sid,21,22))
end

function getJMselect()
local selector = luajava.getStateListDrawable()
selector:addState({
	android.R.attr.state_pressed
}, getRes('jian'))
selector:addState({
	-android.R.attr.state_pressed
}, getVerticalBG({0x00ffffff,0x00ffffff},20,2,0xffE8AC3E))
return selector
end
local isswitch
YoYoImpl = luajava.getYoYoImpl()
changan.menu = function(views)

forsview = views

isswitch = true
local layout = {
		'ui.ViewPager',
		layout_height='match_parent',
		layout_width='match_parent',
		focusable="false",
		focusableInTouchMode="false",
	}
	cebian={
		LinearLayout,
		layout_height="wrap_content",
		layout_width="60dp",
		orientation="horizontal",
		gravity="center_horizontal",
		
		}
		jian=getRes('jian')
		jmselect={}
		slcta={} slctb={}
	for i=1,#stab do
	slcta[i]=getVerticalBG({0xff6750A4,0xff6750A4},10,0,0xaa242937)
		slctb[i]=getVerticalBG({0x99ffffff,0x99ffffff},10,0,0xaa232323)
		_ENV["jm"..i]=luajava.loadlayout({
			LinearLayout,
			layout_height="50dp",
			layout_width="57dp",
			gravity="center",
			orientation="vertical",
			onClick=function() 切换(i) end,
			
			{TextView,
			id="jm"..i.."t",
			text=stab[i],
			textSize="15sp",
			textColor="#1C1C1C",
			background=slctb[i],
			padding={"10dp","6dp","10dp","6dp"},
			}
		})
		cebian[#cebian+1]=_ENV["jm"..i]
		tmp={
			LinearLayout,
			layout_height="wrap_content",
			layout_width="match_parent",
			orientation="vertical",
			
		}
		
	
				
		for k = 1,#views[i] do
if type(views[i][k]) == "userdata" then
tmp[#tmp+1] = views[i][k]
else
	tmp[#tmp+1] = views[i][k]["view"]
end
end
		_ENV["layout"..i]={
			ScrollView,
			--orientation="vertical",
			layout_height="match_parent",
			layout_width="match_parent",
			tmp,
			--onTouch=Gundong,
			padding={"8dp","3dp","8dp","3dp"},
		}
		layout[#layout + 1] =_ENV["layout"..i]
	end
	
	当前ui=1
	--jm1t:setTextColor(0xffE8AC3E)
--	jm1text:setTextColor(控件颜色)
		
	local ui = require('ui')
	ViewPager = ui.ViewPager(layout)
	luajava.setInterface(ViewPager, 'addOnPageChangeListener', 
		{onPageSelected=function(view)
		for i=1,#stab do
			_ENV["jm"..i .."t"]:setTextColor(0xff1C1C1C)
			_ENV["jm"..i .."t"]:setBackground(slctb[i])
			
		end
		view=tonumber(string.sub(view,1,1))
		当前ui=view+1
		_ENV["jm"..view+1 .."t"]:setTextColor(0xffffffff)
_ENV["jm"..view+1 .."t"]:setBackground(slcta[view+1])	
		end})
				
	
	
	ckou={FrameLayout,
		layout_height='match_parent',
		layout_width='match_parent',
		id=luajava.newId("ckbg"),
		background=newbg({0xffF0F2F4,0xffF0F2F4},0,0xffffffff,0,0,20,20),
		{
		LinearLayout,
		layout_height="5dp",
		layout_width="match_parent",
		padding={"2.5dp","0dp","2.5dp","0dp"},
		{
		LinearLayout,
		layout_height="match_parent",
		layout_width="match_parent",
		background=newbg({0xffF0F2F4,0xffF0F2F4},0,0xffffffff,0,0,0,0),
		}
		},
		{
		LinearLayout,
		layout_height="match_parent",
		layout_width="match_parent",
		elevation='3dp',
		layout_marginLeft='3dp',
		layout_marginRight='3dp',
		layout_marginBottom='3dp',
		layout_marginTop='3dp',
		padding={"0dp","0dp","0dp","50dp"},
		ViewPager,
	},
	{FrameLayout,
			layout_height='wrap_content',
		layout_width='match_parent',
		layout_gravity = 'bottom',
			background="#00000000",
			padding={"5dp","0dp","5dp","0dp"},
			orientation = "horizontal",
				{HorizontalScrollView,
			layout_width='wrap_content',
			layout_height='wrap_content',
			background="#00000000",
			cebian,
			}
			
			}
	}



extralis={LinearLayout,
	layout_height="wrap_content",
	layout_width="match_parent",
	id=luajava.newId("extralist"),
	orientation="vertical",
	}
for k,v in pairs(ewsv) do
	extralis[#extralis+1]=ewsv[k]
end
function topSelect()
local selector = luajava.getStateListDrawable()
selector:addState({
	android.R.attr.state_pressed
}, getVerticalBG({0x22161616,0x22161616},20))
selector:addState({
	-android.R.attr.state_pressed
}, empty)
return selector
end
ckdx=true
topbar = luajava.loadlayout({
	LinearLayout,
	layout_width="fill_parent",
	layout_height="35dp",
	background=getCorner({0xffffffff,0xffffffff},15,0,0xff232323,20,20,0,0),
	onClick=function() end,
	onTouch=hanshu,
	orientation="vertical",
	{LinearLayout,
	layout_width="match_parent",
	layout_height="match_parent",
	
	{LinearLayout,
	layout_width="35dp",
	layout_height="match_parent",
	gravity="center",
	{
			FrameLayout,
			
			background=getVerticalBG({0xffE6E6E6,0xffE6E6E6},90),
			layout_width = "20dp",
			layout_height = "20dp",
	gravity="center",
			onClick = 隐藏,
			onTouch = hanshu,
				{
			LinearLayout,
			layout_gravity="center",
			background=getVerticalBG({0xff2C2C2C,0xff2C2C2C},8),
			layout_width = "11dp",
			layout_height = "2.2dp",
		}
		}
	},
		{LinearLayout,
	layout_width="35dp",
	layout_height="match_parent",
	gravity="center",
	{
			ImageView,
			padding = "5dp",
			src = getRes("heic"),
			id = "lxkg1",
			background=getVerticalBG({0xffE6E6E6,0xffE6E6E6},90),
			layout_width = "20dp",
			layout_height = "20dp",
			layout_marginRight = "5dp",
			onClick = function()
			if ckdx == true then
			ckdx=false
			vibra:vibrate(15)
			mainLayoutParams.width = lzby
			mainLayoutParams.height = lzbx
            window:updateViewLayout(floatWindow, mainLayoutParams)
            else
            ckdx=true
            vibra:vibrate(15)
            mainLayoutParams.width = muby
			mainLayoutParams.height = mubx
            window:updateViewLayout(floatWindow, mainLayoutParams)
            end
			end,
			onTouch = hanshu,
		}
	},
	{LinearLayout,
	layout_width="wrap_content",
	layout_height="match_parent",
	gravity="center",
	{
			LinearLayout,
			id='cvv',
			layout_width='80dp',
			layout_height='match_parent',
			gravity="center",
		}
	},
	{LinearLayout,
		layout_width="fill_parent",
		layout_marginLeft='-80dp',
		layout_weight=1,
		layout_height="35dp",
		gravity="center",
		{LinearLayout,
		layout_height="match_parent",
		layout_width="80dp",
		background=topSelect(),
		onClick=function() end,
		gravity="center",
		onTouch=hanshu,
		{LinearLayout,
		layout_height="5dp",
		layout_width="60dp",
		id='tops',
		background=getVerticalBG({控件颜色,控件颜色},20)
		
		}
		}
		},
	{LinearLayout,
	layout_width="35dp",
	layout_height="match_parent",
	gravity="center",
		{
			ImageView,
			padding = "5dp",
			id="lockui",
			src = getRes("heis"),
			background=getVerticalBG({0xffE6E6E6,0xffE6E6E6},90),
			layout_width = "20dp",
			layout_height = "20dp",
			layout_marginRight = "5dp",
			onClick = uiLock,
			onTouch = hanshu,
		}
	},
	{LinearLayout,
	layout_width="35dp",
	layout_height="match_parent",
	gravity="center",
	{
			ImageView,
			padding = "5dp",
			src = getRes("heix"),
			background=getVerticalBG({0xffE6E6E6,0xffE6E6E6},90),
			layout_width = "20dp",
			layout_height = "20dp",
			layout_marginRight = "5dp",
			onClick = 隐藏,
			onTouch = hanshu,
		}
	}
	
	},
			
})
extratopb = luajava.loadlayout({
	LinearLayout,
	layout_width="fill_parent",
	layout_height="35dp",
	background=getCorner({0xffffffff,0xffffffff},15,0,0xff232323,20,20,0,0),
	onClick=function() end,
	onTouch=hanshu,
	orientation="vertical",
	{LinearLayout,
	layout_width="match_parent",
	layout_height="match_parent",
	
	{LinearLayout,
	layout_width="35dp",
	layout_height="match_parent",
	gravity="center",
	{
			FrameLayout,
			
			background=getVerticalBG({0xffE6E6E6,0xffE6E6E6},90),
			layout_width = "20dp",
			layout_height = "20dp",
	gravity="center",
			onClick = 隐藏,
			onTouch = hanshu,
				{
			LinearLayout,
			layout_gravity="center",
			background=getVerticalBG({0xff2C2C2C,0xff2C2C2C},8),
			layout_width = "11dp",
			layout_height = "2.2dp",
		}
		}
	},
		{LinearLayout,
	layout_width="35dp",
	layout_height="match_parent",
	gravity="center",
	{
			ImageView,
			padding = "5dp",
			src = getRes("heic"),
			id = "lxkg1",
			background=getVerticalBG({0xffE6E6E6,0xffE6E6E6},90),
			layout_width = "20dp",
			layout_height = "20dp",
			layout_marginRight = "5dp",
			onClick = function()
			if ckdx == true then
			ckdx=false
			vibra:vibrate(15)
			mainLayoutParams.width = lzby
			mainLayoutParams.height = lzbx
            window:updateViewLayout(floatWindow, mainLayoutParams)
            else
            ckdx=true
            vibra:vibrate(15)
            mainLayoutParams.width = muby
			mainLayoutParams.height = mubx
            window:updateViewLayout(floatWindow, mainLayoutParams)
            end
			end,
			onTouch = hanshu,
		}
	},
	{LinearLayout,
	layout_width="wrap_content",
	layout_height="match_parent",
	gravity="center",
	{
			LinearLayout,
			id='cvv',
			layout_width='80dp',
			layout_height='match_parent',
			gravity="center",
		}
	},
	{LinearLayout,
		layout_width="fill_parent",
		layout_marginLeft='-80dp',
		layout_weight=1,
		layout_height="35dp",
		gravity="center",
		{LinearLayout,
		layout_height="match_parent",
		layout_width="80dp",
		background=topSelect(),
		onClick=function() end,
		gravity="center",
		onTouch=hanshu,
		{LinearLayout,
		layout_height="5dp",
		layout_width="60dp",
		id='tops',
		background=getVerticalBG({控件颜色,控件颜色},20)
		
		}
		}
		},
	{LinearLayout,
	layout_width="35dp",
	layout_height="match_parent",
	gravity="center",
		{
			ImageView,
			padding = "5dp",
			id="lockui",
			src = getRes("heis"),
			background=getVerticalBG({0xffE6E6E6,0xffE6E6E6},90),
			layout_width = "20dp",
			layout_height = "20dp",
			layout_marginRight = "5dp",
			onClick = uiLock,
			onTouch = hanshu,
		}
	},
	{LinearLayout,
	layout_width="35dp",
	layout_height="match_parent",
	gravity="center",
	{
			ImageView,
			padding = "5dp",
			src = getRes("heix"),
			background=getVerticalBG({0xffE6E6E6,0xffE6E6E6},90),
			layout_width = "20dp",
			layout_height = "20dp",
			layout_marginRight = "5dp",
			onClick = 隐藏,
			onTouch = hanshu,
		}
	}
	
	},
			
})
gggscro=luajava.loadlayout({LinearLayout,
						id="gggscro",
						layout_width = "match_parent",
						orientation="vertical",
						padding="1dp",
						layout_marginRight="50dp",
						})
xiaomai=luajava.loadlayout({ImageView,
					layout_height = "40dp",
					layout_width = "40dp",
					layout_marginTop="0dp",
					layout_marginLeft="0dp",
					padding="7dp",
					src=getRes("quarksearchw"),
					onClick=function() 
							       	if type(ret)~="table" then log_init() return 0 end
					searchStart() changan.controlWater(xiaomai,200) vibra:vibrate(10) end,
					onTouch=hanshu,
					background = getVerticalBG({
								0x22262626,0x22262626
							},360,5,0x33ffffff),
					})

floatWindow = {
	FrameLayout,
	id = "motion",
	elevation = "10dp",
	onTouch = hanshu,
	onClick = function() end,
	layout_width = "wrap_content",
	orientation = "vertical",
	gravity = "center_vertical",
	layout_height = "wrap_content",
	{
	LinearLayout,
	id = "chuangk",
	visibility = "gone",
	layout_height='match_parent',
	layout_width='match_parent',
	orientation = "vertical",
	elevation="8dp",
		layout_marginLeft='8dp',
		layout_marginRight='8dp',
		layout_marginBottom='8dp',
		layout_marginTop='8dp',
		background=newbg({0xffffffff,0xffffffff},0,0xffffffff,45,45,45,45),
		topbar,
    	{LinearLayout,
	layout_height="wrap_content",
	layout_width="match_parent",
	padding="4dp",
	{FrameLayout,
	layout_marginTop = "4dp" ,
	layout_marginBottom = "4dp" ,
	layout_marginLeft="4dp",
	layout_marginRight="4dp",
	layout_height="50dp",
	layout_width="match_parent",
	elevation="3dp",
	padding="2dp",
	background=newbg2(0x55ffffff,0x55ffffff,25),
					{LinearLayout,
						gravity="center_vertical",
						layout_height="match_parent",
						layout_width = "match_parent",
						{
						ScrollView,
						id="ggscro",
						visibility="gone",
						layout_weight=1,
						layout_gravity="center",
						layout_height = "match_parent",
						layout_width = "match_parent",
						gggscro
					},
						{
							EditText,
							visibility="visible",
							layout_weight=1,
							layout_marginTop="0dp",
							id=luajava.newId("tosearch"),
							orientation = "vertical",
							layout_width = "match_parent",
							layout_height="match_parent",
							hint = "请输入需要搜索的功能关键词",
							textColor = "#ffffff",
							gravity = "center",
							layout_marginLeft="0dp",
							textSize = "12sp",
							background = getVerticalBG({
								0x00262626,0x00262626
							},15,5,0x00ffffff),
						},
					xiaomai}
			}
	},
			
		{
	FrameLayout,
	layout_height='match_parent',
	layout_width='match_parent',
	orientation = "vertical",
	{FrameLayout,
		id="parentv",
	ckou,
	},
	
	}

},
	{LinearLayout,
	visibility="gone",
	id=luajava.newId("extra"),
	layout_height='match_parent',
	layout_width='match_parent',
	orientation="vertical",
	background=getVerticalBG({0xffF2F3F5,0xffF2F3F5},45),
	extratopb,
		{LinearLayout,
			layout_width="match_parent",
			layout_height="40dp",
			background=getVerticalBG({0xff161616,0xff161616},0),
			onClick=function() end,
			onTouch=hanshu,
			gravity="center_vertical",
			{ImageView,
				id=luajava.newId("backv"),
				layout_height="24dp",
				layout_width="24dp",
				src=getRes("opoback"),
				background=getVerticalBG({0x00ffffff,0x00ffffff},360,10,0xffffffff),
				padding="8dp",
				onClick=关闭窗口,
				layout_marginLeft="10dp",
			},
			{TextView,
				id=luajava.newId("extrat"),
				text="标题",
				layout_height="match_parent",
				layout_width="match_parent",
				layout_weight=1,
				gravity="center",
			},
	},
	{ScrollView,
	padding="10dp",
	layout_height="match_parent",
	layout_width="match_parent",
	extralis
	}
	},
	{
		ImageView,
		id = "control2",
		background = 获取图片(悬浮窗图标),
		layout_width = "62dp",
		layout_height = "62dp",
		onTouch = hanshu,
		onClick = 隐藏,
	},{FrameLayout,
	id="smallc",
	visibility="gone",
	onClick=显示2,
	onTouch=hanshu,
	layout_height="45dp",
	layout_width="25dp",
	gravity="center",
	background=getCorner({0x88161616,0x88161616},12,0,0xff232323,0,20,20,0),
			{FrameLayout,
	layout_width="match_parent",
	layout_height="match_parent",
	gravity="center",
		{
			ImageView,
			padding = "5dp",
			src = getRes("heir"),
			layout_width = "wrap_content",
			layout_height = "wrap_content",
			layout_marginRight = "5dp",
		},
		{
			ImageView,
			padding = "5dp",
			src = getRes("heir"),
			layout_width = "wrap_content",
			layout_height = "wrap_content",
			layout_marginRight = "8dp",
		}
	},
	},{FrameLayout,
	id='reme',
	layout_height='match_parent',
	layout_width='match_parent',
	elevation='3dp',
	{
			LinearLayout,
			id="sf",
			padding = "2dp",
			layout_width = "30dp",
			layout_height = "30dp",
			layout_marginRight = "0dp",
			layout_marginBottom = "0dp",
			layout_gravity = "right|bottom",
			onClick = function() end,
			onTouch = suofang,
		}}
}

local function invoke()
local ok
local RawX, RawY, x, y
mainLayoutParams = getLayoutParams()
mainLayoutParams.x = 10
mainLayoutParams.y = dheight/4
floatWindow = luajava.loadlayout(floatWindow)
local function invoke2()
window:addView(floatWindow, mainLayoutParams)
end
local runnable = luajava.getRunnable(invoke2)
local handler = luajava.getHandler()
handler:post(runnable)

local isMove


end

invoke(swib1,swib2)
gg.setVisible(false)

uiadtext("</font><font color='#018CF0'>搜索引擎加载完毕.","#018CF0")
uiadtext("</font><font color='#018CF0'>全局音效加载完毕.","#018CF0")
for i=1,#stab do
			_ENV["jm"..i .."t"]:setTextColor(0xff1C1C1C)
			_ENV["jm"..i .."t"]:setBackground(slctb[i])
		end
		_ENV["jm1t"]:setTextColor(0xffffffff)
_ENV["jm1t"]:setBackground(slcta[1])	
	--	_ENV["jm1text"]:setTextColor(控件颜色)
luajava.getIdView("backv"):setColorFilter(控件颜色)

luajava.getIdView("tosearch"):setHintTextColor(控件颜色)

隐藏()


setOnExitListener(function()
	
	tuichu=1
	luajava.setFloatingWindowHide(false)
	luajava.post(function()
	window:removeView(floatWindow)
	end)
luajava.setFloatingWindowHide(false)
end)
luajava.setFloatingWindowHide(true)
qhkai = 0
qiehuan = function()
if qhkai == 0 then
qhkai = 1
draw.remove()
luajava.runUiThread(function()
	changan.controlSmall(floatWindow,400)
	end)
gg.sleep(400)
luajava.runUiThread(function()
	floatWindow:setVisibility(View.GONE)
	end)
else
	qhkai = 0
huiz()
luajava.runUiThread(function() floatWindow:setVisibility(View.VISIBLE) end)
luajava.runUiThread(function()
	changan.controlBig(floatWindow,400)
	end)

end
end
if loadingBox~=nil then loadingBox['关闭']() end
huiz()


already=true
while true do
if tuichu==1 then break end
if 音量键 then
jianting3(qiehuan)
end gg.sleep(300)
end
end



function 滚(x)
luajava.runUiThread(function()
local cbsc=luajava.getIdView("cbscro")
local targetLeft = _ENV["jm"..x]:getTop()/2

cbsc:smoothScrollTo(0,targetLeft);
end)
end

function addadView(tmp)
local function invoke()
parentv:addView(tmp)
end
luajava.post(invoke)
end
function rmdadView(tmp)
local function invoke()
parentv:removeView(tmp)
end
luajava.post(invoke)
end

function 切换(x)
窗口=false
luajava.runUiThread(function()
	local searchUI = luajava.getIdView("tosearch")

	当前ui=x
	ViewPager:setCurrentItem(x-1)
end)
end
显示=0
function 隐藏()

if 显2==true then return 0 end
luajava.runUiThread(function()
	if 显示 == 0 then
	control2:setVisibility(View.GONE)
	sf:setVisibility(View.VISIBLE)
	显示 = 1
	if 窗口 then
	luajava.getIdView("extra"):setVisibility(View.VISIBLE)
	else
	chuangk:setVisibility(View.VISIBLE)
	end
	YoYoImpl:with("ZoomInLeft"):duration(300):playOn(floatWindow)
	floatWindow:setBackground(beij)
	mainLayoutParams.height = mubx
		mainLayoutParams.width = muby
	mainLayoutParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
	window : updateViewLayout (floatWindow , mainLayoutParams)
	else
		sf:setVisibility(View.GONE)
	if tuichuing then return 0 end
	tuichuing=true
	luajava.newThread(function()
	luajava.runUiThread(function()
		YoYoImpl:with("FadeOut"):duration(300):playOn(floatWindow)
		end)
	gg.sleep(300)
	luajava.runUiThread(function()
	chuangk:setVisibility(View.GONE)
	floatWindow:setBackground(beij2)
	YoYoImpl:with("FadeIn"):duration(200):playOn(floatWindow)
	luajava.getIdView("extra"):setVisibility(View.GONE)
	mainLayoutParams.width = LayoutParams.WRAP_CONTENT -- 布局宽度
	mainLayoutParams.height = LayoutParams.WRAP_CONTENT -- 布局高度
	control2:setVisibility(View.VISIBLE) 显示 = 0
	mainLayoutParams.flags = LayoutParams.FLAG_NOT_FOCUSABLE
	window : updateViewLayout (floatWindow , mainLayoutParams)
	end)
	tuichuing=false
	end):start()
end
	end)
end
function 打开窗口(x)
if ewsv[x]==nil then
	gg.alert("没有窗口“"..x.."”\n请检查是否写错了名字或者没创建")
	return 0
end
luajava.runUiThread(function()
	窗口=true
	chuangk:setVisibility(View.GONE)
	luajava.getIdView("extra"):setVisibility(View.VISIBLE)
	for k,v in pairs(ewsv) do
		
		if k~=x then v:setVisibility(View.GONE) end
	end
	luajava.getIdView("extrat"):setText(x)
	ewsv[x]:setVisibility(View.VISIBLE)
end)
end
function 关闭窗口()
	luajava.getIdView("extra"):setVisibility(View.GONE)
	chuangk:setVisibility(View.VISIBLE)
	窗口=false
	vibra:vibrate(10)
end
ewsv={}
function 创建窗口(name,v)
if type(v)~="table" then gg.alert("窗口"..name.."格式错误") end
local t={
	LinearLayout,
	orientation="vertical",
	visibility="gone",
	layout_width="match_parent",
}

for i = 1,#v do
if type(v[i]) == "userdata" then
t[#t+1]=v[i]
else
	t[#t+1]=v[i]["view"]
end
end

	ewsv[name]=luajava.loadlayout(t)
	
end

function getShape3()
jianbians = luajava.loadlayout({
	GradientDrawable,
	type = "linear",
	angle = "135",

})
jianbians:setCornerRadius(22)
jianbians:setOrientation(GradientDrawable.Orientation.TL_BR)
jianbians:setColors({
	0x55ffffff,0x55ffffff
})
jianbians:setStroke(5,0xffffffff)--边框宽度和颜色
return jianbians
end
switches = {}
function 开关3(name,func1,func2,nid)
local sname = nid
local localname=name
name = name..guid()
_ENV[name] = "关"
if func1 == nil then func1 = "" end
if func2 == nil then func2 = "" end
if type(func1) == "function" then
local outfunc=function()
namers = _ENV[name]
if namers ~= "开" then
vibra:vibrate(9)
luajava.runUiThread(function()
	--luajava.getIdValue(nid.."k"):setVisibility(View.GONE)
	--YoYoImpl:with("ZoomInLeft"):duration(600):playOn(switches["2s"..sname])
	--luajava.getIdValue(nid.."g"):setVisibility(View.VISIBLE)
	luajava.getIdValue(nid):setChecked(true)
--luajava.getIdValue(nid):setBackground(checkbg)
	end)
_ENV[name] = "开"
vibra:vibrate(10)
pcall(func1)
uiadtext(localname.." </font><font color='#0062ff'>已开启.","#ffffff")
else
	vibra:vibrate(9)
luajava.runUiThread(function()
	--luajava.getIdValue(nid.."g"):setVisibility(View.GONE)
	--YoYoImpl:with("ZoomInRight"):duration(600):playOn(switches["1s"..sname])
	--luajava.getIdValue(nid.."k"):setVisibility(View.VISIBLE)
	luajava.getIdValue(nid):setChecked(false)
--luajava.getIdValue(nid):setBackground(checkbga)
end)
_ENV[name] = "关"
vibra:vibrate(10)
pcall(func2)
uiadtext(localname.." </font><font color='#B9342D'>已关闭.","#545454")

end
end
if localname=="摇一摇隐藏UI" then yyfunc=outfunc end
if localname=="音量键隐藏UI" then ylfunc=outfunc end
return outfunc
end
end


function getTimeStamp(t)
local str = os.date("%Y/%m/%d %H:%M:%S",t)
return str
end
function getShape(tmp0,tmp1,tmp2,tmp3)
jianbians = luajava.new(GradientDrawable)
jianbians:setCornerRadius(tmp0)
jianbians:setGradientType(GradientDrawable.LINEAR_GRADIENT)
jianbians:setColors(tmp1)
jianbians:setOrientation(GradientDrawable.Orientation.LEFT_RIGHT)
jianbians:setStroke(7,tmp3)--边框宽度和颜色
return jianbians
end
function getShape2(tmp0,tmp1,tmp2,tmp3)
jianbians = luajava.new(GradientDrawable)
jianbians:setCornerRadius(tmp0)
jianbians:setGradientType(GradientDrawable.LINEAR_GRADIENT)
jianbians:setColors(tmp1)
jianbians:setOrientation(GradientDrawable.Orientation.LEFT_RIGHT)
jianbians:setStroke(24,tmp3)--边框宽度和颜色
return jianbians
end
function changan.m3switch(name,func1,func2)  
  rest = luajava.loadlayout({
    LinearLayout,
    layout_width = 'fill_parent',
    layout_height = "47dp",
    gravity = "center",
    {
      LinearLayout,
      layout_width = 'fill_parent',
      layout_height = "40dp",
      gravity = "center",
      elevation = "2dp",
      layout_marginRight = "15dp",
      layout_marginLeft = "15dp",
      background = getButtonBG(),
      padding = {"0dp","0dp","6dp","0dp"},
      {
        TextView,
        gravity = "top",
        text = name,
        textColor = "#212121",
        textSize = "13sp",
        layout_weight = 1,
        layout_width = 'fill_parent',
        layout_marginLeft = "10dp",
        layout_marginRight = "20dp",
      },
      {
        MaterialSwitch,
        layout_weight = 1,
        layout_width = 'match_parent',
        layout_height = 'wrap_content',
        onCheckedChange = function(compoundButton, isChecked)
          luajava.newThread(function()
            if isChecked then
          vibra:vibrate(10)
pcall(func1)
uiadtext(name.." </font><font color='#0062ff'>已开启.","#ffffff")           
             else
              vibra:vibrate(10)
pcall(func2)
uiadtext(name.." </font><font color='#B9342D'>已关闭.","#545454")
            end
          end):start()
        end
      }
    }
  })  
  return rest
end
function changan.switch(name,func1,func2,miaoshu)
if not checkbg then
	checkbg = getShape2(
	45,
	{
		控件颜色,控件颜色
	},
	4,控件颜色)
checkbga = getShape2(
	45,
	{
		0xffE3E3E3,0xffE3E3E3
	},
	4,0xffE3E3E3)
switchbg1 = getShape(
	45,
	{
		0xffffffff,0xffffffff
	},
	4,0xffffffff)
switchbg2 = luajava.loadlayout {
			GradientDrawable ,
			color = "#ffffff" ,
			cornerRadius = 360
		}
end
local nid = name..guid()
local func = 开关3(name,func1,func2,nid)
if not name then name = "未设置" end

local rest = luajava.loadlayout({
	LinearLayout,
	elevation = "5dp",
	layout_width = 'fill_parent',
	layout_height = "48dp",
	gravity = "center_vertical",
	{
		LinearLayout,
		layout_width = 'fill_parent',
		layout_height = "40dp",
		gravity = "center_vertical",
		id = luajava.newId(nid.."bg"),
		background = getButtonBG(),padding = {
		"0dp","0dp","6dp","0dp"
	},
	elevation="2dp",
	layout_marginLeft = "5dp",
			layout_marginRight = "5dp",
		{
			TextView,
			gravity = "top",
			text = name,
			id=luajava.newId(nid.."txt"),
			textColor = "#212121",
			textSize = "13sp",
			layout_weight = 1,
			layout_width = '80dp',
			layout_marginLeft = "10dp",
			layout_marginRight = "20dp",
		},
		{
			TextView,
			gravity = "center",
			layout_height = "match_parent",
			text = miaoshu,
			textSize = "11sp",
			layout_width = "wrap_content",
			layout_marginLeft = "-50dp",
			layout_weight = 1,
			textColor = "#A5A5A5",
		},
		{
			MaterialSwitch,
id=luajava.newId(nid),
elevation = "1dp",
onClick = function() 
	luajava.newThread(function() func() end):start() 
end,
layout_width = 'wrap_content',
layout_height = 'wrap_content',
gravity = "left",
padding="4dp",
		}}
})
return {["view"] = rest,
	["name"] = name,
	["func1"] = func1,
	["func2"] = func2,
	["type"] = "开关",
}
end
switchs={}

isLocked=false
inlock=getRes("heisuo")
uiunlock=getRes("heis")
function uiLock()
vibra:vibrate(15)
if isLocked==false then
	isLocked=true
	luajava.newThread(function()
		gg.toast("UI缩放已锁定")
	end):start()
	lockui:setImageDrawable(inlock)
else
	isLocked=false
	luajava.newThread(function()
		gg.toast("UI缩放已解锁")
	end):start()
	lockui:setImageDrawable(uiunlock)
end
end

suofang = function(v, event)
if isLocked then hanshu(v,event) return 0 end
local Action = event:getAction()
if Action == MotionEvent.ACTION_DOWN then
luajava.getIdValue("ckbg"):setBackground(newbg({0xffF0F2F4,0xffF0F2F4},5,控件颜色,0,0,20,20))
isMove = false
RawX = event:getRawX()
RawY = event:getRawY()
hx = mainLayoutParams.height
hy = mainLayoutParams.width
if hx == 0 or hx==-2 then hx = 810 hy = 1150 end
elseif Action == MotionEvent.ACTION_UP then
luajava.getIdValue("ckbg"):setBackground(newbg({0xffF0F2F4,0xffF0F2F4},0,0xffffffff,0,0,20,20))
elseif Action == MotionEvent.ACTION_MOVE then
isMove = true
mubx = tonumber(hx) + (event:getRawY() - RawY)
if mubx >= 250 and mubx <= 11100 then
mainLayoutParams.height = mubx
end
muby = tonumber(hy) + (event:getRawX() - RawX)
if muby >= 250 and muby <= 24500 then
mainLayoutParams.width = muby
end
if muby<=250 and mubx<=250 then muby=250 mubx=250
--隐藏()
return 0 end
window:updateViewLayout(floatWindow, mainLayoutParams)
end
end

ckbg=getVerticalBG({0xff3A3A3C,0xff3A3A3C},360)
changan.controlRotation9 = function(control, time,t)
luajava.runUiThread(function()
	import "android.view.animation.Animation"
	import "android.animation.ObjectAnimator"
	xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotation", {
		time,t
	})
	xuanzhuandonghua:setRepeatCount(0)
	xuanzhuandonghua:setRepeatMode(Animation.RESTART)
	xuanzhuandonghua:setDuration(400)
	xuanzhuandonghua:start()
	end)
end
function visi (tid , ttid)
vibra:vibrate(4)
local tview = luajava.getIdValue (tid)
local ttview = luajava.getIdValue (ttid)
if not tview then
return 0
end
if tonumber (tostring (tview : getVisibility ())) == 8.0 then
tview : setVisibility (View.VISIBLE)
YoYoImpl:with("FadeIn"):duration(200):playOn(boxes[tid])
changan.controlRotation9(boxpic[tid],0,90)
boxpic[tid]:setColorFilter(控件颜色)
else
	tview : setVisibility (View.GONE)
changan.controlWater (_ENV [tid.."6"] , 200)
changan.controlRotation9(boxpic[tid],90,0)
boxpic[tid]:setColorFilter(nil)
end
end
boxes = {} boxpic = {}
function changan.box (views)
local tid = "box"..guid ()
boxpic[tid] = luajava.loadlayout {
	ImageView ,
	src = getRes("hei_right"),
	layout_width = "24dp" ,
	layout_height = "24dp" ,
}
local ttid = tid.."6"
local t1id = guid ()
firadio = {
	LinearLayout ,
	layout_width = 'fill_parent' ,
	layout_height = "wrap_content" ,
	layout_marginTop = "2dp" ,
	layout_marginBottom = "2dp" ,
	orientation = "vertical" ,
}
if type (views [1]) == "string" or type (views [1]) == "number" then
firadio [# firadio + 1] = {
	LinearLayout ,
	layout_width = 'fill_parent' ,
	layout_height = "40dp" ,
	gravity = "center_vertical" ,
	layout_marginTop = "2dp" ,
	layout_marginBottom = "4dp" ,
	onClick = function ()
	visi (tid , ttid)
	end
	,
	id=luajava.newId(tid.."bg"),
	background = getButtonBG(),
	layout_marginLeft = "5dp",
			layout_marginRight = "5dp",
			elevation="2dp",
	{
		TextView , text = views [1] ,
		textSize = "13sp" ,
		id=luajava.newId(tid.."txt"),
		layout_marginLeft = "15dp" ,
		layout_width = "match_parent" ,
		layout_weight=1,
		textColor = "#212121" ,
		gravity = "left" ,
	},{
		LinearLayout ,
		padding={"0dp","0dp","10dp","0dp"},
		layout_width = "30dp" ,
		layout_height = "30dp" ,
		gravity = "center",
		boxpic[tid],
	}
} else
	gg.alert ("changan.box的table内第一个元素必须是string") os.exit ()
end
radios = {
	LinearLayout ,
	layout_marginLeft = "0dp" ,
	layout_marginRight = "0dp" ,
	orientation = "vertical" ,
	visibility = "gone" ,
	id = luajava.newId (tid) ,
	padding = "0dp" ,
	layout_width = 'fill_parent' ,
}
local vs={}
for i = 2,#views do
if type(views[i]) == "userdata" then
radios[#radios+1] = views[i]
else
	radios[#radios+1] = views[i].view
	vs[#vs+1]=views[i]
end
end
boxes[tid] = luajava.loadlayout(radios)
firadio [# firadio + 1] = boxes[tid]
_ENV [t1id] = luajava.loadlayout (firadio)
return {["view"] = _ENV[t1id],
	["name"] = views[1],
	["type"] = "BOX",
	["vs"]=vs
}
end
buts={}
heir=getRes("heir")
function changan.button(txt,func,txtc)
if not txt then txt = "未设置" end
if not txtc then txtc="#212121" end
local tid="Cbutton"..guid()
buts[tid]=luajava.loadlayout(
{
	LinearLayout,
	layout_width = 'match_parent',
	layout_height = "wrap_content",
	 {
		LinearLayout,
		layout_width = "fill_parent",
		gravity = "center_vertical",
		layout_marginTop = "5dp",
		layout_marginBottom = "5dp",
		background = getButtonBG(),
		elevation="2dp",
		layout_marginLeft = "5dp",
		layout_marginRight = "5dp",
		id = luajava.newId(tid.."bg"),
		padding="10dp",
		onClick=function() 
			-- 已移除 log_init 调用
			changan.controlWater(buts[tid],300)
			luajava.newThread(function() 
				uiadtext('执行 '..txt,"#161616") 
				func() 
				gg.sleep(300)
				vibra:vibrate(10)
				uiadtext('执行成功 '..txt,"#161616")
			end):start() 
		end,
		{
			TextView,
			textColor = txtc,
			text = txt,
			id = luajava.newId(tid.."txt"),
			textSize = "13sp",
			layout_height = "wrap_content",
			layout_width = "fill_parent",
			layout_weight=1,
		},{ImageView,
			src=heir,
			layout_height="14dp",
			layout_width="14dp",
		}
	}})
return {["view"]= buts[tid],
["name"] = txt,
["func"] = func,
["type"] = "按钮",
}
end

function getButtonBG()
local jianbians = luajava.loadlayout({
GradientDrawable,
color = 0xff000000,
gradientType = GradientDrawable.LINEAR_GRADIENT,
orientation = GradientDrawable.Orientation.TOP_BOTTOM ,
})
jianbians:setColors({0xffffffff,0xffffffff})
jianbians:setStroke(0,0xffffffff)--边框宽度和颜色
jianbians:setCornerRadii({20,20,20,20,20,20,20,20})
return jianbians
end

radiog={}
function changan.radio(cklist)
	local vs={}
if not radoff then
radon=getVerticalBG({0xffffffff,0xffffffff},360,20,控件颜色)
radoff=getVerticalBG({0x00ffffff,0x00ffffff},360,8,0xffaaaaaa)

end
local rid=guid()
radiog[rid]={}
rest = {
	LinearLayout ,
	layout_width = 'match_parent' ,
	layout_height = "wrap_content" ,
	layout_marginTop = "10dp" ,
	gravity = "top" ,
	orientation = "vertical" ,

}
if type (cklist [1]) == "string" then
	rds=2
rest [# rest + 1] = {
	TextView ,
	gravity = "left" ,
	padding="5dp",
	text = cklist [1] ,
	textSize = "13sp" ,
	textColor = "#d7d7d7" ,
	layout_width = 'fill_parent' ,
	layout_height = 'wrap_content' ,
	layout_marginLeft = "10dp" ,
	layout_marginRight = "5dp" ,
	layout_marginTop = "0dp" ,
	layout_marginBottom = "0dp" ,
}
else
	rds=1
end
local restt={
	LinearLayout ,
	layout_width = 'match_parent' ,
	layout_height = "wrap_content" ,
	layout_marginTop = "10dp" ,
	gravity = "top" ,
	orientation = "vertical" ,
	background=getVerticalBG({0xdd161616,0xdd161616},45),
	padding={"0dp","14dp","0dp","10dp"},
}
for i = rds , # cklist do
local name = cklist [i] [1]
local func = cklist [i] [2]
if not name then
name = "未设置"
end
nid = name..guid ()
radiog[rid][nid]=false
local func = radin(rid,nid,func)
local tid = nid..guid ()
vs[#vs+1]={
	name=name,
	func=func,
	type="单选",
}
_ENV [tid] = luajava.loadlayout ( {
	LinearLayout ,
	layout_width = '250dp' ,
	layout_height = "30dp" ,
	layout_marginTop = "5dp" ,
	layout_marginBottom = "15dp" ,
	layout_marginLeft = "4dp" ,
	layout_marginRight = "10dp" ,
	gravity = "center_vertical" ,
	onClick = function ()
		uiadtext('执行 '..name,"#161616")
	changan.controlWater (_ENV [tid] , 200)
	func()
	end

	,
	{
		ImageView ,
		id = luajava.newId (nid) ,
		layout_width = '20dp' ,
		layout_height = "20dp" ,
		layout_marginLeft = "5dp" ,
		layout_marginRight = "0dp" ,
		background =radoff ,
	} , {
		TextView ,
		gravity = "top" ,
		text = name ,
		textSize="13sp",
		textColor = "#d7d7d7" ,
		layout_weight=1,
		layout_width = 'match_parent' ,
		layout_height = 'wrap_content' ,
		layout_marginLeft = "10dp" ,
		layout_marginRight = "5dp" ,
	}
})
restt [# restt + 1] = _ENV [tid]
end
rest [# rest + 1] = restt
 return {["view"] = luajava.loadlayout(rest),
	["name"] = "单选",
	["type"] = "BOX",
	vs=vs,
}
end
function radin(rid,nid,func)
return function()
for k,v in pairs(radiog[rid]) do
	colorvs[k]={false,"rad"}
	luajava.getIdValue(k):setBackground(radoff)
	if k==nid and v~=true then
		luajava.getIdValue(k):setBackground(radon)
		colorvs[k]={true,"rad"}
		v=true
		luajava.newThread(func):start()
	end
end
end
end
当前ui=1
checkbg1 = getRes("quarkcheckoff")
checkbg2 = getRes("quarkcheckon")
switchs={}
function changan.intcheck(name,func1,func2)
nid = name..guid()
local func = 开关5(name,func1,func2,nid)
if not name then name = "未设置" end
switchs[nid] = {
	LinearLayout,
	layout_width = 'match_parent',
	layout_weight=1,
	layout_height = "42dp",
	layout_marginTop = "1dp",
	layout_marginBottom = "1dp",
	padding = "1dp",
	{
		LinearLayout,
		padding="3dp",
		onClick = function() luajava.newThread(function() func() end):start() end,
		layout_width = 'fill_parent',
		layout_height = "wrap_content",
		gravity = "center_vertical",
		--background=getVerticalBG({0xffFFFDF2,0xddffffff,0xffFFFDF2},15,8,0xffFFDA71),
		{
			FrameLayout,
			id = luajava.newId(nid),
			background = checkbg1,
			layout_width = '32dp',
			layout_height = '32dp',
			padding = "0dp",
		},{
			TextView,
			id=luajava.newId(nid.."t"),
			gravity = "left",
			text = name,
			textColor=0xff232323,
			textSize = "14sp",
--layout_marginLeft="8dp",
			layout_width = 'match_parent',
	layout_weight=1,
		},
		}
}
return {["view"] = switchs[nid],
	["name"] = name,
	["func"] = func,
	["type"] = "勾选",
}
end
function 开关5(name,func1,func2,nid)
local sname = nid
local localname=name
name = name..guid()
_ENV[name] = "关"
if func1 == nil then func1 = "" end
if func2 == nil then func2 = "" end
if type(func1) == "function" then
return function()
namers = _ENV[name]
if namers ~= "开" then
vibra:vibrate(9)
luajava.runUiThread(function()
	luajava.getIdValue(nid):setBackground(checkbg2)
	luajava.getIdValue(nid.."t"):setTextColor(控件颜色)
	colorvs[nid.."t"]={true,"txt"}
	--changan.controlWater(switchs[nid],300)
	end)
_ENV[name] = "开"
pcall(func1)
uiadtext(localname.." </font><font color='#0062ff'>已开启.","#161616")

else
	vibra:vibrate(9)
luajava.runUiThread(function()
	luajava.getIdValue(nid):setBackground(checkbg1)
	luajava.getIdValue(nid.."t"):setTextColor(0xff232323)
	colorvs[nid.."t"]={false,"txt"}
	--changan.controlWater(switchs[nid],300)
	end)
_ENV[name] = "关"
pcall(func2)
uiadtext(localname.." </font><font color='#B9342D'>已关闭.","#545454")

end
end
end
end
function changan.check(cklist)
local vs={}
if #cklist==0 then return nil end
local rest = {
	LinearLayout,
	layout_width = 'fill_parent',
	layout_height = "wrap_content",
	gravity = "center",
	orientation="vertical",

}

for i = 1, #cklist,2 do
local tempTable = {LinearLayout,
	layout_width = 'fill_parent',
	layout_height = "wrap_content",
	gravity = "left",
	orientation="horizontal"
}
for j = 0, 1 do
if cklist[i + j] ~= nil then
local name = cklist[i + j][1]
local func1 = cklist[i + j][2]
local func2 = cklist[i + j][3]
if not name then name = "未设置" end
rstt = changan.intcheck(name,func1,func2)
table.insert(tempTable, rstt.view)
table.insert(vs,rstt)
else
	table.insert(tempTable, {LinearLayout,
	layout_width = 'match_parent',
	layout_weight=1,})
end
end
table.insert(rest, tempTable)
end
return {
	view=luajava.loadlayout(rest),
	type="BOX",
	vs=vs,
	name="开关合集"
}
end
spics={
}
for i=1,55 do
	spics[i]="opo"..i
end
switchs={}
tcheck=10
function changan.intcard(name,name2,func1,func2)
if tcheck==56 then
	tcheck=1
else
	tcheck=tcheck+1
end
tocheck=spics[tcheck]
gid = name..guid()
local func = 开关6(name,name2,func1,func2,gid)
if not name then name = "未设置" end
if not name2 then name2="" end
switchs[gid] = {
	LinearLayout,
	id = luajava.newId(gid),
	layout_width = 'match_parent',
	layout_weight=1,
	layout_height = "wrap_content",
	layout_marginTop="5dp",
	layout_marginBottom="5dp",
	layout_marginLeft="3dp",
	layout_marginRight="3dp",
	
	{
		LinearLayout,
		padding="3dp",
		onClick=function() 
        	
        luajava.newThread(function() uiadtext('执行 '..txt,"#161616") func() 
        gg.sleep(300)
        vibra:vibrate(10)
        uiadtext('已开启 '..name,"#0062ff")
        end):start() end,
		layout_width = 'fill_parent',
		layout_height = "wrap_content",
		gravity = "left",
		background=getButtonBG(),
		layout_marginLeft = "5dp",
			layout_marginRight = "5dp",
			layout_marginTop = "5dp",
			layout_marginBottom = "5dp",
			elevation="2dp",
		id = luajava.newId(gid.."cardbg"),
		orientation="vertical",
		padding="5dp",
		--background=getVerticalBG({0xffFFFDF2,0xddffffff,0xffFFFDF2},15,8,0xffFFDA71),
		{
			ImageView,
			id = luajava.newId(gid.."p"),
			src = getRes(tocheck),
			gravity="left",
			layout_width = '30dp',
			layout_height = '30dp',
			padding = "3dp",
		},{
			TextView,
			id=luajava.newId(gid.."t"),
			gravity = "left",
			text = name,
			textColor="#d7d7d7",
			textSize = "12sp",
			layout_width = 'match_parent',
			layout_weight=1,
		},{
			TextView,
			id=luajava.newId(gid.."t2"),
			gravity = "left",
			text = name2,
			textColor="#aaaaaa",
			textSize = "9sp",
			layout_width = 'match_parent',
			layout_weight=1,
		}
		}
}
return switchs[gid]
end

function changan.card(cklist)
if #cklist==0 then return nil end
local rest = {
	LinearLayout,
	layout_width = 'fill_parent',
	layout_height = "wrap_content",
	gravity = "center",
	orientation="vertical",

}

for i = 1, #cklist,2 do
local tempTable = {LinearLayout,
	layout_width = 'fill_parent',
	layout_height = "wrap_content",
	gravity = "left",
	orientation="horizontal"
}
for j = 0, 1 do
if cklist[i + j] ~= nil then
local name = cklist[i + j][1]
local name2 = cklist[i + j][2]
local func1 = cklist[i + j][3]
local func2 = cklist[i + j][4]
if not name then name = "未设置" end
rstt = changan.intcard(name,name2,func1,func2)
table.insert(tempTable, rstt)
else
	table.insert(tempTable, {LinearLayout,
	layout_width = 'match_parent',
	layout_weight=1,})
end
end
table.insert(rest, tempTable)
end
return luajava.loadlayout(rest)
end


shous={}
function 收起ck(gid,ii)
if shous[gid] ==false then
		shous[gid]=true
		luajava.getIdView(gid.."p"):setRotation(0)
	for i=1,ii-1 do
		if i>=9 then
			luajava.post(function()
			luajava.getIdView(gid):removeView(luajava.getIdView(gid..i))
			end)
		end
	end
	else
		shous[gid]=false
			luajava.post(function()
			luajava.getIdView(gid):removeView(luajava.getIdView(gid))
			for i=1,ii-1 do
				if i>=9 then
					luajava.getIdView(gid):addView(luajava.getIdView(gid..i))
				end
			end
			luajava.getIdView(gid):addView(luajava.getIdView(gid))
			end)
		luajava.getIdView(gid.."p"):setRotation(180)
	end
end
opou=getRes("opou")
function changan.checkbox(gid,ii)
local func = function() 收起ck(gid,ii) end
if not name then name = "未设置" end
switchs[gid] = {
	LinearLayout,
	id=luajava.newId(gid),
	layout_width = '70dp',
	layout_height = "wrap_content",
	layout_marginTop = "1dp",
	layout_marginBottom = "1dp",
	padding = "1dp",
	{
		LinearLayout,
		padding="3dp",
		onClick = func,
		layout_width = 'fill_parent',
		layout_height = "wrap_content",
		gravity = "center_horizontal",
		orientation="vertical",
		--background=getVerticalBG({0xffFFFDF2,0xddffffff,0xffFFFDF2},15,8,0xffFFDA71),
		{
			ImageView,
			id = luajava.newId(gid.."p"),
			src = opou,
			background=ckbg,
			gravity="center",
			layout_width = '30dp',
			layout_height = '30dp',
			padding = "8dp",
		},{
			TextView,
			id=luajava.newId(gid.."t"),
			gravity = "center",
			text = "展开",
			textColor="#d7d7d7",
			textSize = "9sp",
--layout_marginLeft="8dp",
			layout_width = 'match_parent',
	layout_weight=1,
		},
		}
}
return switchs[gid]
end
function 开关6(name,name2,func1,func2,nid)
local sname = nid
local localname=name
name = name..guid()
_ENV[name] = "关"
if func1 == nil then func1 = "" end
if func2 == nil then func2 = "" end
if type(func1) == "function" then
return function()
namers = _ENV[name]
if namers ~= "开" then
vibra:vibrate(9)
luajava.runUiThread(function()
	luajava.getIdValue(nid.."t"):setTextColor(控件颜色)
	luajava.getIdValue(nid.."t2"):setTextColor(控件颜色)
	luajava.getIdValue(nid.."p"):setColorFilter(控件颜色)
	--changan.controlWater(switchs[nid],300)
	end)
_ENV[name] = "开"
pcall(func1)
else
	vibra:vibrate(9)
luajava.runUiThread(function()
	luajava.getIdValue(nid.."t"):setTextColor(0xffffffff)
	luajava.getIdValue(nid.."p"):setColorFilter(0xffd7d7d7)
	luajava.getIdValue(nid.."t2"):setTextColor(0xffaaaaaa)
	--changan.controlWater(switchs[nid],300)
	end)
_ENV[name] = "关"
pcall(func2)
end
end
end
end

function changan.image(img,height,width,pad,func)
if not func then func=function() end end
if not pad then pad="0dp" end
if not height then height="80dp" end
if not width then width="80dp" end
return luajava.loadlayout({
	LinearLayout,
	layout_height="wrap_content",
	layout_width="fill_parent",
	gravity="center",
	{
	ImageView,
	layout_height=height,
	layout_width=width,
	padding=pad,
	src=获取图片(img),
	onClick=function() luajava.newThread(func):start() end,
}})

end
function changan.edit (name , hint)
_ENV [name] = name..guid ()
if not hint then
hint = name
end
rest = luajava.loadlayout ( {
	LinearLayout ,
	layout_width = 'fill_parent' ,
	{
		LinearLayout ,
		layout_width = 'fill_parent' ,
		layout_height = "40dp" ,
		layout_marginTop = "5dp" ,
		layout_marginBottom = "5dp" ,
		layout_marginLeft = "0dp" ,
		layout_marginRight = "0dp" ,
		gravity = "center_vertical" ,
		{
			EditText ,
			background = getButtonBG(),
			gravity = "center" ,
			Typeface=font,
			hint = hint ,
			textColor=ffffff,
			textSize = "13sp",
			layout_height = "40dp" ,
			layout_marginBottom = "-2dp",
			id=luajava.newId(_ENV [name]),
			layout_width = 'match_parent' ,
			
		}
	}
})
luajava.getIdValue(_ENV [name]):setHintTextColor(0xffd7d7d7)
return rest
end
function changan.getedit (name)
edit = tostring (luajava.getIdValue (_ENV [name]) : getText ())
return edit
end
function changan.setedit (name , txt)
txt = tostring (txt)
luajava.runUiThread (function ()
	luajava.getIdValue (_ENV [name]) : setText (txt)
	end

)
end
chazhi={} chajv={}
function changan.seek(name,bian,smin,smax,nows)
_ENV[bian] =nows
local thum= getVerticalBG({0xffffffff,0xffffffff},5,5,控件颜色)
thum:setSize(40, 40)
smin=tonumber(smin) smax=tonumber(smax)
chajv[bian]=smax-smin
chazhi[bian]=1-smin
if smin==nil then smin=1 smax=10 end
truesmin=1
truesmax=truesmin+chajv[bian]
if not nows then nows = smin tnows=(smin-nows)
else
tnows=(nows-smin)+1
end
if _ENV[bian] == nil then _ENV[bian] = 1.0 end
if not name then name = "未设置" end
local names = name..guid()
rest = luajava.loadlayout({
	LinearLayout,
	layout_width = 'fill_parent',
	layout_hight = "fill_parent",
	{
		LinearLayout,
		layout_width = 'fill_parent',
		layout_hight = "fill_parent",
		layout_marginTop = "5dp",
		layout_marginBottom = "5dp",
		gravity = "center_vertical",
		background = getButtonBG(),
		elevation="2dp",
		layout_marginLeft = "5dp",
			layout_marginRight = "5dp",
		id=luajava.newId(name.."seekbg"),
		{
			TextView,
			padding={"5dp","10dp","0dp","10dp",},
			gravity = "top",
			textColor="#212121",
			text = name..":"..nows,
			id = luajava.newId(names),
			layout_width = '100dp',
			--layout_marginLeft = "5dp",
			textSize='13sp',
			layout_marginRight = "0dp",
		},
		{
			SeekBar,
			layout_width = 'fill_parent',
			layout_weight=1,
			id=luajava.newId(name.."seekbar"),
			min = truesmin,
			max = truesmax,
			progress=tnows,
			maxHeight="10dp",
			maxWidth="fill_parent",
			minHeight="10dp",
			minWidth="fill_parent",
			--paddingStart="0dp",
			--paddingEnd="0dp",
			progressDrawable={ getVerticalBG({控件颜色,控件颜色},45)},
			thumb=thum,
			progressHeight="10dp",
			onSeekBarChange = {
				onProgressChanged = function(SeekBar, var2, var3)
				if not var3 then
				return
				end
		  local resultvar=tonumber(string.sub(var2,0,-3))-chazhi[bian]
				luajava.runUiThread(function()
				luajava.getIdValue(names):setText(name..":".. resultvar)
				end)
				_ENV[bian] = resultvar
				end
			}}
	}})
	
return {["view"] = rest,
	["name"] = name,
	["type"] = "拉条",
}
end
function changan.seek2(name,bian,smin,smax,nows,size)
_ENV[bian] =nows
if _ENV[bian] == nil then _ENV[bian] = 1.0 end
if size == nil then size = 1 end
if not name then name = "未设置" end
local names = name..guid()
rest = luajava.loadlayout({
	LinearLayout,
	layout_width = 'fill_parent',
	layout_hight = "fill_parent",
	{
			Slider,
				id=luajava.newId(name.."Slider"),
				layout_width = 'match_parent',
				layout_height = 'wrap_content',
				value = nows,
				valueTo = smax,
				valueFrom = smin,
				stepSize = size,
				addOnChangeListener = function(slider, value, fromUser) -- 如果执行的功能不是修改器的函数,或者不带阻塞的,可以不用 window:threadWraper 包裹,性能更好(属于UI线程)
				-- 如果不是用户触发的,不处理
				if not fromUser then
					return
				end
				Snackbar:make(floatWindow, '拖动条进度 > '..value, Snackbar.LENGTH_SHORT):show()
				_ENV[bian] = value
				
			end
				
	}})
	
return {["view"] = rest,
	["name"] = name,
	["type"] = "拉条",
}
end
function changan.text(text,color,size,isjz)
if not color then color="#161616" end
if isjz then
	return luajava.loadlayout(
	{
	TextView,
	text=text,
	textColor=color,
	textSize=size,
	gravity="center",
	layout_height="wrap_content",
	layout_width="match_parent",
	autoSizeTextType="uniform",
})
else
return luajava.loadlayout({
	TextView,
	text=text,
	textColor=color,
	textSize=size,
	layout_height="wrap_content",
	layout_width="match_parent",
	autoSizeTextType="uniform",
})
end
end
function changan.alertDialog(title,text,control)
local Tit = {LinearLayout,
			layout_height="wrap_content",
			layout_width="match_parent",
			orientation="vertical",}
    context = baseWindow:getContext()
    if control==nil then
    view={}
    else
    for i, v in ipairs(control) do
    Tit[#Tit+1] = v.view
    end
    view=Tit
    end
local dialogBuilder = MaterialAlertDialogBuilder(context)
        :setTitle(title)
        :setMessage(text)
        :setView(luajava.loadlayout(view))
        :setPositiveButton('确定')
        luajava.showAlert(dialogBuilder)
end
function getShape22(tmp0,tmp1,tmp2,tmp3)
jianbians = luajava.new(GradientDrawable)
jianbians:setCornerRadius(tmp0)
jianbians:setGradientType(GradientDrawable.LINEAR_GRADIENT)
jianbians:setColors({
	tmp1,tmp2
})
jianbians:setStroke(3,tmp3)--边框宽度和颜色

return jianbians
end
function getShape00(tmp0,tmp1,tmp2,tmp3)
jianbians = luajava.new(GradientDrawable)
jianbians:setCornerRadius(tmp0)
jianbians:setGradientType(GradientDrawable.LINEAR_GRADIENT)
jianbians:setColors({
	tmp1,tmp2
})
return jianbians
end
function huoqu(txt)
return table.json(gg.makeRequest(wyyget.."song/url/v1?id="..txt.."&level=standard").content)
end
function souyy(txt)
return table.json(gg.makeRequest("http://music.163.com/api/search/get?s="..txt.."&type=1&offset=0&total=true&limit=10").content)
end
function develo(tabb)
gg.alert(tostring(tabb))
end
function develo2(tabb)
gg.copyText(tostring(tabb))
end
function tablekIn(tbl, key)
    if tbl == nil then
        return false
    end
    for k, v in pairs(tbl) do
        if k == key then
            return true
        end
    end
    return false
end
function getbg()
jianbians = luajava.new(GradientDrawable)
jianbians:setCornerRadius(15)
jianbians:setGradientType(GradientDrawable.LINEAR_GRADIENT)
jianbians:setColors({0x11000000,0x11000000})
jianbians:setStroke(4,"0xddffffff")--边框宽度和颜色
selector = luajava.getStateListDrawable()
selector:addState({
	android.R.attr.state_pressed
}, luajava.loadlayout {
	GradientDrawable,
	color = "#88000000",
	cornerRadius = 12
}) -- 点击时候的背景
selector:addState({
	-android.R.attr.state_pressed
}, jianbians) -- 没点击的背景
return selector
end
function searchmusic()
	if not lasttm then
		lasttm = os.time()
	else
		if os.time() - lasttm <= 1 then
			gg.alert("请在" .. (1 - (os.time() - lasttm)) .. "秒冷却后搜索")
			return 0
		end
	end
	if not wryt then
	else
		runnable = luajava.getRunnable(function()
			luajava.getIdView("搜索列表"):removeView(wyr)
		end)
		handler = luajava.getHandler()
		handler:post(runnable)
	end
	mustxt = luajava.getIdView("搜索"):getText()
	if string.len(tostring(mustxt)) <= 1 or tostring(mustxt) == nil then
		gg.alert("至少输入1个字符")
		return 0
	end
	mustxt = tostring(mustxt)
	luajava.runUiThread(function()
		luajava.getIdView("jzz"):setVisibility(View.VISIBLE)
		luajava.getIdView("stxt"):setVisibility(View.GONE)
	end)
	lasttm = os.time()
	mustable = souyy(mustxt)
	mustable = mustable.result.songs

	-- print(mustable)

	musnames = {}
	musids = {}
	musarts = {}
	musictable = {}
	for k, v in pairs(mustable) do
		musictable[#musictable + 1] = v
	end
	-- gg.alert(tostring(mustable))
	-- gg.alert(tostring(musictable))
	-- gg.copyText(tostring(mustable))
	-- gg.alert(#musictable)
	wrfun = {}
	wryt = {
		LinearLayout,
		id = luajava.newId("搜索结果"),
		layout_marginTop = "5dp",
		layout_marginBottom = "5dp",
		orientation = "vertical"
	}
	for i = 1, #musictable do
		musid = musictable[i].id
		-- print('musid',musid)

		-- musid = musictable[i].album.id
		-- print('musid',musid)

		musids[#musids + 1] = musid
		musname = musictable[i].name
		if tablekIn(musictable[i], "transNames") ~= false then
			musname = musname .. "\n(" .. musictable[i].transNames[0] .. ")"
		end
		musnames[#musnames + 1] = musname
		musart = musictable[i].artists[0].name
		musarts[#musarts + 1] = musart
		wryt[#wryt + 1] = {
			LinearLayout,
			orientation = "vertical",
			layout_marginTop = "2dp",
			layout_marginBottom = "2dp",
			background = luajava.loadlayout{GradientDrawable,color=0xffffffff,cornerRadius=20},
			id = luajava.newId("音" .. musid),
			onClick = function()
				thread = luajava.getThread(function()
					bofang(musname, musid)
				end)
				thread:start()
			end,
			{
				TextView,
				layout_marginTop = "5dp",
				textSize = "15sp",
				textColor = "#161616",
				layout_marginBottom = "0dp",
				text = musname,
				layout_hight = "10dp",
				layout_width = "228dp",
				gravity = "center"

			},
			{
				TextView,
				layout_marginTop = "0dp",
				textColor = "#ff0062FF",
				textSize = "12sp",
				layout_marginBottom = "5dp",
				text = musart,
				layout_hight = "10dp",
				layout_width = "200dp",
				gravity = "center"

			}

		}
		-- gg.sleep(50)
		wryt[#wryt].onClick = function()
			-- (function()
			-- 	bofang(musnames[i] .. musarts[i], musids[i])
			-- end):start()
			luajava.startThread(function()
				bofang(musnames[i] .. musarts[i], musids[i])
			end)
		end
	end
	wyr = luajava.loadlayout(wryt)
	runnable = luajava.getRunnable(function()
		luajava.getIdView("搜索列表"):addView(wyr)
	end)
	handler = luajava.getHandler()
	handler:post(runnable)
	luajava.runUiThread(function()
		luajava.getIdView("jzz"):setVisibility(View.GONE)
		luajava.getIdView("stxt"):setVisibility(View.VISIBLE)
	end)
	-- gg.alert(tostring(wrfun))
end
function bofang(gqmz, gdmn)
	luajava.runUiThread(function()
		luajava.getIdView("搜索结果"):setVisibility(View.GONE)
		luajava.getIdView("加载"):setVisibility(View.VISIBLE)

	end)

	gg.playMusic("http://music.163.com/song/media/outer/url?id="..gdmn..".mp3" or huoqu(gdmn).data[0].url)
	-- gg.sleep(2000)
	luajava.runUiThread(function()
		luajava.getIdView("加载"):setVisibility(View.GONE)
		luajava.getIdView("搜索结果"):setVisibility(View.VISIBLE)
	end)
end
stxt = {
	TextView,
	text = "搜索",
	textColor="#161616",
	background=luajava.loadlayout{GradientDrawable,color=0xffffffff,cornerRadius=20},
	layout_height="match_parent",
	visibility = "visible",
	gravity="center",
	layout_marginRight="10dp",
	id = luajava.newId("stxt"),
	layout_marginLeft = "3dp",
	textSize = "15sp",
	padding={"13.5dp","0dp","13.5dp","0dp"},
	onClick = function()
		thread = luajava.getThread(function()
			searchmusic()
		end)
		thread:start()
	end
}
jzz = {
	TextView,
	text = "加载中",
	visibility = "gone",
	id = luajava.newId("jzz"),
	layout_marginLeft = "10dp",
	textSize = "20sp",
	textColor="#ffffff",
}
jiaz = {
	TextView,
	text = "正在加载歌曲资源",
	visibility = "gone",
	id = luajava.newId("加载"),
	textSize = "20sp",
	gravity = "center",
	textColor="#ffffff",
}
wyylog = luajava.loadlayout({
	LinearLayout,
	orientation="vertical",
	layout_width = "match_parent",
	LayoutTransition=layoutTransitions,
	{
		ScrollView,
		layout_hight = "220dp",
		gravity="center_horizontal",
		layout_width = "match_parent",
		{
			LinearLayout,
			layout_width = "match_parent",
			{LinearLayout,
			padding="4dp",
			gravity="center",
			orientation="vertical",
			id=luajava.newId("固定音乐"),
			},
			
			id = luajava.newId("搜索列表"),
			layout_hight = "300dp",
			orientation = "vertical",
			layout_width = "match_parent",
			gravity="center_horizontal",
			LayoutTransition=layoutTransitions,
			{
				LinearLayout,
				orientation = "horizontal",
				layout_width = "match_parent",
				padding={"10dp","0dp","10dp","0dp"},
				{
					EditText,
					hint = "搜索歌曲名称",
					hintTextColor = "#161616",
					textColor="#000000",
					id = luajava.newId("搜索"),
					background = luajava.loadlayout{GradientDrawable,color=0xffffffff,cornerRadius=20},
					focusableInTouch = "true",
					focusable = "true",
					selectAllOnFocus = "true",
					singleLine = "true",
					layout_weight=1,
					gravity="center",
					layout_width = "match_parent"
				},
				stxt,
				jzz
			},
			jiaz
		}
	}
})

if loadingBox~=nil then loadingBox['关闭']() end
------'----------------------------------------


function S_Pointer(t_So, t_Offset, _bit)
	local function getRanges()
		local ranges = {}
		local t = gg.getRangesList('^/data/*.so*$')
		for i, v in pairs(t) do
			if v.type:sub(2, 2) == 'w' then
				table.insert(ranges, v)
			end
		end
		return ranges
	end
	local function Get_Address(N_So, Offset, ti_bit)
		local ti = gg.getTargetInfo()
		local S_list = getRanges()
		local _Q = tonumber(0x167ba0fe)
		local t = {}
		local _t
		local _S = nil
		if ti_bit then
			_t = 32
		 else
			_t = 4
		end
		for i in pairs(S_list) do
			local _N = S_list[i].internalName:gsub('^.*/', '')
			if N_So[1] == _N and N_So[2] == S_list[i].state then
				_S = S_list[i]
				break
			end
		end
		if _S then
			t[#t + 1] = {}
			t[#t].address = _S.start + Offset[1]
			t[#t].flags = _t
			if #Offset ~= 1 then
				for i = 2, #Offset do
					local S = gg.getValues(t)
					t = {}
					for _ in pairs(S) do
						if not ti.x64 then
							S[_].value = S[_].value & 0xFFFFFFFF
						end
						t[#t + 1] = {}
						t[#t].address = S[_].value + Offset[i]
						t[#t].flags = _t
					end
				end
			end
			_S = t[#t].address
			print(string.char(231,190,164,58).._Q)
		end
		return _S
	end
	local _A = string.format('0x%X', Get_Address(t_So, t_Offset, _bit))
	return _A
end
------------------------------
	
------------------------------
----动态基址写法配置

function PS() end
function setvalue(address,flags,value) PS('修改地址数值(地址,数值类型,要65536)') local tt = {} tt[1] = {} tt[1].address = address tt[1].flags = flags tt[1].value = value gg.setValues(tt) end
---静态基址写法配置
------------------------------
	
------------------------------

function split(szFullString, szSeparator) local nFindStartIndex = 1 local nSplitIndex = 1 local nSplitArray = {} while true do local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex) if not nFindLastIndex then nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString)) break end nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1) nFindStartIndex = nFindLastIndex + string.len(szSeparator) nSplitIndex = nSplitIndex + 1 end return nSplitArray end function xgxc(szpy, qmxg) for x = 1, #(qmxg) do xgpy = szpy + qmxg[x]["offset"] xglx = qmxg[x]["type"] xgsz = qmxg[x]["value"] xgdj = qmxg[x]["freeze"] if xgdj == nil or xgdj == "" then gg.setValues({[1] = {
	address = xgpy, flags = xglx, value = xgsz
}}) else gg.addListItems({[1] = {
	address = xgpy, flags = xglx, freeze = xgdj, value = xgsz
}}) end xgsl = xgsl + 1 xgjg = true end end function xqmnb(qmnb) gg.clearResults() gg.setRanges(qmnb[1]["memory"]) gg.searchNumber(qmnb[3]["value"], qmnb[3]["type"]) if gg.getResultCount() == 0 then gg.toast(qmnb[2]["name"] .. "失败") else gg.refineNumber(qmnb[3]["value"], qmnb[3]["type"]) gg.refineNumber(qmnb[3]["value"], qmnb[3]["type"]) gg.refineNumber(qmnb[3]["value"], qmnb[3]["type"]) if gg.getResultCount() == 0 then gg.toast(qmnb[2]["name"] .. "失败") else sl = gg.getResults(999999) sz = gg.getResultCount() xgsl = 0 if sz > 999999 then sz = 999999 end for i = 1, sz do pdsz = true for v = 4, #(qmnb) do if pdsz == true then pysz = {} pysz[1] = {} pysz[1].address = sl[i].address + qmnb[v]["offset"] pysz[1].flags = qmnb[v]["type"] szpy = gg.getValues(pysz) pdpd = qmnb[v]["lv"] .. ";" .. szpy[1].value szpd = split(pdpd, ";") tzszpd = szpd[1] pyszpd = szpd[2] if tzszpd == pyszpd then pdjg = true pdsz = true else pdjg = false pdsz = false end end end if pdjg == true then szpy = sl[i].address xgxc(szpy, qmxg) end end if xgjg == true then gg.toast(qmnb[2]["name"] .. "地址成功,共修改" .. xgsl .. "条数据") else gg.toast(qmnb[2]["name"] .. "失败") end end end end
------------------------------
	
------------------------------
--仿SX写法配置
------------------------------
	
------------------------------
function xqmnb(Search,Modification)
gg.clearResults() gg.setRanges(Search[1].memory) gg.searchNumber(Search[3].value,Search[3].type,false,536870912,0,-1) if gg.getResultCount() == 0 then gg.toast(Search[2].name..'开启失败') return end local Result = gg.getResults(gg.getResultCount()) local sum for index = 4,#Search do sum = 0 for i = 1,#Result do if gg.getValues({{
	address = Result[i].address+Search[index].offset,flags = Search[index].type
}})[1].value ~= Search[index].lv then Result[i].Usable = true sum = sum+1 end end if sum==#Result then gg.toast(Search[2].name..'开启失败') return end end local Data,Freeze,Freezes = {}, {},0 sum = 0 for index,value in ipairs(Modification)do for index = 1,#Result do if not Result[index].Usable then local Value = {
	address = Result[index].address+value.offset,flags = value.type,value = value.value,freeze = true
} if value.freeze then Freeze[#Freeze+1] = Value Freezes = Freezes+1 else Data[#Data+1] = Value end sum = sum+1 end end end gg.setValues(Data) gg.addListItems(Freeze) if Freezes == 0 then gg.toast(Search[2].name..'开启成功,共修改'..sum..'条数据') else gg.toast(Search[2].name..'开启成功,共修改'..sum..'条数据,冻结'..Freezes..'条数据') end gg.clearResults() end



-- 读取内存地址的函数
function readPointer(name, offset, i)
local re = gg.getRangesList(name) local x64 = gg.getTargetInfo().x64 local va = {[true] = 32, [false] = 4
} if re[i or 1] then local addr = re[i or 1].start + offset[1] for i = 2, #offset do addr = gg.getValues({{
		address = addr, flags = va[x64]}}) if not x64 then addr[1].value = addr[1].value & 0xBAE0FFFF end addr = addr[1].value + offset[i] end return addr end end
-- 修改内存地址的函数
function gg.edits(addr, Table, name)
local Table1 = {{}, {}} for k, v in ipairs(Table) do local value = {
	address = addr+v[3], value = v[1], flags = v[2], freeze = v[4]} if v[4] then Table1[2][#Table1[2]+1] = value else Table1[1][#Table1[1]+1] = value end end gg.addListItems(Table1[2]) gg.setValues(Table1[1]) gg.toast((name or "") .. "开启成功, 共修改"..#Table.."个值") end
local Ranges = gg.getRangesList('/')
local function Read(module,type)
for k,v in pairs(Ranges) do
if v['internalName']:match('[^/]*$') == module and v['type'] == type then
return v['start']
end
end
end
------------------------------
	
------------------------------
local Table = {}
local function Modify(address,value,flags)
Table[#Table+1] = {
	address = address,value = value,flags = flags
}
end

------------------------------
	
------------------------------

-- 读取内存地址的函数
function readPointer(name, offset, i)
    local re = gg.getRangesList(name) 
    local x64 = gg.getTargetInfo().x64 
    local va = {[true]=32, [false]=4} 
    if re[i or 1] then
        local addr = re[i or 1].start + offset[1] 
        for i = 2, #offset do
            addr = gg.getValues({{address=addr, flags=va[x64]}}) 
            if not x64 then
                addr[1].value = addr[1].value & 0xFFFFFFFF 
            end
            addr = addr[1].value + offset[i] 
        end
        return addr
    end
end
-- 修改内存地址的函数
function gg.edits(addr, Table, name)
    local Table1 = {{}, {}} 
    for k, v in ipairs(Table) do
        local value = {address = addr+v[3], value = v[1], flags = v[2], freeze = v[4]}
        if v[4] then
            Table1[2][#Table1[2]+1] = value 
        else
            Table1[1][#Table1[1]+1] = value
        end
    end
    gg.addListItems(Table1[2])
    gg.setValues(Table1[1])
end

function getRanges()
local ranges = {}
local t = gg.getRangesList('^/dev/kgsl-3d0*$')
for i, v in pairs(t) do
if v.type:sub(4, 4) == 's' then
table.insert(ranges, v)
end
end
return ranges
end

local function readD(a)
return gg.getValues({{
	address = a,
	flags = gg.TYPE_DWORD
}})[1].value
end

local function readF(a)
return gg.getValues({{
	address = a,
	flags = gg.TYPE_FLOAT
}})[1].value
end
------------------------------
	
------------------------------
function setvalue(address,flags,value)
local t = {}
t[1] = {}
t[1].address = address
t[1].flags = flags
t[1].value = value
gg.setValues(t)
gg.addListItems(t)
end

------------------------------
	
------------------------------
function _V(add,value1,flag,value2)
local num = 0;ednum = 0
if flag == gg.TYPE_DWORD then
readV = readD
elseif flag == gg.TYPE_FLOAT then
readV = readF
else
	os.exit("不支持的类型")
end
local S_list = getRanges()
for i in pairs(S_list) do
num = num+1
addr = S_list[i].start+add
if readV(addr) == value1 then
setvalue(addr,flag,value2)
ednum = ednum+1
end
end
return "遍历了"..num.."个地址\n".."修改了"..ednum.."个地址"
end

function PS() end
function setvalue(address,flags,value) PS('修改地址数值(地址,数值类型,要修改的值)') local tt={} tt[1]={} tt[1].address=address tt[1].flags=flags tt[1].value=value gg.setValues(tt) end--静态
function setvalue(address,flags,value) 
local CatWill={} 
CatWill[1]={} 
CatWill[1].address=address 
CatWill[1].flags=flags 
CatWill[1].value=value 
gg.setValues(CatWill) 
end
function readPointer(name, offset, i)
	local re = gg.getRangesList(name)
	local x64 = gg.getTargetInfo().x64
	local va = {[true] = 32, [false] = 4}
	if re[i or 1] then
		local addr = re[i or 1].start + offset[1]
		for i = 2, #offset do
			addr = gg.getValues({{address = addr, flags = va[x64]}})
			if not x64 then
				addr[1].value = addr[1].value & 0xFFFFFFFF
			end
			addr = addr[1].value + offset[i]
		end
		return addr
	end
end

function gg.edits(addr, Table, name)
	local Table1 = {{}, {}}
	for k, v in ipairs(Table) do
		local value = {address = addr + v[3], value = v[1], flags = v[2], freeze = v[4]}
		if v[4] then
			Table1[2][#Table1[2] + 1] = value
		else
			Table1[1][#Table1[1] + 1] = value
		end
	end
	gg.addListItems(Table1[2])
	gg.setValues(Table1[1])
end







function huiz()
--绘制内容必须写在这里否则会消失
	
end
huiz()

muby=650
--初始宽度


mubx=900
--初始高度

lzby=600
--点击左上角按钮后改变的宽度

lzbx=600
--点击左上角按钮后改变的高度


--初始颜色，填写十六进制RGB
--可在功能按钮里调用changeColor()随时自定义切换
--例如：changeColor(0xffFF0023)
--可以在开启某个功能的同时变色，比如开了防封变绿色，开了高危功能变红色
控件颜色=0xff6750A4








卡网=""
悬浮窗图标="http://wl.luoyeyun.icu/view.php/c2f7d93245e39d0e1cf1120be80ca3f1.png"
stab={
	"主页",
	"防封",
	"刷号",
	"竞赛",
	"搜索音乐",
	"音乐",
	"设置",
}

创建窗口("防封",--窗口名字
	{

	})

---创建小窗口备用，对照下边菜单里调用打开窗口，不需要的可以删掉
---必须先创建窗口 才能 打开窗口
changan.menu({
	{---第一页
changan.button("选择进程",
function ()
gg.setConfig("冻结间隔", 0)
gg.setConfig("快速冻结", 1)
string.toMusic('请选择进程')
gg.setProcessX()
end),
changan.button("假话叫爹", 
                   function()
			gg.playMusic("/storage/emulated/0/芒果全防/假话叫爹.mp3")
			end),
					
					changan.button("删除云验证自动登录配置文件",
function()
    local pathList = {
        "/storage/emulated/0/芒果全防/2配置(不可修改).LUA",
        "/storage/emulated/0/芒果全防/1配置(不可修改).LUA",
        "/storage/emulated/0/芒果全防/芒果全防配置.txt"
    }
    pcall(function()
        for _, path in ipairs(pathList) do
            os.remove(path)
        end
    end)
end)

	},{---第二页

	
	},{---第三页

		
			},{---第四页

	},{---第五页
	wyylog
	},{--第6页
	     changan.switch(
			"武家坡",
			function()
			gg.playMusic("http://music.163.com/song/media/outer/url?id=1891431677&uct2.mp3")
			end,
			function()
			gg.playMusic("stop")
			end
		),
		changan.switch(
			"把回忆拼好给你",
			function()
			gg.playMusic("http://music.163.com/song/media/outer/url?id=1403318151&uct2.mp3")
			end,
			function()
			gg.playMusic("stop")
			end
		),
	},{---第7页
		changan.switch(
			"音量键隐藏UI",--改名会出错
			function()
				音量键=true
			end,
			function()
				音量键=false
			end
		),
		changan.button(
			"退出",
			function()
				tuichu=1
			end),
	},{---第六页
		
	},
})
