dex.loadfile("/sdcard/那年冬/年冬/CircleImageView.dex")
import("android.widget.CircleImageView")
local baseWindow = require 'floatingWindowManager2'
baseWindow:darkMode()
baseWindow:lightMode()
local ui = require('ui')
import "android.animation.LayoutTransition"
layoutTransition=LayoutTransition()
layoutTransition:setDuration(900)
import("android.view.animation.Animation")
import("android.animation.ObjectAnimator")
import("android.view.animation.ScaleAnimation")
context:setTheme(0xff98C6D5)
import 'com.google.android.material.progressindicator.LinearProgressIndicator'
local window = require('windowManager')
local ui = require('ui')
file.checkFile("/sdcard/那年冬/年冬/收藏歌单")
local musiclist = file.read("/sdcard/那年冬/年冬/收藏歌单")
if musiclist ~= "" then
musiclist = load("return"..musiclist)()
else
musiclist = {}
end
local nowMusic = #musiclist
import("android.media.MediaPlayer")
mediaPlayer=MediaPlayer()
local currentLyrics = "词:未播放歌曲"
local lyricCache = {}
local lyricLineCache = {}
currentLyricColor = "#fffffff"
defaultLyricColor = "#d6d6d6"
local isPlaying = false
local 音量键 =false
local isReady = false
import "android.animation.ArgbEvaluator"
import "android.animation.ValueAnimator"
import("android.content.res.ColorStateList")
dex.loadfile("/sdcard/那年冬/年冬/Lottie.dex")
import "com.airbnb.lottie.*"
local typeface = import("android.graphics.Typeface")
local FontPath = "/storage/emulated/0/那年冬/年冬/软糖.ttf"
local font = typeface:createFromFile(FontPath)
import "android.animation.ValueAnimator"
import "android.graphics.Path"
import "android.view.animation.*"
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])
_ENV['tupian'..当前ui..当前分区[当前ui]]:setColorFilter(0xff000000)
_ENV['tupian'..当前ui..i]:setColorFilter(0xff9C9FA5)
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
changan.pauseRotation = function()
luajava.runUiThread(function()
if rotateAnimator ~= nil and rotateAnimator:isRunning() then
rotateAnimator:pause()
end
end)
end
local rotateAnimator1 = nil
changan.controlRotation1 = function(control, time)
luajava.runUiThread(function()
import "android.view.animation.Animation"
import "android.animation.ObjectAnimator"
if rotateAnimator1 ~= nil then
if rotateAnimator1:isPaused() then
rotateAnimator1:resume()
end
return
end
rotateAnimator1 = ObjectAnimator:ofFloat(control, "rotation", {0, 360})
rotateAnimator1:setRepeatCount(-1)
rotateAnimator1:setRepeatMode(Animation.RESTART)
rotateAnimator1:setDuration(time)
rotateAnimator1:start()
end)
end
changan.pauseRotation1 = function()
luajava.runUiThread(function()
if rotateAnimator1 ~= nil and rotateAnimator1:isRunning() then
rotateAnimator1:pause()
end
end)
end
function proo()
changan.controlRotation(IslandPic1, 10000)
end
function proo1()
changan.pauseRotation()
end
function proo3()
changan.controlRotation1(IslandPic2, 10000)
end
function proo4()
changan.pauseRotation1()
end
function getpx(x)
if type(x) == 'string' then
if string.find(x, 'dp') then
x = string.gsub(x, 'dp', '')
x = tonumber(x)
end
return x * (context:getResources():getDisplayMetrics().densityDpi / 160)
else
return x
end
end
local DP40 = getpx("40dp") -- 悬浮球尺寸
function write(fileName, content)
file.write(fileName, content)
end
local function 获取年冬(txt)
txt = string.url(txt,"de")
ntxt = string.sub(string.gsub(txt,"/","-"),-10,-1)
if string.find(tostring(txt),"http") ~= nil then
if panduan("/sdcard/那年冬/年冬/"..ntxt) == false then
file.download(txt,"/sdcard/那年冬/年冬/"..ntxt)
else
if file.length("/sdcard/那年冬/年冬/"..ntxt) <= 1 then
file.download(txt,"/sdcard/那年冬/年冬/"..ntxt)
end
end
txt = "/sdcard/那年冬/年冬/"..ntxt
end
return luajava.getBitmapDrawable(txt)
end
local function getRes(x)
return 获取年冬("/sdcard/那年冬/年冬/"..x)
end
function panduan(rec) fille,err = io.open(rec) if fille == nil then return false else return true 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_FOCUSABLE
layoutParams.gravity = Gravity.TOP|Gravity.LEFT
layoutParams.width = LayoutParams.WRAP_CONTENT
layoutParams.height = LayoutParams.WRAP_CONTENT
return layoutParams
end
slctb = luajava.loadlayout {
GradientDrawable,
color = "#00000000",
cornerRadius = 30
}
slcta = getVerticalBG({0xffE6EEF9,0xffE6EEF9},10,2,0xff969FAE)
slctb1 = getVerticalBG({0xffE6EEF9,0xffE6EEF9},10,2,0xff969FAE)
slcta1 = getVerticalBG({0xdd66709A,0xdd66709A},10,2,0xdd66709A)
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
YoYoImpl = luajava.getYoYoImpl()
changan.menu = function(sview)
forsview = sview
菜单页数=#sview
当前分区={} 分区页数={}
侧边={} 功能区={}
IslandPic2=luajava.loadlayout({
CircleImageView,
id=luajava.newId("IslandPic2"),
src=获取年冬(xfcpic),
layout_width="70dp",
layout_height="70dp",
clipToOutline=true,
onClick=function() 灵动岛() end,
})
IslandPic1=luajava.loadlayout({
CircleImageView,
id=luajava.newId("IslandPic"),
src=获取年冬(xfcpic),
layout_width="25dp",
layout_height="25dp",
layout_marginLeft="8dp",
clipToOutline=true,
onClick=function() 灵动岛() end,
})
cebian = {
LinearLayout,
id = "cebiannn",
layout_marginTop="5dp",
layout_marginLeft="2dp",
background = "#00000000",
layout_height = "match_parent",
layout_width = "match_parent",
orientation = "vertical",
gravity = "center_horizontal",
}
顶边 = {
LinearLayout,
background = "#00000000",
layout_height = "wrap_content",
layout_width = "match_parent",
gravity = "center_vertical",
}
for i = 1,菜单页数 do
分区页数[i]= #sview[i]
table.insert(cebian,
{
TextView,
Typeface=font,
id="jm"..i,
gravity = "center",
text=sview[i]['分页名字'],
layout_width = "90dp",
onClick = function() 切换(i) end,
layout_height = "23dp",
textColor = "#66709A",
textSize = "14sp",
})
功能区[i]={}
local layoutm={
LinearLayout,
id = "layoutm"..i,
layout_marginLeft = "10dp",
layout_width = "match_parent",
orientation = "vertical",
gravity = "center_horizontal",
}
local 顶边菜单 = {
LinearLayout,
layout_margin="5dp",
id = "cebigannn",
background = "#00000000",
layout_height = "wrap_content",
layout_width = "match_parent",
orientation = "horizontal",
}
for j = 1,分区页数[i] do
table.insert(顶边菜单,
{
TextView,
Typeface=font,
layout_height = "23dp",
layout_marginLeft="3dp",
layout_marginRight="3dp",
paddingLeft = "8dp",
paddingRight = "8dp",
layout_width = "wrap_content",
gravity = "center",
text = sview[i][j]['分区名字'],
id="dingwen"..i..j,
onClick = function() 分区(j) end,
background=slctb1,
textColor = "#66709A",
textSize = "12sp",
})
侧边[i] = luajava.loadlayout(
{
HorizontalScrollView,
layout_height = "35dp",
visibility = "gone",
layout_width = "match_parent",
顶边菜单
})
table.insert(顶边,侧边[i])
local menulayout={
LinearLayout,
layout_width='match_parent',
layout_height='wrap_content',
orientation = "vertical",
id='menu'..i..j,
}
for k,v in pairs(sview[i][j]['功能配置']) do
table.insert(menulayout,v)
end
local menulayout=menulayout
功能区[i][j]=menulayout
table.insert(layoutm,menulayout)
end
local menus={
LinearLayout,
layout_width = "250dp",
layout_height = "280dp",
orientation = "vertical",
padding = {
"5dp","1dp","0dp","0dp"
},
{
ScrollView,
fillViewport = "true",
gravity = "center",
layout_width = "match_parent",
layout_height = "match_parent",
orientation = "horizontal",
layoutm
}}
_ENV["layout"..i] =luajava.loadlayout(menus)
end
control=luajava.loadlayout({ImageView,
id = "control",
background = 获取年冬(xfcpic),
layout_width = "40dp",
layout_height = "40dp",
onTouch = hanshu,
onClick = 隐藏,})
ckou = {
LinearLayout,
layout_width = "match_parent",
layout_height = "match_parent",
orientation = "vertical",
}
for i = 1,菜单页数 do
ckou[#ckou+1] = _ENV["layout"..i]
end
ckou=luajava.loadlayout(ckou)
heir=getRes("heir")
leftbar=luajava.loadlayout({
LinearLayout,
orientation = "vertical",
padding = "1dp",
layout_height = "match_parent",
{
MaterialCardView,
id="cnm",
layout_width='100dp',
layout_height='70dp',
useCompatPadding=false,
layout_margin='3dp',
cardElevation='5dp',
cardBackgroundColor=获取年冬(左上角头像),
strokeColor=0x00ffffff,
background=getVerticalBG({0xffFEFEFD,0xffFEFEFD},15,2,0xffD7D7D7),
onClick=隐藏,
onTouch=hanshu,
__onCreate=function(v)
v:setRadius(20)
local c=ColorStateList({{android.R.attr.state_pressed},{-android.R.attr.state_pressed}}, {0x00ffffff,0x00ffffff})
v:setRippleColor(c)
end,
{
ImageView,
layout_width='match_parent',
layout_height='55dp',
gravity='center',
background=获取年冬(左上角头像),
},
{
TextView,
layout_width='match_parent',
layout_height='10dp',
gravity='center',
textSize='10sp',
Typeface=font,
textColor = "#66709A",
layout_marginBottom = "3dp",
layout_gravity='bottom',
text=左上角标题,
},
},
{
LinearLayout,
layout_width = "match_parent",
layout_height = "0dp",
layout_weight = 1,
orientation = "vertical",
cebian,
},
{
TextView,
Typeface = font,
layout_width = "match_parent",
layout_height = "20dp",
gravity = "center",
id="banben",
textSize = "12sp",
textColor = "#66709A",
text = "Version:1.0",
},
})
musicldd=luajava.loadlayout({
FrameLayout,
layout_gravity="center",
id="shadow",
visibility="gone",
{MaterialCardView,
__onCreate=function(v)
v:setRadius(20)
local c=ColorStateList({{android.R.attr.state_pressed},{-android.R.attr.state_pressed}}, {0x00ffffff,0x00ffffff})
v:setRippleColor(c)
end,
{
LinearLayout,
id="Island",
layout_height="280dp",
layout_width="468dp",
visibility="gone",
layout_gravity="center",
background=获取年冬("https://wp.kayyw.com/f/bYqEIv/1769681744187.jpg"),
onClick=function() end,
{
LinearLayout,
id=luajava.newId("music"),
layout_height="fill_parent",
layout_width="fill_parent",
layout_gravity="center|top",
orientation="vertical",
{
LinearLayout,
layout_height="230dp",
gravity="center|left",
orientation="horizontal",
layout_width="460dp",
onClick=function() end,
{
ImageView,
layout_gravity="center|top",
src = "/storage/emulated/0/那年冬/年冬/111",
ColorFilter="#FAFAFA",
background = getVerticalBG({0x80000000,0x80000000},20),
layout_marginLeft = "5dp",
layout_marginTop = "5dp",
layout_width = "25dp",
layout_height = "25dp",
onClick=function()
canSwipeUp=false
canSwipeDown=true
if 灵动 then
luajava.startThread(function()
luajava.runOnUiThread(function()
changan.controlSmall(shadow,1500)
Island:setVisibility(View.GONE)
luajava.getIdView("music"):setVisibility(View.INVISIBLE)
end)
灵动=false
gg.sleep(500)
end)
end
end,
},
{
LinearLayout,
layout_marginLeft = "25dp",
layout_height="125dp",
layout_width="125dp",
layout_gravity="center|left",
gravity="center",
background=获取年冬("https://wp.kayyw.com/f/JDpjCx/1762874221285.jpg.png"),
IslandPic2,
},
{
LinearLayout,
orientation="vertical",
layout_width="230dp",
layout_marginLeft = "20dp",
layout_gravity="center|top",
layout_height="wrap_content",
gravity="center_horizontal",
{
LinearLayout,
layout_height="wrap_content",
layout_width="fill_parent",
orientation="vertical",
{
TextView,
id="Mname",
gravity="center",
layout_width="fill_parent",
layout_height="wrap_content",
layout_marginTop="10dp",
Typeface = font,
text="当前无音乐播放",
ellipsize="marquee",
singleLine=true,
selected=true,
textColor="#FAFAFA",
textSize="12dp",
},
{
TextView,
id="GSname",
gravity="center",
layout_width="fill_parent",
Typeface = font,
layout_height="wrap_content",
text="作者:xxx",
ellipsize="marquee",
singleLine=true,
selected=true,
textColor="#000000",
textSize="8dp",
},
},
{
ScrollView,
layout_width="fill_parent",
layout_height="wrap_content",
scrollbars="vertical",
fadingEdge="vertical",
{
TextView,
id=luajava.newId("Muname"),
gravity="center_horizontal|top",
layout_width="fill_parent",
layout_height="wrap_content",
Typeface = font,
layout_marginTop="5dp",
layout_marginBottom="5dp",
text="词:未播放歌曲",
ellipsize="none",
selected=true,
textColor="#FAFAFA",
textSize="12dp",
__onFinish = function(v)
v:setLineSpacing(dpToPx(4), 1.2)
end,
}
}
}
},
{
LinearLayout,
gravity="center",
layout_width='match_parent',
layout_height='20dp',
{
Slider,
id="hkuai",
trackStopIndicatorSize="0dp",
stepSize=1,
valueTo=100,
valueFrom=0,
trackHeight="6dp",
ThumbHeight="12dp",
tickVisible=false,
thumbWidth="3dp",
layout_width='match_parent',
layout_height='wrap_content',
labelFormatter=function(seconds)
if isPlaying then return ctime(seconds) else return "0:00" end
end,
addOnChangeListener=function(slider, value, fromUser)
if fromUser and isPlaying and isReady then mediaPlayer:seekTo(value*1000) end
end
},
},
{
LinearLayout,
layout_width='468dp',
layout_height='30dp',
background = getVerticalBG({0x80000000,0x80000000},0),
{
LinearLayout,
layout_weight=1,
layout_width="match_parent",
layout_height="match_parent",
gravity="center",
{
TextView,
id="ntime",
gravity="center|right",
layout_width="wrap_content",
layout_height="wrap_content",
text="0:00",
textColor="#FAFAFA",
textSize="11dp",
},
{
TextView,
gravity="center|right",
layout_width="wrap_content",
layout_height="wrap_content",
text="/",
textColor="#FAFAFA",
textSize="11dp",
},
{
TextView,
id="atime",
gravity="center|left",
layout_width="wrap_content",
layout_height="wrap_content",
text="0:00",
textColor="#FAFAFA",
textSize="11dp",
},
},
{
LinearLayout,
id=luajava.newId("Collection"),
layout_weight=1,
layout_width="match_parent",
layout_height="match_parent",
gravity="center",
{
ImageView,
id="souc",
src="/sdcard/那年冬/年冬/unlove",
layout_width="20dp",
layout_height="20dp",
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/那年冬/年冬/last",
layout_width="25dp",
layout_height="25dp",
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="25dp",
layout_height="25dp",
onClick=function() 暂停() end,
},
},
{
LinearLayout,
id=luajava.newId("NextSong"),
layout_weight=1,
layout_width="match_parent",
layout_height="match_parent",
gravity="center",
{
ImageView,
src="/sdcard/那年冬/年冬/next",
layout_width="25dp",
layout_height="25dp",
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",
src="/sdcard/那年冬/年冬/setPlay",
layout_width="20dp",
layout_height="20dp",
onClick=function() 播放设置() end,
ColorFilter="#FAFAFA",
},
},
{
LinearLayout,
layout_weight=1,
layout_width="match_parent",
layout_height="match_parent",
gravity="center",
{
ImageView,
src="/sdcard/那年冬/年冬/playlist",
layout_width="20dp",
layout_marginLeft="match_parent",
layout_marginRight="15dp",
layout_gravity="center|right",
layout_height="20dp",
onClick=function() 播放列表() end,
ColorFilter="#FAFAFA",
}
},
}}
}
},
})
linelm=luajava.loadlayout({
LinearLayout,
layout_width = "1dp",
layout_height = "fill_parent",
background = "#D7D7D7"
})
centerbar=luajava.loadlayout({LinearLayout,
layout_width='match_parent',
layout_height='match_parent',
orientation='vertical',
{LinearLayout,
layout_width = "match_parent",
layout_height = "35dp",
orientation = "horizontal",
gravity = "center_vertical",
paddingLeft = "10dp",
{ImageView,
src=heir,
rotation=180,
layout_height="18dp",
layout_width="20dp",
ColorFilter=0xffB8B8B8,
onClick=function() if 当前分区[当前ui] > 1 then
分区(当前分区[当前ui] - 1)
end end,
onTouch=hanshu,
id=luajava.newId('toleft'),
},{ImageView,
src=heir,
layout_height="18dp",
onClick=function() if 当前分区[当前ui] < 分区页数[当前ui] then
分区(当前分区[当前ui] + 1)
end end,
layout_width="20dp",
ColorFilter=0xffB8B8B8,
id=luajava.newId('toright'),
},
{
HorizontalScrollView,
HorizontalScrollBarEnabled=false,
layout_height='wrap_content',
layout_width="210dp",
fillViewport = "true",
顶边,}
},
ckou,})
rightbar=luajava.loadlayout({LinearLayout,
id="yj1",
orientation='vertical',
layout_gravity = "right|top",
{
MaterialCardView,
orientation = "horizontal",
layout_width = "95dp",
layout_height = "25dp",
layout_margin = "2dp",
background=getVerticalBG({0xffFEFEFD,0xffFEFEFD},15,2,0xffD7D7D7),
cardElevation='3dp',
strokeColor=0x00ffffff,
onClick=隐藏,
onTouch=hanshu,
{
ImageView,
padding = "5dp",
src = getRes("lcsz"),
ColorFilter=0xff66709A,
layout_width = "wrap_content",
layout_height = "wrap_content",
layout_marginLeft = "5dp",
layout_gravity="center_vertical|left",
onClick = 隐藏,
onTouch = hanshu,
},
{
LinearLayout,
layout_width = "1dp",
layout_margin = "3dp",
layout_height = "match_parent",
background = "#D7D7D7",
layout_gravity = "center",
},
{
ImageView,
padding = "5dp",
layout_gravity = "right",
src = getRes("heix"),
ColorFilter=0xff66709A,
layout_width = "wrap_content",
layout_height = "wrap_content",
layout_marginRight = "5dp",
layout_gravity="center_vertical|right",
onClick = 隐藏,
onTouch = hanshu,
}
},
{
MaterialCardView,
orientation = "horizontal",
layout_marginTop = "5dp",
layout_width = "95dp",
layout_height = "25dp",
layout_margin = "2dp",
background=getVerticalBG({0xffFEFEFD,0xffFEFEFD},15,2,0xffD7D7D7),
cardElevation='3dp',
strokeColor=0x00ffffff,
{
LinearLayout,
gravity="center_vertical",
layout_height="match_parent",
layout_width = "match_parent",
{LinearLayout,
layout_weight=1,
layout_height='34dp',
layout_marginTop='3dp',
layout_marginBottom='3dp',
layout_marginLeft='3dp',
layout_marginRight='3dp',
layout_width='match_parent',
padding='3dp',
elevation='2dp',
{ScrollView,
id='ggscro',
layout_height='match_parent',
layout_width='match_parent',
{LinearLayout,
id='gggscro',
orientation='vertical',
layout_margin = "1dp",
layout_width='match_parent',
layout_height='wrap_content',
}
}
}
} },
{
MaterialCardView,
orientation = "horizontal",
layout_marginTop = "5dp",
layout_width = "95dp",
layout_height = "50dp",
layout_margin = "2dp",
cardElevation='3dp',
strokeColor=0x00ffffff,
background=getVerticalBG({0xffFEFEFD,0xffFEFEFD},15,2,0xffD7D7D7),
{LinearLayout,
layout_gravity = "center",
gravity = "center",
layout_height="40dp",
layout_width="40dp",
background="https://wp.kayyw.com/f/JDpjCx/1762874221285.jpg.png",
IslandPic1,
},
},
{
MaterialCardView,
cardBackgroundColor="/storage/emulated/0/那年冬/年冬/yjttkx",
layout_marginTop = "5dp",
layout_width = "95dp",
layout_height = "155dp",
layout_margin = "1dp",
cardElevation='3dp',
strokeColor=0x00ffffff,
background=getVerticalBG({0xffFEFEFD,0xffFEFEFD},15,2,0xffD7D7D7),
{
ImageView,
layout_width='match_parent',
layout_height='155dp',
gravity='center',
background="/storage/emulated/0/那年冬/年冬/yjttkx",
},
},
})
floatWindow = {
FrameLayout,
id = "motion",
elevation = "10dp",
onTouch = hanshu,
onClick = function() end,
layout_width = "470dp",
orientation = "vertical",
gravity = "center_vertical",
layout_height = "wrap_content",
{
LinearLayout,
id = "chuangk",
background=beij,
visibility = "visible",
layout_width = "wrap_content",
layout_height = "wrap_content",
orientation = "horizontal",
leftbar,
linelm,
centerbar,
rightbar},musicldd,
control,
}
local function invoke()
local ok
local RawX, RawY, x, y
mainLayoutParams = getLayoutParams()
floatWindow = luajava.loadlayout(floatWindow)
local function invoke2()
block('start')
window:addView(floatWindow, mainLayoutParams)
block('end')
end
local runnable = luajava.getRunnable(invoke2)
local handler = luajava.getHandler()
handler:post(runnable)
block('join')
local isMove
end
invoke(swib1,swib2)
隐藏()
uiadtext(" UI启动成功.","#161616")
切换(1)
分区(1)
gg.setVisible(false)
luajava.setFloatingWindowHide(true)
setOnExitListener(function()
mediaPlayer:reset()
mediaPlayer:release()
window:removeView(floatWindow)
tuichu=1
end)
function SliderColor(id,color1,color2,color3)
id:setTrackActiveTintList(ColorStateList({{}},{"0xff"..color1}))
id:setTrackInactiveTintList(ColorStateList({{}},{"0x55"..color2}))
id:setThumbTintList(ColorStateList({{}},{"0x55"..color3}))
end
function SwitchColor(id,color)
id:setTrackTintList(ColorStateList({{android.R.attr.state_checked}},{color}))
end
SliderColor(hkuai,"ffffff","ffffff","FFFFFF")
ztkq:setAnimationFromJson(io.open("/sdcard/那年冬/年冬/Pause", "r"):read("*all"))
while true do
if tuichu == 1 then os.exit() end
if 音量键 then
jianting3(qiehuan)
gg.sleep(300)
end
if isPlaying and isReady and #musiclist ~= 0 then
luajava.runOnUiThread(function()
local currentPos = mediaPlayer:getCurrentPosition()
ntime:setText(ctime(math.floor(currentPos/1000)))
hkuai:setValue(math.floor(currentPos/1000))
syncLyricWithProgress(currentPos)
end)
end
gg.sleep(60)
end
end
function souyy(txt)
return table.json(gg.makeRequest("http://music.163.com/api/search/get?s="..txt.."&type=1&offset=0&total=true&limit=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)
YoYoImpl:with("FadeIn"):duration(500):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)
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=getVerticalBG({0xffE6EEF9,0xffE6EEF9},10,2,0xff969FAE),
layout_width="match_parent",
strokeWidth=0,
layout_margin = "2dp",
{
LinearLayout,
orientation="vertical",
padding="3dp",
gravity="center",
layout_width="match_parent",
{
TextView,
textSize="14sp",
textColor="#66709A",
Typeface = font,
layout_hight="10dp",
layout_width="wrap_content",
gravity="center"
},
{
TextView,
textColor="#000000",
textSize="10sp",
Typeface = font,
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/那年冬/年冬/收藏歌单",lovemusic)
end
function 灵动岛()
luajava.runOnUiThread(function()
end)
luajava.getIdView("music"):setVisibility(View.VISIBLE)
if 灵动 then
luajava.startThread(function()
luajava.runOnUiThread(function()
changan.controlSmall(shadow1,1500)
Island:setVisibility(View.GONE)
end)
灵动=false
luajava.runOnUiThread(function()
end)
end)
else
luajava.startThread(function()
luajava.runOnUiThread(function()
Island:setVisibility(View.VISIBLE)
end)
灵动=true
luajava.runOnUiThread(function()
luajava.getIdView("music"):setVisibility(View.VISIBLE)
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 playMusic(id)
pcall(function()
mediaPlayer:reset()
mediaPlayer:setDataSource("/sdcard/那年冬/年冬/音乐缓存/"..id)
mediaPlayer:prepare()
luajava.getIdValue("IslandPic"):setImageDrawable(获取年冬("/sdcard/那年冬/年冬/音乐缓存/Pic2"..id))
luajava.getIdValue("IslandPic2"):setImageDrawable(获取年冬("/sdcard/那年冬/年冬/音乐缓存/Pic2"..id))
proo()
proo3()
end)
end
function parseLyrics(lyricText)
local lines = {}
if not lyricText or lyricText == "" then return lines end
for line in lyricText:gmatch("[^\r\n]+") do
local timeStr, text = line:match("%[(%d+:%d+%.?%d*)%](.*)")
if timeStr and text then
local textTrimmed = text:trim()
if textTrimmed ~= "" then
local minutes, seconds = timeStr:match("(%d+):(%d+%.?%d*)")
if minutes and seconds then
local totalMs = math.floor((tonumber(minutes) * 60 + tonumber(seconds)) * 1000)
table.insert(lines, {
timestamp = totalMs,
text = textTrimmed
})
end
end
end
end
table.sort(lines, function(a, b) return a.timestamp < b.timestamp end)
for i, line in ipairs(lines) do
line.text = line.text:gsub("\r\n", "\n"):gsub("\r", "\n")
end
return lines
end
function getLyrics(songId)
if not songId then return "暂无歌词", {} end
if lyricCache[songId] and lyricLineCache[songId] then
return lyricCache[songId], lyricLineCache[songId]
end
local url = "http://music.163.com/api/song/lyric?os=pc&id=" .. songId .. "&lv=-1&kv=-1&tv=-1"
local success, response = pcall(gg.makeRequest, url)
if not success or not response or not response.content then
lyricCache[songId] = "歌词加载失败:网络异常"
lyricLineCache[songId] = {}
return lyricCache[songId], lyricLineCache[songId]
end
local jsonData = table.json(response.content)
if not jsonData or not jsonData.lrc or not jsonData.lrc.lyric then
lyricCache[songId] = "暂无歌词"
lyricLineCache[songId] = {}
return lyricCache[songId], lyricLineCache[songId]
end
local originalLyrics = jsonData.lrc.lyric
local translatedLyrics = jsonData.tlyric and jsonData.tlyric.lyric and jsonData.tlyric.lyric ~= ""
and jsonData.tlyric.lyric or ""
local mergedLyric, formattedLines = mergeLyrics(originalLyrics, translatedLyrics)
lyricCache[songId] = mergedLyric
lyricLineCache[songId] = formattedLines
return mergedLyric, formattedLines
end
function mergeLyrics(original, translated)
local origLines = parseLyrics(original)
local transLines = parseLyrics(translated)
if #origLines == 0 then
return "暂无歌词", {}
end
local result = ""
local formattedLines = {}
local transMap = {}
for _, trans in ipairs(transLines) do
transMap[trans.timestamp] = trans.text
end
local matchThreshold = 300
for _, origLine in ipairs(origLines) do
local transText = nil
if transMap[origLine.timestamp] then
transText = transMap[origLine.timestamp]
else
for transTs, text in pairs(transMap) do
if math.abs(transTs - origLine.timestamp) < matchThreshold then
transText = text
break
end
end
end
result = result .. origLine.text .. "\n"
if transText then
result = result .. "「" .. transText .. "」\n"
table.insert(formattedLines, {
timestamp = origLine.timestamp,
fullText = origLine.text .. "\n「" .. transText .. "」"
})
else
table.insert(formattedLines, {
timestamp = origLine.timestamp,
fullText = origLine.text
})
end
end
result = result:gsub("\n$", ""):gsub("\r\n", "\n"):gsub("\r", "\n")
return result, formattedLines
end
function getMusicPictures(id)
local briefIntroduction = table.json(file.read("/sdcard/那年冬/年冬/音乐缓存/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 syncLyricWithProgress(progressMs)
if not currentFormattedLyrics or #currentFormattedLyrics == 0 then
return
end
luajava.runOnUiThread(function()
local scrollView = luajava.getIdView("Muname"):getParent()
local munameView = luajava.getIdView("Muname")
if not munameView or not isPlaying or not scrollView then
return
end
local targetIndex = 1
for i = #currentFormattedLyrics, 1, -1 do
if currentFormattedLyrics[i].timestamp <= progressMs then
targetIndex = i
break
end
end
local fullLyric = ""
for i = 1, #currentFormattedLyrics do
local lineText = currentFormattedLyrics[i].fullText:gsub("\n", "
")
if i == targetIndex then
fullLyric = fullLyric .. "" .. lineText .. "
"
else
fullLyric = fullLyric .. "" .. lineText .. "
"
end
end
fullLyric = fullLyric:gsub("
$", "")
munameView:setText(string.fromHtml(fullLyric))
munameView:setLineSpacing(dpToPx(8), 1.5)
local lineHeight = munameView:getLineHeight()
local scrollY = (targetIndex - 2) * lineHeight
scrollY = math.max(0, scrollY)
scrollView:smoothScrollTo(0, scrollY)
end)
end
function updateLyricDisplay(songId)
luajava.newThread(function()
local lyricText, formattedLines = getLyrics(songId)
luajava.runOnUiThread(function()
local scrollView = luajava.getIdView("Muname"):getParent()
local munameView = luajava.getIdView("Muname")
if not munameView or not scrollView then
return
end
local defaultFullLyric = "" .. lyricText .. ""
munameView:setText(string.fromHtml(defaultFullLyric))
munameView:setLineSpacing(dpToPx(6), 1.3)
munameView:setGravity(Gravity.CENTER_HORIZONTAL + Gravity.TOP)
currentFormattedLyrics = formattedLines
scrollView:fullScroll(View.FOCUS_DOWN)
scrollView:scrollTo(0, 0)
end)
end):start()
end
function 播放歌曲(id)
isReady=false
if #musiclist == 0 then return end
if isPlaying==false then ztkq:setSpeed(1) ztkq:playAnimation() isPlaying=true end
currentFormattedLyrics = {}
if file.length("/sdcard/那年冬/年冬/音乐缓存/"..id) ~= 0 or file.length("/sdcard/那年冬/年冬/音乐缓存/Pic2"..id) ~= 0 then
playMusic(id)
updateLyricDisplay(id)
else
luajava.startThread(function()
local co = coroutine.create(function()
local success = file.download("http://music.163.com/song/media/outer/url?id=".. id.. ".mp3","/sdcard/那年冬/年冬/音乐缓存/".. id)
file.download('http://music.163.com/api/song/detail/?id='..id..'&ids=['..id..']',"/sdcard/那年冬/年冬/音乐缓存/pic".. id)
file.download(getMusicPictures(id),"/sdcard/那年冬/年冬/音乐缓存/Pic2"..id)
return success
end)
local status, result = coroutine.resume(co)
if status and result then
playMusic(id)
updateLyricDisplay(id)
else
gg.alert("播放失败\n下载出现问题,无法播放音乐")
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)
Mname:setText(musiclist[nowMusic][2])
GSname:setText(musiclist[nowMusic][3])
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 isPlaying then
ztkq:setSpeed(-1)
ztkq:playAnimation()
proo1()
proo4()
if isReady then
proo1()
proo4()
mediaPlayer:pause()
end
isPlaying=false
else
if isReady then
mediaPlayer:start()
end
ztkq:setSpeed(1)
proo()
proo3()
ztkq:playAnimation()
isPlaying=true
end
end
function 下一首()
if #musiclist == 0 then MaterialAlert("列表没有可播放歌曲,请前往音乐界面添加!")
切换(5)
luajava.runOnUiThread(function()
end) return end
nowMusic=nowMusic + 1
if nowMusic > #musiclist then
nowMusic=1
end
musicInfo=musiclist[nowMusic]
播放歌曲(musicInfo[1])
end
function 上一首()
if #musiclist == 0 then MaterialAlert("列表没有可播放歌曲,请前往音乐界面添加!")
luajava.runOnUiThread(function()
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",
Typeface = font,
layout_height="wrap_content",
layout_gravity="center",
gravity="center",
textColor="#27253A",
},
{
ImageView,
id="songremove",
src="/sdcard/那年冬/年冬/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
function uiadtext(txt,color,size)
if not txt then txt = "" end
if not color then color = "#000000" end
if not size then size = "10sp" end
local tmp=luajava.loadlayout(
{
TextView,
Typeface=font,
text = string.fromHtml(" "..getTimeStamp55(os.time()).." "..txt..""),
textSize = size,
gravity="left",
layout_width = "wrap_content",
})
luajava.post(function()
gggscro:addView(tmp)
end)
luajava.newThread(function()
gg.sleep(100)
luajava.post(function()
ggscro:fullScroll(View.FOCUS_DOWN)
end)
end):start()
end
function addadView(tmp)
local function invoke()
parentv:addView(tmp)
end
luajava.post(invoke)
end
function rmdadView(tmp)
local function invoke()
parentv:removeView(tmp)
end
luajava.post(invoke)
end
function getTimeStamp55(t)
local str = os.date("%H:%M:%S",t)
return str
end
当前ui = 1
function 切换(x)
当前ui = x
luajava.runUiThread(function()
if 当前分区[当前ui]==nil then
分区(1)
else
for i=1,分区页数[当前ui] do
_ENV['dingwen'..当前ui..i]:setBackground(getVerticalBG({0xffE6EEF9,0xffE6EEF9},10,2,0xff969FAE))
_ENV['dingwen'..当前ui..i]:setTextColor(0xff66709A)
end
_ENV['dingwen'..当前ui..当前分区[当前ui]]:setBackground(getVerticalBG({0xdd66709A,0xdd66709A},10,2,0xdd66709A))
_ENV['dingwen'..当前ui..当前分区[当前ui]]:setTextColor(0xffffffff)
end
for i = 1,菜单页数 do
_ENV["layout"..i]:setVisibility(View.GONE)
_ENV["jm"..i]:setBackground(slctb)
侧边[i]:setVisibility(View.GONE)
end
_ENV["layout"..当前ui]:setVisibility(View.VISIBLE)
侧边[当前ui]:setVisibility(View.VISIBLE)
_ENV["jm"..当前ui]:setBackground(slcta)
currentFuncLayout = _ENV['menu'..当前ui..当前分区[当前ui]]
end)
end
function 分区(x)
当前分区[当前ui]=x
luajava.runUiThread(function()
for i=1,分区页数[当前ui] do
_ENV['menu'..当前ui..i]:setVisibility(View.GONE)
_ENV['dingwen'..当前ui..i]:setBackground(getVerticalBG({0xffE6EEF9,0xffE6EEF9},10,2,0xff969FAE))
_ENV['dingwen'..当前ui..i]:setTextColor(0xff66709A)
end
_ENV['menu'..当前ui..当前分区[当前ui]]:setVisibility(View.VISIBLE)
_ENV['dingwen'..当前ui..当前分区[当前ui]]:setBackground(getVerticalBG({0xdd66709A,0xdd66709A},10,2,0xdd66709A))
_ENV['dingwen'..当前ui..当前分区[当前ui]]:setTextColor(0xffffffff)
currentFuncLayout = _ENV['menu'..当前ui..当前分区[当前ui]]
end)
end
显示 = 0
beij = luajava.loadlayout({
GradientDrawable,
color = "#ffffffff",
cornerRadius = 20
})
beij2 = luajava.loadlayout({
GradientDrawable,
color = "#001E1C27",
cornerRadius = 10
})
import "android.animation.FloatEvaluator"
import "android.view.animation.AccelerateDecelerateInterpolator"
显示 = 0
function 隐藏()
luajava.runUiThread(function()
if tonumber(tostring(control:getVisibility())) == 0 then
control:setVisibility(View.GONE)
显示 = 1
luajava.runUiThread(function()
height1 = DP40
width1 = DP40
local animator = ValueAnimator:ofFloat({0, 1})
animator:setDuration(600)
-- 三阶贝塞尔曲线(回弹插值:先快后回弹收尾,更自然)
local path = Path()
path:moveTo(0.0, 0.0)
path:cubicTo(0.4, 0.0, 0.2, 1.0, 1.0, 1.0)
animator:setInterpolator(PathInterpolator(path)) -- 绑定贝塞尔插值
local listener = luajava.createProxy('android.animation.ValueAnimator$AnimatorUpdateListener', {
onAnimationUpdate = function(animation)
local animatedProgress = animation:getAnimatedValue()
if animatedProgress > 1 then
animatedProgress = 1 + (animatedProgress - 1) / 6
end
mainLayoutParams.height = height1 + (getpx("300") - height1) * animatedProgress
mainLayoutParams.width = width1 + (getpx("470") - width1) * animatedProgress
window:updateViewLayout(floatWindow, mainLayoutParams)
end
})
animator:addUpdateListener(listener)
local listener = luajava.createProxy('android.animation.Animator$AnimatorListener', {
onAnimationStart = function()
YoYoImpl:with("FadeOut"):duration(1000):playOn(control)
chuangk:setVisibility(View.VISIBLE)
end,
onAnimationEnd = function()
control:setVisibility(View.GONE)
chuangk:setVisibility(View.VISIBLE)
shadow:setVisibility(View.VISIBLE)
end,
onAnimationCancel = function(animator)
end
})
animator:addListener(listener)
animator:start()
end)
mainLayoutParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
window:updateViewLayout(floatWindow, mainLayoutParams)
else
luajava.runUiThread(function()
height1 = getpx("300")
width1 = getpx("470")
local animator = ValueAnimator:ofFloat({0, 1})
animator:setDuration(600)
-- 三阶贝塞尔曲线(回弹插值:先快后回弹收尾,更自然)
local path = Path()
path:moveTo(0.0, 0.0)
path:cubicTo(0.4, 0.0, 0.2, 1.0, 1.0, 1.0)
animator:setInterpolator(PathInterpolator(path)) -- 绑定贝塞尔插值
local listener = luajava.createProxy('android.animation.ValueAnimator$AnimatorUpdateListener', {
onAnimationUpdate = function(animation)
local animatedProgress = animation:getAnimatedValue()
if animatedProgress > 1 then
animatedProgress = 1 + (animatedProgress - 1) / 6
end
mainLayoutParams.height = height1 + (DP40 - height1) * animatedProgress
mainLayoutParams.width = width1 + (DP40 - width1) * animatedProgress
window:updateViewLayout(floatWindow, mainLayoutParams)
end
})
animator:addUpdateListener(listener)
local listener = luajava.createProxy('android.animation.Animator$AnimatorListener', {
onAnimationStart = function()
YoYoImpl:with("FadeIn"):duration(500):playOn(control)
control:setVisibility(View.VISIBLE)
end,
onAnimationEnd = function()
chuangk:setVisibility(View.GONE)
control:setVisibility(View.VISIBLE)
shadow:setVisibility(View.GONE)
end,
onAnimationCancel = function(animator)
end
})
animator:addListener(listener)
animator:start()
end)
mainLayoutParams.flags = LayoutParams.FLAG_NOT_FOCUSABLE
window : updateViewLayout (floatWindow , mainLayoutParams)
显示 = 0
end
end)
end
changan.controlWater = function(control,time)
luajava.runUiThread(function()
import "android.animation.ObjectAnimator"
ObjectAnimator():ofFloat(control,"scaleX", {
1, 0.8, 0.9, 1
}):setDuration(time):start()
ObjectAnimator():ofFloat(control,"scaleY", {
1,0.8,0.9,1
}):setDuration(time):start()
end) end
changan.controlSmall = function(control,time)
luajava.runUiThread(function()
import "android.animation.ObjectAnimator"
ObjectAnimator():ofFloat(control,"scaleX", {
1, 0.7, 0.4, 0
}):setDuration(time):start()
ObjectAnimator():ofFloat(control,"scaleY", {
1, 0.7, 0.4, 0
}):setDuration(time):start()
end) end
changan.controlBig = function(control,time)
luajava.runUiThread(function()
import "android.animation.ObjectAnimator"
ObjectAnimator():ofFloat(control,"scaleX", {
0, 0.4, 0.7, 1
}):setDuration(time):start()
ObjectAnimator():ofFloat(control,"scaleY", {
0, 0.4, 0.7, 1
}):setDuration(time):start()
end) end
function getButtonBG()
local selector = luajava.getStateListDrawable()
selector:addState({
android.R.attr.state_pressed
}, getVerticalBG({0x66d7d7d7,0x66d7d7d7},15))
selector:addState({
-android.R.attr.state_pressed
}, getVerticalBG({0xffffffff,0xffffffff},15,3,0xffB8B8B8))
return selector
end
function changan.text(txt , color , size,bjz )
if not txt then
txt = "未设置文字"
end
if not color then
color = "#ffffff"
end
if not size then
size = "18sp"
end
if not bjz then
bjz = "left"
end
return luajava.loadlayout (
{
TextView ,
text = txt ,
textSize = size ,
Typeface = font,
gravity = bjz ,
textColor = color ,
layout_width = "fill_parent" ,
} )
end
buts={}
function changan.button(txt,func,txtc)
if not txt then txt = "未设置" end
if not txtc then txtc="#66709A" end
local tid="button"..string.randomUUID(true)
buts[tid]=luajava.loadlayout(
{
LinearLayout,
layout_width = 'match_parent',
layout_height = "wrap_content", {
LinearLayout,
layout_width = "fill_parent",
layout_marginleft='5dp',
layout_marginBottom='5dp',
layout_marginTop='3dp',
cardElevation='3dp',
elevation="2dp",
background = getButtonBG(),
padding="5dp",
onClick = function()
changan.controlWater(buts[tid],300)
uiadtext(txt.." 已开启.","#161616")
luajava.newThread(func):start() end,
{
TextView,
Typeface=font,
textColor = txtc,
Typeface = font,
text = txt,
gravity="center",
textSize = "13sp",
layout_height = "wrap_content",
layout_width = "fill_parent",
}
}})
return buts[tid]
end
colorvs = {}
function changan.seek(name,variable,min,max,now)
local nid=name..string.randomUUID(true)
colorvs[#colorvs+1]={"slider",nid}
return{
LinearLayout,
layout_width='fill_parent',
layout_height="wrap_content",
gravity="center_vertical",
orientation="horizontal",
{
TextView,
Typeface=font,
text=name,
textColor="0xff66709A",
textSize="13sp",
layout_width='50dp',
layout_height='wrap_content',
gravity="center_right",
layout_marginLeft = "8dp",
},
{
Slider,
id=luajava.newId(nid),
trackStopIndicatorSize="0dp",
stepSize=1,
valueTo=max,
valueFrom=min,
value=now,
trackHeight="4dp",
ThumbHeight="20dp",
ThumbWidth="20dp",
tickVisible=false,
layout_width='0dp',
layout_height='wrap_content',
layout_weight=1,
CustomThumbDrawable = luajava.getBitmapDrawable("/storage/emulated/0/那年冬/年冬/seek图标"),
TrackActiveTintList=ColorStateList({{}},{0xffD4E3F6}),
TrackInactiveTintList=ColorStateList({{}},{0xffC4C4C4}),
ThumbTintList=ColorStateList({{}},{0xffD4E3F6}),
onClick = function() luajava.newThread(function() func() end):start() end,
addOnChangeListener=function(slider,value,fromUser)
if not fromUser then
return
end
if variable then
_ENV[variable] = value
end
end
},
}
end
function 开关3(name,func1,func2,nid)
local sname = nid
local localname=name
name = name..string.randomUUID(true)
_ENV[name] = "关"
if func1 == nil then func1 = "" end
if func2 == nil then func2 = "" end
if type(func1) == "function" then
local outfunc=function()
namers = _ENV[name]
if namers ~= "开" then
vibra:vibrate(9)
luajava.runUiThread(function()
uiadtext(localname.." 已开启.","#161616")
luajava.getIdValue(nid.."k"):setVisibility(View.GONE)
YoYoImpl:with("Swing"):duration(600):playOn(switches["2s"..sname])
luajava.getIdValue(nid.."g"):setVisibility(View.VISIBLE)
luajava.getIdValue(nid):setBackground(checkbg)
luajava.newThread(function()
pcall(func1)
end):start()
end)
_ENV[name] = "开"
else
vibra:vibrate(9)
luajava.runUiThread(function()
uiadtext(localname.." 已关闭.","#161616")
luajava.getIdValue(nid.."g"):setVisibility(View.GONE)
YoYoImpl:with("Swing"):duration(600):playOn(switches["1s"..sname])
luajava.getIdValue(nid.."k"):setVisibility(View.VISIBLE)
luajava.getIdValue(nid):setBackground(checkbga)
luajava.newThread(function()
pcall(func2)
end):start()
end)
_ENV[name] = "关"
end
end
return outfunc
end
end
function changan.switch(name,func1,func2,miaoshu)
if not checkbg then
checkbga = getVerticalBG({0xffE4E4E4,0xffE4E4E4},360)
checkbg = getVerticalBG({0xffD4E3F6,0xffD4E3F6},360)
switchbg1 = 获取年冬(switch图标)
switchbg2 = 获取年冬(switch图标)
end
local nid="switch"..string.randomUUID(true)
local func = 开关3(name,func1,func2,nid)
if not name then name = "未设置" end
switches["1s"..nid] = luajava.loadlayout {
FrameLayout,
layout_width = '40dp',
layout_height = '20dp',
gravity = "center_vertical",
{
ImageView,
layout_gravity = "left|center_vertical",
id = luajava.newId(nid.."k"),
src = switchbg1,
background=getVerticalBG({0xffffffff,0xffffffff},360),
onClick = function() luajava.newThread(function() func() end):start() end,
layout_width = '20dp',
layout_height = '20dp',
},
}
switches["2s"..nid] = luajava.loadlayout {
FrameLayout,
onClick = function() luajava.newThread(function() func() end):start() end,
layout_width = '40dp',
layout_height = '20dp',
gravity = "center_vertical",
{
ImageView,
visibility = "gone",
layout_gravity = "right|center_vertical",
id = luajava.newId(nid.."g"),
src = switchbg2,
background= getVerticalBG({0xffffffff,0xffffffff},360),
onClick = function() luajava.newThread(function() func() end):start() end,
layout_width = '20dp',
layout_height = '20dp',
}
}
rest = luajava.loadlayout({
LinearLayout,
layout_width = 'fill_parent',
layout_height = "37dp",
gravity = "center",
{
LinearLayout,
layout_width = 'match_parent',
layout_height = "35dp",
gravity = "center",
elevation = "0dp",
layout_marginRight = "4dp",
layout_marginLeft = "4dp",
{
TextView,
gravity = "top",
text = name,
textColor = "0xff66709A",
textSize = "15sp",
Typeface=font,
layout_weight = 1,
layout_width = 'wrap_content',
layout_marginLeft = "4dp",
layout_marginRight = "20dp",
},
{
TextView,
gravity = "left",
layout_height = "wrap_content",
text = miaoshu,
textSize = "8sp",
Typeface=font,
layout_width = "wrap_content",
textColor = "#A5A5A5",
},
{
FrameLayout,
id=luajava.newId(nid),
background = checkbga,
elevation = "1dp",
onClick = function() luajava.newThread(function() func() end):start() end,
layout_width = 'wrap_content',
layout_height = 'wrap_content',
gravity = "left",
padding="1dp",
switches["1s"..nid],switches["2s"..nid]
}}
})
return rest
end
switches = {}
wyylog=luajava.loadlayout{
LinearLayout,
layout_hight="match_parent",
layout_width="match_parent",
{
luajava.post(LinearProgressIndicator,baseWindow:getContext()),
id="SearchProgress",
visibility = "gone",
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_hight="wrap_content",
layout_width="match_parent",
layout_margin="5dp",
Elevation="3dp",
background=getVerticalBG({0xffE6EEF9,0xffE6EEF9},10,2,0xff969FAE),
{
EditText,
id=luajava.newId("搜索"),
background="0x00000000",
gravity="center",
hint="请输入关键词",
textSize="13sp",
layout_weight="1",
HintTextColor="0x40201E1E",
layout_width="match_parent",
textColor="#66709A",
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="match_parent",
layout_width="1dp",
},
{
TextView,
text="搜索",
gravity="center",
id=luajava.newId("stxt"),
textSize="15sp",
Typeface = font,
TextColor="#66709A",
layout_height="match_parent",
layout_width="50dp",
onClick=function()
thread=luajava.getThread(function()
searchmusic()
end)
thread:start()
end
},
},
{
ListView,
id="musiclistview",
layout_width='match_parent',
layout_height='match_parent',
dividerHeight=3,
},
},
}
changan.controlRotation9 = function(control, time,t)
luajava.runUiThread(function()
import "android.view.animation.Animation"
import "android.animation.ObjectAnimator"
xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotation", {
time,t
})
xuanzhuandonghua:setRepeatCount(0)
xuanzhuandonghua:setRepeatMode(Animation.RESTART)
xuanzhuandonghua:setDuration(400)
xuanzhuandonghua:start()
end)
end
function visi (tid , ttid)
vibra:vibrate(4)
local tview = luajava.getIdValue (tid)
local ttview = luajava.getIdValue (ttid)
if not tview then
return 0
end
if tonumber (tostring (tview : getVisibility ())) == 8.0 then
tview : setVisibility (View.VISIBLE)
YoYoImpl:with("FadeIn"):duration(200):playOn(boxes[tid])
changan.controlRotation9(boxpic[tid],0,90)
boxpic[tid]:setColorFilter("0xff66709A")
else
tview : setVisibility (View.GONE)
changan.controlWater (_ENV [tid.."6"] , 200)
changan.controlRotation9(boxpic[tid],90,0)
boxpic[tid]:setColorFilter(nil)
end
end
boxes = {} boxpic = {}
function changan.box (views)
local tid="box"..string.randomUUID(true)
boxpic[tid] = luajava.loadlayout {
ImageView ,
src = getRes("hei_right"),
layout_width = "24dp" ,
layout_height = "24dp" ,
}
local ttid = tid.."6"
local t1id = "box22"..string.randomUUID(true)
firadio = {
LinearLayout ,
layout_width = 'fill_parent' ,
layout_height = "wrap_content" ,
layout_marginTop = "2dp" ,
layout_marginBottom = "2dp" ,
orientation = "vertical" ,
}
if type (views [1]) == "string" or type (views [1]) == "number" then
firadio [# firadio + 1] = {
LinearLayout ,
layout_width = 'fill_parent' ,
layout_height = "30dp" ,
gravity = "center_vertical" ,
orientation="horizontal",
layout_marginTop = "2dp" ,
layout_marginLeft='4dp',
layout_marginRight='4dp',
elevation='2dp',
layout_marginBottom = "2dp" ,
onClick = function ()
visi (tid , ttid)
end
,
background = getButtonBG(),
{
TextView , text = views [1] ,
textSize = "13sp" ,
layout_marginLeft = "15dp" ,
layout_marginRight='-20dp',
Typeface = font,
layout_width = "wrap_content" ,
layout_weight=1,
textColor = "#66709A" ,
gravity = "left" ,
},{
LinearLayout ,
padding={"0dp","0dp","10dp","0dp"},
layout_width = "30dp" ,
layout_height = "30dp" ,
gravity = "center",
layout_gravity="center_vertical|right" ,
boxpic[tid],
}
} else
gg.alert ("changan.box的table内第一个元素必须是string") os.exit ()
end
radios = {
LinearLayout ,
layout_marginLeft = "0dp" ,
layout_marginRight = "0dp" ,
orientation = "vertical" ,
visibility = "gone" ,
id = luajava.newId (tid) ,
padding = "0dp" ,
layout_width = 'fill_parent' ,
}
for i = 2 , # views do
radios [# radios + 1] = views [i]
end
boxes[tid] = luajava.loadlayout(radios)
firadio [# firadio + 1] = boxes[tid]
_ENV [t1id] = luajava.loadlayout (firadio)
return _ENV [t1id]
end
function changan.intcheck(name,func1,func2)
nid=name..string.randomUUID(true)
if not name then name="未设置" end
check={
LinearLayout,
layout_width='match_parent',
layout_height="42dp",
layout_weight=1,
layout_marginTop="1dp",
layout_marginBottom="1dp",
orientation='horizontal', -- 横向布局,让文字和CheckBox并排
gravity='center', -- 整体居中,和原效果一致
{
TextView, -- 前置文字控件
layout_width='70dp',
layout_height='wrap_content',
Typeface = font,
text=name, -- 替换为需要显示的文字
textSize='14sp', -- 文字大小,可按需调整
textColor='#66709A', -- 文字颜色,可按需调整
layout_marginRight='8dp' -- 文字和CheckBox的间距,可按需调整
},
{
CheckBox,
id=luajava.newId(nid),
buttonTintList=ColorStateList({{android.R.attr.state_checked},{-android.R.attr.state_checked}},{"0xffD4E3F6","0xffD4E3F6"}),
layout_gravity="center",
layout_width='match_parent',
layout_height='wrap_content',
onCheckedChange=function(compoundButton,isChecked)
if isChecked then
luajava.newThread(function()
pcall(func1)
end):start()
else
luajava.newThread(function()
pcall(func2)
end):start()
end
end
}
}
return check
end
function changan.check(cklist)
if #cklist==0 then return nil end
local rest={
LinearLayout,
layout_width='fill_parent',
layout_height="wrap_content",
layout_marginRight="4dp",
layout_marginLeft="4dp",
layout_marginTop="3.5dp",
layout_marginBottom="3.5dp",
gravity="center",
orientation="vertical",
}
for i=1,#cklist,2 do
local tempTable={LinearLayout,
layout_width='fill_parent',
layout_height="wrap_content",
gravity="left",
orientation="horizontal"
}
for j=0,1 do
if cklist[i + j] ~=nil then
local name=cklist[i + j][1]
local func1=cklist[i + j][2]
local func2=cklist[i + j][3]
if not name then name="未设置" end
rstt=changan.intcheck(name,func1,func2)
table.insert(tempTable,rstt)
else
table.insert(tempTable,{LinearLayout,
layout_width='match_parent',
layout_weight=1,})
end
end
table.insert(rest,tempTable)
end
return rest
end
switch图标="/storage/emulated/0/那年冬/年冬/seek图标"
左上角标题='年冬'
左上角头像='https://wp.kayyw.com/f/lPgluz/share_1766760988477.jpeg'
xfcpic = "https://wp.kayyw.com/f/wjA5UE/mmexport1767537418229.gif"
第一页 = {
['分页名字']="主页",
[1]={
['分区名字']="主页",
['功能配置']={
changan.button('选择进程',gg.setProcessX),
changan.button("使用必看", function()
gg.alert("天天开心")
end),
changan.button("每日语录"
, function()
Y=gg.makeRequest("https://v1.hitokoto.cn/").content
--获取云端数据
Q=string.match(Y,'hitokoto(.+)type')
--模式匹配他们中的一切字符
F=string.gsub(Q,'":"',"")
K=string.gsub(F,'","',"")
--删除多余垃圾
string.toMusic("\n\n"..""..K.."")
QD = gg.alert("今日语录:\n\n"..""..K.."")
if QD == 1 then
end
if QD == 3 then
end
end),
}
}
}
第二页 = {
['分页名字']="内存",
[1]={
['分区名字']="功能",
['功能配置']={
changan.switch(
"功能",
function()
end,
function()
end),
changan.switch(
"功能",
function()
end,
function()
end),
changan.switch(
"功能",
function()
end,
function()
end),
changan.switch(
"功能",
function()
end,
function()
end),
changan.switch(
"功能",
function()
end,
function()
end),
}
},
[2]={
['分区名字']="功能",
['功能配置']={
}
},
[3]={
['分区名字']="功能",
['功能配置']={
}
},
}
第三页 = {
['分页名字']='分区',
[1]={
['分区名字']="功能",
['功能配置']={
}
},
[2]={
['分区名字']="功能",
['功能配置']={
}
},
}
第四页 = {
['分页名字']='娱乐',
[1]={
['分区名字']="功能",
['功能配置']={
}
},
[2]={
['分区名字']="功能",
['功能配置']={
}
},
}
第五页 = {
['分页名字']='音乐',
[1]={
['分区名字']="音乐",
['功能配置']={
wyylog,
}
},
}
第六页 = {
['分页名字']="设置",
[1]={
['分区名字']="设置",
['功能配置']={
changan.switch(
"音量键隐藏UI",
function()
音量键=true
end,
function()
音量键=false
end),
changan.switch(
"退出",
function()
tuichu=1
end,function()
end),
}
},
}
changan.menu({
第一页,
第二页,
第三页,
第四页,
第五页,
第六页,
})
bloc = luajava.getBlock()
bloc('join')