重构 ExecutionConfig
This commit is contained in:
@@ -40,7 +40,10 @@ public class ScriptIntents {
|
||||
long delay = intent.getLongExtra(EXTRA_KEY_DELAY, 0);
|
||||
long interval = intent.getLongExtra(EXTRA_KEY_LOOP_INTERVAL, 0);
|
||||
ScriptSource source = null;
|
||||
ExecutionConfig config = new ExecutionConfig().loop(delay, loopTimes, interval);
|
||||
ExecutionConfig config = new ExecutionConfig();
|
||||
config.setDelay(delay);
|
||||
config.setLoopTimes(loopTimes);
|
||||
config.setInterval(interval);
|
||||
config.setArgument("intent", intent);
|
||||
if (path == null && script != null) {
|
||||
source = new StringScriptSource(script);
|
||||
@@ -51,9 +54,9 @@ public class ScriptIntents {
|
||||
} else {
|
||||
source = fileScriptSource;
|
||||
}
|
||||
config.executePath(new File(path).getParent());
|
||||
config.setWorkingDirectory(new File(path).getParent());
|
||||
} else {
|
||||
config.executePath(Pref.getScriptDirPath());
|
||||
config.setWorkingDirectory(Pref.getScriptDirPath());
|
||||
}
|
||||
if (source == null) {
|
||||
return false;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class RunIntentActivity extends Activity {
|
||||
Uri uri = intent.getData();
|
||||
if (uri != null && "content".equals(uri.getScheme())) {
|
||||
InputStream stream = getContentResolver().openInputStream(uri);
|
||||
Scripts.run(new StringScriptSource(PFiles.read(stream)));
|
||||
Scripts.INSTANCE.run(new StringScriptSource(PFiles.read(stream)));
|
||||
} else {
|
||||
ScriptIntents.handleIntent(this, intent);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class BaseBroadcastReceiver extends BroadcastReceiver {
|
||||
ScriptFile file = new ScriptFile(task.getScriptPath());
|
||||
ExecutionConfig config = new ExecutionConfig();
|
||||
config.setArgument("intent", intent.clone());
|
||||
config.executePath(file.getParent());
|
||||
config.setWorkingDirectory(file.getParent());
|
||||
try {
|
||||
AutoJs.getInstance().getScriptEngineService().execute(file.toSource(), config);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ShortcutActivity extends Activity {
|
||||
|
||||
private void runScriptFile(String path) {
|
||||
try {
|
||||
Scripts.run(new ScriptFile(path));
|
||||
Scripts.INSTANCE.run(new ScriptFile(path));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ScriptWidgetSettingsActivity extends BaseActivity {
|
||||
|
||||
|
||||
private void initScriptListRecyclerView() {
|
||||
mExplorer = new Explorer(new ExplorerFileProvider(Scripts.FILE_FILTER), 0);
|
||||
mExplorer = new Explorer(new ExplorerFileProvider(Scripts.INSTANCE.getFILE_FILTER()), 0);
|
||||
ExplorerView explorerView = findViewById(R.id.script_list);
|
||||
explorerView.setExplorer(mExplorer, ExplorerDirPage.createRoot(Environment.getExternalStorageDirectory()));
|
||||
explorerView.setOnItemClickListener((view, file) -> {
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
package org.autojs.autojs.model.script;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.stardust.app.GlobalAppContext;
|
||||
import com.stardust.autojs.execution.ExecutionConfig;
|
||||
import com.stardust.autojs.execution.ScriptExecution;
|
||||
import com.stardust.autojs.execution.ScriptExecutionListener;
|
||||
import com.stardust.autojs.execution.SimpleScriptExecutionListener;
|
||||
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
|
||||
import com.stardust.autojs.script.ScriptSource;
|
||||
import com.stardust.util.IntentUtil;
|
||||
|
||||
import org.autojs.autojs.Pref;
|
||||
import org.autojs.autojs.R;
|
||||
import org.autojs.autojs.autojs.AutoJs;
|
||||
import org.autojs.autojs.external.ScriptIntents;
|
||||
import org.autojs.autojs.external.fileprovider.AppFileProvider;
|
||||
import org.autojs.autojs.external.shortcut.Shortcut;
|
||||
import org.autojs.autojs.external.shortcut.ShortcutActivity;
|
||||
import org.autojs.autojs.ui.edit.EditActivity;
|
||||
|
||||
import org.mozilla.javascript.RhinoException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/3.
|
||||
*/
|
||||
|
||||
public class Scripts {
|
||||
|
||||
public static final String ACTION_ON_EXECUTION_FINISHED = "ACTION_ON_EXECUTION_FINISHED";
|
||||
public static final String EXTRA_EXCEPTION_MESSAGE = "message";
|
||||
public static final String EXTRA_EXCEPTION_LINE_NUMBER = "lineNumber";
|
||||
public static final String EXTRA_EXCEPTION_COLUMN_NUMBER = "columnNumber";
|
||||
|
||||
public static final FileFilter FILE_FILTER = file ->
|
||||
file.isDirectory() || file.getName().endsWith(".js") || file.getName().endsWith(".auto");
|
||||
|
||||
private static final ScriptExecutionListener BROADCAST_SENDER_SCRIPT_EXECUTION_LISTENER = new SimpleScriptExecutionListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ScriptExecution execution, Object result) {
|
||||
GlobalAppContext.get().sendBroadcast(new Intent(ACTION_ON_EXECUTION_FINISHED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(ScriptExecution execution, Throwable e) {
|
||||
RhinoException rhinoException = getRhinoException(e);
|
||||
int line = -1, col = 0;
|
||||
if (rhinoException != null) {
|
||||
line = rhinoException.lineNumber();
|
||||
col = rhinoException.columnNumber();
|
||||
}
|
||||
if (ScriptInterruptedException.causedByInterrupted(e)) {
|
||||
GlobalAppContext.get().sendBroadcast(new Intent(ACTION_ON_EXECUTION_FINISHED)
|
||||
.putExtra(EXTRA_EXCEPTION_LINE_NUMBER, line)
|
||||
.putExtra(EXTRA_EXCEPTION_COLUMN_NUMBER, col));
|
||||
} else {
|
||||
GlobalAppContext.get().sendBroadcast(new Intent(ACTION_ON_EXECUTION_FINISHED)
|
||||
.putExtra(EXTRA_EXCEPTION_MESSAGE, e.getMessage())
|
||||
.putExtra(EXTRA_EXCEPTION_LINE_NUMBER, line)
|
||||
.putExtra(EXTRA_EXCEPTION_COLUMN_NUMBER, col));
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
public static void openByOtherApps(Uri uri) {
|
||||
IntentUtil.viewFile(GlobalAppContext.get(), uri, "text/plain", AppFileProvider.AUTHORITY);
|
||||
}
|
||||
|
||||
public static void openByOtherApps(File file) {
|
||||
openByOtherApps(Uri.fromFile(file));
|
||||
}
|
||||
|
||||
public static void createShortcut(ScriptFile scriptFile) {
|
||||
new Shortcut(GlobalAppContext.get()).name(scriptFile.getSimplifiedName())
|
||||
.targetClass(ShortcutActivity.class)
|
||||
.iconRes(R.drawable.ic_node_js_black)
|
||||
.extras(new Intent().putExtra(ScriptIntents.EXTRA_KEY_PATH, scriptFile.getPath()))
|
||||
.send();
|
||||
}
|
||||
|
||||
|
||||
public static void edit(ScriptFile file) {
|
||||
EditActivity.editFile(GlobalAppContext.get(), file.getSimplifiedName(), file.getPath());
|
||||
}
|
||||
|
||||
public static void edit(String path) {
|
||||
edit(new ScriptFile(path));
|
||||
}
|
||||
|
||||
public static ScriptExecution run(ScriptFile file) {
|
||||
try {
|
||||
return AutoJs.getInstance().getScriptEngineService().execute(file.toSource(), new ExecutionConfig()
|
||||
.executePath(file.getParent()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(GlobalAppContext.get(), e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static ScriptExecution run(ScriptSource source) {
|
||||
try {
|
||||
return AutoJs.getInstance().getScriptEngineService().execute(source, new ExecutionConfig()
|
||||
.executePath(Pref.getScriptDirPath())
|
||||
.requirePath(Pref.getScriptDirPath()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(GlobalAppContext.get(), e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ScriptExecution runWithBroadcastSender(File file) {
|
||||
return AutoJs.getInstance().getScriptEngineService().execute(new ScriptFile(file).toSource(), BROADCAST_SENDER_SCRIPT_EXECUTION_LISTENER,
|
||||
new ExecutionConfig().executePath(file.getParent()));
|
||||
}
|
||||
|
||||
|
||||
public static ScriptExecution runRepeatedly(ScriptFile scriptFile, int loopTimes, long delay, long interval) {
|
||||
ScriptSource source = scriptFile.toSource();
|
||||
String directoryPath = scriptFile.getParent();
|
||||
return AutoJs.getInstance().getScriptEngineService().execute(source, new ExecutionConfig()
|
||||
.executePath(directoryPath)
|
||||
.loop(delay, loopTimes, interval));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static RhinoException getRhinoException(Throwable e) {
|
||||
while (e != null) {
|
||||
if (e instanceof RhinoException) {
|
||||
return (RhinoException) e;
|
||||
}
|
||||
e = e.getCause();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void send(ScriptFile file) {
|
||||
Context context = GlobalAppContext.get();
|
||||
context.startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND)
|
||||
.setType("text/plain")
|
||||
.putExtra(Intent.EXTRA_STREAM, IntentUtil.getUriOfFile(context, file.getPath(), AppFileProvider.AUTHORITY)),
|
||||
GlobalAppContext.getString(R.string.text_send)
|
||||
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
|
||||
}
|
||||
}
|
||||
160
app/src/main/java/org/autojs/autojs/model/script/Scripts.kt
Normal file
160
app/src/main/java/org/autojs/autojs/model/script/Scripts.kt
Normal file
@@ -0,0 +1,160 @@
|
||||
package org.autojs.autojs.model.script
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.annotation.Nullable
|
||||
import android.widget.Toast
|
||||
|
||||
import com.stardust.app.GlobalAppContext
|
||||
import com.stardust.autojs.execution.ExecutionConfig
|
||||
import com.stardust.autojs.execution.ScriptExecution
|
||||
import com.stardust.autojs.execution.ScriptExecutionListener
|
||||
import com.stardust.autojs.execution.SimpleScriptExecutionListener
|
||||
import com.stardust.autojs.runtime.exception.ScriptInterruptedException
|
||||
import com.stardust.autojs.script.ScriptSource
|
||||
import com.stardust.util.IntentUtil
|
||||
|
||||
import org.autojs.autojs.Pref
|
||||
import org.autojs.autojs.R
|
||||
import org.autojs.autojs.autojs.AutoJs
|
||||
import org.autojs.autojs.external.ScriptIntents
|
||||
import org.autojs.autojs.external.fileprovider.AppFileProvider
|
||||
import org.autojs.autojs.external.shortcut.Shortcut
|
||||
import org.autojs.autojs.external.shortcut.ShortcutActivity
|
||||
import org.autojs.autojs.ui.edit.EditActivity
|
||||
|
||||
import org.mozilla.javascript.RhinoException
|
||||
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/3.
|
||||
*/
|
||||
|
||||
object Scripts {
|
||||
|
||||
const val ACTION_ON_EXECUTION_FINISHED = "ACTION_ON_EXECUTION_FINISHED"
|
||||
const val EXTRA_EXCEPTION_MESSAGE = "message"
|
||||
const val EXTRA_EXCEPTION_LINE_NUMBER = "lineNumber"
|
||||
const val EXTRA_EXCEPTION_COLUMN_NUMBER = "columnNumber"
|
||||
|
||||
val FILE_FILTER = FileFilter { file ->
|
||||
file.isDirectory || file.name.endsWith(".js")
|
||||
|| file.name.endsWith(".auto")
|
||||
}
|
||||
|
||||
private val BROADCAST_SENDER_SCRIPT_EXECUTION_LISTENER = object : SimpleScriptExecutionListener() {
|
||||
|
||||
override fun onSuccess(execution: ScriptExecution, result: Any?) {
|
||||
GlobalAppContext.get().sendBroadcast(Intent(ACTION_ON_EXECUTION_FINISHED))
|
||||
}
|
||||
|
||||
override fun onException(execution: ScriptExecution, e: Throwable) {
|
||||
val rhinoException = getRhinoException(e)
|
||||
var line = -1
|
||||
var col = 0
|
||||
if (rhinoException != null) {
|
||||
line = rhinoException.lineNumber()
|
||||
col = rhinoException.columnNumber()
|
||||
}
|
||||
if (ScriptInterruptedException.causedByInterrupted(e)) {
|
||||
GlobalAppContext.get().sendBroadcast(Intent(ACTION_ON_EXECUTION_FINISHED)
|
||||
.putExtra(EXTRA_EXCEPTION_LINE_NUMBER, line)
|
||||
.putExtra(EXTRA_EXCEPTION_COLUMN_NUMBER, col))
|
||||
} else {
|
||||
GlobalAppContext.get().sendBroadcast(Intent(ACTION_ON_EXECUTION_FINISHED)
|
||||
.putExtra(EXTRA_EXCEPTION_MESSAGE, e.message)
|
||||
.putExtra(EXTRA_EXCEPTION_LINE_NUMBER, line)
|
||||
.putExtra(EXTRA_EXCEPTION_COLUMN_NUMBER, col))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun openByOtherApps(uri: Uri) {
|
||||
IntentUtil.viewFile(GlobalAppContext.get(), uri, "text/plain", AppFileProvider.AUTHORITY)
|
||||
}
|
||||
|
||||
fun openByOtherApps(file: File) {
|
||||
openByOtherApps(Uri.fromFile(file))
|
||||
}
|
||||
|
||||
fun createShortcut(scriptFile: ScriptFile) {
|
||||
Shortcut(GlobalAppContext.get()).name(scriptFile.simplifiedName)
|
||||
.targetClass(ShortcutActivity::class.java)
|
||||
.iconRes(R.drawable.ic_node_js_black)
|
||||
.extras(Intent().putExtra(ScriptIntents.EXTRA_KEY_PATH, scriptFile.path))
|
||||
.send()
|
||||
}
|
||||
|
||||
|
||||
fun edit(file: ScriptFile) {
|
||||
EditActivity.editFile(GlobalAppContext.get(), file.simplifiedName, file.path)
|
||||
}
|
||||
|
||||
fun edit(path: String) {
|
||||
edit(ScriptFile(path))
|
||||
}
|
||||
|
||||
fun run(file: ScriptFile): ScriptExecution? {
|
||||
try {
|
||||
return AutoJs.getInstance().scriptEngineService.execute(file.toSource(),
|
||||
ExecutionConfig(workingDirectory = file.parent))
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Toast.makeText(GlobalAppContext.get(), e.message, Toast.LENGTH_LONG).show()
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun run(source: ScriptSource): ScriptExecution? {
|
||||
return try {
|
||||
AutoJs.getInstance().scriptEngineService.execute(source, ExecutionConfig(workingDirectory = Pref.getScriptDirPath()))
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Toast.makeText(GlobalAppContext.get(), e.message, Toast.LENGTH_LONG).show()
|
||||
null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun runWithBroadcastSender(file: File): ScriptExecution {
|
||||
return AutoJs.getInstance().scriptEngineService.execute(ScriptFile(file).toSource(), BROADCAST_SENDER_SCRIPT_EXECUTION_LISTENER,
|
||||
ExecutionConfig(workingDirectory = file.parent))
|
||||
}
|
||||
|
||||
|
||||
fun runRepeatedly(scriptFile: ScriptFile, loopTimes: Int, delay: Long, interval: Long): ScriptExecution {
|
||||
val source = scriptFile.toSource()
|
||||
val directoryPath = scriptFile.parent
|
||||
return AutoJs.getInstance().scriptEngineService.execute(source, ExecutionConfig(workingDirectory = directoryPath,
|
||||
delay = delay, loopTimes = loopTimes, interval = interval))
|
||||
}
|
||||
|
||||
@Nullable
|
||||
fun getRhinoException(e: Throwable?): RhinoException? {
|
||||
var e = e
|
||||
while (e != null) {
|
||||
if (e is RhinoException) {
|
||||
return e
|
||||
}
|
||||
e = e.cause
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun send(file: ScriptFile) {
|
||||
val context = GlobalAppContext.get()
|
||||
context.startActivity(Intent.createChooser(Intent(Intent.ACTION_SEND)
|
||||
.setType("text/plain")
|
||||
.putExtra(Intent.EXTRA_STREAM, IntentUtil.getUriOfFile(context, file.path, AppFileProvider.AUTHORITY)),
|
||||
GlobalAppContext.getString(R.string.text_send)
|
||||
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class DevPluginResponseHandler implements Handler {
|
||||
} else {
|
||||
name = PFiles.getNameWithoutExtension(name);
|
||||
}
|
||||
mScriptExecutions.put(viewId, Scripts.run(new StringScriptSource("[remote]" + name, script)));
|
||||
mScriptExecutions.put(viewId, Scripts.INSTANCE.run(new StringScriptSource("[remote]" + name, script)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -53,9 +53,9 @@ public class TimedTask extends BaseModel {
|
||||
mMillis = millis;
|
||||
mTimeFlag = timeFlag;
|
||||
mScriptPath = scriptPath;
|
||||
mDelay = config.delay;
|
||||
mLoopTimes = config.loopTimes;
|
||||
mInterval = config.interval;
|
||||
mDelay = config.getDelay();
|
||||
mLoopTimes = config.getLoopTimes();
|
||||
mInterval = config.getInterval();
|
||||
}
|
||||
|
||||
public boolean isDisposable() {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ScriptLoopDialog {
|
||||
int loopTimes = Integer.parseInt(mLoopTimes.getText().toString());
|
||||
float loopInterval = Float.parseFloat(mLoopInterval.getText().toString());
|
||||
float loopDelay = Float.parseFloat(mLoopDelay.getText().toString());
|
||||
Scripts.runRepeatedly(mScriptFile, loopTimes, (long) (1000L * loopDelay), (long) (loopInterval * 1000L));
|
||||
Scripts.INSTANCE.runRepeatedly(mScriptFile, loopTimes, (long) (1000L * loopDelay), (long) (loopInterval * 1000L));
|
||||
} catch (NumberFormatException e) {
|
||||
GlobalAppContext.toast(R.string.text_number_format_error);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ScriptOperations {
|
||||
}
|
||||
notifyFileCreated(mCurrentDirectory, new ScriptFile(path));
|
||||
if (edit)
|
||||
Scripts.edit(path);
|
||||
Scripts.INSTANCE.edit(path);
|
||||
} else {
|
||||
showMessage(R.string.text_create_fail);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,9 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static org.autojs.autojs.model.script.Scripts.ACTION_ON_EXECUTION_FINISHED;
|
||||
import static org.autojs.autojs.model.script.Scripts.EXTRA_EXCEPTION_COLUMN_NUMBER;
|
||||
import static org.autojs.autojs.model.script.Scripts.EXTRA_EXCEPTION_LINE_NUMBER;
|
||||
import static org.autojs.autojs.model.script.Scripts.EXTRA_EXCEPTION_MESSAGE;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/9/28.
|
||||
@@ -137,9 +140,9 @@ public class EditorView extends FrameLayout implements CodeCompletionBar.OnHintC
|
||||
exitDebugging();
|
||||
}
|
||||
setMenuItemStatus(R.id.run, true);
|
||||
String msg = intent.getStringExtra(Scripts.EXTRA_EXCEPTION_MESSAGE);
|
||||
int line = intent.getIntExtra(Scripts.EXTRA_EXCEPTION_LINE_NUMBER, -1);
|
||||
int col = intent.getIntExtra(Scripts.EXTRA_EXCEPTION_COLUMN_NUMBER, 0);
|
||||
String msg = intent.getStringExtra(EXTRA_EXCEPTION_MESSAGE);
|
||||
int line = intent.getIntExtra(EXTRA_EXCEPTION_LINE_NUMBER, -1);
|
||||
int col = intent.getIntExtra(EXTRA_EXCEPTION_COLUMN_NUMBER, 0);
|
||||
if (line >= 1) {
|
||||
mEditor.jumpTo(line - 1, col);
|
||||
}
|
||||
@@ -405,7 +408,7 @@ public class EditorView extends FrameLayout implements CodeCompletionBar.OnHintC
|
||||
Snackbar.make(this, R.string.text_start_running, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
// TODO: 2018/10/24
|
||||
ScriptExecution execution = Scripts.runWithBroadcastSender(new File(mUri.getPath()));
|
||||
ScriptExecution execution = Scripts.INSTANCE.runWithBroadcastSender(new File(mUri.getPath()));
|
||||
if (execution == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -502,7 +505,7 @@ public class EditorView extends FrameLayout implements CodeCompletionBar.OnHintC
|
||||
|
||||
public void openByOtherApps() {
|
||||
if (mUri != null) {
|
||||
Scripts.openByOtherApps(mUri);
|
||||
Scripts.INSTANCE.openByOtherApps(mUri);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ public class ViewSampleActivity extends AppCompatActivity implements OnActivityR
|
||||
setContentView(mView);
|
||||
handleIntent(getIntent());
|
||||
setUpUI();
|
||||
setUpEditor();
|
||||
registerReceiver(mOnRunFinishedReceiver, new IntentFilter(ACTION_ON_EXECUTION_FINISHED));
|
||||
}
|
||||
|
||||
@@ -85,10 +84,6 @@ public class ViewSampleActivity extends AppCompatActivity implements OnActivityR
|
||||
ButterKnife.bind(this);
|
||||
}
|
||||
|
||||
private void setUpEditor() {
|
||||
|
||||
}
|
||||
|
||||
private void setUpToolbar() {
|
||||
BaseActivity.setToolbarAsBack(this, R.id.toolbar, mSample.getSimplifiedName());
|
||||
}
|
||||
|
||||
@@ -339,11 +339,11 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
|
||||
.createShortcut(mSelectedItem.toScriptFile());
|
||||
break;
|
||||
case R.id.open_by_other_apps:
|
||||
Scripts.openByOtherApps(mSelectedItem.toScriptFile());
|
||||
Scripts.INSTANCE.openByOtherApps(mSelectedItem.toScriptFile());
|
||||
notifyOperated();
|
||||
break;
|
||||
case R.id.send:
|
||||
Scripts.send(mSelectedItem.toScriptFile());
|
||||
Scripts.INSTANCE.send(mSelectedItem.toScriptFile());
|
||||
notifyOperated();
|
||||
break;
|
||||
case R.id.timed_task:
|
||||
@@ -551,13 +551,13 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
|
||||
|
||||
@OnClick(R.id.run)
|
||||
void run() {
|
||||
Scripts.run(new ScriptFile(mExplorerItem.getPath()));
|
||||
Scripts.INSTANCE.run(new ScriptFile(mExplorerItem.getPath()));
|
||||
notifyOperated();
|
||||
}
|
||||
|
||||
@OnClick(R.id.edit)
|
||||
void edit() {
|
||||
Scripts.edit(new ScriptFile(mExplorerItem.getPath()));
|
||||
Scripts.INSTANCE.edit(new ScriptFile(mExplorerItem.getPath()));
|
||||
notifyOperated();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class FileChooserDialogBuilder extends ThemeColorMaterialDialogBuilder {
|
||||
}
|
||||
|
||||
public FileChooserDialogBuilder justScriptFile() {
|
||||
mFileFilter = Scripts.FILE_FILTER;
|
||||
mFileFilter = Scripts.INSTANCE.getFILE_FILTER();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ public class CircularMenu implements Recorder.OnStateChangedListener, LayoutInsp
|
||||
.positiveText(R.string.cancel)
|
||||
.build();
|
||||
explorerView.setOnItemOperatedListener(file -> dialog.dismiss());
|
||||
explorerView.setOnItemClickListener((view, item) -> Scripts.run(item.toScriptFile()));
|
||||
explorerView.setOnItemClickListener((view, item) -> Scripts.INSTANCE.run(item.toScriptFile()));
|
||||
DialogUtils.showDialog(dialog);
|
||||
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CommunityWebView extends EWebView {
|
||||
.subscribe(file ->
|
||||
Snackbar.make(CommunityWebView.this, getResources().getString(R.string.format_file_downloaded, file.getPath())
|
||||
, Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.text_open, v -> Scripts.edit(file))
|
||||
.setAction(R.string.text_open, v -> Scripts.INSTANCE.edit(file))
|
||||
.show(),
|
||||
error -> {
|
||||
error.printStackTrace();
|
||||
@@ -93,7 +93,7 @@ public class CommunityWebView extends EWebView {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(file -> {
|
||||
Snackbar.make(CommunityWebView.this, R.string.text_start_running, Snackbar.LENGTH_SHORT).show();
|
||||
Scripts.run(file);
|
||||
Scripts.INSTANCE.run(file);
|
||||
}, error -> {
|
||||
error.printStackTrace();
|
||||
Snackbar.make(CommunityWebView.this, R.string.text_download_failed, Toast.LENGTH_SHORT).show();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MyScriptListFragment extends ViewPagerFragment implements FloatingA
|
||||
mExplorerView.setExplorer(Explorers.workspace(), ExplorerDirPage.createRoot(Pref.getScriptDirPath()));
|
||||
mExplorerView.setOnItemClickListener((view, item) -> {
|
||||
if (item.isEditable()) {
|
||||
Scripts.edit(item.toScriptFile());
|
||||
Scripts.INSTANCE.edit(item.toScriptFile());
|
||||
} else {
|
||||
IntentUtil.viewFile(GlobalAppContext.get(), item.getPath(), AppFileProvider.AUTHORITY);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.autojs.autojs.ui.timing;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
@@ -344,6 +345,7 @@ public class TimedTaskSettingActivity extends BaseActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressLint("BatteryLife")
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_done) {
|
||||
|
||||
Reference in New Issue
Block a user