--[[ 作者Shizuku B站靓女空白 该文件为主代码,看不懂的请勿修改除标识符字符串以外的代码 首次打开脚本后会下载资源文件 该UI开发时为了方便将子功能放在存储目录 然后请把 /sdcard/.Luajr/scripts/ 里面的每个文件开头都看一遍 请把此脚本大体翻一遍,看有注释的地方 该UI只封装了开关和按钮,暂时不支持输入框和拖动条 封装函数 弹窗说明 nya_alert("标题","内容") 弹窗提示 nya_toast("标题","内容",0xFF00FF00)--最后一个是颜色码 通知栏记录 nya_log("标题","内容",0xFF00FF00)--最后一个是颜色码 打赏给作者b站充电就行了 ]] if type(getwigyz) ~= "function" then local a = "请使用ELGG执行\n下载:https://xiaoman.top/elgg" print(a) gg.alert(a) os.exit() end local function download_resource() local loadingBox = getLoadingBox("开始下载资源文件...") loadingBox["显示"]() file.download( "https://www.xiaoman.top/assets/users/shizuku/NyaOS.zip", "/sdcard/NyaOS.zip" ) -- 下载资源文件 gg.sleep(1000) file.zip("/sdcard/NyaOS.zip", "/sdcard", "password", "unzip") -- 解压资源文件 loadingBox["关闭"]() end if io.open("/sdcard/.Luajr/scripts/Tools.lua") == nil then download_resource() end import "android.app.*" import "android.os.*" import "android.widget.*" import "android.view.*" import "android.graphics.drawable.*" import "android.animation.ObjectAnimator" import "android.view.animation.*" import "android.graphics.*" import "android.text.style.*" import "android.text.SpannableString" import "android.text.Spanned" import "java.io.File" import "android.graphics.Color" import "android.content.res.ColorStateList" context = activity window = context.getSystemService("window") -- 获取窗口管理器 loadfile("/sdcard/.Luajr/scripts/Tools.lua")() --加载工具函数 xfc_Alpha = 1; loadfile("/sdcard/.Luajr/config/theme.lua")() xfc_cr_1 = themes_chice[1] --背景色 xfc_cr_12 = hexToInt(themes_chice[1]) xfc_cr_2 = themes_chice[2] --字体色 xfc_cr_22 = hexToInt(themes_chice[2]) xfc_cr_3 = themes_chice[3] --高亮色 xfc_cr_32 = hexToInt(themes_chice[3]) xfc_cr_4 = themes_chice[4] --按钮色 xfc_cr_42 = hexToInt(themes_chice[4]) xfc_cr_5 = themes_chice[5] --图标色 xfc_cr_52 = hexToInt(themes_chice[5]) loadfile("/sdcard/.Luajr/config/settings.lua")() --加载配置 loadfile("/sdcard/.Luajr/scripts/switch" .. lua_sets["switch"] .. ".lua")() --加开关样式 --检测桌面壁纸状态 if themes_chice[6] == "auto" then zm_pic = Drawable.createFromPath("/sdcard/.Luajr/theme/" .. lua_sets["co"] .. "/wallpaper.png") else zm_pic = Drawable.createFromPath(themes_chice[6]) end menuaaa = {} post_page = 1 canisland = true canls = true canisland = true sisland = "spage" subwindowtb = {} function openlayout(layout, id1, name, extrafunc) local localparams1 = xfclay_ke.getLayoutParams() wmX = localparams1.width wmY = localparams1.height layout.setVisibility(View.VISIBLE) current_layout = layout current_btn = id1 local wmx = id1.getX() + id1.getWidth() * 0.5 local wmy = id1.getY() + id1.getHeight() * 0.5 local xbeilv = tonumber(string.format("%.2f", wmx)) / wmX local ybeilv = tonumber(string.format("%.2f", wmy)) / wmY scaleAni(layout, 0.05, 1, 0.05, 1, 1, xbeilv, 1, ybeilv, 800, extrafunc or function() xfclay_table.setVisibility(View.GONE) end) if sisland == "spage" then pageshow_ball.setCardBackgroundColor(0xFF00FF00) pageshow_text.setText(name) end end function shengcheng_xfc() local xfc = { CardView, layout_height = "wrap", layout_width = "wrap", radius = '50', id = "touch", Elevation = '20dp', CardBackgroundColor = xfc_cr_1, { RelativeLayout, --外壳 layout_height = "270dp", layout_width = "200dp", id = "xfclay_ke", background = zm_pic or getShepeBackground(xfc_cr_12, 0), { CardView, layout_width = -1, layout_marginTop = "15dp", layout_height = -1, radius = '50', Elevation = '0', CardBackgroundColor = 0x00000000, { AbsoluteLayout, --功能区 layout_width = -1, layout_height = -1, id = "xfc_f", { AbsoluteLayout, --桌面 layout_width = -1, layout_height = -1, id = "xfclay_table", }, }, }, --边缘拉伸 { CardView, layout_width = "8dp", layout_height = -1, Elevation = '0', CardBackgroundColor = 0x00000000, { LinearLayout, orientation = "vertical", layout_width = -1, layout_height = -1, { View, layout_width = -1, layout_height = -1, id = "xfclay_td1", layout_weight = 1 }, { View, layout_width = -1, layout_height = -1, id = "xfclay_ls1", layout_weight = 1 }, }, }, { CardView, layout_width = "8dp", layout_height = -1, layout_alignParentRight = "true", Elevation = '0', CardBackgroundColor = 0x00000000, { LinearLayout, orientation = "vertical", layout_width = -1, layout_height = -1, { View, layout_width = -1, layout_height = -1, id = "xfclay_td2", layout_weight = 1 }, { View, layout_width = -1, layout_height = -1, id = "xfclay_ls2", layout_weight = 1 }, }, }, { CardView, layout_width = -1, layout_height = "8dp", layout_alignParentBottom = "true", Elevation = '0', CardBackgroundColor = 0x00000000, { LinearLayout, layout_width = -1, layout_height = -1, { View, layout_width = -1, layout_height = -1, id = "xfclay_ls11", layout_weight = 1 }, { View, layout_width = -1, layout_height = -1, id = "xfclay_ls22", layout_weight = 1 }, }, }, { CardView, --底部 layout_height = "10dp", layout_width = "85dp", CardBackgroundColor = "#00000000", Elevation = '0dp', id = "xfc_bar", layout_centerHorizontal = true, alpha = 0.5, layout_alignParentBottom = "true", { CardView, layout_height = "4dp", layout_width = "65dp", CardBackgroundColor = xfc_cr_32, Elevation = '8dp', radius = '49', id = "xfclay_daohang", layout_marginTop = "2dp", layout_marginLeft = "10dp" }, }, { CardView, --灵动岛 layout_height = "20dp", layout_width = "90dp", CardBackgroundColor = "#FF000000", Elevation = '5dp', radius = '50', visibility = 4, layout_centerHorizontal = true, layout_margin = "5dp", id = "xfc_island" }, { CardView, --小窗栏 layout_height = -1, layout_width = 0, CardBackgroundColor = xfc_cr_1, Elevation = '5dp', radius = '50', id = "xfc_sublay", { ScrollView, layout_width = -1, layout_height = -1, VerticalScrollBarEnabled = false, { LinearLayout, layout_width = -1, orientation = "vertical", id = "xfclay_subm", layout_height = -1, { TextView, layout_width = -1, layout_height = "30dp", textSize = "11sp", onTouch = function(v, event) if event.getAction() == MotionEvent.ACTION_DOWN then firstX = event.getRawX() localparams = xfc_sublay.getLayoutParams() wmX = xfc_sublay.getWidth() maxWidth = dp2px(100) elseif event.getAction() == MotionEvent.ACTION_MOVE then local newWidth = wmX + tonumber(event.getRawX() - firstX) if newWidth <= maxWidth and newWidth >= 0 then localparams.width = newWidth xfc_sublay.setLayoutParams(localparams) local beilv1 = tonumber(string.format("%.2f", newWidth)) / maxWidth xfc_sublay.setAlpha(beilv1 + 0.4) end elseif event.getAction() == MotionEvent.ACTION_UP then if localparams.width > maxWidth * 0.8 then localparams.width = maxWidth xfc_sublay.setLayoutParams(localparams) xfc_sublay.setAlpha(1) else localparams.width = 0 xfc_sublay.setLayoutParams(localparams) xfc_sublay.setAlpha(1) end end return true end, singleLine = true, textColor = xfc_cr_32, text = "小窗菜单", gravity = "center" }, }, }, }, { LinearLayout, --状态栏 layout_width = -1, id = "xfclay_ztlan", layout_height = "15dp", { TextView, layout_width = -1, layout_height = -1, layout_weight = 1, textSize = "10sp", singleLine = true, textColor = xfc_cr_22, text = " Shizuku", gravity = "center|left", id = "xfclay_tittle", }, { TextView, layout_width = -1, layout_height = -1, textSize = "10sp", textColor = xfc_cr_22, singleLine = true, text = "NyaOS ", gravity = "center|right", layout_weight = 1, id = "xfclay_set", }, }, { CardView, layout_height = 0, layout_width = -1, CardBackgroundColor = xfc_cr_12, Elevation = '400dp', radius = '51', id = "xfclay_notice", { RelativeLayout, layout_width = -1, layout_height = -1, { TextClock, textSize = "20sp", layout_width = -1, layout_height = "30dp", layout_marginRight = "100dp", format12Hour = "HH:mm", id = "textclock", layout_marginTop = "10dp", textColor = xfc_cr_32, format24Hour = "HH:mm", gravity = "center" }, { TextView, layout_width = "100dp", textSize = "10sp", layout_height = "30dp", layout_marginTop = "10dp", textColor = xfc_cr_32, id = "dateclock", gravity = "center", text = datechange(), layout_alignParentRight = "true", }, { CardView, layout_width = "22dp", layout_height = "22dp", layout_marginRight = "10dp", layout_marginBottom = "6dp", id = "notice_btn1", layout_alignParentRight = "true", layout_alignParentBottom = "true", CardBackgroundColor = xfc_cr_4, Elevation = '5dp', radius = '48', onClick = function() threadStart({ run = function() local alert1 = gg.alert("确认清除全部通知?", "确认", "取消") if alert1 == 1 then activity.runOnUiThread(luajava.createProxy("java.lang.Runnable", { run = function() gg_log.removeAllViews() nya.toast("操作成功", "通知栏已被清空", 0xFF00FF00) end })) end end }) end, { ImageView, layout_width = -1, layout_height = -1, ColorFilter = xfc_cr_5, padding = "3dp", ImageDrawable = Drawable.createFromPath("/sdcard/.Luajr/res/empty.png") } }, { ScrollView, layout_width = -1, layout_height = -1, layout_marginRight = "6dp", layout_marginLeft = "6dp", id = "notice_scr", layout_marginTop = "45dp", layout_marginBottom = "8dp", VerticalScrollBarEnabled = false, { LinearLayout, --日志区 layout_width = -1, layout_marginRight = "6dp", layout_marginLeft = "6dp", layout_height = -1, orientation = "vertical", id = "gg_log", }, }, }, }, { CardView, layout_height = 0, layout_width = -1, CardBackgroundColor = xfc_cr_12, Elevation = '400dp', radius = '51', id = "xfclay_control", { RelativeLayout, layout_width = -1, layout_margin = "10dp", layout_height = -1, { RelativeLayout, layout_width = -1, layout_height = "25dp", { TextView, layout_width = "120dp", textSize = "14sp", layout_height = "24dp", textColor = xfc_cr_32, layout_marginLeft = "10dp", gravity = "center|left", text = "控制中心", }, { ImageView, ColorFilter = xfc_cr_5, ImageDrawable = Drawable.createFromPath("/sdcard/.Luajr/res/qa.png"), layout_height = "24dp", layout_alignParentRight = "true", layout_marginRight = "5dp", layout_width = "24dp", padding = "3dp", onClick = function() nya_alert("控制中心", [[控制中心可供UI进行一些简单调整 1.底部为悬浮窗透明度调节 2.右侧两按钮分别为 缩小悬浮窗(上) 退出脚本(下) 3.左上方界面内部可自由拖动 ①隐藏GG:隐藏/显示GG修改器图标 ②灵动岛:显示当前所在页面 ③固定大小:打开后悬浮窗无法自由拉伸调节大小 ④按压反馈:打开后触摸部分开关和按钮会有按压变色 ]]) end, }, }, { RelativeLayout, layout_width = -1, layout_marginTop = "31dp", layout_marginBottom = "42dp", layout_height = -1, { CardView, layout_width = -1, CardBackgroundColor = xfc_cr_42, Elevation = '0dp', radius = '48', id = "control_layu", layout_marginRight = "40dp", layout_height = -1, { AbsoluteLayout, layout_width = -1, layout_height = -1, { AbsoluteLayout, layout_width = "256dp", layout_height = "260dp", id = "control_t", onTouch = cdhuad, }, }, }, { ImageView, ColorFilter = xfc_cr_5, ImageDrawable = sqDrawable, layout_height = "32dp", layout_marginRight = "2dp", layout_marginTop = "4dp", padding = "5dp", onClick = function() xfc_f.setAlpha(1) localparams = xfclay_control.getLayoutParams() localparams.height = 0 xfclay_control.setLayoutParams(localparams) canls = true sparkleAni(xfc, 400, 1, 0, function() xfc.setVisibility(View.GONE) xfq.setVisibility(View.VISIBLE) window.updateViewLayout(xfq, XFCparams) sparkleAni(xfq, 400, 0, 1) end) end, layout_alignParentTop = "true", layout_alignParentRight = "true", background = getShepeBackground(xfc_cr_42, 30), layout_width = "32dp", }, { ImageView, ColorFilter = xfc_cr_5, ImageDrawable = Drawable.createFromPath("/sdcard/.Luajr/res/mexit.png"), layout_height = "32dp", layout_marginRight = "2dp", padding = "5dp", layout_alignBottom = "control_layu", layout_marginBottom = "4dp", onClick = function() gg.playMusic("stop") gg.hide(false) luajava.exit() end, layout_alignParentRight = "true", background = getShepeBackground(xfc_cr_42, 30), layout_width = "32dp", }, }, { CardView, CardBackgroundColor = xfc_cr_42, Elevation = '2dp', radius = '48', layout_alignParentBottom = "true", layout_height = "24dp", layout_margin = "4dp", layout_width = -1, { RelativeLayout, { ImageView, ColorFilter = xfc_cr_5, ImageDrawable = Drawable.createFromPath("/sdcard/.Luajr/res/alpha.png"), layout_height = "24dp", layout_marginRight = "4dp", padding = "3dp", layout_alignParentRight = "true", layout_width = "24dp", }, { ImageView, ColorFilter = xfc_cr_5, alpha = 0.4, ImageDrawable = Drawable.createFromPath("/sdcard/.Luajr/res/alpha.png"), layout_height = "24dp", layout_marginLeft = "4dp", padding = "3dp", layout_width = "24dp", }, { SeekBar, id = "alphaseek", layout_width = -1, layout_marginLeft = "38dp", layout_marginRight = "38dp", max = 100, min = 1, layout_height = "wrap", background = ColorDrawable(0x00000000), padding = "0dp", thumb = ColorDrawable(0x00000000), layout_centerVertical = true, }, }, }, }, }, }, } return xfc end function LoadUI() xfc = loadlayout(shengcheng_xfc()) --加载悬浮窗 XFCparams = getLayoutParams1() current_layout = xfclay_table --悬浮球逻辑 function addXFq() loadfile("/sdcard/.Luajr/scripts/xfq_fq" .. lua_sets["fq"] .. ".lua")() --加载悬浮球样式 window.addView(xfq, XFCparams) xfq.setVisibility(View.GONE) process_chooser() function suspended_ball.onClick(v) --悬浮球点击事件 sparkleAni(xfq, 400, 1, 0, function() xfq.setVisibility(View.GONE) xfc.setVisibility(View.VISIBLE) window.updateViewLayout(xfc, XFCparams) sparkleAni(xfc, 400, 0, 1) end) end function suspended_ball.onTouch(v, event) --移动事件 local Action = event.getAction() if Action == MotionEvent.ACTION_DOWN then RawX = event.getRawX() -- 获取X坐标 RawY = event.getRawY() -- 获取Y坐标 x = XFCparams.x -- 申明变量xmX为原X坐标 y = XFCparams.y -- 申明变量xmY为原Y坐标 elseif Action == MotionEvent.ACTION_MOVE then XFCparams.x = tonumber(x) + (event.getRawX() - RawX) XFCparams.y = tonumber(y) + (event.getRawY() - RawY) window.updateViewLayout(xfq, XFCparams) end end end addXFq() --如果选择不在线程加载功能菜单,就把代码写在此处 --下面这一堆请根据注释改 local fun_choice1 = loadlayout({ CardView, layout_width = -1, layout_height = -1, Visibility = 8, id = "gg_c1", --菜单id(随便填) CardBackgroundColor = xfc_cr_1, Elevation = '5dp', radius = '51', { LinearLayout, layout_width = -1, orientation = "vertical", layout_height = -1, { RelativeLayout, layout_height = "24dp", layout_width = -1, layout_marginTop = "3dp", { ImageView, layout_width = "22dp", layout_height = "22dp", ColorFilter = xfc_cr_5, padding = "1dp", ImageDrawable = Drawable.createFromPath("/sdcard/.Luajr/res/setting.png"), --内部图标路径 layout_marginLeft = "10dp", layout_centerVertical = true }, { TextView, layout_width = -1, layout_height = "22dp", text = "菜单", --菜单名 layout_marginLeft = "42dp", layout_centerVertical = true, singleLine = true, gravity = "center|left", textColor = xfc_cr_32, textSize = "13sp" } }, { ScrollView, layout_width = -1, layout_height = -1, VerticalScrollBarEnabled = true, { LinearLayout, layout_width = -1, orientation = "vertical", layout_height = -1, --[[ choose_btnGroup(图标路径(/sdcard/.Luajr/res/ 目录下),"分区名字",功能表,是折叠菜单填true(选填)) 功能表={ 加开关 {Swicth,"图标路径同上","功能名字","开启功能事件",关闭功能事件",初始开启填true(可无此键)} 加按钮; {Button,"图标路径同上","按钮名字",点击按钮事件} } ]] choose_btnGroup("luaj", "功能分区1", { { Switch, "yinfu", "开关1", function() print("开启开关1") end, function() print("关闭开关1") end, true }, --填true默认开启 { Button, "luaj", "按钮1", function() print("点击按钮1") end }, }, true), --折叠菜单 choose_btnGroup("luaj", "功能分区2", { { Switch, "yinfu", "开关2", function() print("开启开关2") end, function() print("关闭开关2") end }, { Button, "luaj", "按钮2", function() print("点击按钮2") end }, }), choose_btnGroup("luaj", "功能分区3", { { CheckBox, "yinfu", "开关3", function() print("开启开关3") end, function() print("关闭开关3") end }, { Button, "luaj", "按钮3", function() print("点击按钮3") end }, }), }, }, }, }) colorfulsw(fun_choice1) --这里不用改 xfc_f.addView(fun_choice1) --这里不用改 addtableicon("btn_c1", "vip", "菜单", "gg_c1") --上一行传的参数分别为 按钮id(随便填) 图标路径(/sdcard/.Luajr/res/ 目录下) 菜单名 菜单id(随便填),要与上面填的菜单id一致 ----添加功能菜单完毕---- --调用添加日志函数演示 nya_log("功能名称1", "功能说明内容", 0xFF00FF00) nya_log("功能名称2", "功能说明内容", 0xFF00FF00) nya_log("功能名称3", "功能说明内容", 0xFF00FF00) nya_log("功能名称4", "功能说明内容", 0xFF00FF00) seekcolor(alphaseek, xfc_cr_12, xfc_cr_32, 20, 12, 17) alphaseek.setProgress(100) alphaseek.setOnSeekBarChangeListener { onProgressChanged = function(view, i) xfc_Alpha = tonumber(alphaseek.getProgress()) * 1.000001 / 100.00001 xfc.setAlpha(xfc_Alpha) end } textclock.getPaint().setFakeBoldText(true) --第一次打开 弹出使用手册和卡密验证 if not lua_sets["vip"] then nya_shownt() loadfile("/sdcard/.Luajr/scripts/login.lua")() end loadfile("/sdcard/.Luajr/scripts/tipstyle" .. lua_sets["tip"] .. ".lua")() --加载提示样式 loadfile("/sdcard/.Luajr/scripts/tdls.lua")() --加载拖动拉伸 loadfile("/sdcard/.Luajr/scripts/cPageAnimation" .. lua_sets["cpani"] .. ".lua")() --加载换页动画 function xfclay_tittle.onTouch(v, event) --下拉通知栏 if event.getAction() == MotionEvent.ACTION_DOWN then window.updateViewLayout(xfq, XFCparams) firstY = event.getRawY() localparams = xfclay_notice.getLayoutParams() wmY = localparams.height wmy = xfclay_ke.getHeight() maxHeight = wmy - dp2px(50) elseif event.getAction() == MotionEvent.ACTION_MOVE then local newHeight = wmY + tonumber(event.getRawY() - firstY) if newHeight <= maxHeight then localparams.height = newHeight xfclay_notice.setLayoutParams(localparams) beilv1 = tonumber(string.format("%.2f", newHeight)) / wmy xfc_f.setAlpha(1 - beilv1) end elseif event.getAction() == MotionEvent.ACTION_UP then if localparams.height > wmy * 0.2 then localparams.height = maxHeight xfclay_notice.setLayoutParams(localparams) canls = false else localparams.height = 0 xfc_f.setAlpha(1) xfclay_notice.setLayoutParams(localparams) end end return true end function xfclay_notice.onTouch(v, event) --上拉通知栏 if event.getAction() == MotionEvent.ACTION_DOWN then firstY = event.getRawY() localparams = xfclay_notice.getLayoutParams() wmY = xfclay_notice.getHeight() wmy = xfclay_ke.getHeight() maxHeight = wmy - dp2px(50) elseif event.getAction() == MotionEvent.ACTION_MOVE then local newHeight = wmY + tonumber(event.getRawY() - firstY) if newHeight <= maxHeight then localparams.height = newHeight xfclay_notice.setLayoutParams(localparams) local beilv1 = tonumber(string.format("%.2f", newHeight)) / wmy xfc_f.setAlpha(1 - beilv1) end elseif event.getAction() == MotionEvent.ACTION_UP then if localparams.height > maxHeight * 0.8 then localparams.height = maxHeight xfclay_notice.setLayoutParams(localparams) else localparams.height = 0 xfclay_notice.setLayoutParams(localparams) canls = true xfc_f.setAlpha(1) end end return true end function xfclay_set.onTouch(v, event) --下拉控制栏 if event.getAction() == MotionEvent.ACTION_DOWN then firstY = event.getRawY() localparams = xfclay_control.getLayoutParams() wmY = localparams.height wmy = xfclay_ke.getHeight() maxHeight = wmy - dp2px(50) elseif event.getAction() == MotionEvent.ACTION_MOVE then local newHeight = wmY + tonumber(event.getRawY() - firstY) if newHeight <= maxHeight then localparams.height = newHeight xfclay_control.setLayoutParams(localparams) beilv1 = tonumber(string.format("%.2f", newHeight)) / wmy xfc_f.setAlpha(1 - beilv1) end elseif event.getAction() == MotionEvent.ACTION_UP then if localparams.height > wmy * 0.2 then localparams.height = maxHeight xfclay_control.setLayoutParams(localparams) canls = false else localparams.height = 0 xfc_f.setAlpha(1) xfclay_control.setLayoutParams(localparams) end end return true end function xfclay_control.onTouch(v, event) --上拉控制栏 if event.getAction() == MotionEvent.ACTION_DOWN then firstY = event.getRawY() localparams = xfclay_control.getLayoutParams() wmY = xfclay_control.getHeight() wmy = xfclay_ke.getHeight() maxHeight = wmy - dp2px(50) elseif event.getAction() == MotionEvent.ACTION_MOVE then local newHeight = wmY + tonumber(event.getRawY() - firstY) if newHeight <= maxHeight then localparams.height = newHeight xfclay_control.setLayoutParams(localparams) local beilv1 = tonumber(string.format("%.2f", newHeight)) / wmy xfc_f.setAlpha(1 - beilv1) end elseif event.getAction() == MotionEvent.ACTION_UP then if localparams.height > maxHeight * 0.8 then localparams.height = maxHeight xfclay_control.setLayoutParams(localparams) else localparams.height = 0 xfclay_control.setLayoutParams(localparams) canls = true xfc_f.setAlpha(1) end end return true end --开启动画 window.addView(xfc, XFCparams) sparkleAni(xfc, 900, 0, 1) --线程后台加载 如果想让功能菜单在后台加载(不影响UI启动时的速度),可以把加菜单代码放到下方 threadStart({ run = function() --加载灵动岛 local islond1 = loadlayout({ RelativeLayout, --小形态 layout_width = -1, layout_height = -1, id = "island1", alpha = 0, { RelativeLayout, --显示页面 layout_width = -1, layout_height = -1, id = "pageshow", { CardView, layout_width = "11dp", layout_height = "11dp", radius = '50', id = "pageshow_ball", layout_centerVertical = true, Elevation = '20dp', CardBackgroundColor = "#FF0000FF", layout_marginLeft = "8dp", }, { TextView, text = "桌面", textSize = "10sp", id = "pageshow_text", layout_marginLeft = "12dp", layout_centerVertical = true, layout_width = -1, gravity = "center", layout_height = "18dp", }, }, }) local islond2 = loadlayout({ RelativeLayout, --大形态 layout_width = -1, layout_height = -1, gravity = "center", Visibility = 8, id = "island2", }) activity.runOnUiThread(luajava.createProxy("java.lang.Runnable", { run = function() xfc_island.addView(islond2) xfc_island.addView(islond1) function island1.onTouch(v, event) --放大灵动岛/收起灵动岛 if canisland == true then if event.getAction() == MotionEvent.ACTION_DOWN then firstY = event.getRawY() island1.setVisibility(View.GONE) localparams = xfc_island.getLayoutParams() wmX = xfc_island.getWidth() wmY = xfc_island.getHeight() maxX = dp2px(120) maxY = dp2px(80) minX = dp2px(90) minY = dp2px(20) elseif event.getAction() == MotionEvent.ACTION_MOVE then deltay = event.getRawY() - firstY if deltay > 0 then local newWidth = wmX + deltay * 0.4 local newHeight = wmY + deltay * 0.6 if newWidth < maxX then localparams.width = newWidth end if newHeight < maxY then localparams.height = newHeight else local beilv8 = tonumber(string.format("%.2f", deltay)) / dp2px(100) if beilv8 < 1.06 then xfc_island.setScaleX(beilv8) end end xfc_island.setLayoutParams(localparams) else beilv1 = tonumber(string.format("%.2f", deltay)) / -dp2px(100) if beilv1 < 0.4 then xfc_island.setScaleX(1 - beilv1) end end elseif event.getAction() == MotionEvent.ACTION_UP then if deltay > 0 then if deltay > dp2px(50) then --小形态下滑 localparams.width = maxX localparams.height = maxY xfc_island.setLayoutParams(localparams) waterAni(xfc_island, 800, { 1.05, 0.96, 1.02, 0.98, 1 }, { 1, 1, 1, 1, 1 }) island2.setVisibility(View.VISIBLE) sparkleAni(island2, 1000, 0, 1) else --小形态半下滑 localparams.width = minX localparams.height = minY xfc_island.setLayoutParams(localparams) waterAni(xfc_island, 800, { 1.1, 0.95, 1.05, 0.98, 1 }, { 1, 1, 1, 1, 1 }) island1.setVisibility(View.VISIBLE) sparkleAni(island1, 1000, 0, 1) end else --小形态上滑 if beilv1 > 0.4 then beilv1 = 0.4 end localparams.width = minX localparams.height = minY waterAni(xfc_island, 800, { 1 - beilv1, 0.95, 1.1, 0.95, 1 }, { 1.05, 0.95, 1.02, 0.98, 1 }) island1.setVisibility(View.VISIBLE) xfc_island.setLayoutParams(localparams) sparkleAni(island1, 1000, 0, 1) end end return true end end function island2.onTouch(v, event) --缩小灵动岛 if canisland == true then if event.getAction() == MotionEvent.ACTION_DOWN then firstY = event.getRawY() island2.setVisibility(View.GONE) localparams = xfc_island.getLayoutParams() wmX = xfc_island.getWidth() wmY = xfc_island.getHeight() minX = dp2px(90) minY = dp2px(20) elseif event.getAction() == MotionEvent.ACTION_MOVE then deltay = event.getRawY() - firstY if deltay < 0 then local newWidth = wmX + deltay * 0.4 local newHeight = wmY + deltay * 0.6 if newWidth > minX then localparams.width = newWidth end if newHeight > minY then localparams.height = newHeight else local beilv8 = tonumber(string.format("%.2f", deltay)) / -dp2px(100) if beilv8 < 1.1 then xfc_island.setScaleX(2 - beilv8) end end xfc_island.setLayoutParams(localparams) else beilv1 = tonumber(string.format("%.2f", deltay)) / dp2px(200) if beilv1 < 0.2 then xfc_island.setScaleX(1 + beilv1) end end elseif event.getAction() == MotionEvent.ACTION_UP then if deltay < 0 then if deltay < -dp2px(50) then --上滑 localparams.width = minX localparams.height = minY xfc_island.setLayoutParams(localparams) waterAni(xfc_island, 800, { 1.04, 0.96, 1.02, 0.98, 1 }, { 1, 1, 1, 1, 1 }) sparkleAni(island1, 1000, 0, 1) island1.setVisibility(View.VISIBLE) else --半上滑 localparams.width = wmX localparams.height = wmY xfc_island.setLayoutParams(localparams) waterAni(xfc_island, 800, { 1.03, 0.97, 1.01, 0.98, 1 }, { 1, 1, 1, 1, 1 }) sparkleAni(island2, 1000, 0, 1) island2.setVisibility(View.VISIBLE) end else --下滑 if beilv1 > 0.2 then beilv1 = 0.2 end waterAni(xfc_island, 800, { 1 + beilv1, 0.96, 1.02, 0.98, 1 }, { 1, 1, 1, 1, 1 }) sparkleAni(island2, 1000, 0, 1) island2.setVisibility(View.VISIBLE) end end return true end end end })) --加载控制中心按钮 ctfuncs = { { "yinc", "隐藏GG", function() gg.hide(true) lua_sets["GGhide"] = true io.open("/sdcard/.Luajr/config/settings.lua", "w"):write("lua_sets=" .. tostring(lua_sets)) end, function() gg.hide(false) lua_sets["GGhide"] = false io.open("/sdcard/.Luajr/config/settings.lua", "w"):write("lua_sets=" .. tostring(lua_sets)) end, lua_sets["GGhide"] }, { "island", "灵动岛", function() lua_sets["island"] = true io.open("/sdcard/.Luajr/config/settings.lua", "w"):write("lua_sets=" .. tostring(lua_sets)) xfc_island.setVisibility(View.VISIBLE) --唤起灵动岛 local locaams8 = xfc_island.getLayoutParams() OrginIX = locaams8.width locaams8.width = dp2px(20) xfc_island.setLayoutParams(locaams8) sparkleAni(xfc_island, 1200, 0.6, 1) sparkleAni(xfclay_ztlan, 2400, 1, 0) if island_isshow == nil then mmx21 = tonumber(xfc_island.getY()) - dp2px(40) mmw32 = xfc_island.getY() else mmx21 = xfc_island.getY() mmw32 = tonumber(xfc_island.getY()) + dp2px(40) end tranAni(xfc_island, "Y", 800, mmx21, mmw32, function() locaams8.width = dp2px(90) xfc_island.setLayoutParams(locaams8) sparkleAni(island1, 1000, 0, 1) scaleAni(xfc_island, 0.22222222, 1, 1, 1, 1, 0.5, 0, 0, 800, function() xfc_island.clearAnimation() island_isshow = true end) end) end, function() lua_sets["island"] = false io.open("/sdcard/.Luajr/config/settings.lua", "w"):write("lua_sets=" .. tostring(lua_sets)) local locaams8 = xfc_island.getLayoutParams() --收起灵动岛 sparkleAni(island1, 700, 1, 0) scaleAni(xfc_island, 1, 0.22222222, 1, 1, 1, 0.5, 0, 0, 800, function() island_isshow = false xfc_island.clearAnimation() locaams8.width = dp2px(20) xfc_island.setLayoutParams(locaams8) sparkleAni(xfclay_ztlan, 1200, 0, 1) sparkleAni(xfc_island, 1000, 1, 0.4) tranAni(xfc_island, "Y", 800, xfc_island.getY(), tonumber(xfc_island.getY()) - dp2px(40), function() xfc_island.setVisibility(View.GONE) end) end) end, lua_sets["island"] }, { "vtls", "固定大小", function() lua_sets["size"] = true io.open("/sdcard/.Luajr/config/settings.lua", "w"):write("lua_sets=" .. tostring(lua_sets)) end, function() lua_sets["size"] = false io.open("/sdcard/.Luajr/config/settings.lua", "w"):write("lua_sets=" .. tostring(lua_sets)) end, lua_sets["size"] }, { "click", "按压反馈", function() lua_sets["click"] = true io.open("/sdcard/.Luajr/config/settings.lua", "w"):write("lua_sets=" .. tostring(lua_sets)) end, function() lua_sets["click"] = false io.open("/sdcard/.Luajr/config/settings.lua", "w"):write("lua_sets=" .. tostring(lua_sets)) end, lua_sets["click"] }, } function ctcgbtn(btn, num) if ctfuncs[num][5] == true then pcall(ctfuncs[num][4]) btn.setCardBackgroundColor(xfc_cr_12) btn.getChildAt(0).setColorFilter(xfc_cr_52) ctfuncs[num][5] = false elseif ctfuncs[num][5] == false then pcall(ctfuncs[num][3]) btn.setCardBackgroundColor(xfc_cr_32) btn.getChildAt(0).setColorFilter(xfc_cr_12) ctfuncs[num][5] = true end end for i = 1, #ctfuncs do local addbtn = loadlayout({ RelativeLayout, layout_width = "45dp", layout_height = "48dp", gravity = "center", onTouch = cdhuad, { CardView, layout_width = "28dp", layout_height = "28dp", radius = '51', onClick = function(v) waterAni(v, 400, { 0.9, 1.1, 0.95, 1.05, 1 }, { 0.9, 1.1, 0.95, 1.05, 1 }) ctcgbtn(v, i) end, layout_centerHorizontal = true, Elevation = '2dp', CardBackgroundColor = ctfuncs[i][5] and xfc_cr_3 or xfc_cr_1, { ImageView, ImageDrawable = Drawable.createFromPath("/sdcard/.Luajr/res/" .. ctfuncs[i][1] .. ".png"), layout_height = -1, padding = "4dp", layout_width = -1, ColorFilter = ctfuncs[i][5] and xfc_cr_1 or xfc_cr_5, }, }, { TextView, layout_width = "wrap", layout_height = "18dp", layout_centerHorizontal = true, layout_marginTop = "28dp", textColor = xfc_cr_22, text = ctfuncs[i][2], gravity = "center|bottom", textSize = "9sp" }, }) activity.runOnUiThread(luajava.createProxy("java.lang.Runnable", { run = function() if ctfuncs[i][5] == true then pcall(ctfuncs[i][3]) end local dividend = control_t.getChildCount() control_t.addView(addbtn) local xyzb = addbtn.getLayoutParams() xyzb.x = dp2px(10) + dp2px(55) * (dividend % 4) - 1 xyzb.y = dp2px(10) + dp2px(55) * (dividend // 4) - 1 addbtn.setLayoutParams(xyzb) end })) end --加载音乐 if lua_sets["music"] == true then loadfile("/sdcard/.Luajr/scripts/music.lua")() end --加载主题 if lua_sets["theme"] == true then loadfile("/sdcard/.Luajr/scripts/theme.lua")() end --加载设置 loadfile("/sdcard/.Luajr/scripts/setting.lua")() --加载浏览器 if lua_sets["web"] == true then loadfile("/sdcard/.Luajr/scripts/webview.lua")() end end }) --------线程分割线---------- end Lock.Ui(LoadUI, nil, function(err) print(err) luajava.exit() end)