/*
软件作者:https://xuhss.com/oxox/pro
*/
/**
* 作者: 大柒
* 功能: Auto.js悬浮按钮样例(补间动画)
* 日期: 2019/04/06
* 备注:
* pro和免费版都可正常使用
*
* 待解决:
* (1)悬浮窗初始化的on事件. 没有找到这个方法目前用定时器解决此问题
* (2)补间动画结束的on事件. 试了很多都不可行目前用多线程解决此问题
* (3)快速双击主按钮会报错
*/
//悬浮窗logo
importClass(java.lang.Runnable);
importClass(android.animation.ObjectAnimator)
importClass(android.animation.PropertyValuesHolder)
importClass(android.animation.ValueAnimator)
importClass(android.animation.AnimatorSet)
importClass(android.view.animation.AccelerateInterpolator)
importClass(android.view.animation.TranslateAnimation)
importClass(android.animation.ObjectAnimator)
importClass(android.animation.TimeInterpolator)
importClass(android.os.Bundle)
importClass(android.view.View)
importClass(android.view.Window)
importClass(android.view.animation.AccelerateDecelerateInterpolator)
importClass(android.view.animation.AccelerateInterpolator)
importClass(android.view.animation.AnticipateInterpolator)
importClass(android.view.animation.AnticipateOvershootInterpolator)
importClass(android.view.animation.BounceInterpolator)
importClass(android.view.animation.CycleInterpolator)
importClass(android.view.animation.DecelerateInterpolator)
importClass(android.view.animation.LinearInterpolator)
importClass(android.view.animation.OvershootInterpolator)
importClass(android.view.animation.PathInterpolator)
importClass(android.widget.Button)
importClass(android.widget.ImageView)
importClass(android.widget.TextView)
var logo_switch = false;//全局: 悬浮窗的开启关闭检测
var logo_buys = false;//全局: 开启和关闭时占用状态 防止多次点击触发
var logo_fx = true//全局: 悬浮按钮所在的方向 真左 假右
var time_0, time_1, time_3//全局: 定时器 点击退出悬浮窗时定时器关闭
//可修改参数
var logo_ms = 200//全局: 动画播放时间
var DHK_ms = 200//全局: 对话框动画播放时间
var tint_color = "#00000"//全局: 对话框图片颜色
/**
* 需要三个悬浮窗一起协作达到Auto.js悬浮窗效果
* win 子菜单悬浮窗 处理子菜单选项点击事件
* win_1 主悬浮按钮
* win_2 悬浮按钮动画替身,只有在手指移动主按钮的时候才会被触发
* 触发时,替身Y值会跟主按钮Y值绑定一起,手指弹起时代替主按钮显示跳动的小球动画
*/
var win = floaty.rawWindow(
<frame >//子菜单悬浮窗
<frame id="id_logo" w="150" h="210" alpha="0" >
<frame id="id_0" w="44" h="44" margin="33 0 0 0" alpha="1">
<img w="44" h="44" src="#009687" circle="true" />
<img w="28" h="28" src="@drawable/ic_perm_identity_black_48dp" tint="#ffffff" gravity="center" layout_gravity="center" />
<img id="id_0_click" w="*" h="*" src="#ffffff" circle="true" alpha="0" />
</frame>
<frame id="id_1" w="44" h="44" margin="86 28 0 0" alpha="1">
<img w="44" h="44" src="#ee534f" circle="true" />
<img w="28" h="28" src="@drawable/ic_assignment_black_48dp" tint="#ffffff" gravity="center" layout_gravity="center" />
<img id="id_1_click" w="*" h="*" src="#ffffff" circle="true" alpha="0" />
</frame>
<frame id="id_2" w="44" h="44" margin="0 83 0 0" alpha="1" gravity="right" layout_gravity="right">
<img w="44" h="44" src="#40a5f3" circle="true" />
<img w="28" h="28" src="@drawable/ic_play_arrow_black_48dp" tint="#ffffff" margin="8" />
<img id="id_2_click" w="*" h="*" src="#ffffff" circle="true" alpha="0" />
</frame>
<frame id="id_3" w="44" h="44" margin="86 0 0 28" alpha="1" gravity="bottom" layout_gravity="bottom">
<img w="44" h="44" src="#fbd834" circle="true" />
<img w="28" h="28" src="@drawable/ic_clear_black_48dp" tint="#ffffff" margin="8" />
<img id="id_3_click" w="*" h="*" src="#ffffff" circle="true" alpha="0" />
</frame>
<frame id="id_4" w="44" h="44" margin="33 0 0 0" alpha="1" gravity="bottom" layout_gravity="bottom">
<img w="44" h="44" src="#bfc1c0" circle="true" />
<img w="28" h="28" src="@drawable/ic_settings_black_48dp" tint="#ffffff" margin="8" />
<img id="id_4_click" w="*" h="*" src="#ffffff" circle="true" alpha="0" />
</frame>
</frame>
<frame id="logo" w="44" h="44" marginTop="83" alpha="1" />
<frame id="logo_1" w="44" h="44" margin="0 83 22 0" alpha="1" layout_gravity="right" />
</frame>
)
win.setTouchable(false);//设置子菜单不接收触摸消息
var win_1 = floaty.rawWindow(
<frame id="logo" w="44" h="44" alpha="0.4" >//悬浮按钮
<img w="44" h="44" src="#ffffff" circle="true" alpha="0.8" />
<img id="img_logo" w="32" h="32" src="https://pro.autojs.org/images/logo.png" gravity="center" layout_gravity="center" />
<img id="logo_click" w="*" h="*" src="#ffffff" alpha="0" />
</frame>
)
win_1.setPosition(-30, device.height / 2)//悬浮按钮定位
var win_2 = floaty.rawWindow(
<frame id="logo" w="{{device.width}}px" h="44" alpha="0" >//悬浮按钮 弹性替身
<img w="44" h="44" src="#ffffff" circle="true" alpha="0.8" />
<img id="img_logo" w="32" h="32" src="https://pro.autojs.org/images/logo.png" margin="6 6" />
</frame>
)
win_2.setTouchable(false);//设置弹性替身不接收触摸消息
/**
* 脚本广播事件
*/
var XY = [], XY1 = [], TT = [], TT1 = [], img_dp = {}, dpZ = 0, logo_right = 0, dpB = 0, dp_H = 0
events.broadcast.on("定时器关闭", function (X) { clearInterval(X) })
events.broadcast.on("悬浮开关", function (X) {
ui.run(function () {
switch (X) {
case true:
win.id_logo.setVisibility(0)
win.setTouchable(true);
logo_switch = true
break;
case false:
win.id_logo.setVisibility(4)
win.setTouchable(false);
logo_switch = false
}
})
});
events.broadcast.on("悬浮显示", function (X1) {
ui.run(function () {
win_2.logo.attr("alpha", "0");
win_1.logo.attr("alpha", "0.4");
})
});
/**
* 等待悬浮窗初始化
*/
var terid = setInterval(() => {
log("13")
if (TT.length == 0 && win.logo.getY() > 0) {// 不知道界面初始化的事件 只能放到这里将就下了
ui.run(function () {
TT = [win.logo.getX(), win.logo.getY()], TT1 = [win.logo_1.getLeft(), win.logo_1.getTop()], anX = [], anY = []// 获取logo 绝对坐标
XY = [
[win.id_0, TT[0] - win.id_0.getX(), TT[1] - win.id_0.getY()],// 获取子菜单 视图和子菜单与logo绝对坐标差值
[win.id_1, TT[0] - win.id_1.getX(), TT[1] - win.id_1.getY()],
[win.id_2, TT[0] - win.id_2.getX(), 0],
[win.id_3, TT[0] - win.id_3.getX(), TT[1] - win.id_3.getY()],
[win.id_4, TT[0] - win.id_4.getX(), TT[1] - win.id_4.getY()]]
log("上下Y值差值:" + XY[0][2] + "DP值:" + (XY[0][2] / 83))
dpZ = XY[0][2] / 83
dpB = dpZ * 22
XY1 = [
[parseInt(dpZ * 41), TT1[0] - win.id_0.getLeft(), TT1[1] - win.id_0.getTop()],
[parseInt(dpZ * -65), TT1[0] - win.id_1.getLeft(), TT1[1] - win.id_1.getTop()],
[parseInt(dpZ * -106), TT1[0] - win.id_2.getLeft(), TT1[1] - win.id_2.getTop()],
[parseInt(dpZ * -65), TT1[0] - win.id_3.getLeft(),
[虚幻私塾】
- 粉丝: 336
- 资源: 1558
最新资源
- 算法竞赛中的离散化 概念总结和基本操作全解
- 算法竞赛位运算(简单易懂)
- 常用一维二维 前缀和与差分算法模板总结
- SAR成像算法+后向投影(BP)算法+星载平台实测数据
- 横向循环焦点轮播图横向循环焦点轮播图横向循环焦点轮播图横向循环焦点轮播图横向循环焦点轮播图横向循环焦点轮播图横向循环焦点轮播图横向循环焦点轮播图横向循环焦点轮播图横向循环焦点轮播图横向循环焦点轮播图横
- 基于Java和HTML的留言墙、验证码、计算器基础项目设计源码
- 基于JAVA C/C++的嵌入式设备组网平台物联网框架设计源码
- 基于Java开发的高性能全文检索工具包jsearch设计源码
- 基于多语言技术的pt遨游助手手机版设计源码
- 基于若依框架的染云盘V1.0.2设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈