LableFormater=function(value) local seconds = math.floor(value / 1000) local minutes = math.floor(seconds / 60) local remaining_seconds = seconds % 60 local res=string.format("%d:%02d", minutes, remaining_seconds) luajava.getIdView('MTimeNow'):setText(res) return res end LableFo2=function(value) local seconds = math.floor(value / 1000) local minutes = math.floor(seconds / 60) local remaining_seconds = seconds % 60 local res=string.format("%d:%02d", minutes, remaining_seconds) return res end MediaPlayer = luajava.bindClass("android.media.MediaPlayer") media = luajava.new(MediaPlayer) media:setOnPreparedListener(luajava.createProxy("android.media.MediaPlayer$OnPreparedListener", { onPrepared=function(mp) mp:start() local r=media:getDuration() luajava.runUiThread(function() luajava.getIdView('seekbar'):setValueTo(r) luajava.getIdView('MTimeNow'):setText('0:00') luajava.getIdView('MTimeEnd'):setText(LableFo2(r)) luajava.getIdView('playMusic'):setSpeed(1) luajava.getIdView('playMusic'):playAnimation() end) isPlayingMusic=true readytoplay=true preparing=false end })) media:setOnCompletionListener(luajava.createProxy("android.media.MediaPlayer$OnCompletionListener", { onCompletion=function() if isPlayingMusic then if isDownLoading then return end isPlayingMusic=false media:pause() luajava.runUiThread(function() luajava.getIdView('seekbar'):setValue(0) luajava.getIdView('playMusic'):setSpeed(-1) luajava.getIdView('playMusic'):playAnimation() end) changan.playNextMusic() end end })) media:setOnErrorListener(luajava.createProxy("android.media.MediaPlayer$OnErrorListener", { onError=function() return true end })) local UI宽度='289dp' --初始宽度 竖屏建议300dp 横屏建议400dp local UI高度='309dp' --初始高度 竖屏建议500dp 横屏建议300dp local 项目名字='MY全防' local 背景1=0xFF94C3F9 local 背景2=0x88525A68 import "android.animation.ObjectAnimator" import "android.view.animation.Animation" import "android.animation.FloatEvaluator" import "android.animation.ValueAnimator" local function CAViewInfo(v, info) local info=table.list(v:getLocationOnScreen()) local start=table.list(starv:getLocationOnScreen()) return {info[1]-mainLayoutParams.x-start[1],info[2]-mainLayoutParams.y-start[2]} end local function CAlayout(v) local p=luajava.loadlayout({FrameLayout,v}) local v=p:getChildAt(0) p:removeView(v) return v end local ViewFakeTransition=CAlayout({ FrameLayout, visibility='gone', elevation='10dp', { ImageView, layout_height='match_parent', layout_width='match_parent' },{ ImageView, layout_height='match_parent', layout_width='match_parent' } }) local nothing=function() end local function CATransition(view1,view2,duration,polator,func,func2) func=func or nothing func2=func2 or nothing if type(view1)=='string' then view1=luajava.getIdView(view1) end if type(view2)=='string' then view2=luajava.getIdView(view2) end if ViewFakeTransition:getVisibility()==View.VISIBLE then return end ViewFakeTransition:setVisibility(View.VISIBLE) local P1=CAViewInfo(view1) local P2=CAViewInfo(view2) local DrawingView1,DrawingView2=ViewFakeTransition:getChildAt(0),ViewFakeTransition:getChildAt(1) DrawingView1:setImageBitmap(View2Bitmap(view1)) DrawingView1:setAlpha(1) DrawingView2:setImageBitmap(View2Bitmap(view2)) DrawingView2:setAlpha(0) local height1,width1,height2,width2,P11,P12,P21,P22=view1:getMeasuredHeight(),view1:getMeasuredWidth(),view2:getMeasuredHeight(),view2:getMeasuredWidth(),P1[1],P1[2],P2[1],P2[2] view1:setVisibility(View.INVISIBLE) view2:setVisibility(View.INVISIBLE) floatmain:addView(ViewFakeTransition) local VP=ViewFakeTransition:getLayoutParams() VP.height=height1 VP.width=width1 VP:setMargins(P11,P12,0,0) ViewFakeTransition:setLayoutParams(VP) local animator=ValueAnimator:ofObject(FloatEvaluator(),{0,1}):setDuration(duration) animator:setInterpolator(polator) 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 VP.height=height1+(height2-height1)*animatedProgress VP.width=width1+(width2-width1)*animatedProgress VP:setMargins(P11+(P21-P11)*animatedProgress,P12+(P22-P12)*animatedProgress,0,0) ViewFakeTransition:setLayoutParams(VP) DrawingView1:setAlpha(1-animatedProgress) DrawingView2:setAlpha(animatedProgress) end }) animator:addUpdateListener(listener) local listener = luajava.createProxy('android.animation.Animator$AnimatorListener', { onAnimationStart = func, onAnimationEnd = function() view2:setVisibility(View.VISIBLE) ViewFakeTransition:setVisibility(View.GONE) floatmain:removeView(ViewFakeTransition) window:updateViewLayout(floatWindow, mainLayoutParams) view2:setVisibility(View.VISIBLE) func2() end, onAnimationCancel = function(animator) end }) animator:addListener(listener) animator:start() end local function SelectorBG(s1,s2) local selector = luajava.getStateListDrawable() selector:addState({ android.R.attr.state_pressed }, s2) selector:addState({ -android.R.attr.state_pressed }, s1) return selector end local function getBG(DrawableColor,Radius,StrokeWidth,StrokeColor) if type(DrawableColor)~='table' then DrawableColor={DrawableColor,DrawableColor} end local jianbians = luajava.loadlayout({ GradientDrawable, color = 0xff000000, gradientType = GradientDrawable.LINEAR_GRADIENT, orientation = GradientDrawable.Orientation.TOP_BOTTOM , }) jianbians:setColors(DrawableColor) jianbians:setStroke(StrokeWidth or 0,StrokeColor or 0xffffffff) if type(Radius)=='table' then jianbians:setCornerRadii({Radius[1],Radius[1],Radius[2],Radius[2],Radius[3],Radius[3],Radius[4],Radius[4]}) else jianbians:setCornerRadius(Radius or 0) end return jianbians end local rs=context:getResources():getDisplayMetrics() local rs=tostring(rs) local rs=string.gsub(rs,',',';') local rs=string.gsub(rs,'DisplayMetrics','') rs=load('return '..rs)() local dheight=rs.height local dwidth=rs.width if tonumber(dheight)==nil then dwidth=1340 dheight=2300 end if dheight>dwidth then dheight,dwidth=dwidth,dheight end local ui = require('ui') local 全局RGB='161616' if not UI宽度 then UI宽度='300dp' end if not UI高度 then UI高度='500dp' end if not 项目名字 then 项目名字='长宁UI' end import('android.content.res.ColorStateList') gg.setVisible(false) luajava.setFloatingWindowHide(true) 背景颜色=0xffffffff check字体颜色=0xff000000 按钮颜色=0xffffffff 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' import "android.animation.ObjectAnimator" import "android.view.animation.Animation" import "android.animation.ArgbEvaluator" import "android.animation.ValueAnimator" import "android.graphics.Color" import'com.google.android.material.divider.MaterialDivider' import'com.google.android.material.progressindicator.*' import'com.google.android.material.dialog.MaterialAlertDialogBuilder' import'com.google.android.material.tabs.TabItem' import'androidx.coordinatorlayout.widget.CoordinatorLayout' import'com.google.android.material.button.MaterialButton' import'androidx.appcompat.widget.LinearLayoutCompat' import'com.google.android.material.slider.Slider' import'com.google.android.material.materialswitch.MaterialSwitch' import'com.google.android.material.card.MaterialCardView' import'androidx.transition.Transition' import'androidx.transition.Scene' import'androidx.transition.TransitionManager' import'androidx.transition.TransitionSet' import'androidx.transition.ChangeBounds' import'androidx.transition.Fade' import'androidx.constraintlayout.motion.widget.MotionLayout' import"android.view.animation.AccelerateInterpolator" import"android.view.animation.DecelerateInterpolator" import"androidx.interpolator.view.animation.FastOutLinearInInterpolator" import"androidx.interpolator.view.animation.LinearOutSlowInInterpolator" import"android.view.animation.OvershootInterpolator" import 'android.animation.ValueAnimator$AnimatorUpdateListener' import 'android.animation.TypeEvaluator' import 'android.graphics.PorterDuff' import 'android.graphics.PorterDuffColorFilter' import'com.google.android.material.tabs.TabLayout' import'com.google.android.material.tabs.TabItem' changan = {} local LayoutParams = luajava.bindClass('android.view.WindowManager$LayoutParams') context:setTheme(0x7f090009) context:setTheme(0x7f0900b4) context:setTheme(0x7f090069) function changan.alertView(title,view,positive,func) luajava.post(function() local p=view:getParent() if p~=nil then p:removeView(view) end local alertBuilder = MaterialAlertDialogBuilder(context) if func then alertBuilder:setTitle(title):setView(view):setPositiveButton(positive or '确定',func) else alertBuilder:setTitle(title):setView(view):setPositiveButton(positive or '确定') end local alert = alertBuilder:create() alert:getWindow():setType(gg.ANDROID_SDK_INT >= 26 and LayoutParams.TYPE_APPLICATION_OVERLAY or LayoutParams.TYPE_PHONE) alert:show() end) end local function rgb_to_hex(r,g,b) r = math.min(math.max(r, 0), 255) g = math.min(math.max(g, 0), 255) b = math.min(math.max(b, 0), 255) local hex_r = string.format("%02X", r) local hex_g = string.format("%02X", g) local hex_b = string.format("%02X", b) return hex_r .. hex_g .. hex_b end local function hexToRgb(hex) hex = hex:sub(-6,-1) local r = tonumber(hex:sub(1, 2), 16) local g = tonumber(hex:sub(3, 4), 16) local b = tonumber(hex:sub(5, 6), 16) return {r, g, b} end local function 获取图片(txt) txt = string.url(txt,"de") if string.find(tostring(txt),"http") ~= nil then ntxt = string.sub(string.gsub(txt,"/","-"),-10,-1) if file.length("/sdcard/长宁/图片/"..ntxt,false)<200 then file.download(txt,"/sdcard/长宁/图片/"..ntxt) end txt = "/sdcard/长宁/图片/"..ntxt end return luajava.getBitmapDrawable(txt) end function getRes(x) return 获取图片("/sdcard/长宁/图片/"..x) end local rgbt=hexToRgb(全局RGB) function CAMusic_init() function saveMusicList() luajava.startThread(function() local tab={} for i,v in pairs(MusicList) do if v[4]==true then table.insert(tab,v) end end local pat='/sdcard/长宁/.收藏歌单' file.write(pat,tostring(tab)) end) end function haveList() if #MusicList<1 then 切换(PageNum-1) luajava.startThread(function() gg.alert('您还没有收藏歌曲\n请先搜索想听的歌曲添加到播放列表\n点击左侧爱心可以收藏,每次重新启动时只会保留收藏的歌曲') end) return false else return true end end function changan.playMusic(m) media:reset() if not readytoplay then luajava.post(function() luajava.getIdView('seekbar'):setVisibility(View.VISIBLE) end) end if #MusicList==0 then noMusic() return 0 end if isDownLoading then -- luajava.startThread(function() -- gg.alert('请等待当前歌曲加载完毕再切换') -- end) return 0 end txt='/sdcard/长宁/音乐缓存/'..m[1] luajava.startThread(function() luajava.runUiThread(function() luajava.getIdView('seekbar'):setValue(0) MusicNameTitle1:setText(m[2]) MusicNameTitle2:setText(m[3]) if m[4] then isLoved:setImageDrawable(lovepic) isLoved:setColorFilter(0xffEC2A37) else isLoved:setImageDrawable(unlovepic) isLoved:setColorFilter(0xffffffff) end end) if file.length(txt,false)<500 then luajava.runUiThread(function() luajava.getIdView('loading'):show() end) isDownLoading=true file.download(string.format('http://music.163.com/song/media/outer/url?id=%s.mp3', m[1]),txt) isDownLoading=false end luajava.runUiThread(function() luajava.getIdView('loading'):hide() end) if preparing then return end luajava.startThread(function() local p,err=pcall(function() media:setDataSource(txt) end) if p==false then if err==nil then elseif string.find(err,'No such file')~=nil then else print(err) end end preparing=true local p,err=pcall(function() media:prepare() end) if p==false then if err==nil then elseif string.find(err,'Prepare failed')~=nil then print(err) else print(err) end end end) end) end playingType=1 function changan.playNextMusic(notAuto) if #MusicList==0 then noMusic() return 0 end lastNum=playingNum if playingType==1 then--列表循环 if playingNum>=#MusicList then playingNum=1 else playingNum=playingNum+1 end if changan.playMusic(MusicList[playingNum])==0 then playingNum=lastNum end elseif playingType==2 then--随机循环 newnum=math.random(1,#MusicList) while true do if playingNum==newnum then newnum=math.random(1,#MusicList) else playingNum=newnum break end end if changan.playMusic(MusicList[playingNum])==0 then playingNum=lastNum end elseif playingType==3 then--单曲循环 luajava.runUiThread(function() luajava.getIdView('seekbar'):setValue(0) end) media:seekTo(0) isPlayingMusic=true if notAuto then if playingNum>=#MusicList then playingNum=1 else playingNum=playingNum+1 end if changan.playMusic(MusicList[playingNum])==0 then playingNum=lastNum end end elseif playingType==4 then--单次播放 luajava.runUiThread(function() luajava.getIdView('seekbar'):setValue(0) end) isPlayingMusic=false media:seekTo(0) media:pause() if notAuto then if playingNum>=#MusicList then playingNum=1 else playingNum=playingNum+1 end if changan.playMusic(MusicList[playingNum])==0 then playingNum=lastNum end end end end function noMusic() luajava.startThread(function() media:pause() isPlayingMusic=false luajava.runUiThread(function() luajava.getIdView('seekbar'):setValue(0) luajava.getIdView('playMusic'):setSpeed(-1) luajava.getIdView('playMusic'):playAnimation() luajava.getIdView('seekbar'):setValueTo(1) isLoved:setImageDrawable(unlovepic) isLoved:setColorFilter(0xffffffff) MusicNameTitle1:setText(greeting()) MusicNameTitle2:setText('') end) gg.alert('歌单已清空,请先搜索想听的歌曲') end) end function changan.playLastMusic() if #MusicList==0 then noMusic() return 0 end if playingNum==1 then playingNum=#MusicList else playingNum=playingNum-1 end changan.playMusic(MusicList[playingNum]) end local ui = require('ui') local ljson = require('ljson') arrayList = ArrayList() gedanList = ArrayList() function freshList() gedanList:clear() for i, v in ipairs(MusicList) do gedanList:add(v) end luajava.runUiThread(function() gedanAdapter:notifyDataSetChanged() end) end gedanAdapter = ui.BaseAdapter({ getCount = function() return gedanList:size() end, getItem = function(position) return gedanList:get(position) end, getItemId = function(position) return position end, getView = function(position, convertView1, parent) local info = gedanAdapter:getItem(position) if not convertView1 then convertView1 = luajava.loadlayout({ LinearLayout, -- background='#000000', layout_width='match_parent', gravity='center_vertical', padding='4dp', {ImageView, layout_width='24dp', layout_height='24dp', }, { TextView, layout_weight=1, textColor='#25253C', textSize='14sp', gravity='center', layout_width='match_parent', },{ImageView, layout_width='24dp', layout_height='24dp', padding='-2dp', colorFilter=0xff4B484F } }) end Iconv1=convertView1:getChildAt(0) Textv1 = convertView1:getChildAt(1) Iconv2=convertView1:getChildAt(2) Textv1:setText(info[2]) if info[4] then Iconv1:setImageDrawable(lovepic) Iconv1:setColorFilter(0xffEC2A37) else Iconv1:setImageDrawable(unlovepic) Iconv1:setColorFilter(0xff4B484F) end convertView1:setOnClickListener(function(v) changan.playMusic(MusicList[position+1]) end) Iconv1:setOnClickListener(function(v) luajava.startThread(function() local n=math.floor(position)+1 if MusicList[n][4] then MusicList[n][4]=false v:setImageDrawable(unlovepic) v:setColorFilter(0xff4B484F) if playingNum==n then isLoved:setImageDrawable(unlovepic) isLoved:setColorFilter(0xffffffff) end saveMusicList() else MusicList[n][4]=true v:setImageDrawable(lovepic) v:setColorFilter(0xffEC2A37) if playingNum==n then isLoved:setImageDrawable(lovepic) isLoved:setColorFilter(0xffEC2A37) end saveMusicList() end freshList() end) end) Iconv2:setImageDrawable(closepic) Iconv2:setOnClickListener(function() luajava.startThread(function() local n=math.floor(position)+1 if gg.alert('确定删除['..MusicList[n][2]..']?','点错了','确定')==2 then table.remove(MusicList,n) if playingNum==n then if not isPlayingMusic then playingNum=playingNum-1 changan.playLastMusic() media:pause() else changan.playLastMusic() end end freshList() if #MusicList==0 then noMusic() end end end) end) return convertView1 end }) gedan = luajava.loadlayout({ 'ui.ListView', adapter = gedanAdapter, layout_width='match_parent', }) function searchMus(s, type, offset, total, limit,clear) searchingName=s if clear then arrayList:clear() end luajava.runUiThread(function() baseAdapter:notifyDataSetChanged() end) local args = { s = s, type = type or 1, offset = offset or 0, total = total or true, limit = limit or 20 } local url = string.format('http://music.163.com/api/search/get?%s', http.arg2data(args)) local res = gg.makeRequest(url) if not isTable(res) then return false, tostring(res) end local content = res.content local jsont = ljson.decode(content) if jsont.code ~= 200 then return false, jsont.msg and tostring(jsont.msg) or content end musresult = jsont.result for i, v in ipairs(musresult.songs) do arrayList:add(v) end luajava.runUiThread(function() baseAdapter:notifyDataSetChanged() end) end local shuaxin baseAdapter = ui.BaseAdapter({ getCount = function() return arrayList:size() end, getItem = function(position) return arrayList:get(position) end, getItemId = function(position) return position end, getView = function(position, convertView, parent) local info = baseAdapter:getItem(position) if shuaxin ~= position and position + 1 == baseAdapter:getCount() and position + 1 < musresult.songCount then shuaxin = position luajava.startThread(function() searchMus(searchingName, nil, math.int(position + 1)) end) end local Iconv, Textv if not convertView then convertView = luajava.loadlayout({ LinearLayout, -- background='#000000', layout_width='match_parent', orientation='vertical', padding='4dp', }) Textv = luajava.loadlayout({ TextView, textColor='#ACD6FF', textSize='14sp', gravity='center', layout_width='match_parent', }) Textv2 = luajava.loadlayout({ TextView, textColor='#5D6981', textSize='11sp', gravity='center', layout_width='match_parent', }) convertView:addView(Textv) convertView:addView(Textv2) else Textv = convertView:getChildAt(0) Textv2 = convertView:getChildAt(1) end local a=info.artists if a[1]~=nil then artname=a[1].name end if a[2]~=nil then for i=2,#a do if a[i].name~=nil then artname=artname..'/'..a[i].name end end end Textv:setText(info.name) Textv2:setText(artname) return convertView end }) listv = luajava.loadlayout({ 'ui.ListView', adapter = baseAdapter, layout_width='match_parent', onSelectedListener = functions.voidThread(function(parent, view, position, id, item) local a=item.artists if a[1]~=nil then artname=a[1].name end if a[2]~=nil then for i=2,#a do if a[i].name~=nil then artname=artname..'/'..a[i].name end end end first=true checkmus=true for i,v in pairs(MusicList) do if v[1]==item.id then playingNum=i checkmus=false end end if checkmus then playingNum=#MusicList+1 table.insert(MusicList,playingNum,{item.id,item.name,artname,false}) end luajava.runUiThread(function() --播放上岛 --callLDBAR() end) changan.playMusic(MusicList[playingNum]) if item.fee == 1 then gg.alert('VIP歌曲可能不支持播放或者只能试听30秒') else -- gg.playMusic(string.format('http://music.163.com/song/media/outer/url?id=%s.mp3', item.id)) end end) }) function greeting() local hour = tonumber(os.date("%H")) -- 获取当前小时数 if hour >= 5 and hour < 12 then return "上午好 ☁" elseif hour >= 12 and hour < 14 then return "中午好 ☀" elseif hour >= 14 and hour < 19 then return "下午好 ☕" elseif hour >= 19 and hour < 24 then return "晚上好 🌙" elseif hour >= 0 and hour < 3 then return "夜深了,早点休息" else return "凌晨了,注意身体" end end local mainView2 = luajava.post(function() return luajava.loadlayout({ LinearProgressIndicator, id = luajava.ids['loading'], layout_width = 'match_parent', layout_height = '10dp', indeterminate = true, __onFinish=function(v) v:hide() v:setIndicatorColor({0xff3455FF, 0xff672AFF, 0xff1D8FFF}) v:setIndeterminateAnimationType(0) end, }) end) MusicCard=luajava.loadlayout({ LinearLayout, layout_height='match_parent', layout_width='match_parent', gravity='center', {LinearLayout, layout_height='match_parent', layout_width='match_parent', gravity='center', orientation='vertical', { LinearLayout, layout_width='match_parent', orientation='vertical', gravity='center', { TextView, __onFinish=function(v) MusicNameTitle1=v end, text=greeting(), textSize='12sp', textColor='#ffffff', gravity='center', layout_width='match_parent', }, { LinearLayout, layout_width='match_parent', layout_height='10dp', mainView2, }, { FrameLayout, layout_width='match_parent', padding={'15dp','0dp','15dp','0dp'}, { TextView, __onFinish=function(v) MusicNameTitle2=v end, text='', textSize='8sp', textColor='#A7B3B4', gravity='center', layout_width='match_parent', },{ImageView, src=getRes('524085136'), layout_height='20dp', layout_width='20dp', layout_gravity='right|center_vertical', onClick=function() freshList() changan.alertView('待播放列表',gedan) end },{ImageView, src=getRes('17bab37e9f'), layout_height='20dp', layout_width='20dp', colorFilter=0xffffffff, layout_gravity='left|center_vertical', onClick=function() 切换(PageNum-1) CloseMenu() end } } }, { LinearLayout,--进度条总栏 layout_width='match_parent', gravity='center', padding={'20dp','0dp','20dp','0dp'}, {TextView,--当前时间 text='', textSize='12sp', gravity='center', id=luajava.ids['MTimeNow'], textColor='#d7d7d7', }, {LinearLayout,--进度条壳 layout_width='match_parent', layout_weight=1, gravity='center', { Slider,--进度条 visibility='gone', thumbHeight='15dp', trackHeight='10dp', thumbHeight='30dp', trackStopIndicatorSize='0dp', thumbTrackGapSize='0dp', __onFinish=function(v) v:setCustomThumbDrawable(getRes('shark')) v:setTrackActiveTintList(ColorStateList({{},},{0xff006DFF})) v:setTrackInactiveTintList(ColorStateList({{},},{0xffCCE5FF})) v:setThumbTintList(ColorStateList({{},},{0xff006DFF})) luajava.setInterface(v, 'addOnSliderTouchListener', { onStartTrackingTouch=function(v) if not readytoplay then return true end notTouching=false end, onStopTrackingTouch=function(v) if not readytoplay then return true end notTouching=true luajava.startThread(function() media:seekTo(v:getValue()) LableFormater(v:getValue()) luajava.runUiThread(function() window:updateViewLayout(floatWindow, mainLayoutParams) end) end) end, }) luajava.setInterface(v, 'addOnChangeListener', function(SeekBar, var2, var3) if not readytoplay then media:seekTo(0) return true end end) v:setLabelFormatter(LableFo2) isPlayingMusic=false notTouching=true luajava.startThread(function() while true do if isPlayingMusic then local nowm=media:getCurrentPosition() if notTouching then luajava.runUiThread(function() local skb=luajava.getIdView('seekbar') if nowm= 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 -- 焦点设置Finish layoutParams1.gravity = Gravity.CENTER -- 重力设置 layoutParams1.width = prm.MATCH_PARENT -- 布局宽度 layoutParams1.height = prm.MATCH_PARENT -- 布局高度 return layoutParams1 end 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 mainLayoutParams=getLayoutParams() xfcParams = getLayoutParams() local rs=RenderScript:create(app.context) local blur=ScriptIntrinsicBlur:create(rs, Element:U8_4(rs)) blur:setRadius(25) function getBlur(bit) local input=Allocation:createFromBitmap(rs,bit) blur:setInput(input) local output=Allocation:createTyped(rs, input:getType()) blur:forEach(output) output:copyTo(bit) return bit end function View2Bitmap(view,isblur) local width = view:getMeasuredWidth() local height = view:getMeasuredHeight() if width==0 then width=1 height=1 end local bitmap = Bitmap:createBitmap(width, height, Bitmap.Config.ARGB_8888); local canvas = Canvas(bitmap) canvas:translate(-view:getScrollX(), -view:getScrollY()) view:draw(canvas) if isblur then return getBlur(bitmap) else return bitmap end end changan.controlBig = function(control,time) luajava.runUiThread(function() 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 local dpi=context:getResources():getDisplayMetrics().densityDpi 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*(dpi/160) else return x end end local 初始宽度=getpx(UI宽度) function getdp(x) if type(x)=='number' then return x/(dpi/160)..'dp' else return x end end DP10=getpx('10dp') DP3=getpx('3dp') DP40=getpx('40dp') RadDP=getpx('100dp') local dp20=getpx('20dp') local dp60=getpx('dp60') local dp130=getpx('130dp') local fdp20= -dp20 local rsid=context:getResources():getIdentifier("status_bar_height", "dimen", "android") if rsid>0 then StatuBarDP=context:getResources():getDimensionPixelSize(rsid) else StatuBarDP=getpx('24dp') end function hanshu(v, event) local view = floatWindow local Action = event:getAction() if Action == MotionEvent.ACTION_DOWN then if ldbg ~= nil then if ldbg:getVisibility() == View.GONE then ldbg:setVisibility(View.INVISIBLE) end end maxheight = isVertical and math.max(dheight, dwidth) or math.min(dheight, dwidth) maxwidth = isVertical and math.min(dheight, dwidth) or math.max(dheight, dwidth) isMove = false RawX = event:getRawX() RawY = event:getRawY() x = mainLayoutParams.x y = mainLayoutParams.y elseif Action == MotionEvent.ACTION_MOVE then isMove = true mainLayoutParams.x = x + (event:getRawX() - RawX) local kd = 显示 == 1 and UI宽度 or DP40 mainLayoutParams.x = math.max(0, math.min(mainLayoutParams.x, maxwidth - kd)) mainLayoutParams.y = y + (event:getRawY() - RawY) local gd = 显示 == 1 and UI高度 or DP40 mainLayoutParams.y = math.max(0, math.min(mainLayoutParams.y, maxheight - gd)) window:updateViewLayout(view, mainLayoutParams) elseif Action == MotionEvent.ACTION_UP then if mainLayoutParams.x <= 0 then mainLayoutParams.x = 0 end if mainLayoutParams.y <= 0 then mainLayoutParams.y = 0 end window:updateViewLayout(view, mainLayoutParams) if math.abs(mainLayoutParams.x - x) >= 10 or math.abs(mainLayoutParams.y - y) >= 10 then return true end end end UI宽度=getpx(UI宽度) UI高度=getpx(UI高度) function checkimg(tmp,ii) if file.length("/sdcard/长宁/图片/"..tmp[1],false)<200 then gg.toast("正在下载资源"..ii.."/"..#ckimg.."\n请耐心等待") file.download(tmp[2],"/sdcard/长宁/图片/"..tmp[1]) end end ckimg = { {'Lottie.dex','https://image.rlyun.fun/down.php/962553ebd72772588c447cbde4ddf8e0.dex'}, {'Play-Pause','https://image.rlyun.fun/down.php/74cf3f3ed14816b3f55445820d066cf1.'}, {'Playing','https://image.rlyun.fun/down.php/54941f05e5434d2d2693b2ce9b790f71.'}, {'sharkTTF','https://image.rlyun.fun/down.php/971ef23ed96102a5bc5a032328331ec7.ttf'}, {'shark','https://image.rlyun.fun/view.php/ccc6d16026025936c182d5c9a76891ef.png'}, {'sharktab','https://image.rlyun.fun/view.php/71177f14b62480e9282abca1ba79ec86.png'}, {'grb','https://image.rlyun.fun/view.php/325c26a7602404237dde7c6ffc8eb5c8.png'}, {'grc','https://image.rlyun.fun/view.php/07fade57df091f58a587b7af53373a32.png'}, {'sensor.dex','https://image.rlyun.fun/down.php/fc6db7447fa46e64cb5e74953bc2fe33.dex'}, {'Gura_Eat','https://image.rlyun.fun/view.php/8e6cf9220728c8bc5573b4801b54d2fb.gif'}, {'GifView','https://image.rlyun.fun/down.php/0ac18d0582dbb0e2b019c0f04de4bc23.dex'}, {'hei_right','https://image.rlyun.fun/down.php/dfcc155180c66711a66a1c6540db5e03.'}, {'heir','https://image.rlyun.fun/down.php/1f8c38a24d8adda4f8f4f897ab2abfbd.'}, {'heix','https://image.rlyun.fun/down.php/1631f943c3cad4fd0aee9e611638198e.'}, {'classes3.dex','https://image.rlyun.fun/down.php/29e1a4722ddf781d8f8d95a68f4e07ad.dex'}, {'LightGura','https://image.rlyun.fun/view.php/5707ab268373b98b733eaf12a2501652.png'}, {'DarkGura','https://image.rlyun.fun/view.php/993a66f89bd4767eba6b79de023b77ff.png'}, {'guralh','https://image.rlyun.fun/view.php/bf82ca7e135b42375e383a40ec269f34.png'}, {'FishBone','https://image.rlyun.fun/view.php/44da5f459d7219fc1883182b4c3abf45.png'}, {'sharkC','https://image.rlyun.fun/view.php/cc09359a81bbec00fb21000d761c6ab9.png'}, {'17bab37e9f','https://image.rlyun.fun/view.php/17bab37e9f7c3b3b0a9394834869c514.png'}, {'836253849','https://image.rlyun.fun/down.php/95c0a82922a7a6a2ae5d12494942521c.'}, {'1360640248','https://image.rlyun.fun/down.php/d38e8c42f3c661433fe33797e1a46ae0.'}, {'238759315','https://image.rlyun.fun/down.php/c8fbb72a8b77a07c54262874988534e9.'}, {'1884812492','https://image.rlyun.fun/down.php/11843b5be6f1568eda187a8f8ff0ba2c.'}, {'764548762','https://image.rlyun.fun/down.php/7d54e887c30bf89e62c70c3e3e2f7de2.'}, {'1265903674','https://image.rlyun.fun/down.php/4beb9f67bb7818f3f772eb45ef3d7a88.'}, {'531183638','https://image.rlyun.fun/down.php/55eaad311b2f86fead7ca636e7321014.'}, {'524085136','https://image.rlyun.fun/down.php/4750102c379a4a3efd734921a0e026bf.'}, {'1316430524','https://image.rlyun.fun/down.php/f2b9eb293e35d099b2e0ab210e5f019f.'}, {'unlove','https://image.rlyun.fun/down.php/361cb58b13cea27c00cfcae5cf33913c.'}, {'love','https://image.rlyun.fun/down.php/daf454d8153d3234747f281d4f4fb0e1.'}, } MainBG=获取图片('https://image.rlyun.fun/view.php/74ac3201457b97001926f72d9de66fa7.png') bloc=luajava.getBlock() progressb=luajava.post(function() return luajava.loadlayout({ LinearProgressIndicator, layout_width = 'match_parent', layout_marginTop='10dp', layout_height = '10dp', indeterminate = true, __onFinish=function(v) v:setIndicatorColor({0xff3455FF, 0xff672AFF, 0xff1D8FFF}) v:setIndeterminateAnimationType(0) end, }) end) luajava.post(function() floatWindow = { MaterialCardView, layout_height='match_parent', layout_width='match_parent', useCompatPadding=false, cardElevation='5dp', cardBackgroundColor='#FF94C3F9', strokeColor=0x00ffffff, onClick=function() end, onTouch=hanshu, __onCreate=function(v) BackCard=v v:setRadius(DP10) local c=ColorStateList({ {android.R.attr.state_pressed}, {-android.R.attr.state_pressed} }, { 0x00ffffff, 0x00ffffff }) v:setRippleColor(c) end, -- strokeWidth='0dp', { FrameLayout, __onFinish=function(v) _ENV['beforejz']=v end, { LinearLayout, layout_width='289dp', layout_height='409dp', orientation='horizontal', background=MainBG, layout_marginTop='-78dp', }, { LinearLayout, layout_width='145dp', layout_height='86dp', orientation='vertical', layout_marginTop='248dp', layout_marginLeft='15dp', rotation=222.8, rotationY=6.9, rotationX=65.8, -- background=getBG(0x00ffffff,0,3,0xffffffff), cameraDistance=11358, gravity='center', __onFinish=function(v) rv=v end, { ScrollView, layout_height='match_parent', layout_width='match_parent', { LinearLayout, layout_width='match_parent', orientation='vertical', gravity='center', background='#ffffff', { LinearProgressIndicator, indicatorTrackGapSize='0dp', trackStopIndicatorSize='0dp', id = luajava.ids['下载进度条'], layout_width = 'match_parent', layout_height = 'wrap_content', min = 0, max = #ckimg, progress=0, trackColor=0xffd7d7d7, __onFinish=function(v) v:setIndicatorColor({0xff161616, 0xff672AFF, 0xff1D8FFF}) end, }, {TextView, layout_marginTop='4dp', text='首次运行,正在下载资源...', textSize='13sp', id=luajava.ids['jzzy'], textColor='#000000', }, { LinearProgressIndicator, layout_marginTop='30dp', id = luajava.ids['加载进度条'], layout_width = 'match_parent', layout_height = 'wrap_content', indeterminate = true, __onFinish=function(v) v:setIndicatorColor({0xff3455FF, 0xff672AFF, 0xff1D8FFF}) v:setIndeterminateAnimationType(0) end, }, {TextView, layout_marginTop='4dp', text=项目名字..' 启动中...', textSize='13sp', textColor='#000000', } } } } } } mainLayoutParams.x = 100 mainLayoutParams.y = 100 mainLayoutParams.height = UI高度 mainLayoutParams.width = UI宽度 floatWindow=luajava.loadlayout(floatWindow) changan.controlBig(floatWindow,800) window:addView(floatWindow,mainLayoutParams) end) local cpIndicator1 = luajava.getIdView('下载进度条') for i = 1,#ckimg do checkimg(ckimg[i],i) cpIndicator1:setProgress(i, true) end local fi=luajava.newInstance("java.io.File", '/sdcard/长宁/图片/sharkTTF') sharkTTF= luajava.bindClass("android.graphics.Typeface"):createFromFile(fi) luajava.runUiThread(function() luajava.getIdView('jzzy'):setText('资源检查完毕') end) UIMAXY=getpx('300dp') UIMAXX=getpx('260dp') animY=getpx('12dp') huiz = function() end function panduan(rec) fille,err = io.open(rec) if fille == nil then return false else return true end end 摇一摇=true YoYoImpl = luajava.getYoYoImpl() vibra = context:getSystemService(Context.VIBRATOR_SERVICE) dex.loadfile('/sdcard/长宁/图片/Lottie.dex') import'com.airbnb.lottie.*' dex.loadfile('/sdcard/长宁/图片/GifView') import'pl.droidsonroids.gif.*' function getTimeStamp(t) local str = os.date("%H:%M:%S ",t) return str end function panduan(rec) fille,err = io.open(rec) if fille == nil then return false else return true end end function 获取图片2(txt) txt = string.url(txt,"de") ntxt = string.sub(string.gsub(txt,"/","-"),-10,-1) if string.find(tostring(txt),"http") ~= nil then if panduan("/sdcard/长宁/图片/"..ntxt) == false then file.download(txt,"/sdcard/长宁/图片/"..ntxt) else if file.length("/sdcard/长宁/图片/"..ntxt) <= 1 then file.download(txt,"/sdcard/长宁/图片/"..ntxt) end end txt = "/sdcard/长宁/图片/"..ntxt end return luajava.getBitmapDrawable(txt) end function getCorner(gtvb1,gtvb3,gtvb4,gtvb5,g1,g2,g3,g4) if not gtvb4 then gtvb4 = 0 gtvb5 = 0xff000000 end local jianbians = luajava.loadlayout({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 getVerticalBG(gtvb1,gtvb3,gtvb4,gtvb5) if not gtvb4 then gtvb4 = 0 gtvb5 = 0xff000000 end local jianbians = luajava.loadlayout({GradientDrawable}) jianbians:setCornerRadius(gtvb3) jianbians:setGradientType(GradientDrawable.LINEAR_GRADIENT) jianbians:setColors(gtvb1) jianbians:setStroke(gtvb4,gtvb5)--边框宽度和颜色 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 changan.controlFlip = function(control,time) luajava.runUiThread(function() xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotationY", { 0, 360 }) xuanzhuandonghua:setRepeatCount(0) xuanzhuandonghua:setRepeatMode(Animation.REVERSE) xuanzhuandonghua:setDuration(time) xuanzhuandonghua:start() end) end changan.controlWater = function(control,time) luajava.runUiThread(function() ObjectAnimator():ofFloat(control,"scaleX", { 1, 0.9, 0.9, 1 }):setDuration(time):start() ObjectAnimator():ofFloat(control,"scaleY", { 1,0.9,0.9,1 }):setDuration(time):start() end) end changan.controlSmall = function(control,time) luajava.runUiThread(function() 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.controlBig2 = function(control,time) luajava.runUiThread(function() control:setPivotX(control:getWidth()/2) control:setPivotY(0) ObjectAnimator():ofFloat(control,"scaleX", { 0, 0.4, 0.7, 1 }):setDuration(time):start() ObjectAnimator():ofFloat(control,"scaleY", { 0, 0.1, 0.4, 1 }):setDuration(time):start() end) end changan.controlSmall2 = function(control,time) luajava.runUiThread(function() control:setPivotX(control:getWidth()/2) control:setPivotY(0) ObjectAnimator():ofFloat(control,"scaleX", { 1, 0.7, 0.4, 0 }):setDuration(time):start() ObjectAnimator():ofFloat(control,"scaleY", { 1, 0.4, 0.1, 0 }):setDuration(time):start() end) end function CAAnimation(view,type,duration) duration=duration or 600 if type=='Big' then ObjectAnimator():ofFloat(view,"scaleX", { 0,0.3,0.7, 1.05,1.05,1 }):setDuration(duration):start() ObjectAnimator():ofFloat(view,"scaleY", { 0,0.3,0.7,1.05,1.05,1 }):setDuration(duration):start() elseif type=='Small' then ObjectAnimator():ofFloat(view,"scaleX", { 1,1.05,1.05, 0.7,0.1,0 }):setDuration(duration):start() ObjectAnimator():ofFloat(view,"scaleY", { 1,1.05,1.05, 0.7,0.1,0 }):setDuration(duration):start() elseif type=='Behind' then ObjectAnimator():ofFloat(view,"scaleX", { 1,0.95,0.88,0.8 }):setDuration(duration):start() ObjectAnimator():ofFloat(view,"scaleY", { 1,0.95,0.88,0.8 }):setDuration(duration):start() elseif type=='Front' then ObjectAnimator():ofFloat(view,"scaleX", { 0.8,0.88,0.95,1 }):setDuration(duration):start() ObjectAnimator():ofFloat(view,"scaleY", { 0.8,0.88,0.95,1 }):setDuration(duration):start() end end gg.setVisible(false) function guid() seed = { 'e','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' } tb = {} for i = 1,32 do table.insert(tb,seed[math.random(1,16)]) end sid = table.concat(tb) return string.format('%s%s%s', string.sub(sid,1,8), string.sub(sid,10,12), string.sub(sid,21,22)) end import("android.media.AudioManager") audi = context:getSystemService("audio") audiotype = { AudioManager.STREAM_ALARM, --手机闹铃的声音 AudioManager.STREAM_MUSIC, --手机音乐的声音 AudioManager.STREAM_NOTIFICATION, --系统提示的通知 AudioManager.STREAM_RING, --电话铃声的声音 AudioManager.STREAM_SYSTEM, --手机系统的声音 AudioManager.STREAM_VOICE_CALL, --语音电话的声音 AudioManager.STREAM_DTMF, --DTMF音调的声音 --AudioManager.STREAM_BLUETOOTH_SCO, } yinl = {} for i = 1,#audiotype do yinl[i] = {} yinl[i].type = audiotype[i] yinl[i].min = audi:getStreamMinVolume(audiotype[i]) yinl[i].max = audi:getStreamMaxVolume(audiotype[i]) yinl[i].now = audi:getStreamVolume(audiotype[i]) end yltype = 0 function jianting3(func) yinln = {} for i = 1,#audiotype do yinln[i] = {} yinln[i].type = audiotype[i] yinln[i].now = audi:getStreamVolume(audiotype[i]) if yinln[i].now > yinl[i].now then yinl[i].now = yinln[i].now if yltype == 1 then yltype = 0 func() end elseif yinln[i].now < yinl[i].now then yinl[i].now = yinln[i].now if yltype == 0 then yltype = 1 func() end end end end function greeting() local hour = tonumber(os.date("%H")) -- 获取当前小时数 if hour >= 5 and hour < 12 then return "上午好 ☁" elseif hour >= 12 and hour < 14 then return "中午好 ☀" elseif hour >= 14 and hour < 19 then return "下午好 ☕" elseif hour >= 19 and hour < 24 then return "晚上好 🌙" elseif hour >= 0 and hour < 3 then return "夜深了,早点休息" else return "凌晨了,注意身体" end end local AddTabV=1 local DP500=getpx('500dp') function defaultP(x) if not screenD then screenD=x return end if x==screenD then return end screenD=x if UI高度 <= UIMAXX then UI高度 = UIMAXX end maxheight= isVertical and math.max(dheight,dwidth)-StatuBarDP or math.min(dheight,dwidth)-StatuBarDP maxwidth= isVertical and math.min(dheight,dwidth) or math.max(dheight,dwidth) if 显示==1 then mainLayoutParams.height = UI宽度 if isVertical then luajava.getIdView('LeftArea'):setVisibility(View.VISIBLE) mainLayoutParams.width = DP500 UI高度=DP500 else luajava.getIdView('LeftArea'):setVisibility(View.INVISIBLE) mainLayoutParams.width = UI高度 end mainLayoutParams.x=math.min(mainLayoutParams.x,200) mainLayoutParams.y=math.min(mainLayoutParams.y,100) window:updateViewLayout(floatWindow, mainLayoutParams) ui宽度=mainLayoutParams.width end UI高度, UI宽度 = UI宽度, UI高度 hx = mainLayoutParams.height hy = mainLayoutParams.width BackV:setTranslationX(0) BackV:setTranslationY(0) SensorV:setTranslationX(0) SensorV:setTranslationY(0) if x==1 then --切换为竖屏时 if AddTabV~=1 then if AddTabV==2 then luajava.getIdView('LeftCard2'):removeView(TabV) luajava.getIdView('LeftCard2'):setVisibility(View.GONE) luajava.getIdView('LeftCard'):removeView(SensorCard) luajava.getIdView('HomePage'):addView(SensorCard) luajava.getIdView('TopArea'):removeView(luajava.getIdView('configButton')) end luajava.getIdView('TimeCard'):setVisibility(View.GONE) luajava.getIdView('TPV'):addView(TabV,0) luajava.getIdView('LeftCard'):addView(luajava.getIdView('configButton'),-1) luajava.getIdView('TimeCard'):setVisibility(View.GONE) AddTabV=1 window:updateViewLayout(floatWindow, mainLayoutParams) end else --切换为横屏时 if AddTabV~=2 then if AddTabV==1 then luajava.getIdView('TPV'):removeView(TabV) luajava.getIdView('HomePage'):removeView(SensorCard) luajava.getIdView('LeftCard'):removeView(luajava.getIdView('configButton')) end luajava.getIdView('TimeCard'):setVisibility(View.VISIBLE) luajava.getIdView('LeftCard'):addView(SensorCard,0) luajava.getIdView('LeftCard2'):addView(TabV) luajava.getIdView('TopArea'):addView(luajava.getIdView('configButton')) luajava.getIdView('LeftCard2'):setVisibility(View.VISIBLE) luajava.getIdView('TimeCard'):setVisibility(View.VISIBLE) AddTabV=2 window:updateViewLayout(floatWindow, mainLayoutParams) end end end suofang = function(v, event) if isLocked then hanshu(v,event) return 0 end local Action = event:getAction() if Action == MotionEvent.ACTION_DOWN then if ldbg~=nil then if ldbg:getVisibility()==View.GONE then ldbg:setVisibility(View.INVISIBLE) end end maxheight = isVertical and math.max(dheight, dwidth) or math.min(dheight, dwidth) maxwidth = isVertical and math.min(dheight, dwidth) or math.max(dheight, dwidth) mainLayoutParams.height = UI高度 mainLayoutParams.width = UI宽度 local mohu=luajava.getIdView('mohu') mohu:setImageBitmap(View2Bitmap(luajava.getIdView('mohuBG'),true)) mohu:setVisibility(View.VISIBLE) ViewPager:setVisibility(View.GONE) isMove = false RawX = event:getRawX() RawY = event:getRawY() hx = mainLayoutParams.height hy = mainLayoutParams.width if hx == 0 or hx==-2 then hx = UIMAXX hy = UIMAXY end elseif Action == MotionEvent.ACTION_MOVE then isMove = true UI高度 = tonumber(hx) + (event:getRawY() - RawY) if UI高度 > UIMAXY then mainLayoutParams.height = math.min(UI高度,maxheight) else mainLayoutParams.height=UIMAXY end UI宽度 = tonumber(hy) + (event:getRawX() - RawX) if UI宽度 > UIMAXX then mainLayoutParams.width = math.min(UI宽度,maxwidth) else mainLayoutParams.width=UIMAXX end UI高度=math.max(UIMAXY,math.min(UI高度,maxheight)) UI宽度=math.max(math.min(UI宽度,maxwidth),UIMAXX) --隐藏() window:updateViewLayout(floatWindow, mainLayoutParams) elseif Action == MotionEvent.ACTION_UP then local mohu=luajava.getIdView('mohu') mohu:setVisibility(View.GONE) ViewPager:setVisibility(View.VISIBLE) end end setOnExitListener(function() if media~=nil then media:release() end luajava.post(function() window:removeView(floatWindow) if verB~=nil then window:removeView(verB) window:removeView(horiB) window:removeView(starv) end end) luajava.setFloatingWindowHide(false) luajava.setFloatingWindowHide(false) gg.setVisible(true) tuichu=1 end) pic_heir=获取图片("/sdcard/长宁/图片/heir") pic_heiright=获取图片('/storage/emulated/0/长宁/图片/FishBone') function changan.menu(sview) -- file.rmdir('/sdcard/.1rlgg定制项目') Gsview=sview closepic=获取图片('/sdcard/长宁/图片/heix') lovepic=获取图片('/sdcard/长宁/图片/love') unlovepic=获取图片('/sdcard/长宁/图片/unlove') playingMusicIcon=获取图片('/sdcard/长宁/图片/764548762') loopOneIcon=获取图片('/sdcard/长宁/图片/1360640248') loopListIcon=获取图片('/sdcard/长宁/图片/1884812492') loopRandomIcon=获取图片('/sdcard/长宁/图片/238759315') onceIcon=获取图片('/sdcard/长宁/图片/836253849') MusicListIcon=获取图片('/sdcard/长宁/图片/1265903674') pic_heix=获取图片("/sdcard/长宁/图片/heix") MusicList={} local pat='/sdcard/长宁/.收藏歌单' if panduan(pat) then load('MusicList='..file.read(pat))() end if #MusicList>0 then playingNum=1 else playingNum=0 end if #sview~=#分页名字 then gg.alert('分页名字数量与菜单配置数量不对应\n请检查你是否写错了') os.exit() end sview[#sview+1]=sview[#sview] sview[#sview-1]={} 分页名字[#分页名字+1]=分页名字[#分页名字] 分页名字[#分页名字-1]='音乐' PageNum=#分页名字 sview=sview huiz() local layout = { 'ui.ViewPager', layout_height='match_parent', layout_width='match_parent', padding=DP3+1, } for i=1,PageNum do local tmp={ LinearLayout, id=luajava.newId("layoutm"..i), orientation="vertical", layout_width="match_parent", layout_height="wrap_content", } table.insert(layout,{ ScrollView, __onFinish=function(v) _ENV['layout'..i]=v v:setVerticalScrollBarEnabled(false) end, padding={'10dp','0dp','10dp','0dp'}, layout_width="match_parent", layout_height="wrap_content", tmp }) end CAMusic_init() local forSearchMusic4 = luajava.post(function() return luajava.loadlayout({ LinearProgressIndicator, visibility='gone', id = luajava.newId('forSearchMusic4'), layout_width = 'match_parent', layout_marginTop='30dp', layout_height = '10dp', indeterminate = true, __onFinish=function(v) v:hide() v:setIndicatorColor({0xff3455FF, 0xff672AFF, 0xff1D8FFF}) v:setIndeterminateAnimationType(0) end, }) end) layout[#sview]={ LinearLayout, layout_width='match_parent', layout_height='match_parent', orientation='vertical', { LinearLayout, layout_width='match_parent', padding='4dp', {LinearLayout, layout_width='match_parent', -- background=getVerticalBG({0x00ffffff,0x00ffffff},20,3,0xff000000), background=getButtonBG(), onClick=function() end, elevation='3dp', layout_margin='3dp', forSearchMusic4, { EditText , gravity = "center" , hint = '请输入关键词' , background=getVerticalBG({0x00ffffff,0x00ffffff},0), textColor='#000000', textSize = "13sp", layout_height = "wrap_content" , layout_marginBottom = "-2dp", id=luajava.newId('musicSearch'), layout_width = 'match_parent' , layout_weight=1, },{LinearLayout, background='#dddddd', id=luajava.newId('forSearchMusic2'), layout_height='match_parent', layout_width='1dp', }, {TextView, text='搜索', textColor='#000000', id=luajava.newId('forSearchMusic3'), textSize='15sp', layout_width='50dp', gravity='center', onClick=function() local t=luajava.getIdView('musicSearch'):getText() luajava.startThread(function() if t=='' then return 0 end luajava.runUiThread(function() luajava.getIdView('forSearchMusic2'):setVisibility(View.GONE) luajava.getIdView('musicSearch'):setVisibility(View.GONE) luajava.getIdView('musicSearch'):setText('') luajava.getIdView('forSearchMusic3'):setVisibility(View.GONE) luajava.getIdView('forSearchMusic4'):setVisibility(View.VISIBLE) luajava.getIdView('forSearchMusic4'):show() end) searchMus(t,nil,nil,nil,nil,true) luajava.runUiThread(function() luajava.getIdView('forSearchMusic2'):setVisibility(View.VISIBLE) luajava.getIdView('musicSearch'):setVisibility(View.VISIBLE) luajava.getIdView('forSearchMusic3'):setVisibility(View.VISIBLE) luajava.getIdView('forSearchMusic4'):setVisibility(View.GONE) luajava.getIdView('forSearchMusic4'):hide() YoYoImpl:with("FadeIn"):duration(1000):playOn(listv) end) end) end } } }, listv } local bottombar={ LinearLayout, layout_width="match_parent", layout_height="wrap_content", layout_marginTop='3dp', elevation='3dp', __onFinish=function(v) v:setBackground(getVerticalBG({0xffffffff,0xffffffff},0)) end, {HorizontalScrollView, layout_weight=1, layout_width='match_parent', id=luajava.ids['cbscro'], __onFinish=function(v) v:setHorizontalScrollBarEnabled(false) end, }, } CloseMenu=function() CATransition(ldbg,'configButton',400,OvershootInterpolator(),function () --CAAnimation(ExitButton,'Small',600) --CAAnimation(MusicCard,'Small',600) vibra:vibrate(10) local mohu=luajava.getIdView('mohu') if mohu then mohu:setVisibility(View.VISIBLE) YoYoImpl:with("FadeOut"):onEnd(function() mohu:setVisibility(View.GONE) mohu:setAlpha(1) end):duration(400):playOn(mohu:getParent():getChildAt(1)) end end,function() ldbg:setVisibility(View.GONE) end) end OpenMenu=function() local mohu=luajava.getIdView('mohu') if mohu then mohu:setImageBitmap(View2Bitmap(luajava.getIdView('mohuBG'),true)) end CATransition('configButton',ldbg,400,OvershootInterpolator(),function() --ldbg:setVisibility(View.VISIBLE) vibra:vibrate(10) mohu:setVisibility(View.VISIBLE) --CAAnimation(ExitButton,'Big',600) --CAAnimation(MusicCard,'Big',600) YoYoImpl:with("FadeIn"):duration(400):playOn(mohu:getParent():getChildAt(1)) end) end UpAndDown=function(view, event) local Action = event:getAction() if Action == MotionEvent.ACTION_DOWN then RawX = event:getRawX() RawY = event:getRawY() x = mainLayoutParams.x y = mainLayoutParams.y elseif Action == MotionEvent.ACTION_MOVE then local deltaY = event:getRawY()-RawY--移动Y距离 local deltaX = event:getRawX()-RawX--移动X距离 local absX=math.abs(deltaX) local absY=math.abs(deltaY) local t=IsLandStatus if deltaY < fdp20 then RawY = event:getRawY() OpenMenu() elseif deltaY > dp20 then RawY = event:getRawY() CloseMenu() end elseif Action == MotionEvent.ACTION_UP then end end local topbar={ LinearLayout, layout_width="wrap_content", layout_height="match_parent", orientation='vertical', layout_marginTop='-5dp', --gravity='center_horizontal', id=luajava.ids['LeftCard'], onClick=function(v) end, onTouch=hanshu, { LinearLayout, id=luajava.ids['TopArea'], layout_width='match_parent', gravity='center_vertical', { ImageView, --background = 获取图片2(悬浮窗图标), layout_width = "40dp", layout_height = "40dp", layout_marginTop='5dp', padding='4dp', src=获取图片2(悬浮窗图标), onClick = 隐藏, onTouch = hanshu, __onFinish=function(v) MenuV=v end, }, { LinearLayout, id=luajava.ids['TimeCard'], layout_height='match_parent', layout_width='match_parent', layout_weight=1, visibility='gone', gravity='center', layout_margin='3dp', elevation='3dp', background=getBG(0xffffffff,20), { TextView, layout_height='match_parent', layout_width='match_parent', textSize='15sp', gravity='center', textColor=0xff007BFF, __onFinish=function(v) v:setTypeface(sharkTTF) luajava.startThread(function() while true do gg.sleep(1000) luajava.runUiThread(function() v:setText(getTimeStamp()) end) end end) end } } }, {LinearLayout, layout_width='200dp', id=luajava.ids['LeftCard2'], visibility='gone' }, { LinearLayout, id=luajava.ids['LeftArea'], layout_height='match_parent', layout_width='match_parent', layout_margin='4dp', layout_marginTop='0dp', elevation='3dp', gravity='bottom', layout_weight=1, background=getBG(0x66ffffff,getpx('6dp'),getpx('2dp'),0xffffffff), { LinearLayout, layout_width='match_parent', layout_height='match_parent', layout_weight=1, orientation='horizontal', gravity='left', layout_marginRight='-20dp', padding='5dp', HistoryView }, { ImageView, layout_width='70dp', layout_height='70dp', gravity='center', src=getRes('guralh'), }, }, { GifImageView, id=luajava.ids['configButton'], layout_width='46dp', layout_height='46dp', src='/sdcard/长宁/图片/Gura_Eat', -- src=获取图片2('https://image.rlyun.fun/view.php/cc09359a81bbec00fb21000d761c6ab9.png'), __onFinish=function(v) v:getDrawable():start() end, onClick=OpenMenu, onTouch=UpAndDown } } ViewPager = ui.ViewPager(layout) ViewPagerV=ViewPager luajava.setInterface(ViewPager, 'addOnPageChangeListener', {onPageSelected=function(view) 当前ui=view 滚(view) end}) changan.colorf = function(control,colors,t) control:post(function() colorAnim = ObjectAnimator:ofInt(control,"colorFilter", colors) colorAnim:setDuration(t) colorAnim:setEvaluator(ArgbEvaluator()) colorAnim:setRepeatCount(ValueAnimator.INFINITE) colorAnim:setRepeatMode(ValueAnimator.REVERSE) end) end local wideView=luajava.loadlayout({LinearLayout, layout_width='130dp', layout_height='25dp', }) local menui=luajava.loadlayout({ LinearLayout,--菜单 layout_height = "match_parent", layout_width = "match_parent", gravity = "center_horizontal", -- id=luajava.ids['sideBG'], -- background=getVerticalBG({0xffffffff,0xffffffff},20,getpx('3dp'),'0xff'..全局RGB), onClick = function() end, onTouch = hanshu, topbar, { LinearLayout, layout_height='match_parent', layout_width='2dp', layout_marginTop='40dp', layout_marginBottom='20dp', background=getBG(0xffffffff,10), }, {LinearLayout, layout_weight=1, layout_height='match_parent', layout_width='match_parent', layout_marginLeft=-DP3-1, orientation='vertical', layout_marginTop='1dp', id=luajava.ids['TPV'], TabV, {FrameLayout, layout_height='match_parent', layout_width='match_parent', id=luajava.ids['mohuBG'], __onFinish=function(v) mohuBG=v end, -- background=getBG({0x55ffffff,0x33ffffff,0x55ffffff},10), ViewPager, {ImageView, visibility='gone', gravity='top', layout_height='match_parent', layout_width='match_parent', scaleType='fitXY', id=luajava.ids['mohu'], } }}, }) transManager=TransitionManager() dp35=getpx('39dp') local ckou=luajava.loadlayout({ FrameLayout, layout_height = "match_parent", layout_width = "match_parent", __onFinish=function(v) WindowView=v end, menui, { ImageView, id="sf", padding = "2dp", layout_width = "30dp", layout_height = "30dp", layout_marginRight = "0dp", layout_marginBottom = "0dp", layout_gravity = "right|bottom", onClick = function() -- floatWindow:setBackground(beij) end, __onFinish=function(v) v:setOnTouchListener(suofang) end, },{LinearLayout, visibility='invisible', layout_height='match_parent', layout_width='match_parent', gravity='center', --layout_marginLeft='52dp', orientation='vertical', -- background=getBG(0x33ffffff,10), __onFinish=function(v) ldbg=v end, onClick=function(v) CloseMenu() end, onTouch=UpAndDown, { MaterialCardView, id=luajava.ids['configUI'], layout_height='100dp', layout_width='200dp', layout_margin='10dp', useCompatPadding=false, cardElevation='5dp', cardBackgroundColor='#00f00000', strokeColor=0x00ffffff, __onCreate=function(v) v:setRadius(DP10/2) end, { ImageView, layout_width='match_parent', layout_height='match_parent', gravity='center', src=getRes('LightGura'), id=luajava.ids['LightGura'], onClick=function(v) CATransition('LightGura','DarkGura',400,LinearOutSlowInInterpolator(),function() floatWindow:setCardElevation(0) changan.colorCard(BackCard,背景1,背景2,600) end) end, }, { ImageView, layout_width='match_parent', layout_height='match_parent', gravity='center', visibility='invisible', src=getRes('DarkGura'), id=luajava.ids['DarkGura'], onClick=function(v) CATransition('DarkGura','LightGura',400,LinearOutSlowInInterpolator(),function() floatWindow:setCardElevation(DP3) changan.colorCard(BackCard,背景2,背景1,600) end) end, }, }, { LinearLayout, layout_height='130dp', layout_marginBottom='10dp', layout_width='match_parent', layout_marginLeft='10dp', layout_marginRight='10dp', gravity='center', background=getBG(0xdd161616,30), elevation='4dp', __onFinish=function(v) MusicCard=v end, MusicCard }, { ImageView, __onFinish=function(v) ExitButton=v end, layout_width='30dp', layout_height='30dp', gravity='center', src=获取图片('https://image.rlyun.fun/view.php/98e7a54b8e92f732b77a37a006152028.png'), padding='5dp', colorFilter=0xffffffff, background=getBG(0x66161616,20,4,0xffffffff), onClick=function(v) tuichu=1 end, }, }, }) changan.loadViews(PageNum,sview) floatmain={ FrameLayout, id='floatmain', fillViewPort=true, layout_height='match_parent', layout_width='match_parent', onClick = function() end, -- onTouch = suofang, ckou, { ImageView, id=luajava.ids['xfc'], __onFinish=function(v) control2=v end, background = 获取图片2(悬浮窗图标), layout_width = "40dp", layout_height = "40dp", onTouch = hanshu, onClick = 隐藏, visibility='gone', } } function checkSize() end luajava.post(function() floatmain=luajava.loadlayout(floatmain) local vertiParam=getLayoutParams2() vertiParam.width=0 local horiParam=getLayoutParams2() horiParam.height=0 local tabLayout=luajava.getIdView('tab') --tabLayout:setSelectedTabIndicatorColor('0xff000000') tabLayout:setTabTextColors(ColorStateList({ {android.R.attr.state_selected}, {}, }, { '0xFFffffff', 0xffeeeeee })) tabLayout:setTabRippleColor(ColorStateList({ {android.R.attr.state_pressed}, {android.R.attr.state_hovered}, {android.R.attr.state_focused}, }, { 0xffd7d7d7, 0xff525252, 0xff000000, })) tabLayout:setupWithViewPager(ViewPager) for i=1,PageNum do tabLayout:getTabAt(i-1):setText(分页名字[i]) --tabLayout:getTabAt(i-1):setIcon(getRes(分页名字[i][2])) end -- tabLayout:setTabMode(TabLayout.MODE_FIXED) -- tabLayout:setTabGravity(TabLayout.GRAVITY_CENTER) window:addView(luajava.loadlayout({ LinearLayout, __onFinish=function(v) verB=v end }),vertiParam) local wm=getLayoutParams() wm.flags = LayoutParams.FLAG_NOT_FOCUSABLE window:addView(luajava.loadlayout({ LinearLayout, __onFinish=function(v) starv=v end }),wm) window:addView(luajava.loadlayout({ LinearLayout, __onFinish=function(v) horiB=v luajava.startThread(function () isVertical=true defaultP(1) while true do gg.sleep(200) luajava.runUiThread(function () local Vheight=verB:getMeasuredHeight() local Vwidth=horiB:getMeasuredWidth() if Vheight>Vwidth then defaultP(1) isVertical=true else defaultP(0) isVertical=false if 显示==0 then SensorCard:setVisibility(View.GONE) end end end) end end) end }),horiParam) floatWindow:addView(floatmain) 隐藏(floatWindow) -- floatWindow:removeView(beforejz) luajava.runUiThread(function() YoYoImpl:with("FadeIn"):duration(800):playOn(floatmain) YoYoImpl:with("FadeOut"):onStart(function() end):onEnd(function() PrintLog(getTimeStamp()..'启动完毕') beforejz:setVisibility(View.GONE) local Vheight=verB:getMeasuredHeight() local Vwidth=horiB:getMeasuredWidth() if Vheight1 then animatedProgress=1+(animatedProgress-1)/6 end mainLayoutParams.height=height1+(UI高度-height1)*animatedProgress mainLayoutParams.width=width1+(UI宽度-width1)*animatedProgress window:updateViewLayout(floatWindow, mainLayoutParams) end }) animator:addUpdateListener(listener) local listener = luajava.createProxy('android.animation.Animator$AnimatorListener', { onAnimationStart = function() floatWindow:setCardBackgroundColor(MainColor) end, onAnimationEnd = function() sf:setVisibility(View.VISIBLE) Closing=false end, onAnimationCancel = function(animator) end }) animator:addListener(listener) animator:start() --YoYoImpl:with("FadeIn"):onStart(function() --floatWindow:setCardElevation(DP3) mainLayoutParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL --mainLayoutParams.width = UI宽度 --mainLayoutParams.height = UI高度 --window:updateViewLayout(floatWindow, mainLayoutParams) --WindowView:setVisibility(View.VISIBLE) --end):duration(300):playOn(WindowView) end) zzdh=false else --print(os.clock()) if not isVertical then SensorCard:setVisibility(View.GONE) end 显示=0 zzdh=true v:post(function() -- changan.controlSmall(MenuV,600) -- changan.controlBig(control2,600) floatWindow:setCardElevation(0) sf:setVisibility(View.GONE) --YoYoImpl:with("FadeOut"):onEnd(function() --WindowView:setVisibility(View.GONE) mainLayoutParams.flags = LayoutParams.FLAG_NOT_FOCUSABLE mainLayoutParams.width = LayoutParams.WRAP_CONTENT mainLayoutParams.height = LayoutParams.WRAP_CONTENT window:updateViewLayout(floatWindow, mainLayoutParams) --end):duration(300):playOn(WindowView) height1=UI高度 width1=UI宽度 -- changan.controlSmall(control2,600) -- changan.controlBig(MenuV,600) local animator=ValueAnimator:ofObject(FloatEvaluator(),{0,1}):setDuration(300) animator:setInterpolator(DecelerateInterpolator()) 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 = func, onAnimationEnd = function() ViewPagerV:setVisibility(View.GONE) floatWindow:setCardBackgroundColor(0x00ffffff) Closing=false end, onAnimationCancel = function(animator) end }) animator:addListener(listener) animator:start() end) zzdh=false end end function launch(pkg) local loadBox = getLoadingBox('正在启动游戏') gg.setProcess(pkg) gg.sleep(500) if tostring(gg.getTargetPackage()) == pkg then gg.toast("进程已选择:"..pkg) return 0 end gg.toast("正在启动游戏...") loadBox['显示']() app.start(pkg) jci=0 --gg.sleep(5000) while true do gg.setProcess(pkg) gg.sleep(400) if tostring(gg.getTargetPackage()) == pkg then gg.alert("启动成功") loadBox['关闭']() break else jci=jci+1 if jci==14 then loadBox['关闭']() gg.alert("自动获取进程失败\n请手动选择游戏进程") gg.setProcessX() break end end gg.sleep(100) end end local RadTint=ColorStateList({ {android.R.attr.state_checked}, {-android.R.attr.state_checked}, {}, }, { 0xff5AA7FF, 0xff161616, 0xffffffff }) function changan.intcheck(name,func1,func2) local nid = name..guid() local func = 开关(name,func1,func2,nid) if not name then name = "未设置" end return { LinearLayout, layout_width = 'match_parent', layout_weight=1, layout_height = "42dp", layout_marginTop = "1dp", layout_marginBottom = "1dp", padding = "1dp", { LinearLayout, padding="3dp", layout_width = 'match_parent', layout_height = "wrap_content", gravity = "center_vertical", --background=getVerticalBG({0xffFFFDF2,0xddffffff,0xffFFFDF2},15,8,0xffFFDA71), { CheckBox, id=luajava.newId(nid.."t"), layout_width = '32dp', layout_height = '32dp', padding = "0dp", __onFinish=function(v) v:setButtonTintList(RadTint) end, onClick = function(v) luajava.newThread(function() func() end):start() end, },{ TextView, gravity = "left", text = name, textColor=0xff000000, textSize = "14sp", layout_width = 'match_parent', layout_weight=1, __onFinish=function(v) v:setTypeface(sharkTTF) end, onClick = function() local v=luajava.getIdView(nid..'t') if v:isChecked() then v:setChecked(false) else v:setChecked(true) end luajava.newThread(function() func() end):start() end, }, } } end changan.controlRotation9 = function(control, time,t) luajava.runUiThread(function() xuanzhuandonghua = ObjectAnimator:ofFloat(control, "rotation", { time,t }) xuanzhuandonghua:setRepeatCount(0) xuanzhuandonghua:setRepeatMode(Animation.RESTART) xuanzhuandonghua:setDuration(400) xuanzhuandonghua:start() end) end function visi (tid) vibra:vibrate(4) if boxes[tid][5] then boxes[tid][5]=false transManager:go(boxes[tid][1],boxes[tid][4]) changan.controlRotation9(boxes[tid][3],90,0) --boxes[tid][3]:setColorFilter(0xffffffff) else boxes[tid][5]=true transManager:go(boxes[tid][2],boxes[tid][4]) changan.controlRotation9(boxes[tid][6],0,90) --boxes[tid][6]:setColorFilter('0xff'..全局RGB) end end function 开关(name , func1 , func2 ) local localname=name local tname=name..guid() if func1 == nil then func1 = "" end if func2 == nil then func2 = "" end if type(func1 ) == "function" then return function() namers = _ENV [ tname ] if namers ~= "开" then _ENV [ tname ] = "开" PrintLog(getTimeStamp()..''..localname..'已开启') pcall(func1 ) else _ENV [ tname ] = "关" PrintLog(getTimeStamp()..''..localname..'已关闭') pcall(func2 ) end end end end swfuncs,buts,sliders,boxes,textvs={},{},{},{},{} function changan.getedit (name) edit = tostring (luajava.getIdValue (_ENV [name]) : getText ()) return edit end function changan.setedit (name , txt) txt = tostring (txt) luajava.runUiThread (function () luajava.getIdValue (_ENV [name]) : setText (txt) end ) end function getButtonBG() local selector = luajava.getStateListDrawable() selector:addState({ android.R.attr.state_pressed }, getVerticalBG({0x55d7d7d7,0x55d7d7d7},20)) selector:addState({ -android.R.attr.state_pressed }, getVerticalBG({0xffffffff,0xffffffff},20)) return selector end function changan.text(text,color,size,isjz) if not color then color="#161616" end if color=='跟随主题' then color='#7F5EFF' end if isjz then jzjz='center' else jzjz='left' end return { TextView, text=text, textColor=color, textSize=size, gravity=jzjz, layout_height="wrap_content", layout_width="match_parent", autoSizeTextType="uniform", __onFinish=function(v) if color=='#7F5EFF' then v:setTextColor('0xff'..全局RGB) table.insert(textvs,v) end end, } end function changan.button(txt,func,txtc) if not txt then txt = "未设置" end if not txtc then txtc="#000000" end if txtc=='跟随主题' then txtc='#190335' end local tid="Cbutton".. guid() return { LinearLayout, layout_width = "match_parent", gravity = "center_vertical", layout_margin = "4dp", background = getButtonBG(), elevation='2dp', padding="10dp", onClick = function(v) PrintLog(getTimeStamp()..'执行 '..txt..'') changan.controlWater(v,300) luajava.newThread(func):start() end, { TextView, --id = luajava.newId(tid), textColor = txtc, text = txt, __onFinish=function(v) v:setTypeface(sharkTTF) if txtc=='#190335' then table.insert(textvs,v) v:setTextColor('0xff'..全局RGB) end end, textSize = "13sp", layout_height = "wrap_content", layout_width = "match_parent", layout_weight=1, },{ImageView, src=pic_heir, layout_height="14dp", layout_width="14dp", colorFilter=0xff94c3f9 } } end local marg=luajava.new(RectF,10,10,10,10) local swcDraw=ColorStateList({ {android.R.attr.state_checked}, {-android.R.attr.state_checked}, }, { '0xFF94C3F9', '0x43366295', }) local swctrack=ColorStateList({ {android.R.attr.state_checked}, {-android.R.attr.state_checked}, }, { '0x00ffffff', 0xffffffff, }) local swcThumb=ColorStateList({ {android.R.attr.state_checked}, {android.R.attr.state_pressed}, {-android.R.attr.state_pressed}, }, { 0xffffffff, 0xffeeeeee, 0xffffffff }) function changan.switch(name,func1,func2,miaoshu) local nid = name..guid() swfuncs[nid]= {func1,func2} if not name then name = "未设置" end local rest ={ FrameLayout, layout_width = 'match_parent', layout_height = "48dp", gravity = "center_vertical", { LinearLayout, layout_width = 'match_parent', layout_height = "40dp", layout_margin="4dp", gravity = "center_vertical", background = getBG(0xffffffff,20), elevation="2dp", padding = { "0dp","0dp","6dp","0dp" }, { TextView, gravity = "top", text = name, textColor = '#000000', textSize = "13sp", layout_weight = 1, layout_width = '80dp', layout_marginLeft = "10dp", layout_marginRight = "20dp", __onFinish=function(v) v:setTypeface(sharkTTF) end, }, { TextView, gravity = "center", layout_height = "match_parent", text = miaoshu, textSize = "11sp", layout_width = "wrap_content", layout_marginLeft = "-50dp", layout_weight = 1, textColor = "#A5A5A5", __onFinish=function(v) v:setTypeface(sharkTTF) end, }, { SwitchButton, id=luajava.newId(nid), __onFinish=function(v) v:setBackRadius (DP3) v:setThumbColor(swcThumb) v:setBackColor(swcDraw) v:setThumbRadius(DP3) v:setThumbRangeRatio(2.2) v:setThumbMargin(marg) table.insert(switchs,v) if name=='音量键隐藏UI' then 音量键=true v:post(function() v:setChecked(true) end) end if name=='摇一摇隐藏UI' then 摇一摇=true v:post(function() v:setChecked(true) end) end -- v:setTrackTintList(swcDraw) -- v:setThumbTintList(swcThumb) -- v:setTrackDecorationTintList(swctrack) luajava.setInterface(v, 'setOnCheckedChangeListener', {onCheckedChanged=function(view,isc) if isc then PrintLog(getTimeStamp()..''..name..'已开启') local func=swfuncs[nid][1] or function() end if func~=nil then luajava.startThread(func) end else PrintLog(getTimeStamp()..''..name..'已关闭') local func=swfuncs[nid][2] or function() end if func~=nil then luajava.startThread(func) end end end}) end, layout_width = 'wrap_content', layout_height = 'wrap_content', }}, -- { -- LinearLayout, -- layout_width = '4dp', -- layout_height = "match_parent", -- layout_margin="4dp", -- layout_gravity = "left", -- background = getBG(0xff5f91ae,{10,0,0,10}), -- elevation="2dp", -- }, } return rest end function changan.check(cklist) if #cklist==0 then return nil end local rest = { LinearLayout, layout_width = 'match_parent', layout_height = "wrap_content", layout_margin='4dp', elevation='3dp', background=getBG(0xffffffff,20), gravity = "center", orientation="vertical", } for i = 1, #cklist,2 do local tempTable = {LinearLayout, layout_width = 'match_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 function changan.box(views) local tid = "box".. guid () boxes[tid]={} local firadio = { LinearLayout , layout_width = 'match_parent' , layout_height = "wrap_content" , layout_margin = "4dp" , orientation = "vertical" , background=getButtonBG(), elevation='2dp', __onFinish=function(v) boxes[tid][2]=Scene(v,boxes[tid][2]) boxes[tid][1]=Scene(v,boxes[tid][1]) boxes[tid][4]=luajava.new(TransitionSet) local bds=luajava.new(ChangeBounds) bds:setDuration(500) boxes[tid][4]:addTransition(bds) boxes[tid][4]:setDuration(500) end, } if type (views [1]) == "string" or type (views [1]) == "number" then else gg.alert ("changan.box的table内第一个元素必须是string") os.exit () end local but={ LinearLayout , layout_width = 'match_parent' , layout_height = "40dp" , gravity = "center_vertical" , layout_margin = "3dp" , background = getButtonBG(), onClick = function () visi (tid) end, { TextView , text = views [1] , textSize = "13sp" , layout_marginLeft = "15dp" , layout_width = "match_parent" , layout_weight=1, textColor = "#000000" , gravity = "left" , __onFinish=function(v) v:setTypeface(sharkTTF) end, },{ LinearLayout , padding={"0dp","0dp","10dp","0dp"}, layout_width = "30dp" , layout_height = "30dp" , gravity = "center", { ImageView , padding='1dp', src = pic_heiright, layout_width = "24dp" , layout_height = "24dp" , colorFilter=0xff94c3f9 } } } boxes[tid][1]=luajava.loadlayout{ LinearLayout, layout_width='match_parent', { LinearLayout , layout_width = 'match_parent' , layout_height = "40dp" , gravity = "center_vertical" , layout_margin = "3dp" , background = getButtonBG(), onClick = function () visi (tid) end, { TextView , text = views [1] , textSize = "13sp" , layout_marginLeft = "15dp" , layout_width = "match_parent" , layout_weight=1, textColor = "#000000" , gravity = "left" , __onFinish=function(v) v:setTypeface(sharkTTF) end, },{ LinearLayout , padding={"0dp","0dp","10dp","0dp"}, layout_width = "30dp" , layout_height = "30dp" , gravity = "center", { ImageView , src = pic_heiright, padding='1dp', layout_width = "24dp" , layout_height = "24dp" , colorFilter=0xff94c3f9, __onFinish=function(v) boxes[tid][3]=v end, } } } } table.insert(firadio,but) local radios = { LinearLayout, orientation = "vertical", layout_width = 'match_parent', } for i = 2 , # views do radios [# radios + 1] = views [i] end boxes[tid][2]=luajava.loadlayout{ LinearLayout, layout_width='match_parent', orientation = "vertical" , { LinearLayout , layout_width = 'match_parent' , layout_height = "40dp" , gravity = "center_vertical" , layout_margin = "3dp" , background = getButtonBG(), onClick = function () visi (tid) end, { TextView , text = views [1] , textSize = "13sp" , layout_marginLeft = "15dp" , layout_width = "match_parent" , layout_weight=1, textColor = "#000000" , gravity = "left" , __onFinish=function(v) v:setTypeface(sharkTTF) end, },{ LinearLayout , padding={"0dp","0dp","10dp","0dp"}, layout_width = "30dp" , layout_height = "30dp" , gravity = "center", { ImageView , src = pic_heiright, padding='1dp', layout_width = "24dp" , layout_height = "24dp" , colorFilter='0xffffffff', __onFinish=function(v) boxes[tid][6]=v end, } } }, radios } return firadio end function changan.edit(name , hint) _ENV [name] = name..guid () if not hint then hint = "点击输入文字" end return { LinearLayout , layout_width = 'match_parent' , layout_height = "40dp" , layout_marginTop = "5dp" , layout_marginBottom = "5dp" , layout_marginLeft = "0dp" , layout_marginRight = "0dp" , gravity = "center_vertical" , { EditText , background = getButtonBG(), __onFinish=function(v) v:setHintTextColor(0xaa000000) end, gravity = "center" , hint = hint , textColor='#000000', textSize = "13sp", layout_height = "40dp" , layout_marginRight='5dp', layout_marginLeft='5dp', --layout_marginBottom = "-2dp", id=luajava.newId(_ENV [name]), layout_width = 'match_parent' , } } end function changan.seek(name,bian,smin,smax,nows) _ENV[bian] =nows local smin=tonumber(smin) local smax=tonumber(smax) if _ENV[bian] == nil then _ENV[bian] = 1.0 end if not name then name = "未设置" end local names = name..guid() kid=guid().."sk" return { LinearLayout, id=luajava.newId(kid), layout_width = 'match_parent', layout_hight = "match_parent", layout_marginTop = "5dp", layout_marginBottom = "5dp", gravity = "center_vertical", { TextView, padding={"10dp","10dp","0dp","10dp",}, gravity = "top", textColor='#000000', text = name, id = luajava.newId(names), layout_width = '80dp', --layout_marginLeft = "5dp", layout_marginRight = "0dp", __onFinish=function(v) v:setTypeface(sharkTTF) end, }, { Slider, thumbHeight='26dp', trackHeight='10dp', trackStopIndicatorSize='0dp', thumbTrackGapSize='0dp', tickVisible=false, __onFinish=function(v) v:setCustomThumbDrawable(getRes('shark')) table.insert(sliders,v) v:setTrackActiveTintList(ColorStateList({{},},{0xff006DFF})) v:setTrackInactiveTintList(ColorStateList({{},},{0xffCCE5FF})) v:setThumbTintList(ColorStateList({{},},{0xff006DFF})) luajava.setInterface(v, 'addOnChangeListener', function(SeekBar, var2, var3) _ENV[bian] = var2 end) end, layout_width = 'match_parent', id=luajava.newId(name.."seekbar"), valueFrom=smin, valueTo=smax, value=nows, stepSize=1.0, } } end function changan.radio(cklist) local rest = { LinearLayout , layout_width = 'match_parent' , layout_height = "wrap_content" , gravity = "top" , orientation = "vertical" , } if type (cklist [1]) == "string" then rds=2 rest [# rest + 1] = { TextView , gravity = "left" , padding="5dp", text = cklist [1] , textSize = "13sp" , textColor = '#000000' , layout_width = 'match_parent' , layout_height = 'wrap_content' , layout_marginLeft = "10dp" , layout_marginRight = "5dp" , layout_marginTop = "0dp" , layout_marginBottom = "0dp" , __onFinish=function(v) v:setTypeface(sharkTTF) end, } else rds=1 end local restt={ RadioGroup , layout_width = 'match_parent' , layout_height = "wrap_content" , layout_margin = "4dp" , gravity = "top" , orientation = "vertical" , elevation='2dp', background=getVerticalBG({0xffffffff,0xffffffff},20,DP3,0xffffffff), } for i = rds , # cklist do local name = cklist [i] [1] local func = cklist [i] [2] if not name then name = "未设置" end local nid = name..guid () restt [# restt + 1] = { RadioButton , gravity = "top" , text = name , textSize="13sp", gravity='center_vertical', textColor = '#000000', layout_width = 'match_parent' , layout_height = 'wrap_content' , layout_marginLeft = "2dp" , layout_marginRight = "2dp" , __onFinish=function(v) v:setTypeface(sharkTTF) v:setButtonTintList(RadTint) end, onClick=function() PrintLog(getTimeStamp()..'选择 '..name..'') luajava.startThread(func) end } end rest [# rest + 1] = restt return rest end function changan.image(img,height,width,pad,func) if not func then func=function() end end if not pad then pad="0dp" end if not height then height="80dp" end if not width then width="80dp" end return { LinearLayout, layout_height="wrap_content", layout_width="match_parent", gravity="center", { ImageView, layout_height=height, layout_width=width, padding=pad, src=获取图片(img), onClick=function() luajava.newThread(func):start() end, }} end function changan.loadViews(PageNum) local i=1 local gsi=Gsview[i] for j=1,#gsi do if type(gsi[j])=='table' then local CreatedView CreatedView=gsi[j] local ParentV=luajava.loadlayout({LinearLayout,CreatedView}) CreatedView=ParentV:getChildAt(0) ParentV:removeView(CreatedView) local layoutm=luajava.getIdView('layoutm'..i) luajava.runUiThread(function() layoutm:addView(CreatedView) end) elseif type(gsi[j])=='userdata' then luajava.getIdView('layoutm'..i):addView(gsi[j]) end end for i=2,PageNum do if i~=PageNum-1 then local gsi=Gsview[i] luajava.startThread(function() for j=1,#gsi do if type(gsi[j])=='table' then local CreatedView CreatedView=gsi[j] local ParentV=luajava.loadlayout({LinearLayout,CreatedView}) CreatedView=ParentV:getChildAt(0) ParentV:removeView(CreatedView) local layoutm=luajava.getIdView('layoutm'..i) luajava.runUiThread(function() layoutm:addView(CreatedView) end) elseif type(gsi[j])=='userdata' then luajava.getIdView('layoutm'..i):addView(gsi[j]) end end end) end end end HistoryList={} HistoryAdapter = ui.BaseAdapter({ getCount = function() return #HistoryList end, getItem = function(position) return HistoryList[position+1] end, getItemId = function(position) return position end, getView = function(position, convertView, parent) local pos=position+1 local info = HistoryList[pos] if not convertView then local tmp={ TextView, layout_width='wrap_content', layout_height='wrap_content', textSize='13sp', textColor='#000000', onClick=nothing, __onFinish=function(v) v:setTypeface(sharkTTF) end, } convertView = luajava.loadlayout(tmp) end convertView:setText(string.fromHtml(info)) return convertView end }) HistoryView = luajava.loadlayout({ 'ui.ListView', adapter = HistoryAdapter, layout_width='match_parent', layout_height='match_parent', overScrollMode="never", dividerHeight='0dp', __onFinish=function(v) v:setNestedScrollingEnabled(true) end, }) function PrintLog(txt) luajava.runUiThread(function() table.insert(HistoryList,txt) HistoryAdapter:notifyDataSetChanged() HistoryView:setSelection(#HistoryList -2) end) end MainColor=0xFF94C3F9 changan.colorCard=function(control,startColor,endColor,t) MainColor=endColor luajava.runUiThread(function() control:setCardBackgroundColor(startColor) local animator=ValueAnimator:ofObject(ArgbEvaluator(),{startColor,endColor}):setDuration(t) local listener=luajava.createProxy('android.animation.ValueAnimator$AnimatorUpdateListener',{ onAnimationUpdate=function(animation) local animatedColor = animation:getAnimatedValue() control:setCardBackgroundColor(animatedColor) end }) animator:addUpdateListener(listener) animator:start() end) end import'android.hardware.*'; local sensor2 = luajava.createProxy('android.hardware.SensorEventListener', { onSensorChanged = function(event) if 显示==0 then return end local sensorList = table.list(event.values) deltaX = sensorList[isVertical and 2 or 1] deltaY = sensorList[isVertical and 1 or 2] -- 滤波处理 local alpha = 0.5 -- 滤波系数 deltaX = alpha * deltaX + (1 - alpha) * (lastDeltaX or 0) deltaY = alpha * deltaY + (1 - alpha) * (lastDeltaY or 0) lastDeltaX = deltaX lastDeltaY = deltaY -- 阈值处理 local threshold = 0.1 -- 阈值 if math.abs(deltaX) < threshold then deltaX = 0 end if math.abs(deltaY) < threshold then deltaY = 0 end view1 = BackV view2 = SensorV -- 更新 view1 的位置 local translationX1 = view1:getTranslationX() + deltaX * 2 --local translationY1 = view1:getTranslationY() + deltaY *1 view1:setTranslationX(math.max(-dp20, math.min(dp20, translationX1))) --view1:setTranslationY(translationY1) -- 获取 view2 当前的位置 local transx = view2:getTranslationX() local transy = view2:getTranslationY() -- 计算新的 translationX 和 translationY local newTransX = transx + deltaX * 5 local newTransY = transy - deltaY * 2 -- 限制 translationX 在 -10 到 10 之间 -- 限制 translationY 在 -10 到 10 之间 newTransY = math.max(-DP10, math.min(DP10, newTransY)) -- 更新 view2 的位置 view2:setTranslationX(newTransX) view2:setTranslationY(newTransY) end, onAccuracyChanged = function() -- 可以在这里处理传感器精度变化 end }) dexloader=dex.loadfile('/sdcard/长宁/图片/sensor.dex') MySensorManager2 = dexloader:loadClass('com.changan.CACore.MySensorManager') SwitchButton=dexloader:loadClass('com.changan.CACore.SwitchButton') TabV=luajava.loadlayout({ TabLayout, id=luajava.newId('tab'), layout_width = "wrap_content", layout_height = "30dp", setTabMode = 0, tabMinWidth='20dp', __onFinish=function(v) -- v:setTabIndicatorFullWidth(true) v:setSelectedTabIndicatorColor(0xffffffff) -- local skt=getRes('sharktab') -- skt:setBounds(0,0,100,30) -- v:setSelectedTabIndicator(skt,300,10) v:setBackground(getBG(0x00ffffff)) end }) SensorCard=luajava.loadlayout( {LinearLayout, layout_width='match_parent', gravity='center', {MaterialCardView, layout_width='200dp', layout_height='100dp', useCompatPadding=false, cardElevation='5dp', layout_margin='5dp', -- layout_marginTop='0dp', cardBackgroundColor='#00f00000', strokeColor=0x00ffffff, __onCreate=function(v) v:setRadius(DP10/2) end, { LinearLayout, layout_width='250dp', layout_height='150dp', layout_gravity='center', orientation='horizontal', gravity='center', background=getRes('grb'), onClick=function(v) BackV:setTranslationX(0) BackV:setTranslationY(0) SensorV:setTranslationX(0) SensorV:setTranslationY(0) end, onTouch=hanshu, __onFinish=function(v) BackV=v MySensorManager2(context, sensor2) end, { LinearLayout, layout_width='160dp', layout_height='126dp', background=getRes('grc'), __onFinish=function(v) SensorV=v end, } },{ TextView, text='公告:身穷不恋富家女I', textColor='#ffffff', textSize='10sp', ellipsize='marquee', scrollHorizontally=true, layout_width='match_parent', background='#bb000000', singleLine=true, focusable=true, layout_height='wrap_content', layout_gravity='bottom', __onFinish=function(v) v:setSelected(true) v:setTypeface(sharkTTF) end, }, } } ) function huiz() --绘制内容必须写在这里否则会消失 draw3 = require("draw3") draw.setStyle("填充") draw.setColor('#00ffff') end 悬浮窗图标="https://image.rlyun.fun/view.php/e417754891c91d0536f5579d93012d3e.png" 分页名字={ "公告", "功能", "功能", '功能', "设置", } changan.menu({ {---第一页 luajava.loadlayout({ LinearLayout, layout_width='match_parent', id=luajava.ids['HomePage'], SensorCard }), changan.text(项目名字,'#ffffff',"15sp",true), changan.switch( "防闪", function() end, function() end ), changan.box({ "调试区", changan.edit("输入框演示"), changan.button( "调用输入框", function() local tmp=changan.getedit("输入框演示") gg.alert(tmp) end, 0xff0056FF), changan.seek("拉条演示","ltxx",1,20,1),--“ltxx”为此拉条变量名字,使用时每个拉条不可重复 changan.button( "调用拉条", function() gg.alert(ltxx) end, 0xffE20C30), }),--box结尾 changan.switch( "功能区", function() end, function() end ), changan.check({ { "A内存范围", function() end, function() end }, { "广角", function() end, function() end }, { "人物加速", function() end, function() end }, }), changan.button( "进程", function() gg.setProcessX() end), }, {---第二页 changan.switch( "功能3", function() end, function() end ), changan.switch( "功能4", function() gg.alert(1) end, function() gg.alert(2) end ), changan.button( "功能5", function() end), changan.radio({--单选 { "单选1" , function () gg.alert(1) end } , { "单选2" , function () end } , { "单选3" , function () end } , { "单选4" , function () end } , }), },{ },{ },{---第五页 changan.switch( "音量键隐藏UI", function() 音量键=true end, function() 音量键=false end ), changan.button( "退出", function() tuichu=1 end), }, })