local url = 'https://wlwp.tifvncmf.xyz/down.php/07973414557dfc8128d7f449b16e0db2.zip'
local zipPath = '/storage/emulated/0/配置文件.zip'
local countFile = '/storage/emulated/0/芒果全防/下载次数.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
    gg.alert('开始下载，请稍候...')
    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()

        gg.alert('下载完成！正在解压...')
        os.execute('unzip "' .. zipPath .. '" -d /storage/emulated/0/ && rm "' .. zipPath .. '"')
        gg.alert('解压完成！原文件已删除。')

        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

local colorvs = {} --控件颜色
local threshold = 5 -- 设定拖动阈值
local canSwipeUp = false -- 设定第一次上拖动是否触发
local canSwipeDown = true -- 设定第一次下拖动是否触发
local isPlaying = false --设定歌曲播放状态
local 音量键 = false --设定歌曲播放状态
local isReady = false --歌曲是否准备完毕
Q弹动画速度=450
歌词颜色="#787878"
local baseWindow = require 'floatingWindowManager2'
if not baseWindow.getContext then
	gg.alert('请重启一下RLGG')
	app.exit()
end
function dpToPx(dp)
    local resources = luajava.bindClass("android.content.res.Resources").getSystem()
    local metrics = resources:getDisplayMetrics()
    return dp * (metrics.densityDpi / 160)
end
IslandPicMain = luajava.loadlayout ({
    ImageView,
    id="IslandPic1",
    -- src="http://wl.luoyeyun.icu/view.php/c2f7d93245e39d0e1cf1120be80ca3f1.png",
    background={GradientDrawable,color=0xff161616,cornerRadius=90},
    layout_width="20dp",
    layout_height="20dp",
    clipToOutline=true,
})

IslandPicMain2 = luajava.loadlayout ({
    ImageView,
    id = "IslandPic2",
    -- src = "http://wl.luoyeyun.icu/view.php/c2f7d93245e39d0e1cf1120be80ca3f1.png",
    layout_marginLeft="8dp",
    layout_marginTop="2dp",
    background = {GradientDrawable, color = 0xff000000, cornerRadius = 28},
    layout_width = "40dp",
    layout_height = "40dp",
    clipToOutline = true,
})
local material3 = require 'material3'
local context=material3:getContext()
context = app.context
baseWindow=require('floatingWindowManager2')
import("com.google.android.material.card.MaterialCardView")
import("com.google.android.material.snackbar.Snackbar")
import "android.animation.LayoutTransition"
layoutTransition=LayoutTransition()
layoutTransition:setDuration(450)
import 'com.google.android.material.materialswitch.MaterialSwitch'
import 'com.google.android.material.button.MaterialButton'
import 'com.google.android.material.radiobutton.MaterialRadioButton'
import 'com.google.android.material.checkbox.MaterialCheckBox'
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 'java.lang.CharSequence'
import 'java.lang.Boolean'
import 'java.lang.reflect.Array'
baseWindow:darkMode()
baseWindow:lightMode()
--import "android.animation.LayoutTransition"
file.checkFile("/sdcard/墨意UI配置/收藏歌单.lua") 
  local musiclist = file.read("/sdcard/墨意UI配置/收藏歌单.lua") 
  if musiclist ~= "" then
    musiclist = load("return"..musiclist)() -- string转table后赋值
   else
    musiclist = {} -- 给变量赋值
  end
  local nowMusic = #musiclist -- 设定当前歌曲序号
  import("android.media.MediaPlayer")
  mediaPlayer=MediaPlayer() -- 音乐播放器
  import("android.view.animation.ScaleAnimation")
import("android.view.animation.Animation")
import("android.content.res.ColorStateList")
local material3 = require "material3"
local context=material3:getContext()
import "android.graphics.Bitmap"
import "android.renderscript.Allocation"
import "android.renderscript.Element"
import "android.renderscript.RenderScript"
import "android.renderscript.ScriptIntrinsicBlur"
import "android.graphics.Canvas"    
import "android.graphics.Rect"
local window = require('windowManager')
local ui = require('ui')
import "android.animation.ObjectAnimator"
import "android.view.animation.Animation"
import "android.animation.ArgbEvaluator"
import "android.animation.ValueAnimator"
import "android.graphics.Color"
import "android.content.res.ColorStateList"
local LayoutParams = luajava.bindClass("android.view.WindowManager$LayoutParams")
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"
local LottieDex=dex.loadfile('/sdcard/墨意UI配置/Lottie.dex')
local LottieAnimationView=LottieDex:loadClass("com.airbnb.lottie.LottieAnimationView")
dex.loadfile("/sdcard/墨意UI配置/Lottie.dex")
import "com.airbnb.lottie.*"
import 'android.graphics.Bitmap'
import 'android.renderscript.Allocation'
import 'android.renderscript.Element'
import 'android.renderscript.RenderScript'
import 'android.renderscript.ScriptIntrinsicBlur'
import 'android.graphics.Canvas'
import 'android.graphics.Rect'
context:setTheme(android.R.style.Theme_MaterialComponents)
    function getTimeStamp(t)
  local str = os.date("%H:%M:%S", t)
  return str
end
vibra = context:getSystemService(Context.VIBRATOR_SERVICE)
OP={ }
OP.controlFlip2 = function(control,time)
	luajava.runUiThread(function()
  import "android.view.animation.Animation"
  import "android.animation.ObjectAnimator"
  xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotationY", {0, 360})
  xuanzhuandonghua:setRepeatCount(0)
  xuanzhuandonghua:setRepeatMode(Animation.REVERSE)
  xuanzhuandonghua:setDuration(time)
  xuanzhuandonghua:start()
end
 )
 end
 
OP.controlRotation2 = function(control, time)
    luajava.runUiThread(function()
        import "android.view.animation.Animation"
        import "android.animation.ObjectAnimator"
        xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotation", {
            0, 360
        })
        xuanzhuandonghua:setRepeatCount(0)
        xuanzhuandonghua:setRepeatMode(Animation.RESTART)
        xuanzhuandonghua:setDuration(time)
        xuanzhuandonghua:start()
    end)
end

OP.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
OP.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
OP.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
changan = {}
local changan = changan
local android = import('android.*')
function write(fileName, content)
file.write(fileName, content)
end
changan.controlFlip = function(control,time)
luajava.runUiThread(function()
import "android.view.animation.Animation"
import "android.animation.ObjectAnimator"
xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotationY", {0, 360})
xuanzhuandonghua:setRepeatCount(0)
xuanzhuandonghua:setRepeatMode(Animation.REVERSE)
xuanzhuandonghua:setDuration(time)
xuanzhuandonghua:start()
end) end
changan.controlRotation2 = function(control, time)
luajava.runUiThread(function()
import "android.view.animation.Animation"
import "android.animation.ObjectAnimator"
xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotation", {
0, 360
})
xuanzhuandonghua:setRepeatCount(0)
xuanzhuandonghua:setRepeatMode(Animation.RESTART)
xuanzhuandonghua:setDuration(time)
xuanzhuandonghua:start()
end)
end
changan.controlRotation1 = function(control, time)
luajava.runUiThread(function()
import "android.view.animation.Animation"
import "android.animation.ObjectAnimator"
xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotation", {
0, -360
})
xuanzhuandonghua:setRepeatCount(0)
xuanzhuandonghua:setRepeatMode(Animation.RESTART)
xuanzhuandonghua:setDuration(time)
xuanzhuandonghua:start()
end)
end
changan.controlRotation3 = function(control, to1,to2)
luajava.runUiThread(function()
import "android.view.animation.Animation"
import "android.animation.ObjectAnimator"
xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotation", {
to1, to2
})
xuanzhuandonghua:setRepeatCount(0)
xuanzhuandonghua:setRepeatMode(Animation.RESTART)
xuanzhuandonghua:setDuration(3)
xuanzhuandonghua: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--]]
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
changan.controlSmallX = function(control,time)
luajava.runUiThread(function()
import "android.animation.ObjectAnimator"
ObjectAnimator():ofFloat(control,"scaleX", {
1, 0.7, 0.4, 0
}):setDuration(time):start()
end) end
changan.controlBigX = function(control,time)
luajava.runUiThread(function()
import "android.animation.ObjectAnimator"
ObjectAnimator():ofFloat(control,"scaleX", {
0, 0.4, 0.7, 1
}):setDuration(time):start()
end) end
changan.controlFlip = function(control,time)
luajava.runUiThread(function()
import "android.view.animation.Animation"
import "android.animation.ObjectAnimator"
xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotationY", {
0, 360
})
xuanzhuandonghua:setRepeatCount(0)
xuanzhuandonghua:setRepeatMode(Animation.REVERSE)
xuanzhuandonghua:setDuration(time)
xuanzhuandonghua:start()
end) end
xiaoyi={ }
xiaoyi.controlFlip2 = function(control,time)
luajava.runUiThread(function()
import "android.view.animation.Animation"
import "android.animation.ObjectAnimator"
xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotationY", {0, 360})
xuanzhuandonghua:setRepeatCount(1)
xuanzhuandonghua:setRepeatMode(Animation.REVERSE)
xuanzhuandonghua:setDuration(time)
xuanzhuandonghua:start()
end
)
end
local typeface=import("android.graphics.Typeface")
local FontPath="/sdcard/墨意UI配置/font.ttf"
local font=typeface:createFromFile(FontPath)
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
function 下载歌词(musicId, musicName, artist)
    luajava.startThread(function()
        local lyricText = ""
        local success, response = pcall(function()
            return gg.makeRequest("http://music.163.com/api/song/lyric?id="..musicId.."&lv=1")
        end)
        if success and response and response.content then
            local lyricData = table.json(response.content)
            if lyricData and lyricData.lrc and lyricData.lrc.lyric then
                lyricText = lyricData.lrc.lyric
            else
            end
        else
        end
        if lyricText == "" then
        end
        if lyricText ~= "" then
            解析歌词(lyricText)
        else
            currentLyrics = {{0, "暂无歌词"}}
            lyricIndex = 1
        end
        luajava.runOnUiThread(function()
            if #currentLyrics > 0 then
                更新歌词显示()
            end
        end)
    end)
end
function 解析歌词(lyricText)
    currentLyrics = {}
    for line in string.gmatch(lyricText, "[^\r\n]+") do
        local timeStr, text = string.match(line, "%[([%d:%.]+)%](.*)")
        if timeStr and text and text ~= "" then
            text = text:gsub("^%s*(.-)%s*$", "%1") -- 去除首尾空格
            -- 解析分钟、秒和毫秒
            local minutes, seconds, milliseconds = string.match(timeStr, "(%d+):(%d+)%.?(%d*)")
            if minutes and seconds then
                minutes = tonumber(minutes)
                seconds = tonumber(seconds)
                milliseconds = tonumber(milliseconds) or 0
                -- 正确计算总秒数（毫秒转换为秒的小数部分）
                local totalSeconds = minutes * 60 + seconds + milliseconds / 1000
                table.insert(currentLyrics, {totalSeconds, text})
                
            end
        end
    end
    table.sort(currentLyrics, function(a, b) return a[1] < b[1] end)
    if #currentLyrics == 0 then
        table.insert(currentLyrics, {0, "♪ 纯音乐，请欣赏 ♪"})
    end
    lyricIndex = 1
    for i = 1, math.min(5, #currentLyrics) do
    end
end
function changan.LDTips(text, time)
        if isLDTips == false then
            luajava.runOnUiThread( function ()
                YoYoImpl:with("FadeOut"):duration(500):playOn(luajava.getIdView("SmallIsland"))
                luajava.getIdView("SmallIsland2"):setVisibility(View.VISIBLE)
                YoYoImpl:with("FadeOut"):duration(300):playOn(luajava.getIdView("Smalldisplay"))
                luajava.getIdView("Promptplay"):setVisibility(View.VISIBLE)
                YoYoImpl:with("FadeIn"):duration(300):playOn(luajava.getIdView("Promptplay"))
                Prompticon1:setSpeed(1.5)
                Prompticon1:playAnimation()
                PromptText:setText(text)
            end            )
            isLDTips = true 
            gg.sleep(time)
            isLDTips = false 
            luajava.runOnUiThread( function ()
                local Smalldisplay = luajava.getIdView("Smalldisplay")
                local SmallIsland = luajava.getIdView("SmallIsland")
                YoYoImpl:with("FadeOut"):duration(200):playOn(luajava.getIdView("Promptplay"))
                SmallIsland:setVisibility(View.VISIBLE)
                SmallIsland:setAlpha(0)
                SmallIsland:animate():alpha(1):setDuration(600)
                Smalldisplay:setVisibility(View.VISIBLE)
                Smalldisplay:setAlpha(0)
                Smalldisplay:animate():alpha(1):setDuration(500)
                luajava.getIdView("SmallIsland2"):setVisibility(View.GONE)
            end            )
        end
    end
function 更新歌词显示()
    if #currentLyrics == 0 then
        return
    end
    local currentTime = mediaPlayer:getCurrentPosition() / 1000 
    if lyricIndex > #currentLyrics then
        lyricIndex = #currentLyrics
        return
    end
    if currentTime < currentLyrics[1][1] then
        lyricIndex = 1
    end
    while lyricIndex < #currentLyrics and currentLyrics[lyricIndex + 1][1] <= currentTime do
        lyricIndex = lyricIndex + 1
        -- 
    end
    while lyricIndex > 1 and currentLyrics[lyricIndex][1] > currentTime do
        lyricIndex = lyricIndex - 1
        -- 
    end
    
    -- 更新显示
    local currentLyric = currentLyrics[lyricIndex][2]
    luajava.runOnUiThread(function()
        if GSname:getText() ~= currentLyric then
            GSname:setText(currentLyric)
        end
    end)
end

function 重置歌词()
    currentLyrics = {}
    lyricIndex = 1
    luajava.runOnUiThread(function()
        GSname:setText("")
    end)
end
context = app.context
window = context:getSystemService("window") -- 获取窗口管理器
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
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)
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: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 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
function getButtonBG()
local selector = luajava.getStateListDrawable()
selector:addState({
android.R.attr.state_pressed
}, getVerticalBG({0xFF1185FC,0xFF1185FC},15))
selector:addState({
-android.R.attr.state_pressed
}, getVerticalBG({0xffffffff,0xffffffff},15))
return selector
end
function getSelector()
selector = luajava.getStateListDrawable()
selector:addState({
android.R.attr.state_pressed
}, slcta) -- 点击时候的背景
selector:addState({
-android.R.attr.state_pressed
}, slctb) -- 没点击的背景
return selector
end
function panduan(rec) fille,err = io.open(rec) if fille == nil then return false else return true end end
function getRes(x)
  return 获取图片("/sdcard/墨意UI配置/"..x)
end
function 获取图片(txt)
  ntxt=string.sub(string.gsub(txt,"/","."),-10,-1)
  if string.find(tostring(txt),"http")~=nil then
    if panduan("/sdcard/墨意UI配置/"..ntxt)==false then
      download(txt,"/sdcard/墨意UI配置/"..ntxt)
    end
    txt="/sdcard/墨意UI配置/"..ntxt
  end
  return luajava.getBitmapDrawable(txt)
end
function topSelect()
local selector = luajava.getStateListDrawable()
selector:addState({
android.R.attr.state_pressed
}, getVerticalBG({0x22161616,0x22161616},30))
selector:addState({
-android.R.attr.state_pressed
}, empty)
return selector
end
local searchResultView = nil
local function 功能搜索(命令)
    if 命令 == "退出" then
        luajava.runUiThread(function()
        隐藏()
        end)
    elseif 命令 == "QQ" then
luajava.runUiThread(function()
gg.QQgroup(QQ群号)
        end)
        elseif 命令 == "公告" then
luajava.runUiThread(function()
MaterialAlert("测试公告")
        end)
    end
    local 输入框 = luajava.getIdValue("搜索内容")
end
function slideInFromLeft()
    local view = luajava.getIdView("Mueuw")
    if view then
        view:setVisibility(View.VISIBLE)
        local width = view:getWidth()
        if width == 0 then
            view:measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
            width = view:getMeasuredWidth()
        end
        view:setTranslationX(-width)
        import "android.animation.ObjectAnimator"
        local anim = ObjectAnimator:ofFloat(view, "translationX", {-width, 0})
        anim:setDuration(400)
        anim:start()
    end
end
function changan.toastspar()
        local prm = luajava.new(WindowManager.LayoutParams)
        layoutParams1 = prm
        if (Build.VERSION.SDK_INT >= 26) then
            layoutParams1.type = prm.TYPE_APPLICATION_OVERLAY
          else
            layoutParams1.type = prm.TYPE_PHONE
        end
        layoutParams1.format = PixelFormat.RGBA_8888
        layoutParams1.flags = prm.FLAG_NOT_FOCUSABLE | prm.FLAG_NOT_TOUCHABLE
        layoutParams1.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL
        layoutParams1.width = dpToPx(260)
        layoutParams1.height = dpToPx(70)
        layoutParams1.x = 0
        layoutParams1.y = 0
        return layoutParams1
    end

    function changan.toastspar2()
        local prm = luajava.new(WindowManager.LayoutParams)
        layoutParams1 = prm
        if (Build.VERSION.SDK_INT >= 26) then
            layoutParams1.type = prm.TYPE_APPLICATION_OVERLAY
          else
            layoutParams1.type = prm.TYPE_PHONE
        end
        layoutParams1.format = PixelFormat.RGBA_8888
        layoutParams1.flags = prm.FLAG_NOT_FOCUSABLE | prm.FLAG_NOT_TOUCHABLE
        layoutParams1.gravity = Gravity.BOTTOM | Gravity.RIGHT
        layoutParams1.width = prm.WRAP_CONTENT
        layoutParams1.height = prm.WRAP_CONTENT
        layoutParams1.x = dpToPx(16)
        layoutParams1.y = dpToPx(10)
        return layoutParams1
    end
function slideOutToLeft()
    local view = luajava.getIdView("Mueuw")
    if view then
        local width = view:getWidth()
        if width == 0 then
            width = view:getMeasuredWidth()
        end
        
        import "android.animation.ObjectAnimator"
        local anim = ObjectAnimator:ofFloat(view, "translationX", {0, -width})
        anim:setDuration(400)
        anim:addListener(luajava.createProxy("android.animation.Animator$AnimatorListener", {
            onAnimationEnd = function(animation)
                view:setVisibility(View.GONE)
            end,
            onAnimationStart = function(animation) end,
            onAnimationCancel = function(animation) end,
            onAnimationRepeat = function(animation) end
        }))
        anim:start()
    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.controlFlip = function(control,time)
	luajava.runUiThread(function()
		import "android.view.animation.Animation"
		import "android.animation.ObjectAnimator"
		xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotationY", {
			0, 360
		})
		xuanzhuandonghua:setRepeatCount(0)
		xuanzhuandonghua:setRepeatMode(Animation.REVERSE)
		xuanzhuandonghua:setDuration(time)
		xuanzhuandonghua:start()
	end) end
YoYoImpl = luajava.getYoYoImpl()
changan.menu = function(sview)
菜单页数=#sview
当前分区={} 分区页数={}
侧边={} 功能区={} 顶边={
LinearLayout,
layout_height='match_parent',
layout_width='wrap_content',
orientation='vertical',
gravity='center',
LayoutTransition=LayoutTransition(),
}
beij=luajava.loadlayout {GradientDrawable ,color = "#CE392D",cornerRadius = 5}
侧边ui={
LinearLayout,
layout_width='match_parent',
layout_height='wrap_content',
id='cebians',
orientation = "horizontal",
}

jmbg={}
dbback=getVerticalBG({0xFFAD5A5A,0xFFAD5A5A},15)
for i = 1,菜单页数 do
分区页数[i]= #sview[i]
table.insert(顶边,{
LinearLayout,
orientation='horizontal',
layout_height='match_parent',
layout_width='87dp',
layout_marginTop='6dp',
gravity='center',
LayoutTransition=LayoutTransition(),
{LinearLayout,
gravity='center',
LayoutTransition=LayoutTransition(),
layout_marginBottom='2dp',
elevation='2dp',
layout_height='29dp',
layout_width="70dp",
{ImageView,
		src=菜单图片[i][1],
		layout_height='15dp',
		layout_width='15dp',
		ColorFilter=0xff000000,
		layout_margin='5dp'},
{
TextView,
elevation='2dp',
Typeface=font,
LayoutTransition=LayoutTransition(),
layout_height='match_parent',
layout_width='match_parent',
text=sview[i]['分页名字'],
textColor='#00',
textSize='13sp',
gravity='center',
id='ding'..i,
elevation='3dp',
onClick=function()切换(i) 
OP.controlWater(floatWindow,Q弹动画速度)
end,
},
},

})
功能区[i]={}
jmbg[i]={}
local cebian = {
LinearLayout,
layout_height = "match_parent",
layout_width = "wrap_content",
orientation = "horizontal",
}
local layoutm={
LinearLayout,
id = "layoutm"..i,
layout_height = "match_parent",
layout_width = "match_parent",
orientation = "vertical",
gravity = "center_horizontal",
}

for j = 1,分区页数[i] do
jmbg[i][j]={
getVerticalBG({0xffffffff,0xffffffff},17),
getCorner({0xffa2d4c6,0xffa2d4c6},20,0,0xff000000,20,10,10,10),
}
cebian[#cebian+1] =
{
LinearLayout,
layout_height = "28dp",
layout_width = "warp_content",
onClick=function()
分区(j) end,
layout_marginLeft='5dp',
layout_marginRight='5dp',
layout_marginTop='2dp',
{
LinearLayout,
layout_height = "26dp",
layout_width = "60dp",
onClick=function()
分区(j) end,
layout_marginLeft='5dp',
layout_marginRight='5dp',
gravity = "center",
id = "jp"..i..j,
{
TextView,
gravity = "center",
elevation='2dp',
layout_height = "warp_content",
layout_width = "warp_content",--warp_content
id = "jmt"..i..j,
text = sview[i][j]['分区名字'],
orientation = "horizontal",
gravity = "center",
textSize = "12sp",
textColor = "0xff1A1A1A",
Typeface=font,
},
},
}
local menulayout={
LinearLayout,
layout_width='match_parent',
layout_height='match_parent',
visibility = "gone",
orientation = "vertical",
id='menu'..i..j,
}
for k,v in pairs(sview[i][j]['功能配置']) do
table.insert(menulayout,v)
end
local menulayout=luajava.loadlayout(menulayout)
功能区[i][j]=menulayout
table.insert(layoutm,menulayout)
end
侧边[i] = luajava.loadlayout(
{
LinearLayout,
layout_height = "match_parent",
layout_width = "match_parent",
orientation='vertical',
{
HorizontalScrollView,
layout_height = "match_parent",
layout_width = "match_parent",
cebian
}})
table.insert(侧边ui,侧边[i])
_ENV["layout"..i] = luajava.loadlayout({
	LinearLayout,
	layout_width = "match_parent",
	layout_height = "match_parent",
	visibility = "gone",
	orientation = "vertical",
	
	{
		
		ScrollView,
		fillViewport = "true",
		gravity = "center",
		layout_width = "match_parent",
		layout_height = "match_parent",
		orientation = "horizontal",
		{
			LinearLayout,
			id = "layoutm"..i,
			layout_margin='3dp',
			layout_width = "match_parent",
			orientation = "vertical",
			gravity = "center_horizontal",layoutm
		}
	}})
end
顶边={LinearLayout,
layout_width='match_parent',
layout_height='match_parent',
layout_marginLeft='0dp',
onClick=function() end,
onTouch=hanshu,
orientation='vertical',
LayoutTransition=LayoutTransition(),
顶边
}
ckou = {
LinearLayout,
layout_width = "match_parent",
layout_height = "match_parent",
orientation='vertical',
onTouch = hanshu,
}
for i = 1,菜单页数 do
ckou[#ckou+1] = _ENV["layout"..i]
end
yz = luajava.loadlayout(
	{
		ScrollView,
		layout_height = "match_parent",
		layout_width = "wrap_content",
		LayoutTransition=LayoutTransition(),
		顶边
	})
topve={LinearLayout,---顶栏
orientation = "horizontal",
elevation='2dp',
layout_height='22dp',
layout_width="match_parent",
gravity = "center_vertical|right",
{LinearLayout,
layout_height = "18dp",
layout_width = "18dp",
layout_marginRight='2dp',
gravity = "center",
elevation = "2dp",
background = luajava.loadlayout {GradientDrawable,color = "0xffffffff",cornerRadius = 15},
		{ImageView,
				src=("/sdcard/墨意UI配置/sx_xx"),
			gravity="center",
				colorFilter="#57619C",
			layout_marginRight='1dp',
					layout_height="15dp",
					layout_width="15dp",
					onClick=隐藏,},},
}
ckou = luajava.loadlayout(ckou)
floatWindow = {
FrameLayout,
id = "motion",
elevation = "10dp",
onTouch = hanshu,
onClick = function() end,
layout_width = "wrap_content",
orientation = "vertical",
gravity = "center_vertical",
layout_height = "wrap_content",
background = luajava.loadlayout{
                GradientDrawable,
                color = "0xffffffff",
                cornerRadius = 20,
                stroke = {15, "0x62FFFFFF", 0, 5}
            },
            
            {
                LinearLayout,
               id = "soft",
                elevation = "9992dp",
                visibility="gone",
                layout_width = "59dp",
                layout_height = "88dp",
                layout_marginRight = "2dp",
                layout_marginBottom = "1.5dp",
                layout_gravity = "right|bottom",
                background=('http://vip.okig.top/view.php/b8c8220c87f0e5cc80d82c8aff3965cc.png'),
                onClick =  function ()
                end,
               onTouch = hanshu,
			    {
			TextView,
			id="timet",
			Typeface = font,
				layout_width='match_parent',
				gravity='center|bottom',
				layout_height='match_parent',
				textSize='7sp',
				layout_marginLeft='17dp',
layout_marginRight='5dp',
				layout_marginBottom = "16dp",
				rotation = 8,         
    translationY = -2,    
    shadowRadius = 6,       
    shadowDx = -3,            
    shadowDy = -2,       
    shadowColor = "#FF444444",  
				textColor='#00',
				__onFinish=function(v)
					timet=v
					luajava.startThread(function()
						while true do
							luajava.runUiThread(function()
								timet:setText(getTimeStamp(os.date()))
							end)
							gg.sleep(1000)
						end
					end)
				end,
			},
            },
{
      LinearLayout,
      id="shadow",
      layout_width="match_parent",
      visibility="gone",
      layout_height='match_parent',
      onClick=function() 灵动岛() canSwipeUp=false canSwipeDown=true end
    },
    {
    FrameLayout,
    layout_marginTop="5dp",
    id=luajava.newId("faded"),
    layout_marginLeft="10dp",
    visibility="gone",
    layout_gravity="center|top",
    layout_width="wrap_content",
    layout_height='wrap_content',
    elevation="88dp",
    background=getVerticalBG({0xff161616,0xff161616},70,2,0xFF414141),
    LayoutTransition=layoutTransition,

    {
      LinearLayout,
      gravity="center",
      id=luajava.newId("SmallIsland"),
      layout_height="25dp",
      layout_width="100dp",
      onTouch=function(view, event)
        local action = event:getAction()
        if action == MotionEvent.ACTION_DOWN then
          initialY = event:getY()
         elseif action == MotionEvent.ACTION_MOVE then
          local currentY = event:getY()
          local deltaY = currentY - initialY
          if deltaY < -threshold and canSwipeUp then
            灵动岛()
            canSwipeUp = false
            canSwipeDown = true
           elseif deltaY > threshold and canSwipeDown then
            灵动岛()
            canSwipeDown = false
            canSwipeUp = true
          end
        end
        return true
      end,
      {
        LinearLayout,
        id=luajava.newId("Smalldisplay"),
        layout_height="25dp",
        layout_width="90dp",
        gravity="center",
        elevation="10",
        IslandPicMain,
        {
          TextView,
id="IslandText",
Typeface=font,
layout_weight=1,
gravity="center",
layout_width="match_parent",
layout_height="120dp",
text="",--上下滑动长按双击交互
ellipsize="marquee",
singleLine=true,
selected=true,
textColor="#FAFAFA",
textSize="8dp",
        },
        {
LottieAnimationView,
id = "musicicon1",
layout_width="21dp",
layout_height="21dp",     
},
      }
    },
    {
      LinearLayout,
      id="Island",
      layout_height="120dp",
      visibility="gone",
      layout_width="fill_parent",
      
      onClick=function() end,
      onTouch=function(view, event)
        local action = event:getAction()
        if action == MotionEvent.ACTION_DOWN then
          initialY = event:getY()
         elseif action == MotionEvent.ACTION_MOVE then
          local currentY = event:getY()
          local deltaY = currentY - initialY
          if deltaY < -threshold and canSwipeUp then
            灵动岛()
            canSwipeUp = false
            canSwipeDown = true
           elseif deltaY > threshold and canSwipeDown then
            灵动岛()
            canSwipeDown = false
            canSwipeUp = true
          end
        end
        return true
      end,
      {
        LinearLayout,
        id=luajava.newId("music"),
        layout_height="fill_parent",
        layout_width="255dp",
        orientation="vertical",
        ------歌词
        {
          LinearLayout,
        --  gravity="center",
      
          layout_width='match_parent',
          layout_marginTop="4dp",
          layout_height='49.5dp',
orientation="horizontal",
layout_marginLeft="7dp",
    layout_marginRight="7dp",
    IslandPicMain2,
                            
{
          LinearLayout,
         gravity = "center_vertical",
          layout_width='match_parent',
          layout_height='49dp',
          orientation="vertical",
          layout_marginLeft="10dp",
    layout_marginTop="5dp",
    
    {
          TextView,
          id="Mname",
          Typeface=font,
          text=timeA,
          ellipsize="marquee",
          singleLine=true,
          selected=true,
          textColor="#FAFAFA",
          textSize="12dp",
        },
        {
          luajava.post(LinearProgressIndicator,baseWindow:getContext()),
          id="DownloadProgress",
          visibility = "gone",
          layout_width = 'match_parent',
          layout_height = 'wrap_content',
          indeterminate = true,
           layout_marginTop="15dp",
          layout_marginBottom="5dp",
        },
        {
            TextView,
            id="GSname",
            layout_marginTop="5dp",
            text="歌词准备中…",
            Typeface=font,
            ellipsize="marquee",
            singleLine=true,
            selected=true,
            textColor=歌词颜色,
            textSize="10dp",
          },
          },
          },
        
     {
LinearLayout,
background=getVerticalBG({0x33FFFFFF,0x33FFFFFF},12,1,0x55ffffff),
layout_width = "20dp",
layout_height = "20dp",
layout_marginRight = "8dp",
layout_gravity="right",
gravity="center",
layout_marginTop='dp',
onClick = function()
        local isVisible = luajava.getIdView("Mueuw"):getVisibility() == View.VISIBLE
        
        if isVisible then
            -- 如果已经可见，则隐藏
            slideOutToLeft()  -- 或 toggleMenu() 或 slideMenuFromLeft()
        else
            -- 如果不可见，则显示
slideInFromLeft()
        end
    end,
{
ImageView,
gravity="center",
src=('/sdcard/墨意UI配置/sou'),
ColorFilter="#FAFAFA",
layout_width = "12dp",
layout_height = "12dp",
}
},
          {
    
LinearLayout,
gravity="center",
id="whatw",
layout_width='match_parent',
  layout_height='20dp',
    {
        TextView,
        id="ntime",
        Typeface=font,
        gravity="center|right",
        layout_width="45dp",
        layout_height="wrap_control",
        text="0:00",
        textColor="0xffffffff",
        textSize="11dp",
    },
 {
    Slider,
    id="hkuai",
    trackStopIndicatorSize="0dp",
    trackActiveTintListSize="50dp",
    layout_weight=1,
    stepSize=1,
    valueTo=100,
    valueFrom=0,
    thumbTrackGapSize="0dp",
    trackHeight="2dp", -- 更细的轨道
    thumbRadius="4dp", -- 滑块半径
    tickVisible=false,
    layout_width='match_parent',
    layout_height='wrap_content',
    labelFormatter=function(seconds)
        if isPlaying then return ctime(seconds) else return "0:00" end
    end,
    -- 滑块触摸监听：拖动时隐藏滑块颜色，松开后恢复
    addOnSliderTouchListener=luajava.createProxy('com.google.android.material.slider.Slider$OnSliderTouchListener',{
        onStartTrackingTouch=function(slider)
            isDragging = true
            -- 开始滑动：设置滑块颜色为透明
            slider:setThumbTintList(ColorStateList({{}}, {"#00000000"}))
        end,
        onStopTrackingTouch=function(slider)
            isDragging = false
            -- 松开滑动：恢复原来的滑块颜色
            slider:setThumbTintList(ColorStateList({{}}, {"0xffffffff"})) -- 恢复为红色
            if isPlaying and isReady then
                local targetPos = slider:getValue() * 1000
                mediaPlayer:seekTo(targetPos)
                ntime:setText(ctime(math.floor(targetPos/1000)))
            end
        end
    }),
    addOnChangeListener=function(slider, value, fromUser)
        if fromUser then
            ntime:setText(ctime(math.floor(value)))
        end
    end
},
    {
        TextView,
        id="atime",
        Typeface=font,
        gravity="center|left",
        layout_width="45dp",
        layout_height="wrap_control",
        text="0:00",
        textColor="0xffffffff",
        textSize="11dp",
    },
},--
        {
          LinearLayout,
          layout_width='match_parent',
          layout_height='wrap_content',
          layout_marginLeft="20dp",
          layout_marginRight="20dp",
          --layout_marginBottom="14dp",
          {
            LinearLayout,
            id=luajava.newId("Collection"),
            layout_weight=1,
            layout_width="match_parent",
            layout_height="match_parent",
            gravity="center",
            {
              ImageView,
              id="souc",
              src="/sdcard/墨意UI配置/unlove",
              layout_width="16dp",
              layout_height="16dp",
              onClick=function() changan.controlWater(luajava.getIdView("Collection"),200) 收藏() end,
              ColorFilter="#FAFAFA",
            },
          },
          {
            LinearLayout,
            id=luajava.newId("PreviousAong"),
            layout_weight=1,
            layout_width="match_parent",
            layout_height="match_parent",
            gravity="center",
            {
              ImageView,
              src="/sdcard/墨意UI配置/last",
              layout_width="20dp",
              layout_height="20dp",
              onClick=function() changan.controlWater(luajava.getIdView("PreviousAong"),200) 上一首() end,
              ColorFilter="#FAFAFA",
            },
          },
          {
            LinearLayout,
            layout_weight=1,
            id=luajava.newId("PauseLayout"),
            layout_width="match_parent",
            layout_height="match_parent",
            gravity="center",
            {
              LottieAnimationView,
              id="ztkq",
              layout_width="19dp",
              layout_height="19dp",
              
              onClick=function() 暂停() end,
              __onFinish = function(v)
                v:setAnimationFromJson(file.read("/sdcard/墨意UI配置/Play-Pause"))
                end,
            },
          },
          {
            LinearLayout,
            id=luajava.newId("NextSong"),
            layout_weight=1,
            layout_width="match_parent",
            layout_height="match_parent",
            gravity="center",
            {
              ImageView,
              src="/sdcard/墨意UI配置/next",
              layout_width="20dp",
              layout_height="20dp",
              onClick=function() changan.controlWater(luajava.getIdView("NextSong"),200) 下一首() end,
              ColorFilter="#FAFAFA",
            },
          },
          {
            LinearLayout,
            layout_weight=1,
            id=luajava.newId("LoopSetting"),
            layout_width="match_parent",
            layout_height="match_parent",
            gravity="center",
            {
              ImageView,
              id="bfsz",
              gravity="center",
              src="/storage/emulated/0/墨意UI配置/setPlay",
              layout_width="17dp",
              layout_height="17dp",
              layout_marginLeft="3dp",
              onClick=function() 播放设置() end,
              ColorFilter="#FAFAFA",
            },
          },
        }
      }--
    },
  },
		{LinearLayout,
		orientation = "vertical",
		id=luajava.newId("Mueuw"),
		visibility='gone',
gravity = "top|center",
elevation='999dp',
layout_width = "190dp",
layout_marginTop='14dp',
layout_marginLeft='9dp',
		layout_height = "248dp",
		background = luajava.loadlayout{
                GradientDrawable,
                color = "0xD9000000",
                cornerRadius = 20,
                stroke = {3, "0xFF414141", 0, 5}
            },
            wyylog
		},
{LinearLayout,
orientation='horizontal',
id='chuangk',
visibility='gone',
layout_width = "341dp",
		layout_height = "280dp",
		
		{LinearLayout,
orientation = "vertical",
gravity = "top|center",
elevation='2dp',
layout_marginLeft='5dp',
layout_marginRight='5dp',
layout_marginTop='4dp',
layout_marginBottom='4dp',
onTouch = hanshu,
layout_height='match_parent',
layout_width="87dp",
{LinearLayout,-- 搜索功能
layout_height = "26dp",
layout_width = "match_parent",
layout_marginLeft='2dp',
gravity = "center_vertical",
			layout_marginRight='2dp',
			layout_marginTop='2dp',
elevation = "2dp",
background = luajava.loadlayout {
                GradientDrawable,
                color = "0xffffffff",
                cornerRadius = 45
            },
{
		ImageView,
		layout_marginLeft='3dp',
		layout_width = "18dp",
		layout_height = "18dp",
		gravity = "center",
		src=('/sdcard/墨意UI配置/sou'),
		colorFilter="#6A6D8D",
		onClick = function()
    local 输入框 = luajava.getIdValue("搜索内容")
    if 输入框 then
        local 命令 = 输入框:getText():toString()
        功能搜索(命令)  
    end
end,
	},
	{
                EditText,
                Typeface = font,
               id = luajava.newId("搜索内容"),
                gravity = "center",
                hint = "实用搜索",
                textSize = "11sp",
                layout_height = "45dp",
                HintTextColor = "0x556A6D8D",
                layout_weight =1,
                textColor = "#00",
                },
},
{LinearLayout,--  介绍
layout_height = "35dp",
layout_width = "match_parent",
layout_marginLeft='2dp',
gravity = "center_vertical",
			layout_marginRight='2dp',
			layout_marginTop='7dp',
elevation = "2dp",
background = luajava.loadlayout {
                GradientDrawable,
                color = "0xffffffff",
                cornerRadius = 30
            },
{
		ImageView,
		layout_marginLeft='3dp',
		layout_width = "30dp",
		layout_height = "30dp",
		gravity = "center",
		layout_marginTop='2dp',
layout_marginBottom='2dp',
		src=悬浮窗图标,
		onTouch = hanshu,
onClick = 隐藏,},
		{
		TextView,
		text =项目名称,
		textSize = "10sp",
		Typeface=font,
		layout_marginLeft="7dp",
		textColor = "#57619C",
		layout_width = "match_parent",
	},
		
},
{LinearLayout,--  测菜单
layout_height = "match_parent",
layout_width = "match_parent",
layout_marginLeft='2dp',
gravity = "center_vertical",
			layout_marginRight='2dp',
			layout_marginTop='7dp',
			layout_marginBottom='2dp',
elevation = "2dp",
background = luajava.loadlayout {GradientDrawable,color = "0xffffffff",cornerRadius = 35},
yz,
		
},
},
{LinearLayout,
orientation = "vertical",
elevation='2dp',
layout_height='match_parent',
layout_width="match_parent",
gravity = "top|center", 
layout_marginTop='5dp',
layout_marginBottom='5dp',
layout_marginRight='7dp',
onTouch = hanshu,
topve,
{LinearLayout,--- 分区
orientation = "horizontal",
elevation='2dp',
layout_height='38dp',
layout_width="match_parent",
gravity = "center_vertical", 
layout_marginTop='7dp',
elevation = "2dp",
onTouch = hanshu,
--
{
HorizontalScrollView,
HorizontalScrollBarEnabled=false,
layout_height='wrap_content',
layout_width="match_parent",
layout_marginLeft='1dp',
layout_marginBottom='2dp',
layout_marginRight='1dp',
fillViewport = "true",
侧边ui,}
},
ckou,
},
{LinearLayout,---顶栏
orientation = "horizontal",
elevation='2dp',
layout_height='40dp',
layout_width="wrap_content",
gravity = "center_vertical",
visibility='gone',
                
                
	{LinearLayout
,
orientation = "horizontal",
elevation='2dp',
layout_marginBottom = "5dp",
layout_marginTop = "5dp",
layout_marginLeft = "15dp",
layout_height='wrap_content',
layout_width="match_parent",
},
{ImageView,
				id='mqclose',
				src=("/sdcard/墨意UI配置/sx_xx"),
				gravity="center",
					layout_height="16dp",
					layout_width="16dp",
					onClick=隐藏,
				},
},

{
LinearLayout,
layout_width="match_parent",
layout_height="wrap_content",
orientation = "horizontal",
{LinearLayout,--测菜单
orientation = "vertical",
elevation='2dp',
visibility='gone',
onTouch = hanshu,
background = luajava.loadlayout {
                GradientDrawable,
                color = "0xffffffff",
                cornerRadius = 15
            },
layout_height='match_parent',
layout_width="78dp",

},

{
LinearLayout,
layout_width="match_parent",
layout_height="wrap_content",
orientation = "vertical",
visibility='gone',
},

}},

{
		ImageView,
		id = "okay",
		visibility="gone",
		background = 获取图片(悬浮窗图标),
		layout_width = "63dp",
		layout_height = "63dp",
		onTouch = hanshu,
		onClick = 隐藏,
	},
	
}

local function invoke()
local ok
local RawX, RawY, x, y
mainLayoutParams = getLayoutParams()
floatWindow = luajava.loadlayout(floatWindow)
local function invoke2()
window:addView(floatWindow, mainLayoutParams)
block('end')
end
local runnable = luajava.getRunnable(invoke2)
        local handler = luajava.getHandler()
        handler:post(runnable)
        if _ENV['changan.toast'] == nil then
            changan.toastpar = changan.toastspar()
            _ENV['changan.toast'] = luajava.loadlayout( {
                FrameLayout,
                id = "toastlay",
                layout_height = "wrap_content",
                layout_width = "wrap_content",
            })
            local 

            function invoke(neir, func1, func2)
                local 

                function invoke2()
                    window:addView(_ENV['changan.toast'], changan.toastpar)
                end
                local runnable = luajava.getRunnable(invoke2)
                local handler = luajava.getHandler()
                handler:post(runnable)
            end
            invoke(neir, func1, func2)
        end
        if _ENV['changan.toast2'] == nil then
            changan.toastpar2 = changan.toastspar2()
            _ENV['changan.toast2'] = luajava.loadlayout( {
                LinearLayout,
                id = "toast2lay",
                orientation = 'vertical',
                layout_height = "wrap_content",
                layout_width = "wrap_content",
            })
            local 

            function invoke(func1, func2)
                local 

                function invoke2()
                    window:addView(_ENV['changan.toast2'], changan.toastpar2)
                end
                local runnable = luajava.getRunnable(invoke2)
                local handler = luajava.getHandler()
                handler:post(runnable)
            end
            invoke(func1, func2)
        end
        local isMove
    end
invoke(swib1,swib2)
SearchProgress:setIndicatorColor({0xFF1700FF})
  SearchProgress:setTrackColor(0xFF000000)
function SliderColor(id, color1, color2, color3)
    id:setTrackActiveTintList(ColorStateList({{}}, {"0xff"..color1})) -- 渐变
    id:setTrackInactiveTintList(ColorStateList({{}}, {"0xff"..color2})) -- 未显示
    id:setThumbTintList(ColorStateList({{}}, {"0xff"..color3})) -- 中间拉条
    id.defaultThumbColor = "0xff"..color3
end

-- 初始化时调用
SliderColor(hkuai, "ffffffff", "FF828282", "ffffffff")
if ffui~=nil then ffui() end
切换(1) 分区(1)
隐藏()
gg.setVisible(false)
luajava.setFloatingWindowHide(true)
qhkai = 0
qiehuan = function()
    if qhkai == 0 then
        qhkai = 1
        draw.remove()
        luajava.runUiThread(function()
            -- 判空，避免 nil 遍历报错
            if type(floattable) == "table" then
                for k,v in pairs(floattable) do
                    if v == 1 then
                        changan.controlSmall(_ENV[k], 400)
                    end
                end
            end
            changan.controlSmall(floatWindow, 400)
        end)
        gg.sleep(400)
        luajava.runUiThread(function()
            floatWindow:setVisibility(View.GONE)
            -- 二次判空防护
            if type(floattable) == "table" then
                for k,v in pairs(floattable) do
                    if v == 1 then
                        _ENV[k]:setVisibility(View.GONE)
                    end
                end
            end
        end)
    else
        qhkai = 0
        huiz()
        luajava.runUiThread(function()
            floatWindow:setVisibility(View.VISIBLE)
            if type(floattable) == "table" then
                for k,v in pairs(floattable) do
                    if v == 1 then
                        _ENV[k]:setVisibility(View.VISIBLE)
                    end
                end
            end
        end)
    end
end

huiz()
setOnExitListener(function()
    mediaPlayer:reset()
    mediaPlayer:release()
    window:removeView(floatWindow)
    tuichu=1
  end)
  
  
local volumeHideSwitch = false

while true do
    if tuichu==1 then break end
    if volumeHideSwitch then
        jianting3(qiehuan)
    end
    if isPlaying and isReady and #musiclist ~= 0 then
        luajava.runOnUiThread(function()
            ntime:setText(ctime(math.floor(mediaPlayer:getCurrentPosition()/1000)))
            hkuai:setValue(math.floor(mediaPlayer:getCurrentPosition()/1000))
        end) 
        if #currentLyrics > 0 then
            更新歌词显示()
        end
    end
    gg.sleep(200) 
end
end

import'android.hardware.*';
---@type android.hardware.SensorEventListener-
local sensor = luajava.createProxy('android.hardware.SensorEventListener', {
onSensorChanged = functions.debounce(function()
if 摇一摇==false then return 0 end
if qhkai~=0 then
qhkai=0
luajava.runUiThread(function()
floatWindow:setVisibility(View.VISIBLE)

YoYoImpl:with("FadeIn"):duration(300):playOn(floatWindow)
end)
else
qhkai=1
luajava.newThread(function()
luajava.runUiThread(function()
YoYoImpl:with("FadeOut"):duration(300):playOn(floatWindow)
end)
gg.sleep(400)
luajava.runUiThread(function()
floatWindow:setVisibility(View.GONE)
end)
draw.remove()
gg.toast("隐藏")
end):start()

end
end,500)
})
function changan.toasts(title, neir, qiucolor, bgcolor)
    if qiucolor == nil then
        qiucolor = 0xFF55FFAA
    end
    if bgcolor == nil then
        bgcolor = 0xFFFFFEFE
    end
    if title[2] == nil then
        title[2] = 0xff55AAFF
    end
    if neir[2] == nil then
        neir[2] = 0xff00FFFF
    end
    local toastid = "toast" .. title[1] .. string.randomUUID( true )
    _ENV[toastid] = luajava.loadlayout( {
        LinearLayout,
        visibility = "gone",
        layout_height = "70dp",
        layout_width = "260dp",
        orientation = 'vertical',
        gravity = 'center_horizontal',
        background = luajava.loadlayout( {GradientDrawable, color = bgcolor, cornerRadius = 15}),
        {
            LinearLayout,
            layout_height = "wrap_content",
            layout_width = "match_parent",
            {
                LinearLayout,
                background = luajava.loadlayout {GradientDrawable, color = qiucolor, cornerRadius = 360},
                layout_width = "20dp",
                layout_height = "20dp",
                layout_marginRight = "8dp",
                layout_marginLeft = "8dp",
                layout_marginTop = "8dp",
                layout_marginBottom = "8dp",
            },
            {
                TextView,
                text = title[1],
                textColor = title[2],
                textSize = "15sp",
                layout_width = "match_parent",
                layout_height = "wrap_content",
                layout_marginTop = "8dp",
                layout_marginBottom = "8dp",
            } 
        },
        {
            LinearLayout,
            layout_width = "match_parent",
            layout_height = "fill_parent",
            {View, layout_width = "30dp", layout_height = "fill_parent", },
            {
                TextView,
                text = neir[1],
                textSize = "13sp",
                textColor = neir[2],
                layout_width = "wrap_content",
                layout_height = "wrap_content",
                layout_gravity = "center|left"
            },
        } 
    })
    luajava.newThread( function ()
        luajava.runUiThread( function ()
            toastlay:addView(_ENV[toastid])
            _ENV[toastid]:setVisibility(View.VISIBLE)
            _ENV[toastid]:measure(0, 0)
            local height = _ENV[toastid]:getMeasuredHeight()
            _ENV[toastid]:setTranslationY( -height)
            _ENV[toastid]:animate():translationY(0):setDuration(1000):start()
        end        )
        gg.sleep(2000)
        luajava.runUiThread( function ()
            _ENV[toastid]:animate():translationY( -_ENV[toastid]:getHeight()):setDuration(1000):withEndAction( function ()
                local 

                function invoke2()
                    toastlay:removeView(_ENV[toastid])
                end
                luajava.post(invoke2)
            end            ):start()
        end        )
    end    ):start()
end

function changan.toast2s(title, neir, qiucolor, bgcolor)
    if qiucolor == nil then
        qiucolor = 0xFF55FFAA
    end
    if bgcolor == nil then
        bgcolor = 0xFFFFFEFE
    end
    if title[2] == nil then
        title[2] = 0xff55AAFF
    end
    if neir[2] == nil then
        neir[2] = 0xffffFFFF
    end
    local toast2id = "toast2" .. title[1] .. string.randomUUID( true )
    _ENV[toast2id] = luajava.loadlayout( {
        LinearLayout,
        visibility = "gone",
        layout_height = "wrap_content",
        layout_width = "wrap_content",
        {
            LinearLayout,
            layout_height = "50dp",
            layout_width = "100dp",
            gravity = 'center',
            background = luajava.loadlayout( {GradientDrawable, color = bgcolor, cornerRadius = 20, }),
            layout_marginTop = "5dp",
            layout_marginBottom = "5dp",
            {
                LinearLayout,
                layout_height = "match_parent",
                layout_width = "wrap_content",
                {
                    LinearLayout,
                    background = luajava.loadlayout {GradientDrawable, color = qiucolor, cornerRadius = 360},
                    layout_width = "15dp",
                    layout_height = "15dp",
                    layout_marginRight = "8dp",
                    layout_marginLeft = "8dp",
                    layout_marginTop = "8dp",
                    layout_marginBottom = "8dp",
                    layout_gravity = "center",
                },
                {
                    LinearLayout,
                    layout_width = "fill_parent",
                    layout_height = "match_parent",
                    orientation = 'vertical',
                    {
                        TextView,
                        text = title[1],
                        Typeface = font,
                        textColor = title[2],
                        textSize = "13sp",
                        layout_width = "match_parent",
                        layout_height = "wrap_content",
                        layout_marginTop = "5dp",
                        layout_marginBottom = "2dp",
                    },
                    {
                        TextView,
                        Typeface = font,
                        text = neir[1],
                        textSize = "10sp",
                        textColor = neir[2],
                        layout_width = "match_parent",
                        layout_height = "wrap_content",
                    },
                },
            } 
        } 
    })
    luajava.newThread( function ()
        luajava.runUiThread( function ()
            toast2lay:addView(_ENV[toast2id])
            _ENV[toast2id]:setVisibility(View.VISIBLE)
            _ENV[toast2id]:setAlpha(0)
            _ENV[toast2id]:animate():alpha(1):setDuration(1000):start()
        end        )
        gg.sleep(2000)
        luajava.runUiThread( function ()
            _ENV[toast2id]:animate():alpha(0):setDuration(1000):withEndAction( function ()
                local 

                function invoke2()
                    toast2lay:removeView(_ENV[toast2id])
                end
                luajava.post(invoke2)
            end            ):start()
        end        )
    end    ):start()
end
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
Q弹动画速度=600
changan.controlWater2 = function(control, time)
    luajava.runUiThread(function()
        import "android.animation.ObjectAnimator"
        import "android.animation.AnimatorSet"
        
        -- 水平方向弹动（主要效果）
        local scaleXAnim = ObjectAnimator():ofFloat(control, "scaleX", {
            1,      -- 原始大小
            1.2,    -- 向右拉伸
            0.9,    -- 向左压缩
            1.05,   -- 轻微过冲
            1       -- 回到原始大小
        })
        scaleXAnim:setDuration(time)
        
        -- 垂直方向轻微波动（可选，增加生动感）
        local scaleYAnim = ObjectAnimator():ofFloat(control, "scaleY", {
            1,      -- 原始大小
            0.95,   -- 轻微压缩
            1.02,   -- 轻微拉伸
            0.98,   -- 轻微压缩
            1       -- 回到原始大小
        })
        scaleYAnim:setDuration(time)
        
        -- 使用动画集同时播放
        local animSet = AnimatorSet()
        animSet:playTogether({scaleXAnim, scaleYAnim})
        animSet:start()
    end)
end
local hourStr=os.date("%H")
  local hour=tonumber(hourStr) -- 获取当前小时
  if hour >=0 and hour < 3 then
    timeA="夜深了，早点休息"
   elseif hour >=3 and hour < 5 then
    timeA="凌晨了，注意身体"
   elseif hour >=5 and hour < 12 then
    timeA="上午好☁️"
   elseif hour >=12 and hour < 14 then
    timeA="中午好🎱"
   elseif hour >=14 and hour < 19 then
    timeA="下午好☕️"
   elseif hour >=19 and hour < 24 then
    timeA="晚上好🌙"
  end
import"android.graphics.Paint"
  function souyy(txt)
    return table.json(gg.makeRequest("http://music.163.com/api/search/get?s="..txt.."&type=1&offset=0&total=true&limit=20").content)
  end
  function searchmusic()
    mustxt=luajava.getIdView("搜索"):getText()
    mustxt=tostring(mustxt)
    luajava.runOnUiThread(function()
      luajava.getIdView("搜索"):setText("")
      luajava.getIdView("musicWindow"):setVisibility(View.GONE)
      SearchProgress:setVisibility(View.VISIBLE)  
    end)
    if string.trim(mustxt)~="" then
      musictable={}
        mustable=souyy(mustxt)
        mustable=mustable.result.songs
        for k,v in pairs(mustable) do
          musictable[#musictable + 1]=v
        end
      Sortsong(20)
    end
    luajava.runOnUiThread(function()
      luajava.getIdView("musicWindow"):setVisibility(View.VISIBLE)
      SearchProgress:setVisibility(View.GONE)
     -- gg.sleep(1900)
      
      YoYoImpl:with("FadeIn"):duration(2000):playOn(luajava.getIdView("musicWindow"))
    end)
  end
  function Sortsong(formath)
    musiccheck={}
    for i=1,formath do
      musid=musictable[#musictable+1-i].id
      musname=musictable[#musictable+1-i].name
      musart=musictable[#musictable+1-i].artists[0].name
      musvip=musictable[#musictable+1-i].fee
      musiccheck[#musiccheck+1]={musid,musname,musart,musvip}
    end
    musicadapter=ui.BaseAdapter({
      getCount = function()
        return table.getn(musiccheck) -- 使用 table.getn 获取表中元素的数量
      end,
      getItem = function(position)
        return musiccheck[position + 1]
      end,
      getItemId = function(position)
        return position
      end,
         getView=function(position, convertView, parent)
        local SwitchView
        local info=musicadapter:getItem(position)
        if not convertView then
          SwitchView=luajava.loadlayout({
          MaterialCardView,
      background={GradientDrawable,color=0x,cornerRadius=0},
      layout_width="match_parent",
      strokeWidth=0,
      {
            LinearLayout,
            orientation="vertical",
            padding="3dp",
            gravity="center",
            layout_width="match_parent",
            
            {
              TextView,
              textSize="14sp",
              textColor="0xffffffff",
              Typeface=font,
              layout_hight="10dp",
              layout_width="wrap_content",
              gravity="center"
            },
            
            {
              TextView,
              textColor="#787878",
              Typeface=font,
              textSize="10sp",
              layout_hight="10dp",
              layout_width="wrap_content",
              gravity="center"
            }
            }
          })
         else
          SwitchView=convertView
        end
        SwitchView:getChildAt(0):getChildAt(0):setText(info[2])
        SwitchView:getChildAt(0):getChildAt(1):setText(info[3])
        SwitchView:setOnClickListener(function()
          bofang(info[1],info[2],info[3])
          if info[4] == 1 then
          MaterialAlert("当前为付费VIP歌曲,可能只支持部分试听")
          end
        end)
        return SwitchView
      end
    })
    luajava.runOnUiThread(function()
      musiclistview:setAdapter(musicadapter)
    end)
  end
  lastClickTime1=0
  function bofang(musicid, musicname, musicstart)
    local currentTime1=os.time()
    if currentTime1 - lastClickTime1 < 1 then return 0 end lastClickTime1=currentTime1
    isExist=false
    for i, _ in ipairs(musiclist) do
      if musiclist[i][1] == musicid then
        nowMusic = i
        播放歌曲(musiclist[i][1])
        isExist=true
      end
    end
    if not isExist then
      table.insert(musiclist, {musicid, musicname, musicstart, false})
      nowMusic = #musiclist
      播放歌曲(musicid)
    end
  end
  function 写入()
    lovemusic = {}
    for _, v in pairs(musiclist) do
      if v[4] then
        table.insert(lovemusic, v)
      end
    end
    file.write("/sdcard/墨意UI配置/收藏歌单.lua",lovemusic)
  end
  function 灵动岛()
    luajava.getIdView("Smalldisplay"):setVisibility(View.GONE)
    luajava.getIdView("music"):setVisibility(View.INVISIBLE)
    if 灵动 then
      luajava.startThread(function()
        luajava.runOnUiThread(function()
          shadow:setVisibility(View.GONE)
          luajava.getIdView("SmallIsland"):setVisibility(View.VISIBLE)
          Island:setVisibility(View.GONE)
        end)
        灵动=false
      gg.sleep(400)
        luajava.runOnUiThread(function()
       changan.controlWater2(luajava.getIdView("faded"),Q弹动画速度)
          luajava.getIdView("Smalldisplay"):setVisibility(View.VISIBLE)
          YoYoImpl:with("FadeIn"):duration(400):playOn(luajava.getIdView("Smalldisplay"))
        end)
      end)
     else
      luajava.startThread(function()
        luajava.runOnUiThread(function()
          shadow:setVisibility(View.VISIBLE)
          luajava.getIdView("SmallIsland"):setVisibility(View.GONE)
          
          Island:setVisibility(View.VISIBLE)
        end)
        灵动=true
        gg.sleep(500)
        
        luajava.runOnUiThread(function()-- 展开
        
          luajava.getIdView("music"):setVisibility(View.VISIBLE)
          YoYoImpl:with("FadeIn"):duration(400):playOn(luajava.getIdView("music"))
        end)
      end)
    end
  end
  function ctime(value)
    local minutes=math.floor(value / 60)
    local seconds=value % 60
    return string.format("%d:%02d",minutes,seconds)
  end
  function setTime(value)
    local minutes=math.floor(value/1000)
    luajava.runOnUiThread(function()
      hkuai:setValueTo(minutes)
      atime:setText(ctime(minutes))
    end)
  end
function getMusicPictures(id)
local briefIntroduction = table.json(file.read("/sdcard/墨意UI配置/音乐缓存/pic".. id))
    if briefIntroduction.code == 200 then
        picUrl = briefIntroduction.songs[0].album.picUrl
    else
        picUrl = 'http://s4.music.126.net/style/web2/img/default/default_list.jpg'
    end
return picUrl
end
  
  function playMusic(id)
    pcall(function()
      mediaPlayer:reset()
      mediaPlayer:setDataSource("/sdcard/墨意UI配置/音乐缓存/"..id)
      mediaPlayer:prepare()
      IslandPic2:setImageDrawable(获取图片("/sdcard/墨意UI配置/音乐缓存/Pic2"..id))
      IslandPic1:setImageDrawable(获取图片("/sdcard/墨意UI配置/音乐缓存/Pic2"..id))
      if isRotate ~= true then
    	isRotate = true
        luajava.newThread(function()--更新逻辑
    	while true do
    	changan.controlRotation2(IslandPicMain,5000)
    	
		gg.sleep(5500)
    	end
        end):start()
      end
    end)
  end

  function 播放歌曲(id)
    isReady=false
    if #musiclist == 0 then return end
    if isPlaying==false then ztkq:setSpeed(1) ztkq:playAnimation()
      IslandText:setVisibility(View.VISIBLE)
      GSname:setVisibility(View.VISIBLE)
      IslandPic1:setVisibility(View.VISIBLE)
      IslandPic2:setVisibility(View.VISIBLE)
      musicicon1:setSpeed(1) musicicon1:playAnimation()
musicicon1:loop(true)  
musicicon1:setVisibility(View.VISIBLE)
     isPlaying=true end
     重置歌词()
    -- 获取歌曲信息用于下载歌词
    local musicInfo = musiclist[nowMusic]
    if musicInfo then
        
        下载歌词(id, musicInfo[2], musicInfo[3]) -- 传递id, 歌曲名, 艺术家
    end
    if file.length("/sdcard/墨意UI配置/音乐缓存/"..id) ~= 0 or file.length("/sdcard/墨意UI配置/音乐缓存/Pic2"..id) ~= 0 then
      playMusic(id)
     else
      luajava.startThread(function()
        luajava.runOnUiThread(function() DownloadProgress:setVisibility(View.VISIBLE) end)
        local co = coroutine.create(function()
          local success = file.download("http://music.163.com/song/media/outer/url?id=".. id.. ".mp3","/sdcard/墨意UI配置/音乐缓存/".. id)
          file.download('http://music.163.com/api/song/detail/?id='..id..'&ids=['..id..']',"/sdcard/墨意UI配置/音乐缓存/pic".. id)
          file.download(getMusicPictures(id),"/sdcard/墨意UI配置/音乐缓存/Pic2"..id)
          return success
        end)
        local status, result = coroutine.resume(co)
        if status and result then
          luajava.runOnUiThread(function() DownloadProgress:setVisibility(View.GONE) end)
          playMusic(id)
         else
          print("下载出现问题，无法播放音乐")
        end
      end)
    end
  end
  luajava.setInterface(mediaPlayer, 'setOnPreparedListener',--资源准备完毕监听
  {onPrepared=function(media)
      isReady=true
      mediaTime=media:getDuration()
      media:start()
      setTime(mediaTime)
      luajava.runOnUiThread(function()
        hkuai:setValue(1)
        IslandText:setText(musiclist[nowMusic][2])
        Mname:setText(musiclist[nowMusic][2])
        if musiclist[nowMusic][4] then
          sc=false
          souc:setImageDrawable(getRes("love"))
          souc:setColorFilter(0xffEC2937)
         else
          sc=true
          souc:setImageDrawable(getRes("unlove"))
          souc:setColorFilter(0xffFAFAFA)
        end
      end)
  end})
  luajava.setInterface(mediaPlayer, 'setOnCompletionListener',--播放完毕监听
  {onCompletion=function(media)
      换一首()--问题
  end})
  
  function MaterialAlert(text)
    MaterialAlertDialog=MaterialAlertDialogBuilder(baseWindow:getContext())
    :setTitle(项目名字) -- 设置标题
    :setMessage(text)
    :setPositiveButton('确定')
    luajava.showAlert(MaterialAlertDialog)
  end
  BSZ=0
  function 换一首()
    if BSZ==0 then--列表循环
      下一首()
     elseif BSZ==1 then--随机播放
      local randomnowMusic=math.random(1,#musiclist)
      local selectedNumber=musiclist[randomnowMusic]
      nowMusic=randomnowMusic
      播放歌曲(selectedNumber[1])
     elseif BSZ==2 then--单曲循环
      播放歌曲(musiclist[nowMusic][1])
     elseif BSZ==3 then--停止循环
      luajava.newThread(function()
        播放歌曲(musiclist[nowMusic][1])
        gg.sleep(110)
        isPlaying=false
        mediaPlayer:pause()
        luajava.runOnUiThread(function()
          ztkq:setSpeed(-1)
          ztkq:playAnimation()
        end)
      end):start()
    end
  end
  function 播放设置()
    changan.controlWater(luajava.getIdView("LoopSetting"),200)
    if BSZ==0 then--随机播放
      BSZ=BSZ+1
      bfsz:setImageDrawable(getRes("repeatone"))
     elseif BSZ==1 then--单曲循环
      BSZ=BSZ+1
      bfsz:setImageDrawable(getRes("stoploop"))
     elseif BSZ==2 then--停止循环
      BSZ=BSZ+1
      bfsz:setImageDrawable(getRes("listloop"))
     elseif BSZ==3 then--列表循环
      BSZ=0
      bfsz:setImageDrawable(getRes("setPlay"))
    end
  end
  function 暂停()
  if #musiclist == 0 then MaterialAlert("您还没有收藏歌曲\n请搜索想听的歌曲添加到播放列表\n点击左侧爱心可以收藏，每次重新启动时只会保留收藏的歌曲")
    luajava.runOnUiThread(function()
     Page:setCurrentItem(#stab-2)
     end) return end
    if isPlaying then
      ztkq:setSpeed(-1)--暂停
      ztkq:playAnimation()
      IslandPic1:setVisibility(View.GONE)
      IslandText:setVisibility(View.GONE)
      if isReady then
      
        mediaPlayer:pause()
      end
      isPlaying=false
     else
      if isReady then
        mediaPlayer:start()
        else
        nowMusic = 1
        播放歌曲(musiclist[1][1])
      end
      ztkq:setSpeed(1)
      ztkq:playAnimation()
      musicicon1:setVisibility(View.GONE)
      IslandText:setVisibility(View.VISIBLE)
      IslandText:setVisibility(View.VISIBLE)
      GSname:setVisibility(View.VISIBLE)
      IslandPic1:setVisibility(View.VISIBLE)
      IslandText:setVisibility(View.VISIBLE)
      isPlaying=true
    end
  end
  function 下一首()
    if #musiclist == 0 then MaterialAlert("您还没有收藏歌曲\n请搜索想听的歌曲添加到播放列表\n点击左侧爱心可以收藏，每次重新启动时只会保留收藏的歌曲")
    luajava.runOnUiThread(function()
     Page:setCurrentItem(#stab-2)
     end) return end
    nowMusic=nowMusic + 1
    if nowMusic > #musiclist then
      nowMusic=1
    end
    ztkq:setSpeed(1)
    ztkq:playAnimation()
    
    musicInfo=musiclist[nowMusic]
    播放歌曲(musicInfo[1])
  end
  function 上一首()
    if #musiclist == 0 then MaterialAlert("您还没有收藏歌曲\n请搜索想听的歌曲添加到播放列表\n点击左侧爱心可以收藏，每次重新启动时只会保留收藏的歌曲") 
    luajava.runOnUiThread(function()
     Page:setCurrentItem(#stab-2)
     end) return end
    nowMusic=nowMusic - 1
    if nowMusic < 1 then
      nowMusic=#musiclist
    end
    musicInfo=musiclist[nowMusic]
    播放歌曲(musicInfo[1])
    
  end
  sc=true
  function 收藏()
  if isReady then
    if sc then
      sc=false
      musiclist[nowMusic][4]=true
      souc:setImageDrawable(getRes("love"))
      souc:setColorFilter(0xffEC2937)
     else
      sc=true
      musiclist[nowMusic][4]=false
      souc:setImageDrawable(getRes("unlove"))
      souc:setColorFilter(0xffFAFAFA)
    end
    写入()
    end
  end
  function 刷新列表()
    playadapter=ui.BaseAdapter({
      getCount = function()
        return #musiclist
      end,
      getItem = function(position)
        return musiclist[position + 1]
      end,
      getItemId = function(position)
        return position
      end,
      getView=function(position, convertView, parent)
        local SwitchView
        local info=playadapter:getItem(position)
        if info[4] then
          MTP=getRes("love")
          MTPC=0xffEC2937
         else
          MTP=getRes("unlove")
          MTPC=0xff4B484F
        end
        if not convertView then
          SwitchView=luajava.loadlayout(
          {
            FrameLayout,
            layout_width="match_parent",
            layout_height="30dp",
            paddingLeft="5dp",
            paddingRight="5dp",
            {
              ImageView,
              id="Playlike",
              src=MTP,
              layout_gravity="center|left",
              ColorFilter=MTPC,
              layout_width="22dp",
              layout_height="22dp",
            },
            {
              TextView,
              id="playname",
              layout_marginLeft="25dp",
              layout_marginRight="25dp",
              layout_width="match_parent",
              layout_height="wrap_content",
              layout_gravity="center",
              gravity="center",
              textColor="#27253A",
            },
            {
              ImageView,
              id="songremove",
              src=getRes("heix"),
              ColorFilter="#4B484F",
              layout_gravity="center|right",
              layout_width="18dp",
              layout_height="18dp",
            },
          })
         else
          SwitchView=convertView
        end
        Playlike:setOnClickListener(function()
          if info[4] then
            info[4]=false
            musiclist[position+1][4]=false
            写入()
            刷新列表()
            luajava.runOnUiThread(function()
              if nowMusic==position+1 then sc=true
                souc:setImageDrawable(getRes("unlove"))
                souc:setColorFilter(0xffFAFAFA) end
            end)
           else
            info[4]=true
            musiclist[position+1][4]=true
            写入()
            刷新列表()
            luajava.runOnUiThread(function()
              if nowMusic==position+1 then sc=false
                souc:setImageDrawable(getRes("love"))
                souc:setColorFilter(0xffEC2937) end
            end)
          end
        end)
        playname:setOnClickListener(function()
          播放歌曲(info[1],info[2],info[3],info[4])
          nowMusic=position+1
        end)
        playname:setText(info[2])
        songremove:setOnClickListener(function()
          luajava.startThread(function()
            if gg.alert('确定删除['..info[2]..']吗？','确定','点错了')==1 then
              table.remove(musiclist,position+1) 刷新列表() 写入()
              if nowMusic==position+1 then 下一首() end end
          end)
        end)
        return SwitchView
      end
    })
    luajava.runOnUiThread(function()
      songlistview:setAdapter(playadapter)
    end)
  end
  songlist={
    LinearLayout,
    orientation="vertical",
    layout_width="match_parent",
    layout_height="wrap_content",
    {
      ListView,--列表适配器
      id="songlistview",
      layout_width='match_parent',
      layout_height='match_parent',
      dividerHeight=3,
    }
  }
  function 播放列表()
    dialogBuilder=MaterialAlertDialogBuilder(baseWindow:getContext()) -- 创建对话框构造器
    :setTitle('待播放列表') -- 设置标题
    :setView(luajava.loadlayout(songlist))
    :setPositiveButton('确定')
    luajava.showAlert(dialogBuilder)
    刷新列表()
  end
corbk = true
当前ui = 1
local 选中文字颜色 = "0xff57619C" 
local 未选中文字颜色 = "0xff57619C"
local 选中背景颜色 = getVerticalBG({0x,0x},18,4,0xff57619C)
local 未选中背景颜色 =getVerticalBG({0x,0x},18,4,0x59939393)
function 分区(x)
    当前分区[当前ui] = x
    luajava.runUiThread(function()
        for i=1, 分区页数[当前ui] do
            _ENV['menu'..当前ui..i]:setVisibility(View.GONE)
        end
        _ENV['menu'..当前ui..当前分区[当前ui]]:setVisibility(View.VISIBLE)
        for j = 1, 分区页数[当前ui] do
            local btn = _ENV['jmt'..当前ui..j] 
            if btn then
                btn:setTextColor(未选中文字颜色) 
            end
            
        end
for j = 1, 分区页数[当前ui] do
            local btn2 = _ENV['jp'..当前ui..j]
            if btn2 then
                btn2:setBackground(未选中背景颜色)
            end
            end
        local currentBtn = _ENV['jmt'..当前ui..x]
        local currentBtn2 = _ENV['jp'..当前ui..x]
        if currentBtn then
            currentBtn:setTextColor(选中文字颜色) -- 设置文字颜色
        end
        if currentBtn2 then
           currentBtn2:setBackground(选中背景颜色) 
        end
    end)
end
function 切换(x)
当前ui = x
luajava.runUiThread(function()
if 当前分区[当前ui]==nil then
分区(1)
end
for i = 1,菜单页数 do
_ENV["ding"..i]:setTextColor(0xff787878)
_ENV["layout"..i]:setVisibility(View.GONE)
侧边[i]:setVisibility(View.GONE)
end
_ENV["ding" .. 当前ui]:setTextColor(0xff57619C)
_ENV["layout"..当前ui]:setVisibility(View.VISIBLE)
侧边[当前ui]:setVisibility(View.VISIBLE)
end)
end

beij2 = luajava.loadlayout({
GradientDrawable,
color = "#001E1C27",
cornerRadius = 10
})
function changan.text(txt,color,size)
if not txt then txt = "未设置文字" end
if not color then color = "#545454" end
if not size then size = "12sp" end
return luajava.loadlayout(
{
TextView,
text = txt,
textSize = size,
textColor = color,
layout_width = "match_parent",
padding={'10dp','0dp','0dp','0dp'}
})
end
function 隐藏()
luajava.runUiThread (function ()
	if tonumber (tostring (chuangk: getVisibility ())) == 8.0 then
	显示 = 1
	okay:setVisibility(View.GONE)
	luajava.newThread(function()
		end):start()
	chuangk:setVisibility(View.VISIBLE)
	luajava.getIdView("faded"):setVisibility(View.VISIBLE)-- 灵动岛
soft:setVisibility(View.VISIBLE)--右下角
floatWindow:setBackground(luajava.loadlayout({
                GradientDrawable,
                color = "0xffffffff",
                cornerRadius = 20,
                stroke = {15, "0x62FFFFFF", 0, 5}
            }))
	mainLayoutParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
	window : updateViewLayout (floatWindow , mainLayoutParams)
	YoYoImpl:with("FadeIn"):duration(400):playOn(floatWindow)
	else
		显示 = 0
	luajava.newThread(function()
		luajava.runUiThread(function()
			YoYoImpl:with("FadeOut"):duration(300):playOn(floatWindow)
			end)
		gg.sleep(310)
		luajava.runUiThread(function()
			YoYoImpl:with("FadeIn"):duration(200):playOn(floatWindow)
			okay:setVisibility(View.VISIBLE)
			chuangk:setVisibility(View.GONE)
			floatWindow:setBackground(nil)
luajava.getIdView("faded"):setVisibility(View.GONE)
soft:setVisibility(View.GONE)
			mainLayoutParams.flags = LayoutParams.FLAG_NOT_FOCUSABLE
			window : updateViewLayout (floatWindow , mainLayoutParams)
			end)
		end):start()
	end
	end)
end

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音调的声音
}
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
function jianting2()
yinln = {}
for i = 1,#audiotype do
yinln[i] = {}
yinln[i].type = audiotype[i]
yinln[i].min = audi:getStreamMinVolume(audiotype[i])
yinln[i].max = audi:getStreamMaxVolume(audiotype[i])
yinln[i].now = audi:getStreamVolume(audiotype[i])

if yinln[i].now > yinl[i].now then
audi:adjustStreamVolume(yinln[i].type,AudioManager.ADJUST_LOWER,0)
gg.alert("up")
elseif yinln[i].now < yinl[i].now then
audi:adjustStreamVolume(yinln[i].type,AudioManager.ADJUST_RAISE,0)
gg.alert("down\n"..yinln[i].now.."\n"..yinl[i].now)
end
end

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
function jianting(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].max then
audi:adjustStreamVolume(yinln[i].type,AudioManager.ADJUST_LOWER,0)
end
if yinln[i].now > yinl[i].now then
audi:setStreamVolume(yinln[i].type,yinl[i].now,0)
func()
end
end
end
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%s%s',
string.sub(sid,1,8),
string.sub(sid,10,12),
string.sub(sid,21,22))
..string.format('%s%s%s%s%s',
string.sub(sid,1,6),
string.sub(sid,21,25)
)
end
local function exit()
tuichu = 1
luajava.setFloatingWindowHide(false)
luajava.post(function()
window:removeView(floatWindow)
end)
end
setExitEvent(exit)
buts={}
heir=getRes("heir")
	function changan.button(txt,func,txtc)
		if not txt then txt = "未设置" end
		if not txtc then txtc="#00" 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",
				layout_marginLeft='2dp',
				layout_marginRight='2dp',
				elevation='2dp',
				background = luajava.loadlayout {
                GradientDrawable,
                color = "0xffffffff",
                cornerRadius = 15
            },
				padding="10dp",
				onClick = function()
				changan.controlWater(buts[tid], 400)  -- 使
					luajava.newThread(func):start() end,
				{
					TextView,
					textColor = "#00",
					Typeface=font,
					text = txt,
					textSize = "13sp",
					layout_height = "wrap_content",
					layout_width = "fill_parent",
					layout_weight=1,
				},
				{ImageView,
        src=getRes("heir"),
        layout_height="14dp",
        layout_gravity = "center",
        layout_width="14dp",

      }
			}})
		return buts[tid]
	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

boxes={} boxpic={}
Rotation=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)
  boxpic[tid]:setColorFilter("0xff6E8258")
    Rotation(boxpic[tid],0,90)
   else
    tview:setVisibility(View.GONE)
    boxpic[tid]:setColorFilter(0xff787878)
    Rotation(boxpic[tid],90,0)
  end
end
function changan.box(views, subtitle)
  local tid="box"..string.randomUUID(true)
  colorvs[#colorvs+1]={"box",tid}
  boxpic[tid]=luajava.loadlayout {
    ImageView,
    src=getRes("heir"),
    layout_width="15dp",
    layout_height="15dp",
    ColorFilter="0xff787878",
  }
  local ttid=tid.."6"
  firadio={
    LinearLayout,
    layout_width='fill_parent',
    background=luajava.loadlayout{GradientDrawable,color=0xffffffff,cornerRadius=20},
    elevation="3dp",
    layout_height="wrap_content",
    layout_margin="4dp",
    orientation="vertical",
    LayoutTransition=LayoutTransition()
  }
  if type(views[1])=="string" or type(views[1])=="number" then
    firadio[# firadio + 1]={
      LinearLayout,
      layout_width='fill_parent',
      layout_height="47dp",
      gravity="center_vertical",
      {
        LinearLayout,
        layout_width='fill_parent',
        layout_height="40dp",
        layout_marginRight="4dp",
        layout_marginLeft="4dp",
        gravity="center_vertical",
        onClick=function() visi(tid,ttid) end,
        {
          ImageView,
          src = "http://vip.okig.top/view.php/2430ca4f71fd283ca9d5c4788be481bc.png",
          layout_marginLeft="7dp",
          layout_height = "19dp",
          layout_width = "19dp",
        },
        {
          LinearLayout,
          orientation="horizontal",  
          layout_weight=1,
          layout_width='fill_parent',
          layout_marginLeft="10dp",
          layout_marginRight="20dp",
          gravity="center_vertical",  
          {
            TextView,
            text=views[1],
            Typeface=font,
            textColor="0xff161616",
            textSize="11sp",
            layout_width="wrap_content",
          },
          
        },
        {
          LinearLayout,
          padding={"0dp","0dp","10dp","0dp"},
          layout_width="wrap_content",
          layout_height="wrap_content",
          gravity="center",
          {
            TextView,
            Typeface=font,
            text=subtitle and ""..subtitle or "",  
            textColor="#6E8258",
            textSize="10sp",
            layout_width="wrap_content",
layout_marginRight="14dp",
            visibility=subtitle and View.VISIBLE or View.GONE,
          },
          boxpic[tid],
        }
      }
    }
  else
    gg.alert("box 的 table 内第一个元素必须是 string")
    os.exit()
  end
  radios={
    LinearLayout,
    layout_marginLeft="5dp",
    layout_marginRight="5dp",
    orientation="vertical",
    visibility="gone",
    id=luajava.newId(tid),
    layout_width='fill_parent',
  }
  for i=2,# views do
    radios[# radios + 1]=views[i]
  end
  boxes[tid]=luajava.loadlayout(radios)
  firadio[# firadio + 1]=boxes[tid]
  return firadio
end
function SwitchDrawable(on,off)
local switchSelector = luajava.getStateListDrawable()
  switchSelector:addState({ android.R.attr.state_checked }, luajava.getBitmapDrawable("/sdcard/墨意UI配置/xyopen"))
  switchSelector:addState({ -android.R.attr.state_checked }, luajava.getBitmapDrawable("/sdcard/墨意UI配置/xyclose"))
  return switchSelector
  end
function changan.switch(name,func1,func2)
  local nid=name..string.randomUUID(true)
  colorvs[#colorvs+1]={"switch",nid}
  if ""..name=="摇一摇隐藏UI" or ""..name=="音量键隐藏UI" then ztai=false else ztai=false end
  _G["switch_"..name] = nid
  return{
    LinearLayout,
    layout_width='fill_parent',
    layout_height="44dp",
    gravity="center",
    elevation="2dp",
    layout_margin="4dp",
    background={GradientDrawable,color=0xffffffff,cornerRadius=20},
    paddingRight="6dp",
    {
      TextView,
      text=name,
      textColor="0xff161616",
      textSize="13sp",
      Typeface=font,
      layout_weight=1,
      layout_width='fill_parent',
      layout_marginLeft="10dp",
      layout_marginRight="20dp",
    },
    {
      MaterialSwitch,
      checked=ztai,
      id=luajava.newId(nid),
      thumbIconDrawable=SwitchDrawable("xyopen","xyclose"),
      setThumbIconSize = "15dp",
      TrackTintList=ColorStateList({{android.R.attr.state_checked}},{"0xff161616"}),
      layout_weight=1,
      layout_marginTop="-3.5dp",
      layout_marginBottom="-3.5dp",
      layout_width='match_parent',
      layout_height='wrap_content',
      onCheckedChange=function(compoundButton,isChecked)
        if isChecked then
          luajava.newThread(function()
          local tips = name .. "开启成功"
          string.toMusic(tips)
          changan.toast2s( {"芒果全房:", 0xFF55AAFF}, {tips, 0xff161616}, 0xFF55FFAA, 0xaaffffff)
          changan.LDTips('开启成功', 1300)
           pcall(func1)
          end):start()
         end
        end
    }
  }
end
wyylog=luajava.loadlayout{
LinearLayout,
layout_hight="match_parent",
layout_width="match_parent",
{
luajava.post(LinearProgressIndicator,baseWindow:getContext()),
id="SearchProgress",
visibility = "gone",
layout_marginLeft='1dp',
layout_marginTop = "5dp",
layout_marginRight='1dp',
layout_width = 'match_parent',
layout_height = 'wrap_content',
indeterminate = true,
},
{
LinearLayout,
id=luajava.newId("musicWindow"),
orientation="vertical",
layout_height="match_parent",
layout_width="match_parent",
{
LinearLayout,
layout_height="19dp",
layout_hight="wrap_content",
layout_width="match_parent",
layout_margin="5dp",
Elevation="3dp",
background={GradientDrawable,color=0x4D989898,cornerRadius=360},
{
EditText,
Typeface=font,
id=luajava.newId("搜索"),
gravity="center",
layout_height="35dp",
layout_marginBottom='120dp',
hint="请输入关键词",
textSize="13sp",
layout_weight="1",
HintTextColor="0x40201E1E",
layout_width="match_parent",
textColor="0xffffffff",
OnKeyListener={
onKey=function(v,keyCode,event)
if (KeyEvent.KEYCODE_ENTER == keyCode and KeyEvent.ACTION_DOWN == event:getAction()) then
thread=luajava.getThread(function()
searchmusic()
end)
thread:start()
return true;
 else
return false;
end
end
}
},
{
LinearLayout,
layout_height="10dp",
layout_width="1dp",
gravity="center",
layout_marginTop = "5dp",
backgroundColor="#787878",
},
{
TextView,
Typeface=font,
text="搜索",
gravity="center",
id=luajava.newId("stxt"),
textSize="11sp",
TextColor="0xffffffff",
layout_height="match_parent",
layout_width="40dp",
onClick=function()
thread=luajava.getThread(function()
searchmusic()
end)
thread:start()
end
},
},
{
		
		ScrollView,
		fillViewport = "true",
		gravity = "center",
		layout_width = "match_parent",
		layout_height = "220dp",
{
ListView,
id="musiclistview",
layout_width='match_parent',
dividerHeight=3,
},
},
},
}
悬浮窗图标 = "http://wl.luoyeyun.icu/view.php/c2f7d93245e39d0e1cf1120be80ca3f1.png"
项目名称="墨白UI"
function huiz()---绘制必须放在这里面
end
第一页 = {--创建分页，结尾调用
['分页名字']="主页",
[1]={--第一分区
['分区名字']="分区",
['功能配置']={
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)

			}},

[2]={
['分区名字']="分区2",
['功能配置']={
changan.button("测试1", function() end),
changan.button("测试1", function() end),
}},
[3]={
['分区名字']="分区3",
['功能配置']={
changan.box({
    "主标题",
    changan.button("测试1", function() end),
    changan.button("测试2", function() end),
}, "副标题"),
}},

}---
第二页 = {
['分页名字']="防封",
[1]={--第一分区
['分区名字']="检测",
['功能配置']={
changan.switch(
"hook测试一下",
function()
gg.alert("测试")
end),
},},
[2]={--第二分区
['分区名字']="旁白区",
['功能配置']={
},}
}
第三页 = {
['分页名字']="美化",
[1]={--第一分区
['分区名字']="分区",
['功能配置']={
},}
}
第四页 = {
['分页名字']="功能",
[1]={--第一分区
['分区名字']="功能区域",
['功能配置']={
},}
}
第五页 = {
['分页名字']="设置",
[1]={--第一分区
['分区名字']="分区",
['功能配置']={
changan.switch(
"退出",
function()
tuichu=1
end),
},}
}
QQ群号=1033843670
菜单图片 = {-- 注:一定要对接changan.menu
--:例如 我又添加了第..页  也要给菜单图片也要加
--也可以把getRes 换成 获取图片 这样的话就可以菜单图片也可以用链接
    {getRes("lchome")},
    {getRes("lcff")},
    {getRes("lcsh")},
    {getRes("lcjs")},
    {getRes("lcsz")},
}
changan.menu({
第一页,--调用上边的分页配置
第二页,
第三页,
第四页,
第五页,
})