Added: setClip
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package com.stardust.scriptdroid.droid.runtime;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -145,6 +148,15 @@ public class DroidRuntime implements IDroidRuntime {
|
||||
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_SET_TEXT, text));
|
||||
}
|
||||
|
||||
public void setClip(final String text) {
|
||||
mUIHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((ClipboardManager) App.getApp().getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText(TAG, text));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean paste(ActionTarget target) {
|
||||
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_PASTE));
|
||||
|
||||
@@ -73,12 +73,14 @@ public class ActionPerformAccessibilityDelegate implements AccessibilityDelegate
|
||||
if (latestPackage == null)
|
||||
return;
|
||||
ActionPerformAccessibilityDelegate.latestPackage = latestPackage.toString();
|
||||
ComponentName componentName = new ComponentName(latestPackage.toString(), latestClass == null ? null : latestClass.toString());
|
||||
if(latestClass == null)
|
||||
return;
|
||||
try {
|
||||
ComponentName componentName = new ComponentName(latestPackage.toString(), latestClass.toString());
|
||||
ActivityInfo activityInfo = App.getApp().getPackageManager().getActivityInfo(componentName, 0);
|
||||
ActionPerformAccessibilityDelegate.latestActivity = activityInfo.name;
|
||||
} catch (PackageManager.NameNotFoundException ignored) {
|
||||
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.stardust.scriptdroid.ui.edit;
|
||||
package com.stardust.scriptdroid.external.open;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -8,12 +8,13 @@ import android.widget.Toast;
|
||||
|
||||
import com.stardust.scriptdroid.ui.BaseActivity;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.ui.edit.EditActivity;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/2/2.
|
||||
*/
|
||||
|
||||
public class EditAndRunIntentActivity extends BaseActivity {
|
||||
public class EditIntentActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -24,6 +25,7 @@ public class EditAndRunIntentActivity extends BaseActivity {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(this, R.string.edit_and_run_handle_intent_error, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private void handleIntent() {
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.stardust.scriptdroid.ui.edit;
|
||||
package com.stardust.scriptdroid.external.open;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.stardust.scriptdroid.ui.BaseActivity;
|
||||
@@ -24,7 +25,13 @@ public class ImportIntentActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
handleIntent();
|
||||
try {
|
||||
handleIntent();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(this, R.string.edit_and_run_handle_intent_error, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private void handleIntent() {
|
||||
40
app/src/main/java/com/stardust/scriptdroid/external/open/RunIntentActivity.java
vendored
Normal file
40
app/src/main/java/com/stardust/scriptdroid/external/open/RunIntentActivity.java
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.stardust.scriptdroid.external.open;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.external.shortcut.ShortcutActivity;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/2/22.
|
||||
*/
|
||||
|
||||
public class RunIntentActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
try {
|
||||
handleIntent();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(this, R.string.edit_and_run_handle_intent_error, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private void handleIntent() {
|
||||
Intent intent = getIntent();
|
||||
String path = intent.getData().getPath();
|
||||
if (!TextUtils.isEmpty(path)) {
|
||||
startActivity(new Intent(this, ShortcutActivity.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra("path", path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,4 +198,17 @@ public class FileUtils {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static String generateNotExistingPath(String path, String extension) {
|
||||
if (!new File(path + extension).exists())
|
||||
return path + extension;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
String pathI = path + "(" + i + ")" + extension;
|
||||
if (!new File(pathI).exists())
|
||||
return pathI;
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class CodeCompletion implements TextWatcher {
|
||||
}
|
||||
|
||||
interface OnCodeCompletionChangeListener {
|
||||
void OnCodeCompletionChange(Collection<CodeCompletionItem> list);
|
||||
void OnCodeCompletionChange(Collection<CodeCompletionItem>... list);
|
||||
}
|
||||
|
||||
private static final String TAG = "CodeCompletion";
|
||||
@@ -101,14 +101,14 @@ public class CodeCompletion implements TextWatcher {
|
||||
|
||||
private static final String[] KEYWORDS = {"arguments", "break", "case", "catch", "class", "continue", "default", "do", "else", "eval", "export", "false", "for", "function", "if", "import", "in", "int", "new", "null", "package", "return", "switch", "this", "throw", "throws", "true", "try", "typeof", "var", "volatile", "while", "with", "Array", "Date", "hasOwnProperty", "Infinity", "isFinite", "isNaN", "isPrototypeOf", "length", "Math", "NaN", "name", "Number", "Object", "prototype", "String", "toString", "undefined", "valueOf"};
|
||||
private static final int KEY_WORD_LENGTH_MAX = 15;
|
||||
private static final String[] FUNCTIONS = {"toast", "launchPackage", "launch", "launchApp", "click", "longClick", "scrollUp", "scrollDown", "select", "focus", "paste", "input", "sleep", "isStopped", "notStopped", "log", "err", "openConsole", "clearConsole", "shell", "getTexts", "getPackageName", "getActivityName"};
|
||||
private static final String[] FUNCTIONS = {"toast", "launchPackage", "launch", "launchApp", "click", "longClick", "scrollUp", "scrollDown", "select", "focus", "paste", "input", "sleep", "isStopped", "notStopped", "log", "err", "openConsole", "clearConsole", "shell", "getTexts", "getPackageName", "getActivityName", "setClip"};
|
||||
|
||||
private boolean searchCodeCompletion(String str) {
|
||||
Collection<CodeCompletionItem> c = searchWordCompletion(str);
|
||||
c.addAll(searchCodeCompletion(str, FUNCTIONS));
|
||||
c.addAll(searchKeyWordCompletion(str));
|
||||
if (c.size() > 0) {
|
||||
mOnCodeCompletionChangeListener.OnCodeCompletionChange(c);
|
||||
mOnCodeCompletionChangeListener.OnCodeCompletionChange(c, DEFAULT_CODE_COMPLETION_LIST);
|
||||
return true;
|
||||
} else {
|
||||
mOnCodeCompletionChangeListener.OnCodeCompletionChange(DEFAULT_CODE_COMPLETION_LIST);
|
||||
|
||||
@@ -68,9 +68,11 @@ public class InputMethodEnhanceBar extends RecyclerView implements CodeCompletio
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnCodeCompletionChange(Collection<CodeCompletion.CodeCompletionItem> list) {
|
||||
public void OnCodeCompletionChange(Collection<CodeCompletion.CodeCompletionItem>... lists) {
|
||||
mCodeCompletionList.clear();
|
||||
mCodeCompletionList.addAll(list);
|
||||
for (Collection<CodeCompletion.CodeCompletionItem> list : lists) {
|
||||
mCodeCompletionList.addAll(list);
|
||||
}
|
||||
getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ public class IssueReportActivity extends IssueReporterActivity {
|
||||
private boolean mCrash = false;
|
||||
private Method mReportIssue, mValidateInput;
|
||||
private boolean mReportFailed = false;
|
||||
private String token = "d";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -129,7 +128,7 @@ public class IssueReportActivity extends IssueReporterActivity {
|
||||
@Override
|
||||
protected String getGuestToken() {
|
||||
//绕过github安全检查
|
||||
return decode("NDlkZDU3NjRiYTk3NzVmZDkxOTA3MDQ4YTdmNzQ1ZDY5NjcyNzEyNA==");
|
||||
return decode("MzA5MWJhNWI0NDM2NWYzOGRmNDA4ZWRhM2Y5MTUxN2ZlNDVlZDBhZQ==");
|
||||
}
|
||||
|
||||
public static String decode(String str) {
|
||||
|
||||
@@ -163,10 +163,11 @@ public class MainActivity extends BaseActivity implements FileChooserDialog.File
|
||||
.input(getString(R.string.text_please_input_name), "", new MaterialDialog.InputCallback() {
|
||||
@Override
|
||||
public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
|
||||
String path = ScriptFile.DEFAULT_FOLDER + input + ".js";
|
||||
String path = FileUtils.generateNotExistingPath(ScriptFile.DEFAULT_FOLDER + input, ".js");
|
||||
MainActivity.this.createScriptFile(input.toString(), path, script);
|
||||
}
|
||||
}).show();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void createScriptFile(String name, String path, String script) {
|
||||
|
||||
Reference in New Issue
Block a user