fix hyb1996-guest/AutoJsIssueReport#1341 and replace JavaAdapter to ProxyObject in ui module to avoid compilation to class file
This commit is contained in:
@@ -45,7 +45,7 @@ module.exports = function(__runtime__, scope){
|
||||
function toStrokes(args){
|
||||
var screenMetrics = __runtime__.getScreenMetrics();
|
||||
var len = args.length;
|
||||
var strokes = [];
|
||||
var strokes = java.lang.reflect.Array.newInstance(android.accessibilityservice.GestureDescription.StrokeDescription, len);
|
||||
for(var i = 0; i < len; i++){
|
||||
var gesture = args[i];
|
||||
var pointsIndex = 1;
|
||||
@@ -63,7 +63,7 @@ module.exports = function(__runtime__, scope){
|
||||
for(var j = pointsIndex + 1; j < gestureLen; j++){
|
||||
path.lineTo(screenMetrics.scaleX(gesture[j][0]), screenMetrics.scaleY(gesture[j][1]));
|
||||
}
|
||||
strokes.push(new android.accessibilityservice.GestureDescription.StrokeDescription(path, start, delay));
|
||||
strokes[i] = new android.accessibilityservice.GestureDescription.StrokeDescription(path, start, delay);
|
||||
}
|
||||
return strokes;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
module.exports = function(__runtime__, scope){
|
||||
var ui = Object.create(__runtime__.ui);
|
||||
ui.__id_cache__ = {};
|
||||
var ui = {};
|
||||
ui.__view_cache__ = {};
|
||||
|
||||
ui.layout = function(xml){
|
||||
view = ui.inflate(activity, xml.toString());
|
||||
var view = __runtime__.ui.layoutInflater.inflate(activity, xml.toString());
|
||||
ui.setContentView(view);
|
||||
}
|
||||
|
||||
ui.setContentView = function(view){
|
||||
ui.view = view;
|
||||
ui.__id_cache__ = {};
|
||||
ui.__view_cache__ = {};
|
||||
activity.setContentView(view);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,10 @@ module.exports = function(__runtime__, scope){
|
||||
}
|
||||
|
||||
ui.nonUi = function(action){
|
||||
ui.runOnNonUiThread(action);
|
||||
if(!ui.__executor__){
|
||||
ui.__executor__ = java.util.concurrent.Executors.newSingleThreadExecutor();
|
||||
}
|
||||
ui.__executor__.submit(action);
|
||||
}
|
||||
|
||||
ui.postDelay = function(action, delay){
|
||||
@@ -39,7 +42,7 @@ module.exports = function(__runtime__, scope){
|
||||
if(typeof(color) == 'string'){
|
||||
color = android.graphics.Color.parseColor(color);
|
||||
}
|
||||
if(Build.VERSION.SDK_INT >= 21){
|
||||
if(android.os.Build.VERSION.SDK_INT >= 21){
|
||||
activity.getWindow().setStatusBarColor(color);
|
||||
}
|
||||
}
|
||||
@@ -48,6 +51,10 @@ module.exports = function(__runtime__, scope){
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
ui.findViewByStringId = function(view, id){
|
||||
return com.stardust.autojs.runtime.api.ui.JsViewHelper.findViewByStringId(view, id);
|
||||
}
|
||||
|
||||
function decorate(view){
|
||||
var view = Object.create(view);
|
||||
view._id = function(id){
|
||||
@@ -70,23 +77,25 @@ module.exports = function(__runtime__, scope){
|
||||
return view;
|
||||
}
|
||||
|
||||
return new JavaAdapter(org.mozilla.javascript.NativeObject, {
|
||||
put: function(name, start, value) {
|
||||
ui[name] = value;
|
||||
},
|
||||
get: function(name, start) {
|
||||
if(!ui[name] && ui.view){
|
||||
var cacheView = ui.__id_cache__[name];
|
||||
if(cacheView){
|
||||
return cacheView;
|
||||
}
|
||||
cacheView = ui.id(name);
|
||||
if(cacheView){
|
||||
ui.__id_cache__[name] = cacheView;
|
||||
return cacheView;
|
||||
}
|
||||
}
|
||||
return ui[name];
|
||||
}
|
||||
});
|
||||
var proxy = __runtime__.ui;
|
||||
proxy.__proxy__ = {
|
||||
set: function(name, value){
|
||||
ui[name] = value;
|
||||
},
|
||||
get: function(name) {
|
||||
if(!ui[name] && ui.view){
|
||||
var cacheView = ui.__view_cache__[name];
|
||||
if(cacheView){
|
||||
return cacheView;
|
||||
}
|
||||
cacheView = ui.id(name);
|
||||
if(cacheView){
|
||||
ui.__view_cache__[name] = cacheView;
|
||||
return cacheView;
|
||||
}
|
||||
}
|
||||
return ui[name];
|
||||
}
|
||||
};
|
||||
return proxy;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user