add sublime text plugin support
This commit is contained in:
@@ -2,6 +2,7 @@ package com.stardust.autojs.runtime;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.stardust.autojs.R;
|
||||
import com.stardust.autojs.engine.ScriptEngine;
|
||||
@@ -10,6 +11,7 @@ import com.stardust.autojs.runtime.api.AbstractShell;
|
||||
import com.stardust.autojs.runtime.api.AppUtils;
|
||||
import com.stardust.autojs.runtime.api.Console;
|
||||
import com.stardust.autojs.runtime.api.UiSelector;
|
||||
import com.stardust.autojs.runtime.api.internal.VolatileBox;
|
||||
import com.stardust.pio.UncheckedIOException;
|
||||
import com.stardust.util.ClipboardUtil;
|
||||
import com.stardust.autojs.runtime.api.ProcessShell;
|
||||
@@ -117,6 +119,20 @@ public class ScriptRuntime extends AbstractScriptRuntime {
|
||||
});
|
||||
}
|
||||
|
||||
public String getClip() {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
return ClipboardUtil.getClipOrEmpty(mUiHandler.getContext()).toString();
|
||||
}
|
||||
final VolatileBox<String> clip = new VolatileBox<>("");
|
||||
mUiHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
clip.setAndNotify(ClipboardUtil.getClipOrEmpty(mUiHandler.getContext()).toString());
|
||||
}
|
||||
});
|
||||
return clip.blockedGet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractShell getRootShell() {
|
||||
ensureRootShell();
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.stardust.autojs.runtime;
|
||||
|
||||
import com.stardust.autojs.runtime.api.AbstractShell;
|
||||
import com.stardust.autojs.runtime.api.AppUtils;
|
||||
import com.stardust.autojs.runtime.api.Console;
|
||||
import com.stardust.util.Supplier;
|
||||
import com.stardust.util.UiHandler;
|
||||
|
||||
public class ScriptRuntimeBuilder {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.stardust.autojs.runtime.api.internal;
|
||||
|
||||
import com.stardust.autojs.runtime.ScriptInterruptedException;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/8.
|
||||
*/
|
||||
|
||||
public class VolatileBox<T> {
|
||||
|
||||
private volatile T mValue;
|
||||
|
||||
public VolatileBox() {
|
||||
|
||||
}
|
||||
|
||||
public VolatileBox(T value) {
|
||||
set(value);
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void set(T value) {
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
public void setAndNotify(T value) {
|
||||
mValue = value;
|
||||
synchronized (this) {
|
||||
notify();
|
||||
}
|
||||
}
|
||||
|
||||
public T blockedGet() {
|
||||
synchronized (this) {
|
||||
try {
|
||||
this.wait();
|
||||
} catch (InterruptedException e) {
|
||||
throw new ScriptInterruptedException();
|
||||
}
|
||||
}
|
||||
return mValue;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user