optimize memory and image size. remove unnecessary language file
@@ -9,8 +9,8 @@ android {
|
||||
applicationId "com.stardust.scriptdroid"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 23
|
||||
versionCode 123
|
||||
versionName "2.0.9d Alpha"
|
||||
versionCode 125
|
||||
versionName "2.0.9 Beta"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
@@ -18,6 +18,11 @@ android {
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
shrinkResources false
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
release {
|
||||
shrinkResources false
|
||||
minifyEnabled false
|
||||
@@ -42,17 +47,7 @@ android {
|
||||
output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
|
||||
}
|
||||
}
|
||||
packagingOptions {
|
||||
pickFirst 'org/mozilla/javascript/tools/debugger/build.xml'
|
||||
pickFirst 'org/mozilla/javascript/tools/debugger/test.js'
|
||||
pickFirst 'org/mozilla/javascript/tools/idswitch/README'
|
||||
pickFirst 'org/mozilla/javascript/NativeString.java.orig'
|
||||
pickFirst 'org/mozilla/javascript/Node.java.orig'
|
||||
pickFirst 'org/mozilla/javascript/resources/Messages_fr.properties'
|
||||
pickFirst 'org/mozilla/javascript/resources/Messages.properties'
|
||||
pickFirst 'org/mozilla/javascript/*.java.orig'
|
||||
pickFirst 'org/mozilla/javascript/tools/resources/*.properties'
|
||||
}
|
||||
|
||||
dexcount {
|
||||
format = "list"
|
||||
includeClasses = true
|
||||
|
||||
22
app/proguard-rules.pro
vendored
@@ -93,19 +93,19 @@
|
||||
}
|
||||
|
||||
# Google Play Services library
|
||||
-keep class * extends java.util.ListResourceBundle {
|
||||
protected Object[ ][ ] getContents();
|
||||
-keep class * extends java.util.ListResourceBundle {
|
||||
protected Object[ ][ ] getContents();
|
||||
}
|
||||
|
||||
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
|
||||
public static final *** NULL;
|
||||
}
|
||||
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
|
||||
public static final *** NULL;
|
||||
}
|
||||
|
||||
-keepnames @com.google.android.gms.common.annotation.KeepName class *
|
||||
-keepclassmembernames class * {
|
||||
-keepnames @com.google.android.gms.common.annotation.KeepName class *
|
||||
-keepclassmembernames class * {
|
||||
@com.google.android.gms.common.annotation.KeepName *;
|
||||
}
|
||||
}
|
||||
|
||||
-keepnames class * implements android.os.Parcelable {
|
||||
public static final ** CREATOR;
|
||||
}
|
||||
-keepnames class * implements android.os.Parcelable {
|
||||
public static final ** CREATOR;
|
||||
}
|
||||
@@ -69,7 +69,9 @@
|
||||
android:resource="@xml/provider_paths"/>
|
||||
</provider>
|
||||
|
||||
<activity android:name=".ui.edit.EditActivity" android:multiprocess="true">
|
||||
<activity
|
||||
android:name=".ui.edit.EditActivity"
|
||||
android:multiprocess="true">
|
||||
|
||||
</activity>
|
||||
<activity android:name=".ui.help.DocumentationActivity"/>
|
||||
@@ -158,7 +160,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".external.open.RunIntentActivity"
|
||||
android:icon="@drawable/ic_play_green"
|
||||
android:icon="@drawable/ic_ali_run"
|
||||
android:label="运行脚本">
|
||||
|
||||
<intent-filter>
|
||||
@@ -198,7 +200,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".external.open.ImportIntentActivity"
|
||||
android:icon="@drawable/ic_folder_open_outline_green"
|
||||
android:icon="@drawable/ic_import"
|
||||
android:label="导入脚本文件">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
@@ -5,11 +5,11 @@ var dialogs = {};
|
||||
|
||||
dialogs.rawInput = function(title, prefill){
|
||||
prefill = prefill || "";
|
||||
return __runtime__.dialogs.rawInput(title, prefill);
|
||||
return String(__runtime__.dialogs.rawInput(title, prefill));
|
||||
};
|
||||
|
||||
dialogs.input = function(title, prefill){
|
||||
return eval(dialogs.rawInput(title, prefill) + "");
|
||||
return eval(dialogs.rawInput(title, prefill));
|
||||
}
|
||||
|
||||
dialogs.prompt = dialogs.rawInput;
|
||||
@@ -25,6 +25,9 @@ dialogs.confirm = function(title, prefill){
|
||||
}
|
||||
|
||||
dialogs.select = function(title, items){
|
||||
if(items instanceof Array){
|
||||
return __runtime__.dialogs.select(title, items);
|
||||
}
|
||||
return __runtime__.dialogs.select(title, [].slice.call(arguments, 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
log("Hello world!!!");
|
||||
toast("Hello, AutoJs!");
|
||||
openConsole();
|
||||
console.show();
|
||||
@@ -1,5 +1,5 @@
|
||||
var num1 = dialogs.input("请输入第一个数字");
|
||||
var op = dialogs.singleChoice("请选择运算", 0, "加", "减", "乘", "除", "幂");
|
||||
var op = dialogs.singleChoice("请选择运算", ["加", "减", "乘", "除", "幂"]);
|
||||
var num2 = dialogs.input("请输入第二个数字");
|
||||
var result = 0;
|
||||
switch(op){
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
var sh = new Shell();
|
||||
sh.setCallback({
|
||||
onNewLine: function(str){
|
||||
console.log(str);
|
||||
onOutput: function(str){
|
||||
print(str);
|
||||
}
|
||||
})
|
||||
console.show();
|
||||
console.info("请输入要运行命令:");
|
||||
do {
|
||||
var cmd = console.rawInput();
|
||||
sh.exec(cmd);
|
||||
|
||||
@@ -45,5 +45,4 @@ public abstract class Fragment extends android.support.v4.app.Fragment {
|
||||
public abstract View createView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class BlockedMaterialDialog extends MaterialDialog {
|
||||
@Override
|
||||
public void show() {
|
||||
if (!isActivityContext(getContext())) {
|
||||
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
||||
getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE);
|
||||
}
|
||||
super.show();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.OvalShape;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.DrawableRes;
|
||||
@@ -75,9 +77,9 @@ public class HoverMenuAdapter implements io.mattcarroll.hover.HoverMenuAdapter {
|
||||
private View getTabViewInner(int index) {
|
||||
String menuItemId = mTabIds.get(index);
|
||||
if (ID_MAIN.equals(menuItemId)) {
|
||||
return createTabView(R.drawable.ic_android_eat_js_100);
|
||||
return createTabView(R.drawable.ic_android_eat_js_64);
|
||||
} else if (ID_RECORD.equals(menuItemId)) {
|
||||
return createTabView(R.drawable.ic_video_record);
|
||||
return createTabView(R.drawable.ic_ali_record);
|
||||
} else if (ID_SCRIPT_LIST.equals(menuItemId)) {
|
||||
return createTabView(R.drawable.ic_menu);
|
||||
} else {
|
||||
@@ -125,7 +127,7 @@ public class HoverMenuAdapter implements io.mattcarroll.hover.HoverMenuAdapter {
|
||||
Resources resources = mContext.getResources();
|
||||
int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, resources.getDisplayMetrics());
|
||||
|
||||
DemoTabView view = new DemoTabView(mContext, resources.getDrawable(R.drawable.tab_background), resources.getDrawable(tabBitmapRes));
|
||||
DemoTabView view = new DemoTabView(mContext, getCircleDrawable(), resources.getDrawable(tabBitmapRes));
|
||||
view.setTabBackgroundColor(backgroundColor);
|
||||
view.setTabForegroundColor(iconColor);
|
||||
view.setPadding(padding, padding, padding, padding);
|
||||
@@ -135,6 +137,12 @@ public class HoverMenuAdapter implements io.mattcarroll.hover.HoverMenuAdapter {
|
||||
return view;
|
||||
}
|
||||
|
||||
private Drawable getCircleDrawable() {
|
||||
ShapeDrawable oval = new ShapeDrawable(new OvalShape());
|
||||
return oval;
|
||||
}
|
||||
|
||||
|
||||
public class DemoTabView extends View {
|
||||
|
||||
private int mBackgroundColor;
|
||||
@@ -183,13 +191,8 @@ public class HoverMenuAdapter implements io.mattcarroll.hover.HoverMenuAdapter {
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
|
||||
// Make circle as large as View minus padding.
|
||||
mCircleDrawable.setBounds(getPaddingLeft(), getPaddingTop(), w - getPaddingRight(), h - getPaddingBottom());
|
||||
|
||||
// Re-size the icon as necessary.
|
||||
updateIconBounds();
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ public class ConsoleView extends FrameLayout implements StardustConsole.LogListe
|
||||
}
|
||||
if (mConsole.submitInput(input)) {
|
||||
mEditText.setText("");
|
||||
mEditText.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +92,17 @@ public class ConsoleView extends FrameLayout implements StardustConsole.LogListe
|
||||
mEditText = (EditText) findViewById(R.id.input);
|
||||
mEditText.setFocusableInTouchMode(true);
|
||||
mInputContainer = (LinearLayout) findViewById(R.id.input_container);
|
||||
OnClickListener listener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mWindow != null) {
|
||||
mWindow.requestWindowFocus();
|
||||
mEditText.requestFocus();
|
||||
}
|
||||
}
|
||||
};
|
||||
mEditText.setOnClickListener(listener);
|
||||
mInputContainer.setOnClickListener(listener);
|
||||
}
|
||||
|
||||
public void setConsole(StardustConsole console) {
|
||||
@@ -103,7 +113,6 @@ public class ConsoleView extends FrameLayout implements StardustConsole.LogListe
|
||||
@Override
|
||||
public void onNewLog(StardustConsole.Log log) {
|
||||
log(log.level, log.content);
|
||||
log(log.level, "\n");
|
||||
}
|
||||
|
||||
private void log(int level, CharSequence log) {
|
||||
@@ -114,6 +123,7 @@ public class ConsoleView extends FrameLayout implements StardustConsole.LogListe
|
||||
public void run() {
|
||||
mTextView.append(spannable);
|
||||
mContentContainer.fullScroll(View.FOCUS_DOWN);
|
||||
mEditText.requestFocus();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -50,6 +50,12 @@ public class JraskaConsole extends AbstractConsole {
|
||||
Console.writeLine(getLevelSpannable(level, charSequence));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int level, CharSequence data) {
|
||||
Console.write(getLevelSpannable(level, getTag(level)));
|
||||
Console.write(getLevelSpannable(level, data));
|
||||
}
|
||||
|
||||
private CharSequence getTag(int level) {
|
||||
return TextUtils.join("", DATE_FORMAT.format(new Date()), TAGS.get(level), ": ");
|
||||
}
|
||||
@@ -80,4 +86,6 @@ public class JraskaConsole extends AbstractConsole {
|
||||
public void setTitle(CharSequence title) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.stardust.enhancedfloaty.FloatyService;
|
||||
import com.stardust.enhancedfloaty.ResizableExpandableFloatyWindow;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.scriptdroid.autojs.api.VolatileBox;
|
||||
import com.stardust.scriptdroid.external.floating_window.FloatingWindowManger;
|
||||
import com.stardust.util.UiHandler;
|
||||
|
||||
@@ -79,7 +78,7 @@ public class StardustConsole extends AbstractConsole {
|
||||
|
||||
@Override
|
||||
public void println(int level, CharSequence charSequence) {
|
||||
Log log = new Log(level, charSequence);
|
||||
Log log = new Log(level, charSequence + "\n");
|
||||
mLogs.add(log);
|
||||
GLOBAL_CONSOLE.println(level, charSequence);
|
||||
if (mLogListener != null) {
|
||||
@@ -88,6 +87,17 @@ public class StardustConsole extends AbstractConsole {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void write(int level, CharSequence charSequence) {
|
||||
Log log = new Log(level, charSequence);
|
||||
mLogs.add(log);
|
||||
GLOBAL_CONSOLE.print(level, charSequence);
|
||||
if (mLogListener != null) {
|
||||
mLogListener.onNewLog(log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
mLogs.clear();
|
||||
|
||||
@@ -5,9 +5,11 @@ import android.content.ClipboardManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.util.SparseIntArray;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -27,16 +29,40 @@ import java.util.TimerTask;
|
||||
public class ErrorReportActivity extends BaseActivity {
|
||||
|
||||
private static final String TAG = "ErrorReportActivity";
|
||||
private static final SparseIntArray CRASH_COUNT = new SparseIntArray();
|
||||
private static final String KEY_CRASH_COUNT = "Eating... you are my halo...";
|
||||
|
||||
static {
|
||||
CRASH_COUNT.put(2, R.string.text_again);
|
||||
CRASH_COUNT.put(3, R.string.text_again_and_again);
|
||||
CRASH_COUNT.put(4, R.string.text_again_and_again_again);
|
||||
CRASH_COUNT.put(5, R.string.text_again_and_again_again_again);
|
||||
}
|
||||
|
||||
private String mTitle;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
try {
|
||||
super.onCreate(savedInstanceState);
|
||||
mTitle = getCrashCountText() + getString(R.string.text_crash);
|
||||
setUpUI();
|
||||
handleIntent();
|
||||
} catch (Throwable throwable) {
|
||||
Log.e(TAG, "", throwable);
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getCrashCountText() {
|
||||
int i = PreferenceManager.getDefaultSharedPreferences(this).getInt(KEY_CRASH_COUNT, 0);
|
||||
i++;
|
||||
PreferenceManager.getDefaultSharedPreferences(this).edit().putInt(KEY_CRASH_COUNT, i).apply();
|
||||
if (i < 2)
|
||||
return "";
|
||||
if (i > 5)
|
||||
i = 5;
|
||||
return getString(CRASH_COUNT.get(i));
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +75,7 @@ public class ErrorReportActivity extends BaseActivity {
|
||||
|
||||
private void showErrorMessageByDialog(String message, final String errorDetail) {
|
||||
new ThemeColorMaterialDialogBuilder(this)
|
||||
.title(R.string.text_crash)
|
||||
.title(mTitle)
|
||||
.content(R.string.crash_feedback)
|
||||
.positiveText(R.string.text_exit)
|
||||
.neutralText(R.string.text_copy_debug_info)
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.stardust.scriptdroid.ui.main;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.stardust.scriptdroid.R;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/23.
|
||||
*/
|
||||
|
||||
public abstract class AppbarWithTabFragment extends BottomNavigationFragment {
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_app_bar_tab, container, false);
|
||||
FrameLayout contentContainer = (FrameLayout) view.findViewById(R.id.content);
|
||||
contentContainer.addView(createContentView(inflater, contentContainer));
|
||||
return view;
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
protected abstract View createContentView(LayoutInflater inflater, @Nullable ViewGroup container);
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.stardust.scriptdroid.ui.main;
|
||||
|
||||
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
|
||||
import com.ashokvarma.bottomnavigation.BottomNavigationBar;
|
||||
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
|
||||
import com.stardust.app.Fragment;
|
||||
import com.stardust.theme.ThemeColor;
|
||||
import com.stardust.theme.ThemeColorManager;
|
||||
import com.stardust.theme.ThemeColorMutable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/23.
|
||||
*/
|
||||
|
||||
public abstract class BottomNavigationFragment extends Fragment {
|
||||
|
||||
public static class Builder implements BottomNavigationBar.OnTabSelectedListener, ThemeColorMutable {
|
||||
private int mFragmentId;
|
||||
private BottomNavigationBar mBottomNavigationBar;
|
||||
private FragmentManager mFragmentManager;
|
||||
private List<BottomNavigationFragment> mFragments = new ArrayList<>();
|
||||
|
||||
public Builder(int fragmentId, BottomNavigationBar bottomNavigationBar, FragmentManager fragmentManager) {
|
||||
mFragmentId = fragmentId;
|
||||
mBottomNavigationBar = bottomNavigationBar;
|
||||
mFragmentManager = fragmentManager;
|
||||
mBottomNavigationBar.setTabSelectedListener(this);
|
||||
ThemeColorManager.add(this);
|
||||
}
|
||||
|
||||
public Builder add(BottomNavigationFragment fragment) {
|
||||
mFragments.add(fragment);
|
||||
mBottomNavigationBar.addItem(new BottomNavigationItem(fragment.getIconResId(), fragment.getTitle()));
|
||||
return this;
|
||||
}
|
||||
|
||||
public void build() {
|
||||
mBottomNavigationBar.setFirstSelectedPosition(0);
|
||||
mBottomNavigationBar.initialise();
|
||||
mFragmentManager.beginTransaction().replace(mFragmentId, mFragments.get(0)).commit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onTabSelected(int position) {
|
||||
BottomNavigationFragment fragment = mFragments.get(position);
|
||||
mFragmentManager.beginTransaction().replace(mFragmentId, fragment).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThemeColor(ThemeColor themeColor) {
|
||||
mBottomNavigationBar.setActiveColor("#" + Integer.toHexString(themeColor.colorPrimary).substring(2));
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getTitle();
|
||||
|
||||
protected abstract int getIconResId();
|
||||
|
||||
|
||||
}
|
||||
@@ -27,8 +27,10 @@ import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.stardust.app.FragmentPagerAdapterBuilder;
|
||||
import com.stardust.app.NotAskAgainDialog;
|
||||
import com.stardust.app.OnActivityResultDelegate;
|
||||
import com.stardust.enhancedfloaty.FloatyService;
|
||||
import com.stardust.scriptdroid.BuildConfig;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.scriptdroid.external.floating_window.FloatingWindowManger;
|
||||
import com.stardust.scriptdroid.script.ScriptFile;
|
||||
import com.stardust.scriptdroid.script.StorageScriptProvider;
|
||||
@@ -80,6 +82,7 @@ public class MainActivity extends BaseActivity {
|
||||
private DrawableSaver mDrawerHeaderBackgroundSaver, mAppbarBackgroundSaver;
|
||||
private VersionGuard mVersionGuard;
|
||||
private Intent mIntentToHandle;
|
||||
private ViewPager mViewPager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -164,15 +167,14 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
private void setUpTabViewPager() {
|
||||
TabLayout tabLayout = $(R.id.tab);
|
||||
ViewPager viewPager = $(R.id.viewpager);
|
||||
mViewPager = $(R.id.viewpager);
|
||||
mPagerAdapter = new FragmentPagerAdapterBuilder(this)
|
||||
.add(new MyScriptListFragment(), R.string.text_my_script)
|
||||
.add(new SampleScriptListFragment(), R.string.text_sample_script)
|
||||
.add(new TaskManagerFragment(), R.string.text_task_manage)
|
||||
.build();
|
||||
viewPager.setAdapter(mPagerAdapter);
|
||||
viewPager.setOffscreenPageLimit(mPagerAdapter.getCount());
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
mViewPager.setAdapter(mPagerAdapter);
|
||||
tabLayout.setupWithViewPager(mViewPager);
|
||||
mPagerAdapter.setOnFragmentInstantiateListener(new FragmentPagerAdapterBuilder.OnFragmentInstantiateListener() {
|
||||
@Override
|
||||
public void OnInstantiate(Fragment fragment) {
|
||||
@@ -235,8 +237,11 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.exit)
|
||||
public void finish() {
|
||||
super.finish();
|
||||
public void exitCompletely() {
|
||||
FloatingWindowManger.hideHoverMenu();
|
||||
stopService(new Intent(this, FloatyService.class));
|
||||
AutoJs.getInstance().getScriptEngineService().stopAll();
|
||||
finish();
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.drawer_header_img)
|
||||
@@ -265,22 +270,38 @@ public class MainActivity extends BaseActivity {
|
||||
handleRecordedScript(intent.getStringExtra(ARGUMENT_SCRIPT));
|
||||
break;
|
||||
case ACTION_IMPORT_SCRIPT:
|
||||
getMyScriptListFragment().importFile(intent.getStringExtra(ARGUMENT_PATH));
|
||||
handleImportScriptFile(intent);
|
||||
break;
|
||||
case ACTION_IMPORT_SAMPLE:
|
||||
importSample((Sample) intent.getSerializableExtra(ARGUMENT_SAMPLE));
|
||||
handleImportSample(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void importSample(Sample sample) {
|
||||
try {
|
||||
getMyScriptListFragment().importFile(sample.name, getAssets().open(sample.path));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Snackbar.make(mDrawerLayout, R.string.text_import_fail, Snackbar.LENGTH_SHORT).show();
|
||||
private void handleImportScriptFile(Intent intent) {
|
||||
mViewPager.setCurrentItem(0, true);
|
||||
MyScriptListFragment fragment = getMyScriptListFragment();
|
||||
if (fragment == null) {
|
||||
mIntentToHandle = intent;
|
||||
} else {
|
||||
fragment.importFile(intent.getStringExtra(ARGUMENT_PATH));
|
||||
}
|
||||
}
|
||||
|
||||
private void handleImportSample(Intent intent) {
|
||||
mViewPager.setCurrentItem(0, true);
|
||||
MyScriptListFragment fragment = getMyScriptListFragment();
|
||||
if (fragment == null) {
|
||||
mIntentToHandle = intent;
|
||||
} else {
|
||||
Sample sample = (Sample) intent.getSerializableExtra(ARGUMENT_SAMPLE);
|
||||
try {
|
||||
getMyScriptListFragment().importFile(sample.name, getAssets().open(sample.path));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Snackbar.make(mDrawerLayout, R.string.text_import_fail, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRecordedScript(final String script) {
|
||||
|
||||
@@ -21,26 +21,25 @@ import com.stardust.scriptdroid.ui.main.MainActivity;
|
||||
|
||||
public class SampleScriptListFragment extends Fragment {
|
||||
|
||||
private SampleScriptListRecyclerView mSampleScriptListRecyclerView;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_sample_script_list, container, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mSampleScriptListRecyclerView = $(R.id.script_list);
|
||||
mSampleScriptListRecyclerView.setSamples(SampleFileManager.getInstance().getSamplesFromAssets(getContext().getAssets(), "sample"));
|
||||
mSampleScriptListRecyclerView.setOnItemLongClickListener(new SampleScriptListRecyclerView.OnItemLongClickListener() {
|
||||
SampleScriptListRecyclerView sampleScriptListRecyclerView = $(R.id.script_list);
|
||||
sampleScriptListRecyclerView.setSamples(SampleFileManager.getInstance().getSamplesFromAssets(getContext().getAssets(), "sample"));
|
||||
sampleScriptListRecyclerView.setOnItemLongClickListener(new SampleScriptListRecyclerView.OnItemLongClickListener() {
|
||||
@Override
|
||||
public void onItemLongClick(Sample sample) {
|
||||
showMenuDialog(sample);
|
||||
}
|
||||
});
|
||||
mSampleScriptListRecyclerView.setOnItemClickListener(new SampleScriptListRecyclerView.OnItemClickListener() {
|
||||
sampleScriptListRecyclerView.setOnItemClickListener(new SampleScriptListRecyclerView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(Sample sample) {
|
||||
viewSample(sample);
|
||||
|
||||
@@ -61,6 +61,7 @@ public class MyScriptListFragment extends Fragment {
|
||||
return inflater.inflate(R.layout.fragment_my_script_list, container, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
@@ -84,6 +84,8 @@ public class ScriptAndFolderListRecyclerView extends RecyclerView {
|
||||
return;
|
||||
}
|
||||
ScriptFile file = mAdapter.getScriptFileAt(position);
|
||||
if (file == null)
|
||||
return;
|
||||
if (file.isDirectory()) {
|
||||
setCurrentDirectory(file, true);
|
||||
} else if (mOnItemClickListener != null) {
|
||||
@@ -96,7 +98,10 @@ public class ScriptAndFolderListRecyclerView extends RecyclerView {
|
||||
public boolean onLongClick(View v) {
|
||||
if (mOnItemLongClickListener != null) {
|
||||
int position = getChildViewHolder(v).getAdapterPosition();
|
||||
mOnItemLongClickListener.onLongClick(mAdapter.getScriptFileAt(position), position);
|
||||
ScriptFile file = mAdapter.getScriptFileAt(position);
|
||||
if (file == null)
|
||||
return false;
|
||||
mOnItemLongClickListener.onLongClick(file, position);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -108,6 +113,8 @@ public class ScriptAndFolderListRecyclerView extends RecyclerView {
|
||||
public void onClick(View v) {
|
||||
int position = getChildViewHolder((View) v.getParent()).getAdapterPosition();
|
||||
ScriptFile file = mAdapter.getScriptFileAt(position);
|
||||
if (file == null)
|
||||
return;
|
||||
Scripts.run(file);
|
||||
}
|
||||
};
|
||||
@@ -337,8 +344,13 @@ public class ScriptAndFolderListRecyclerView extends RecyclerView {
|
||||
return getScriptFileAt(position).isDirectory() ? VIEW_TYPE_DIRECTORY : VIEW_TYPE_FILE;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ScriptFile getScriptFileAt(int position) {
|
||||
return mScriptFileList[mCanGoBack ? position - 1 : position];
|
||||
int actualPos = mCanGoBack ? position - 1 : position;
|
||||
if (actualPos >= mScriptFileList.length || actualPos < 0) {
|
||||
return null;
|
||||
}
|
||||
return mScriptFileList[actualPos];
|
||||
}
|
||||
|
||||
void setScripts(ScriptFile[] scriptFiles) {
|
||||
|
||||
@@ -6,12 +6,16 @@ import android.content.ClipboardManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.stardust.automator.UiObject;
|
||||
import com.stardust.scriptdroid.service.AccessibilityWatchDogService;
|
||||
import com.stardust.scriptdroid.tool.IntentTool;
|
||||
import com.stardust.scriptdroid.ui.BaseActivity;
|
||||
import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||
@@ -29,6 +33,7 @@ import moe.feng.alipay.zerosdk.AlipayZeroSdk;
|
||||
|
||||
public class AboutActivity extends BaseActivity {
|
||||
|
||||
private static final String TAG = "AboutActivity";
|
||||
private int mLolClickCount = 0;
|
||||
|
||||
@Override
|
||||
@@ -100,18 +105,54 @@ public class AboutActivity extends BaseActivity {
|
||||
mLolClickCount++;
|
||||
Toast.makeText(this, R.string.text_lll, Toast.LENGTH_LONG).show();
|
||||
if (mLolClickCount >= 5) {
|
||||
new ThemeColorMaterialDialogBuilder(this)
|
||||
.title("Crash Test")
|
||||
.positiveText("Crash")
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
throw new RuntimeException("Crash Test");
|
||||
}
|
||||
}).show();
|
||||
crashTest();
|
||||
}
|
||||
}
|
||||
|
||||
private void showEasterEgg() {
|
||||
new MaterialDialog.Builder(this)
|
||||
.customView(R.layout.paint_layout, false)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void uiObjectCreateTest() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
AccessibilityNodeInfo root = AccessibilityWatchDogService.getInstance().getRootInActiveWindow();
|
||||
if (root != null) {
|
||||
UiObject uiObject = UiObject.createRoot(root);
|
||||
UiObject child = uiObject.child(0);
|
||||
if (i % 1000 == 0) {
|
||||
Log.v(TAG, String.valueOf(i));
|
||||
Log.v(TAG, Runtime.getRuntime().totalMemory() + "/" + Runtime.getRuntime().maxMemory());
|
||||
if (child != null)
|
||||
Log.v(TAG, String.valueOf(child.getChildCount()));
|
||||
}
|
||||
if (child != null)
|
||||
child.recycle();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
private void crashTest() {
|
||||
new ThemeColorMaterialDialogBuilder(this)
|
||||
.title("Crash Test")
|
||||
.positiveText("Crash")
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
throw new RuntimeException("Crash Test");
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.developer)
|
||||
private void hhh() {
|
||||
Toast.makeText(this, R.string.text_it_is_the_developer_of_app, Toast.LENGTH_LONG).show();
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.stardust.scriptdroid.ui.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.stardust.theme.ThemeColorManagerCompat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/10.
|
||||
*/
|
||||
|
||||
public class PaintView extends View {
|
||||
|
||||
private List<Path> mPaths = new ArrayList<>();
|
||||
private Path mCurrentPath;
|
||||
private Paint mPaint;
|
||||
|
||||
public PaintView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public PaintView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public PaintView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public PaintView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mPaint = new Paint();
|
||||
mPaint.setColor(ThemeColorManagerCompat.getColorPrimary());
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setStrokeWidth(5);
|
||||
setWillNotDraw(false);
|
||||
setClickable(true);
|
||||
setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
for (Path path : mPaths) {
|
||||
canvas.drawPath(path, mPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
float x = event.getY();
|
||||
float y = event.getY();
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
onTouchDown(x, y);
|
||||
return true;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
onTouchMove(x, y);
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
onTouchUp(x, y);
|
||||
return true;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
private void onTouchDown(float x, float y) {
|
||||
if (mCurrentPath != null) {
|
||||
mCurrentPath.close();
|
||||
mPaths.add(mCurrentPath);
|
||||
invalidate();
|
||||
}
|
||||
mCurrentPath = new Path();
|
||||
mCurrentPath.moveTo(x, y);
|
||||
}
|
||||
|
||||
private void onTouchMove(float x, float y) {
|
||||
mCurrentPath.moveTo(x, y);
|
||||
}
|
||||
|
||||
private void onTouchUp(float x, float y) {
|
||||
mCurrentPath.close();
|
||||
mPaths.add(mCurrentPath);
|
||||
mCurrentPath = null;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.stardust.theme.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.support.v7.widget.AppCompatImageView;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.stardust.theme.ThemeColor;
|
||||
import com.stardust.theme.ThemeColorManager;
|
||||
import com.stardust.theme.ThemeColorMutable;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/10.
|
||||
*/
|
||||
|
||||
public class ThemeColorImageViewCompat extends AppCompatImageView implements ThemeColorMutable {
|
||||
private int mColor;
|
||||
|
||||
public ThemeColorImageViewCompat(Context context) {
|
||||
super(context);
|
||||
this.init();
|
||||
}
|
||||
|
||||
public ThemeColorImageViewCompat(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.init();
|
||||
}
|
||||
|
||||
public ThemeColorImageViewCompat(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
ThemeColorManager.add(this);
|
||||
}
|
||||
|
||||
public void setThemeColor(ThemeColor color) {
|
||||
if (this.mColor != color.colorPrimary) {
|
||||
this.mColor = color.colorPrimary;
|
||||
this.setColor(color.colorPrimary);
|
||||
}
|
||||
}
|
||||
|
||||
public void setImageResource(int resId) {
|
||||
super.setImageResource(resId);
|
||||
if (this.mColor != 0) {
|
||||
this.setColor(this.mColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setColor(int color) {
|
||||
getDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
}
|
||||
BIN
app/src/main/res/drawable/ic_add_file.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 806 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 989 B |
BIN
app/src/main/res/drawable/ic_ali_record.png
Normal file
|
After Width: | Height: | Size: 1014 B |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 952 B |
BIN
app/src/main/res/drawable/ic_ali_run.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
BIN
app/src/main/res/drawable/ic_android_eat_js_64.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable/ic_import.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 713 B |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 905 B |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable/ic_robot_64.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/drawable/ic_speech_bubble.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 120 KiB |
BIN
app/src/main/res/drawable/side_menu_bg.webp
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 12 KiB |
@@ -20,7 +20,7 @@
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_developer_512"/>
|
||||
android:src="@drawable/ic_developer"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -89,11 +89,11 @@
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_add_file_green"/>
|
||||
android:src="@drawable/ic_add_file"/>
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorTextView
|
||||
android:layout_width="match_parent"
|
||||
@@ -114,7 +114,7 @@
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:padding="10dp"
|
||||
@@ -140,11 +140,11 @@
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_folder_open_outline_green"/>
|
||||
android:src="@drawable/ic_import"/>
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorTextView
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:paddingLeft="3dp"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="14sp"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_ali_rename"/>
|
||||
@@ -43,7 +43,7 @@
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_ali_delete"/>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_ali_rename"/>
|
||||
@@ -43,7 +43,7 @@
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_ali_open"/>
|
||||
@@ -69,7 +69,7 @@
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_ali_shortcut"/>
|
||||
@@ -95,7 +95,7 @@
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_ali_delete"/>
|
||||
|
||||
@@ -63,8 +63,8 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:baselineAligned="false"
|
||||
android:layout_gravity="bottom">
|
||||
android:layout_gravity="bottom"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/setting"
|
||||
@@ -75,7 +75,7 @@
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:padding="6dp"
|
||||
@@ -98,7 +98,7 @@
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:padding="6dp"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
@@ -20,7 +20,7 @@
|
||||
android:textColor="@android:color/primary_text_light"/>
|
||||
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:id="@+id/expand_hint"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.stardust.scriptdroid.ui.main.MainActivity">
|
||||
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/app_bar_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="128.5dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/toolbar_bg"/>
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="24dp"
|
||||
android:theme="@style/AppTheme.AppBarOverlay"
|
||||
app:elevation="0dp">
|
||||
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:title="@string/_app_name"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/add"
|
||||
android:layout_width="?android:attr/actionBarSize"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:foreground="?selectableItemBackgroundBorderless"
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/ic_add_white_48dp"/>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<com.ashokvarma.bottomnavigation.BottomNavigationBar
|
||||
android:id="@+id/bottom_navigation_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.stardust.widget.SlidingUpPanel
|
||||
android:id="@+id/bottom_menu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:background="@android:color/white"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/create_new_file"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_add_file_green"/>
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_new_file"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/import_from_file"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_folder_open_outline_green"/>
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_import_from_file"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/record"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_video_record"/>
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_script_record"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/root_record"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_video_record"/>
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_root_script_record"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.stardust.widget.SlidingUpPanel>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="16dp"
|
||||
@@ -35,7 +35,7 @@
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="16dp"
|
||||
@@ -57,7 +57,7 @@
|
||||
android:background="?selectableItemBackground"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:id="@+id/icon_assist_service"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="16dp"
|
||||
@@ -35,11 +35,11 @@
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_js"/>
|
||||
android:src="@drawable/ic_speech_bubble"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
@@ -56,7 +56,7 @@
|
||||
android:background="?selectableItemBackground"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:id="@+id/icon_service"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
@@ -90,13 +90,13 @@
|
||||
android:background="?selectableItemBackground"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:id="@+id/icon_assist_service"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_robot_head_green"/>
|
||||
android:src="@drawable/ic_robot_64"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
@@ -124,7 +124,7 @@
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorImageView
|
||||
<com.stardust.theme.widget.ThemeColorImageViewCompat
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_margin="16dp"
|
||||
@@ -138,4 +138,4 @@
|
||||
android:textColor="@android:color/primary_text_light"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
17
app/src/main/res/layout/paint_layout.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="600dp"
|
||||
android:layout_height="600dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:padding="200dp"
|
||||
android:src="@drawable/ic_android_eat_js"/>
|
||||
|
||||
<com.stardust.scriptdroid.ui.settings.PaintView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -45,11 +45,11 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/_app_name"
|
||||
android:src="@drawable/ic_play"/>
|
||||
android:src="@drawable/ic_ali_run"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -174,6 +174,10 @@
|
||||
<string name="text_force_stop">强制停止</string>
|
||||
<string name="text_execution_finished" formatted="false">\n------------\n[%s]运行结束,用时%f秒</string>
|
||||
<string name="text_record_format_error">录制格式错误</string>
|
||||
<string name="text_again">又</string>
|
||||
<string name="text_again_and_again">又双</string>
|
||||
<string name="text_again_and_again_again">又双叒</string>
|
||||
<string name="text_again_and_again_again_again">又双叒叕</string>
|
||||
|
||||
<string-array name="record_control_keys">
|
||||
<item>无</item>
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.stardust.autojs;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.app.UiAutomation;
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.support.test.uiautomator.UiDevice;
|
||||
import android.view.InputEvent;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -11,9 +11,9 @@ module.exports = function(__runtime__, scope){
|
||||
return eval(console.rawInput.call(console, [].slice(arguments)) + "");
|
||||
}
|
||||
|
||||
scope.print = console.log.bind(console);
|
||||
scope.print = console.print.bind(console, android.util.Log.DEBUG);
|
||||
|
||||
scope.log = scope.print;
|
||||
scope.log = console.log.bind(console);
|
||||
|
||||
scope.err = console.error.bind(console);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
module.exports = function(__runtime__, scope){
|
||||
|
||||
scope.SetScreenMetrics = function(w, h){
|
||||
__runtime__.getRootShell().SetScreenMetrics(x, y);
|
||||
__runtime__.getRootShell().SetScreenMetrics(w, h);
|
||||
}
|
||||
|
||||
scope.Tap = function(x, y){
|
||||
|
||||
@@ -1,9 +1,103 @@
|
||||
|
||||
assert = console.assert.bind(console);
|
||||
|
||||
function test(){
|
||||
//testInput();
|
||||
///sleep(500);
|
||||
//testLongClick();
|
||||
//sleep(500);
|
||||
testScrollAndShow();
|
||||
}
|
||||
|
||||
Function.prototype.getName = function(){
|
||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]
|
||||
}
|
||||
|
||||
assert = function(){
|
||||
if(arguments.length == 1){
|
||||
if(!arguments[0]){
|
||||
throw new Error("Assertion fail");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(arguments[0] != arguments[1]){
|
||||
var msg = "Assertion fail: " + arguments[0] + " != " + arguments[1];
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function testInput(){
|
||||
log("testInput...");
|
||||
id("add").findOne().click();
|
||||
while(!click("新建文件"));
|
||||
for(var i = 0; i < 9; i++){
|
||||
input(i);
|
||||
}
|
||||
sleep(200);
|
||||
assert('请输入名称012345678', editable().findOne().text());
|
||||
sleep(400);
|
||||
back();
|
||||
sleep(200);
|
||||
back();
|
||||
sleep(200);
|
||||
back();
|
||||
}
|
||||
|
||||
function random(){
|
||||
return ("" + Math.random()).substring(2);
|
||||
}
|
||||
|
||||
function testLongClick(){
|
||||
log("testLongClick...");
|
||||
id("script_list_recycler_view").findOne().child(0).longClick();
|
||||
while(!click("重命名"));
|
||||
sleep(200);
|
||||
var r = random();
|
||||
editable().setText(r);
|
||||
sleep(200);
|
||||
while(!click("确定"));
|
||||
sleep(200);
|
||||
assert(text(r).exists());
|
||||
}
|
||||
|
||||
function newFile(name){
|
||||
name = name + random();
|
||||
id("add").findOne().click();
|
||||
sleep(400);
|
||||
while(!click("新建文件"));
|
||||
sleep(400);
|
||||
editable().setText(name);
|
||||
sleep(400);
|
||||
while(!click("确定"));
|
||||
sleep(500);
|
||||
back();
|
||||
sleep(200);
|
||||
back();
|
||||
return name;
|
||||
}
|
||||
|
||||
function testScrollAndShow(){
|
||||
var name1 = newFile("zzz");
|
||||
for(var i = 0; i < 10; i++){
|
||||
id("script_list_recycler_view").scrollForward();
|
||||
}
|
||||
assert(text(name1).findOne().visibleToUser());
|
||||
sleep(500);
|
||||
var name2 = newFile("000");
|
||||
sleep(200);
|
||||
for(var i = 0; i < 10; i++){
|
||||
id("script_list_recycler_view").scrollForward();
|
||||
}
|
||||
sleep(500);
|
||||
text(name2).findOne().show();
|
||||
assert(text(name2).findOne().visibleToUser());
|
||||
|
||||
}
|
||||
|
||||
function testApp(){
|
||||
print('正在测试模块:app');
|
||||
before();
|
||||
assert("com.tencent.mm" == app.getPackageName("微信"));
|
||||
assert("com.tencent.mobileqq" == app.getPackageName("QQ"));
|
||||
}
|
||||
|
||||
}
|
||||
module.exports = test;
|
||||
@@ -4,7 +4,6 @@ import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.stardust.autojs.runtime.ScriptStopException;
|
||||
import com.stardust.autojs.runtime.api.Console;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/1.
|
||||
@@ -24,6 +23,12 @@ public abstract class AbstractConsole implements Console {
|
||||
return String.format(data.toString(), options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(int level, Object data, Object... options) {
|
||||
write(level, format(data, options));
|
||||
}
|
||||
|
||||
protected abstract void write(int level, CharSequence data);
|
||||
|
||||
@Override
|
||||
public void verbose(@Nullable Object data, Object... options) {
|
||||
|
||||
@@ -16,6 +16,9 @@ public interface Console {
|
||||
@ScriptInterface
|
||||
void log(@Nullable Object data, Object... options);
|
||||
|
||||
@ScriptInterface
|
||||
void print(int level, Object data, Object... options);
|
||||
|
||||
@ScriptInterface
|
||||
void info(@Nullable Object data, Object... options);
|
||||
|
||||
|
||||
@@ -151,7 +151,6 @@ public class UiSelector extends UiGlobalSelector {
|
||||
} else {
|
||||
super.id(id);
|
||||
}
|
||||
Intent intent;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -160,6 +159,11 @@ public class UiSelector extends UiGlobalSelector {
|
||||
return untilFind().performAction(action, arguments);
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
UiObjectCollection collection = find();
|
||||
return collection != null && collection.size() > 0;
|
||||
}
|
||||
|
||||
@ScriptInterface
|
||||
public boolean click() {
|
||||
return performAction(ACTION_CLICK);
|
||||
|
||||
@@ -25,6 +25,7 @@ dependencies {
|
||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile project(path: ':common')
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.UiAutomation;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.Pools;
|
||||
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
@@ -129,8 +130,10 @@ public class UiObject extends AccessibilityNodeInfoCompat {
|
||||
return getViewIdResourceName();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public CharSequence text() {
|
||||
return getText();
|
||||
CharSequence t = getText();
|
||||
return t == null ? "" : t;
|
||||
}
|
||||
|
||||
public CharSequence desc() {
|
||||
@@ -305,6 +308,10 @@ public class UiObject extends AccessibilityNodeInfoCompat {
|
||||
return mAllocator.getParent(this);
|
||||
}
|
||||
|
||||
public boolean visibleToUser() {
|
||||
return isVisibleToUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccessibilityNodeInfoCompat> findAccessibilityNodeInfosByText(String text) {
|
||||
if (mAllocator == null)
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ActionFactory {
|
||||
@Override
|
||||
protected void performAction(UiObject node) {
|
||||
Bundle args = new Bundle();
|
||||
args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text);
|
||||
args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, node.text() + text);
|
||||
node.performAction(getAction(), args);
|
||||
}
|
||||
};
|
||||
|
||||
35
automator/src/main/java/com/stardust/uiautomator/Test.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.stardust.uiautomator;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.InstrumentationInfo;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/9.
|
||||
*/
|
||||
|
||||
public class Test {
|
||||
|
||||
|
||||
private void runTests(Context context) {
|
||||
final String packageName = context.getPackageName();
|
||||
final List<InstrumentationInfo> list =
|
||||
context.getPackageManager().queryInstrumentation(packageName, 0);
|
||||
if (list.isEmpty()) {
|
||||
Toast.makeText(context, "Cannot find instrumentation for " + packageName,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
final InstrumentationInfo instrumentationInfo = list.get(0);
|
||||
final ComponentName componentName =
|
||||
new ComponentName(instrumentationInfo.packageName,
|
||||
instrumentationInfo.name);
|
||||
if (!context.startInstrumentation(componentName, null, null)) {
|
||||
Toast.makeText(context, "Cannot run instrumentation for " + packageName,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||