Skip to content

Commit

Permalink
优化多维演绎-矩阵循生
Browse files Browse the repository at this point in the history
优化进入交流、公会、宿舍
优化ITimg识图程序
  • Loading branch information
q0314 committed Jul 24, 2024
1 parent bf3c54f commit c59d0aa
Show file tree
Hide file tree
Showing 11 changed files with 798 additions and 684 deletions.
713 changes: 295 additions & 418 deletions ITimg.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions history_update_info.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024-07-24 v1.3.3
优化多维演绎-矩阵循生
优化进入交流、公会、宿舍
优化ITimg识图程序

2024-07-16 v1.3.2
!!不再支持纯armeabi-v7a架构版本
优化助理交流
Expand Down
72 changes: 49 additions & 23 deletions hotrun.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,59 @@ activity.getWindow().setStatusBarColor(android.graphics.Color.TRANSPARENT);
if (device.sdkInt >= 23) {
activity.getWindow().getDecorView().setSystemUiVisibility(android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
let icon = "file://./images/ic_app_logo.png"

if (app.autojs.versionCode < 8082200 || !files.exists(icon)) {
icon = "file://./res/icon.png"
}
ui.layout(
<frame>
<vertical w="*" h="*" layout_gravity="center">
<vertical h="*" gravity="center" >
<img src="file://./res/icon.png" w="120" h="120" scaleType="fitXY" />
<vertical id="script" h="*" gravity="center" >
<img src="{{icon}}" w="120" h="120" scaleType="fitXY" />
<horizontal gravity="center" margin="0 25 0 5" >
<text id="loadingtext">加载中,请稍后</text>
</horizontal>
<text gravity="center" id="lostext" text="" />

<text gravity="center" id="lostext" text="" />
</vertical>
</vertical>
</frame>
);
var isCanFinish = false;


ui.script.click((view) => {
if (!isCanFinish) {
isCanFinish = true;
setTimeout(() => {
toastLog("双击进入脚本调试界面");
isCanFinish = false;
}, 400);
} else {
engines.execScriptFile("./activity/debug.js", {
path: files.path('./activity/'),
});
};

})
let cnt = 0;
setInterval(function() {
cnt = (cnt + 1) % 5;
ui.loadingtext.text('加载中,请稍后' + (new Array(cnt + 1)).join('.'));
}, 400);
let _proj_def_n = 'pgr-assistant';
let path = context.getExternalFilesDir(null).getAbsolutePath() + '/';

console.setGlobalLogConfig({
"file": path + "/" + _proj_def_n + "_log.txt"
"file": path + _proj_def_n + "_log.txt"
});

threads.start(function() {
if (device.sdkInt < 24) {
engines.execScriptFile("./activity/device_usage.js");
setTimeout(function() {
ui.finish();
}, 1000);
}, 1500);
return
}
let packageName = context.packageName;
Expand All @@ -47,7 +68,7 @@ threads.start(function() {
});
setTimeout(function() {
ui.finish();
}, 1000);
}, 1500);
} else {

if (!files.exists(path + _proj_def_n + '/')) {
Expand All @@ -57,38 +78,43 @@ threads.start(function() {
} = require('./modules/ext-files');

filesx.copy(files.path('./'), path);
ui.lostext.setText("重命名项目文件名");

ui.run(() => {
ui.lostext.setText("重命名项目文件名");
})
files.rename(path + 'project/', _proj_def_n);

} else if(files.path("./").indexOf("storage") == -1&&files.path("./").indexOf("sdcard") == -1) {
ui.lostext.setText("检验项目版本");

} else if (files.path("./").indexOf("storage") == -1 && files.path("./").indexOf("sdcard") == -1) {
ui.run(() => {
ui.lostext.setText("检验项目版本");
})
let local_config = JSON.parse(files.read("./project.json"));
let last_version_info = JSON.parse(files.read(path + _proj_def_n + '/project.json'));

if (local_config["versionCode"] > last_version_info["versionCode"]||local_config["versionName"] > last_version_info["versionName"]) {
// files.removeDir(path+_proj_def_n)
if (local_config["versionCode"] > last_version_info["versionCode"] || local_config["versionName"] > last_version_info["versionName"]) {
// files.removeDir(path+_proj_def_n)
let {
filesx
} = require('./modules/ext-files');
ui.lostext.setText("复制项目文件到Android/data/");

ui.run(() => {
ui.lostext.setText("复制项目文件到Android/data/");
})
files.rename(files.path('./'), _proj_def_n);
filesx.copy(files.path('../'+_proj_def_n), path);
ui.lostext.setText("重命名项目文件名");

files.rename(files.path('../'+_proj_def_n), "project");
filesx.copy(files.path('../' + _proj_def_n), path);
ui.run(() => {
ui.lostext.setText("重命名项目文件名");
})
files.rename(files.path('../' + _proj_def_n), "project");

}
}
ui.lostext.setText("运行项目");

ui.run(() => {
ui.lostext.setText("运行项目");
});
engines.execScriptFile(path + _proj_def_n + '/main.js', {
path: path + _proj_def_n + '/'
});
setTimeout(function() {
ui.finish();
}, 1000);
}, 1500);
}
});
1 change: 0 additions & 1 deletion library/gallery/.nomedia
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
/storage/emulated/0/脚本/pgr-assistant/library/gallery
144 changes: 77 additions & 67 deletions modules/__util__.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const scale = _resources_.getDisplayMetrics().density;



module.exports = {
let util = {
dp2px:
/**
* dp转px , 密度比例
Expand All @@ -31,72 +31,74 @@ module.exports = {
* @returns
*/
px => Math.floor(px / scale + 0.5),
isHorizontalScreen:
/**
* 是否横屏
* @returns
*/
function() {
let ori;
/**
* 是否横屏
* @returns
*/
isHorizontalScreen() {
let ori;

try {
ori = context.getSystemService(context.WINDOW_SERVICE).getDefaultDisplay().getRotation();
//0竖屏 1横屏
return ori
} catch (e) {
let config = _resources_.getConfiguration();
ori = config.orientation;
if (ori == config.ORIENTATION_LANDSCAPE) {
//横屏2
return true;
} else if (ori == config.ORIENTATION_PORTRAIT) {
//竖屏1
return false;
}
try {
ori = util.getRotation();
//0竖屏 1横屏
return ori
} catch (e) {
let config = _resources_.getConfiguration();
ori = config.orientation;
if (ori == config.ORIENTATION_LANDSCAPE) {
//横屏2
return true;
} else if (ori == config.ORIENTATION_PORTRAIT) {
//竖屏1
return false;
}
}


},
getWidthHeight:
/**
* 返回分辨率宽,高
* 跟随屏幕方向变化
* 不好用,在某些系统上获取到的分辨率与测试机获取到的完全相反
* 其次,也有些系统获取到的状态栏高度好像是0,
*/
function() {
//方法1
let wPixel = _resources_.getDisplayMetrics().widthPixels;
let hPixel = _resources_.getDisplayMetrics().heightPixels;

if (wPixel > hPixel) {
wPixel += this.iStatusBarHeight;
} else {
hPixel += this.iStatusBarHeight;
};

return [wPixel, hPixel];
},
getRotation() {
return context.getSystemService(context.WINDOW_SERVICE).getDefaultDisplay().getRotation();
},
/**
* 返回分辨率宽,高
* 跟随屏幕方向变化
* 不好用,在某些系统上获取到的分辨率与测试机获取到的完全相反
* 有时候获取到的高度是减掉状态栏高度之后的高度,但有时候不是
* 其次,也有些系统获取到的状态栏高度好像是0,
*/
getWidthHeight() {

//方法1
let wPixel = util.getWidthPixels();
let hPixel = util.getHeightPixels();

},
createShape:
/**
* 创建样式
* @param {px} roundRadius 圆角
* @param {Number} shape 设置样式形状类型:包括默认RECTANGLE(矩形), OVAL(椭圆), LINE(线条), RING(环形);
* @param {ColorString} fillColor 背景颜色 null:透明
* @param {Array} strokes 边框线样式 [宽度:px ,颜色:ColorStr ,间隔:px ,长度:px]
*/
function(roundRadius, shape, fillColor, strokes) {
strokes = strokes || null;
if (strokes != null && strokes[1] != "") strokes[1] = colors.parseColor(strokes[1]);
fillColor = colors.parseColor((fillColor && fillColor != "") ? fillColor : "#00000000");
var gd = new GradientDrawable();
gd.setColor(fillColor);
gd.setShape(shape ? GradientDrawable[shape] : GradientDrawable.RECTANGLE);
if (roundRadius != -1) gd.setCornerRadius(roundRadius);
if (strokes != null && strokes[0] != -1) gd.setStroke.apply(gd, strokes);
return gd;
},
/* if (wPixel > hPixel) {
wPixel += _resources_.getDimensionPixelSize(_resources_.getIdentifier("status_bar_height", "dimen", "android"));
} else {
hPixel += _resources_.getDimensionPixelSize(_resources_.getIdentifier("status_bar_height", "dimen", "android"));
};
*/
return [wPixel, hPixel];

},
/**
* 创建样式
* @param {px} roundRadius 圆角
* @param {Number} shape 设置样式形状类型:包括默认RECTANGLE(矩形), OVAL(椭圆), LINE(线条), RING(环形);
* @param {ColorString} fillColor 背景颜色 null:透明
* @param {Array} strokes 边框线样式 [宽度:px ,颜色:ColorStr ,间隔:px ,长度:px]
*/
createShape(roundRadius, shape, fillColor, strokes) {
strokes = strokes || null;
if (strokes != null && strokes[1] != "") strokes[1] = colors.parseColor(strokes[1]);
fillColor = colors.parseColor((fillColor && fillColor != "") ? fillColor : "#00000000");
var gd = new GradientDrawable();
gd.setColor(fillColor);
gd.setShape(shape ? GradientDrawable[shape] : GradientDrawable.RECTANGLE);
if (roundRadius != -1) gd.setCornerRadius(roundRadius);
if (strokes != null && strokes[0] != -1) gd.setStroke.apply(gd, strokes);
return gd;
},
ObjectDefinePro: function(obj, key, action) {
var mValue = obj[key];
Object.defineProperty(obj, key, {
Expand All @@ -113,10 +115,17 @@ module.exports = {
resources: _resources_,
// log(context.getDisplay)
//context.getSystemService(context.WINDOW_SERVICE).getDefaultDisplay().getHeight();
// getRotation:activity.getWindowManager().getDefaultDisplay().getRotation(),

getWidthPixels: _resources_.getDisplayMetrics().widthPixels,
getHeightPixels: _resources_.getDisplayMetrics().heightPixels,
iStatusBarHeight: _resources_.getDimensionPixelSize(_resources_.getIdentifier("status_bar_height", "dimen", "android")),
getWidthPixels() {
return _resources_.getDisplayMetrics().widthPixels;
},
getHeightPixels() {
return _resources_.getDisplayMetrics().heightPixels;
},
iStatusBarHeight() {
return _resources_.getDimensionPixelSize(_resources_.getIdentifier("status_bar_height", "dimen", "android"));
},
};

/**
Expand All @@ -140,7 +149,7 @@ function ColorEvaluator(value, action) {
[mCurrentRed, mCurrentGreen, mCurrentBlue] = [startRed, startGreen, startBlue];
// 计算初始颜色和结束颜色之间的差值
// 该差值决定着颜色变化的快慢:初始颜色值和结束颜色值很相近,那么颜色变化就会比较缓慢;否则,变化则很快
// 具体如何根据差值来决定颜色变化快慢的逻辑写在getCurrentColor()里.
// 具体如何根据差值来决定颜色变化快慢的\逻辑写在getCurrentColor()里.
var redDiff = Math.abs(startRed - endRed);
var greenDiff = Math.abs(startGreen - endGreen);
var blueDiff = Math.abs(startBlue - endBlue);
Expand Down Expand Up @@ -173,4 +182,5 @@ function ColorEvaluator(value, action) {
}
return currentColor;
}
}
}
module.exports = util;
11 changes: 4 additions & 7 deletions modules/ext-dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ let exp = {
build(props) {
let builder = Object.create(runtime.dialogs.newBuilder());
builder.thread = threads.currentThread();

Object.keys(props).forEach(n => applyDialogProperty.call(this, builder, n, props[n]));

applyOtherDialogProperties(builder, props);
Expand Down Expand Up @@ -184,8 +183,8 @@ let exp = {
cancelable: null,
canceledOnTouchOutside: null,
autoDismiss: null,
type: { method: 'setType' },
};

if (propertySetters.hasOwnProperty(name)) {
let propertySetter = propertySetters[name] || {};
if (propertySetter.method === undefined) {
Expand All @@ -194,7 +193,6 @@ let exp = {
if (propertySetter.adapter) {
value = propertySetter.adapter(value);
}

builder[propertySetter.method].call(builder, value);
}
}
Expand Down Expand Up @@ -283,10 +281,10 @@ let exp = {
let [
$tt, $cnt, $neu, $neg, $pos, $obstinate, $cbx,
] = typeof props === 'string' ? [props] : props;

//log(props, ext)
let _props = {
autoDismiss: !$obstinate,
type: "foreground-or-overlay",
type: "app",
canceledOnTouchOutside: !$obstinate,
checkBoxPrompt: $cbx ? typeof $cbx === 'string'
? $cbx : this.text.no_more_prompt : undefined,
Expand Down Expand Up @@ -314,7 +312,6 @@ let exp = {
_props[k] = String(_props[k]);
}
});

let _diag = this.build(_props);

if (_ext.linkify) {
Expand Down Expand Up @@ -1132,7 +1129,7 @@ let exp = {
_diag.removeAllListeners('positive');
_diag.setActionButton('positive', "重启应用");
_diag.on('positive', d => {
let Process =android.os.Process;
let Process = android.os.Process;
Process.killProcess(Process.myPid());
d.dismiss();
exit();
Expand Down
2 changes: 1 addition & 1 deletion modules/ext-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ let exp = {
* @return {string}
*/
'.local'(children) {
let _local = files.join(files.getSdcardPath(), '.local');
let _local = files.join(files.getSdcardPath(), 'Download/.local');
files.isFile(_local) && files.remove(_local); // just in case

let _res = files.join.apply(files, [_local].concat([].slice.call(arguments)));
Expand Down
Loading

0 comments on commit c59d0aa

Please sign in to comment.