作者:造雾者 微信:LGD-Lang QQ:130468168 autojs/JavaScript 有偿收徒 有偿解答 欢迎打扰~
话不多说直接上代码
"ui";
var storage=storages.create("data");
storage.clear();
function start(){
storage.put("Welcome","true");
engines.execScriptFile("main.js");
}
if(storage.get("Welcome")=="true"){
start();
exit();
}
activity.window.addFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
function Color(color){
return android.graphics.Color.parseColor(color);
}
function GradientDrawable(orientation,color){
var colors=[];
color.forEach(color=>colors.push(Color(color)));
return new android.graphics.drawable.GradientDrawable(android.graphics.drawable.GradientDrawable.Orientation[orientation],colors);
}
ui.layout(
<relative>
<viewpager id="viewpager">
<relative>
<vertical w="*" h="*" id="firstpage" gravity="center">
<text text="作者:造雾者" textSize="45sp" textColor="#FFFFFF" gravity="center"/>
<text text="滑动屏幕来了解更多信息" marginTop="10" textSize="15sp" textColor="#A0FFFFFF" gravity="center"/>
</vertical>
<text id="skip" text="单击此处以跳过" marginBottom="100" textSize="13sp" textColor="#30FFFFFF" gravity="center" layout_alignParentBottom="true" layout_centerHorizontal="true"/>
</relative>
<vertical id="page1" gravity="center">
<text text="造雾" textSize="45sp" textColor="#FFFFFF" gravity="center"/>
<text text="脚本交流社区" marginTop="10" textSize="15sp" textColor="#A0FFFFFF" gravity="center"/>
</vertical>
<vertical id="page2" gravity="center">
<text text="便捷" textSize="45sp" textColor="#FFFFFF" gravity="center"/>
<text text="脚本-一触即发" marginTop="10" textSize="15sp" textColor="#A0FFFFFF" gravity="center"/>
</vertical>
<vertical id="permissionpage" gravity="center">
<text text="需要授权无障碍" textSize="45sp" textColor="#FFFFFF" gravity="center"/>
<text id="permission" text="单击此处进行授权" marginTop="10" textSize="15sp" textColor="#A0FFFFFF" gravity="center"/>
</vertical>
<vertical id="startpage" gravity="center">
<text text="现在开始" textSize="45sp" textColor="#FFFFFF" gravity="center"/>
<text text="单击下方按钮开始使用" marginTop="10" textSize="15sp" textColor="#A0FFFFFF" gravity="center"/>
<card id="start" cardBackgroundColor="#ECEFF1" w="60" h="60" cardCornerRadius="30" marginTop="50" gravity="center">
<img w="30" h="30" src="drawable/ic_collapsed"/>
</card>
</vertical>
</viewpager>
<tabs id="tabs" marginBottom="50" w="80" h="2" bg="#50AAAAAA" layout_alignParentBottom="true" layout_centerHorizontal="true" visibility="gone"/>
</relative>
);
ui.viewpager.overScrollMode=android.view.View.OVER_SCROLL_NEVER;
ui.tabs.setupWithViewPager(ui.viewpager);
ui.tabs.selectedTabIndicatorColor=Color("#FFFFFF");
ui.tabs.selectedTabIndicatorHeight=ui.tabs.layoutParams.height;
ui.firstpage.backgroundDrawable=GradientDrawable("TL_BR",["#81C784","#2E7D32","#2E7D32"]);
ui.page1.backgroundDrawable=GradientDrawable("TL_BR",["#4FC3F7","#0277BD","#0277BD"]);
ui.page2.backgroundDrawable=GradientDrawable("TL_BR",["#FFF176","#F9A825","#F9A825"]);
ui.permissionpage.backgroundDrawable=GradientDrawable("TL_BR",["#80DEEA","#0097A7","#0097A7"]);
ui.startpage.backgroundDrawable=GradientDrawable("TL_BR",["#CFD8DC","#78909C","#78909C"]);
ui.skip.click(()=>ui.viewpager.currentItem=ui.viewpager.childCount-1);
permissionpage=ui.viewpager.childCount-1-1;
ui.permission.click(()=>{
if(!getMissingPermission()){
ui.permission.setText("已获得授权");
setTimeout(()=>{
ui.viewpager.currentItem=ui.viewpager.currentItem+1;
},500);
}else{
ui.permission.setText("单击此处检查授权");
getPermission(getMissingPermission());
}
});
ui.viewpager.setOnPageChangeListener({
onPageSelected:function(index){
if(index==ui.viewpager.childCount-1&&getMissingPermission()){
setTimeout(()=>{
ui.viewpager.currentItem=permissionpage;
},0);
}else if(index==permissionpage){
if(!getMissingPermission())
ui.permission.setText("已获得授权");
else
ui.permission.setText("单击此处进行授权");
}
if(index==ui.viewpager.childCount-1||index==0){
ui.tabs.visibility=android.view.View.GONE;
}else{
ui.tabs.visibility=android.view.View.VISIBLE;
}
}
});
ui.start.click(()=>{
if(getMissingPermission()){
ui.viewpager.currentItem=permissionpage;
}else{
start();
ui.finish();
}
});
function getMissingPermission(){
var result=[];
if(auto.service==null)result.push("accessibility");
return result.length>0?result:null;
}
function getPermission(permission){
if(permission.indexOf("accessibility")>-1){
toast("请找到并启用此应用的无障碍服务");
try{auto()}catch(e){};
return;
}
toast("未知权限,请自行授权\n"+permission);
}
|