replace view binding with aa, change script list to card view, enable minify
@ -20,7 +20,7 @@ android {
|
||||
buildTypes {
|
||||
debug {
|
||||
shrinkResources false
|
||||
minifyEnabled false
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
release {
|
||||
@ -93,6 +93,7 @@ dependencies {
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
|
||||
// Android supports
|
||||
compile 'com.android.support:appcompat-v7:25.3.0'
|
||||
compile 'com.android.support:cardview-v7:25.3.0'
|
||||
compile 'com.android.support:design:25.3.0'
|
||||
compile 'com.android.support:multidex:1.0.1'
|
||||
// Personal libraries
|
||||
|
||||
30
app/proguard-rules.pro
vendored
@ -24,6 +24,7 @@
|
||||
-dontwarn jackpal.androidterm.**
|
||||
-dontwarn com.iwebpp.nodeandroid.**
|
||||
-dontwarn org.msgpack.core.**
|
||||
-dontwarn com.pushtorefresh.storio.**
|
||||
|
||||
-keep class org.mozilla.javascript.** { *; }
|
||||
-keep class com.jecelyin.editor.** { *; }
|
||||
@ -32,19 +33,36 @@
|
||||
-keep class org.greenrobot.eventbus.** { *; }
|
||||
-keep class * extends c
|
||||
-keepattributes *Annotation*
|
||||
# Event bus
|
||||
-keepclassmembers class ** {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
# volley
|
||||
-keepclassmembers class ** {
|
||||
@com.google.common.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keepclassmembers class ** {
|
||||
@com.some.package.server.JsonDeserializerWithOptions$FieldRequired public *;
|
||||
}
|
||||
-keep @interface com.some.package.server.JsonDeserializerWithOptions$FieldRequired
|
||||
-keep class com.some.package.server.JsonDeserializerWithOptions
|
||||
# autojs
|
||||
-keepclassmembers class ** {
|
||||
@com.stardust.autojs.runtime.ScriptInterface <methods>;
|
||||
}
|
||||
# 920 editor
|
||||
-keep class org.msgpack.** { *; }
|
||||
|
||||
# gson
|
||||
-keep class * extends org.json.JSONObject {
|
||||
<fields>;
|
||||
}
|
||||
|
||||
# JNI
|
||||
-keepclasseswithmembernames class * {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
# common
|
||||
-keepclassmembers public class * extends android.view.View {
|
||||
void set*(***);
|
||||
*** get*();
|
||||
@ -88,13 +106,13 @@
|
||||
-keep class com.flurry.** { *; }
|
||||
-dontwarn com.flurry.**
|
||||
-keepattributes *Annotation*,EnclosingMethod,Signature
|
||||
-keepclasseswithmembers class * {
|
||||
public (android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
# Google Play Services library
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
# Google Play Services library
|
||||
-keep class * extends java.util.ListResourceBundle {
|
||||
protected Object[ ][ ] getContents();
|
||||
protected Object[][] getContents();
|
||||
}
|
||||
|
||||
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
|
||||
|
||||
@ -69,11 +69,12 @@
|
||||
<activity android:name=".ui.console.LogActivity_"/>
|
||||
<activity android:name=".ui.error.ErrorReportActivity"/>
|
||||
<activity android:name=".ui.help.LocalWebViewActivity"/>
|
||||
<activity android:name=".external.tasker.TaskerScriptEditActivity"/>
|
||||
<activity android:name=".external.tasker.TaskerScriptEditActivity_"/>
|
||||
<activity android:name=".ui.edit.ViewSampleActivity"/>
|
||||
<activity
|
||||
android:name="com.stardust.autojs.runtime.api.image.ScreenCaptureRequestActivity"
|
||||
android:taskAffinity="com.stardust.scriptdroid.autojs.api.ScreenCaptureRequestActivity"/>
|
||||
android:taskAffinity="com.stardust.autojs.runtime.api.image.ScreenCaptureRequestActivity"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
|
||||
|
||||
<activity
|
||||
android:name=".ui.error.IssueReporterActivity"
|
||||
@ -83,14 +84,14 @@
|
||||
<service android:name="com.stardust.scriptdroid.external.ScriptExecutionIntentService"/>
|
||||
<service android:name="com.stardust.scriptdroid.external.floatingwindow.menu.HoverMenuService"/>
|
||||
|
||||
<activity android:name=".external.tasker.TaskPrefEditActivity"/>
|
||||
<activity android:name=".external.tasker.TaskPrefEditActivity_"/>
|
||||
|
||||
<activity-alias
|
||||
android:name="com.stardust.scriptdroid.external.tasker.PluginActivity"
|
||||
android:exported="true"
|
||||
android:icon="@drawable/ic_android_eat_js"
|
||||
android:label="@string/_app_name"
|
||||
android:targetActivity="com.stardust.scriptdroid.external.tasker.TaskPrefEditActivity"
|
||||
android:targetActivity="com.stardust.scriptdroid.external.tasker.TaskPrefEditActivity_"
|
||||
tools:ignore="ExportedActivity">
|
||||
<intent-filter>
|
||||
<action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING"/>
|
||||
|
||||
@ -18,7 +18,6 @@ import io.mattcarroll.hover.HoverMenuAdapter;
|
||||
import io.mattcarroll.hover.Navigator;
|
||||
import io.mattcarroll.hover.defaulthovermenu.HoverMenuView;
|
||||
import io.mattcarroll.hover.defaulthovermenu.window.InWindowDragger;
|
||||
import io.mattcarroll.hover.defaulthovermenu.window.WindowViewController;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/11.
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
package com.stardust.hover;
|
||||
|
||||
import android.graphics.PixelFormat;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/7/2.
|
||||
*/
|
||||
|
||||
public class WindowViewController extends io.mattcarroll.hover.defaulthovermenu.window.WindowViewController {
|
||||
|
||||
private WindowManager mWindowManager;
|
||||
|
||||
public WindowViewController(@NonNull WindowManager windowManager) {
|
||||
super(windowManager);
|
||||
mWindowManager = windowManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addView(int width, int height, boolean isTouchable, @NonNull View view) {
|
||||
int touchableFlag = isTouchable ? 0 : WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
|
||||
|
||||
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
|
||||
width,
|
||||
height,
|
||||
WindowManager.LayoutParams.TYPE_PHONE,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | touchableFlag,
|
||||
PixelFormat.TRANSLUCENT
|
||||
);
|
||||
params.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
params.x = 0;
|
||||
params.y = 0;
|
||||
|
||||
mWindowManager.addView(view, params);
|
||||
}
|
||||
}
|
||||
@ -16,11 +16,12 @@ import com.stardust.scriptdroid.external.floatingwindow.menu.layout_inspector.La
|
||||
import com.stardust.scriptdroid.ui.main.MainActivity_;
|
||||
import com.stardust.util.ClipboardUtil;
|
||||
import com.stardust.util.MessageEvent;
|
||||
import com.stardust.view.ViewBinder;
|
||||
import com.stardust.view.ViewBinding;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import io.mattcarroll.hover.Navigator;
|
||||
import io.mattcarroll.hover.NavigatorContent;
|
||||
|
||||
@ -30,24 +31,23 @@ import io.mattcarroll.hover.NavigatorContent;
|
||||
|
||||
public class MainMenuNavigatorContent implements NavigatorContent {
|
||||
|
||||
|
||||
private View mView;
|
||||
@ViewBinding.Id(R.id.current_package)
|
||||
private TextView mCurrentPackageTextView;
|
||||
@ViewBinding.Id(R.id.current_activity)
|
||||
private TextView mCurrentActivityTextView;
|
||||
@BindView(R.id.current_package)
|
||||
TextView mCurrentPackageTextView;
|
||||
@BindView(R.id.current_activity)
|
||||
TextView mCurrentActivityTextView;
|
||||
private String mCurrentPackage, mCurrentActivity;
|
||||
private Context mContext;
|
||||
|
||||
public MainMenuNavigatorContent(Context context) {
|
||||
mContext = context;
|
||||
mView = View.inflate(context, R.layout.floating_window_main_menu, null);
|
||||
ViewBinder.bind(this);
|
||||
ButterKnife.bind(this, mView);
|
||||
HoverMenuService.getEventBus().register(this);
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.layout_hierarchy)
|
||||
private void showLayoutHierarchy() {
|
||||
@OnClick(R.id.layout_hierarchy)
|
||||
void showLayoutHierarchy() {
|
||||
if (!ensureCapture()) {
|
||||
return;
|
||||
}
|
||||
@ -67,21 +67,21 @@ public class MainMenuNavigatorContent implements NavigatorContent {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.layout_bounds)
|
||||
private void showLayoutBounds() {
|
||||
@OnClick(R.id.layout_bounds)
|
||||
void showLayoutBounds() {
|
||||
if (!ensureCapture()) {
|
||||
return;
|
||||
}
|
||||
HoverMenuService.postIntent(new Intent(HoverMenuService.ACTION_SHOW_LAYOUT_BOUNDS));
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.stop_all_running_scripts)
|
||||
private void stopAllRunningScripts() {
|
||||
@OnClick(R.id.stop_all_running_scripts)
|
||||
void stopAllRunningScripts() {
|
||||
AutoJs.getInstance().getScriptEngineService().stopAllAndToast();
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.open_launcher)
|
||||
private void openMainActivity() {
|
||||
@OnClick(R.id.open_launcher)
|
||||
void openMainActivity() {
|
||||
App.getApp().startActivity(new Intent(App.getApp(), MainActivity_.class)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
HoverMenuService.postIntent(new Intent(HoverMenuService.ACTION_COLLAPSE_MENU));
|
||||
@ -105,14 +105,14 @@ public class MainMenuNavigatorContent implements NavigatorContent {
|
||||
mCurrentPackageTextView.setText(mContext.getString(R.string.text_current_package) + mCurrentPackage);
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.current_activity)
|
||||
private void copyCurrentActivity() {
|
||||
@OnClick(R.id.current_activity)
|
||||
void copyCurrentActivity() {
|
||||
ClipboardUtil.setClip(mContext, mCurrentActivity);
|
||||
Toast.makeText(mContext, R.string.text_copied, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.current_package)
|
||||
private void copyCurrentPackage() {
|
||||
@OnClick(R.id.current_package)
|
||||
void copyCurrentPackage() {
|
||||
ClipboardUtil.setClip(mContext, mCurrentPackage);
|
||||
Toast.makeText(mContext, R.string.text_copied, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@ -131,8 +131,4 @@ public class MainMenuNavigatorContent implements NavigatorContent {
|
||||
}
|
||||
}
|
||||
|
||||
public View findViewById(int id) {
|
||||
return mView.findViewById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,11 +22,12 @@ import com.stardust.scriptdroid.external.floatingwindow.menu.record.inputevent.K
|
||||
import com.stardust.scriptdroid.external.floatingwindow.menu.record.inputevent.TouchRecorder;
|
||||
import com.stardust.scriptdroid.ui.main.MainActivity;
|
||||
import com.stardust.util.MessageEvent;
|
||||
import com.stardust.view.ViewBinder;
|
||||
import com.stardust.view.ViewBinding;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import io.mattcarroll.hover.Navigator;
|
||||
import io.mattcarroll.hover.NavigatorContent;
|
||||
|
||||
@ -38,21 +39,21 @@ import io.mattcarroll.hover.NavigatorContent;
|
||||
public class RecordNavigatorContent implements NavigatorContent, Recorder.OnStateChangedListener, KeyObserver.KeyListener {
|
||||
|
||||
private View mView;
|
||||
@ViewBinding.Id(R.id.sw_recorded_by_root)
|
||||
private SwitchCompat mRecordedByRootSwitch;
|
||||
@BindView(R.id.sw_recorded_by_root)
|
||||
SwitchCompat mRecordedByRootSwitch;
|
||||
|
||||
@ViewBinding.Id(R.id.sw_record_toast)
|
||||
private SwitchCompat mRecordToastSwitch;
|
||||
@BindView(R.id.sw_record_toast)
|
||||
SwitchCompat mRecordToastSwitch;
|
||||
|
||||
@ViewBinding.Id(R.id.img_start_or_pause)
|
||||
private ImageView mStartOrPauseRecordIcon;
|
||||
@BindView(R.id.img_start_or_pause)
|
||||
ImageView mStartOrPauseRecordIcon;
|
||||
|
||||
@ViewBinding.Id(R.id.text_start_or_pause)
|
||||
private TextView mStartOrPauseRecordText;
|
||||
@BindView(R.id.text_start_or_pause)
|
||||
TextView mStartOrPauseRecordText;
|
||||
|
||||
|
||||
@ViewBinding.Id(R.id.stop_record)
|
||||
private View mStopRecord;
|
||||
@BindView(R.id.stop_record)
|
||||
View mStopRecord;
|
||||
|
||||
private Recorder mRecorder;
|
||||
private Context mContext;
|
||||
@ -75,7 +76,7 @@ public class RecordNavigatorContent implements NavigatorContent, Recorder.OnStat
|
||||
public RecordNavigatorContent(Context context) {
|
||||
mContext = context;
|
||||
mView = View.inflate(context, R.layout.floating_window_record, null);
|
||||
ViewBinder.bind(this);
|
||||
ButterKnife.bind(this, mView);
|
||||
HoverMenuService.getEventBus().register(this);
|
||||
App.getApp().getVolumeChangeObserver().addOnVolumeChangeListener(mOnVolumeChangeListener);
|
||||
if (Pref.hasRecordTrigger()) {
|
||||
@ -101,18 +102,18 @@ public class RecordNavigatorContent implements NavigatorContent, Recorder.OnStat
|
||||
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.sw_root_container)
|
||||
private void toggleRecordedByRootSwitch() {
|
||||
@OnClick(R.id.sw_root_container)
|
||||
void toggleRecordedByRootSwitch() {
|
||||
mRecordedByRootSwitch.toggle();
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.sw_record_toast_container)
|
||||
private void toggleRecordToastSwitch() {
|
||||
@OnClick(R.id.sw_record_toast_container)
|
||||
void toggleRecordToastSwitch() {
|
||||
mRecordToastSwitch.toggle();
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.start_or_pause)
|
||||
private void startOrPauseRecord() {
|
||||
@OnClick(R.id.start_or_pause)
|
||||
void startOrPauseRecord() {
|
||||
if (mRecorder == null) {
|
||||
startRecord();
|
||||
} else if (mRecorder.getState() == Recorder.STATE_PAUSED) {
|
||||
@ -150,18 +151,14 @@ public class RecordNavigatorContent implements NavigatorContent, Recorder.OnStat
|
||||
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.stop_record)
|
||||
private void stopRecord() {
|
||||
@OnClick(R.id.stop_record)
|
||||
void stopRecord() {
|
||||
mRecorder.stop();
|
||||
setState(Recorder.STATE_STOPPED);
|
||||
HoverMenuService.postIntent(new Intent(HoverMenuService.ACTION_COLLAPSE_MENU));
|
||||
}
|
||||
|
||||
|
||||
public View findViewById(int id) {
|
||||
return mView.findViewById(id);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMessageEvent(MessageEvent event) {
|
||||
if (event.message.equals(HoverMenuService.ACTION_MENU_EXPANDING)) {
|
||||
|
||||
@ -7,6 +7,7 @@ import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.workground.WrapContentLinearLayoutManager;
|
||||
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.external.floatingwindow.menu.HoverMenuService;
|
||||
@ -47,6 +48,7 @@ public class ScriptListNavigatorContent implements NavigatorContent {
|
||||
mScriptListWithProgressBarView = new ScriptListWithProgressBarView(new ContextThemeWrapper(context, R.style.AppTheme));
|
||||
mFloatingScriptFileListView = mScriptListWithProgressBarView.getScriptAndFolderListRecyclerView();
|
||||
mFloatingScriptFileListView.setViewHolderSupplier(mViewHolderSupplier);
|
||||
mFloatingScriptFileListView.setLayoutManager(new WrapContentLinearLayoutManager(context));
|
||||
mFloatingScriptFileListView.setStorageScriptProvider(StorageScriptProvider.getDefault());
|
||||
mFloatingScriptFileListView.setOnItemClickListener(new ScriptAndFolderListRecyclerView.OnScriptFileClickListener() {
|
||||
|
||||
|
||||
@ -15,29 +15,29 @@ import com.stardust.scriptdroid.script.StorageScriptProvider;
|
||||
import com.stardust.scriptdroid.ui.BaseActivity;
|
||||
import com.stardust.scriptdroid.ui.main.script_list.ScriptAndFolderListRecyclerView;
|
||||
import com.stardust.scriptdroid.ui.main.script_list.ScriptListWithProgressBarView;
|
||||
import com.stardust.view.ViewBinder;
|
||||
import com.stardust.view.ViewBinding;
|
||||
import com.twofortyfouram.locale.sdk.client.ui.activity.AbstractAppCompatPluginActivity;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.Click;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/27.
|
||||
*/
|
||||
|
||||
@EActivity(R.layout.activity_tasker_edit)
|
||||
public class TaskPrefEditActivity extends AbstractAppCompatPluginActivity {
|
||||
|
||||
private String mSelectedScriptFilePath;
|
||||
private String mPreExecuteScript;
|
||||
private StorageScriptProvider mStorageScriptProvider;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_tasker_edit);
|
||||
@AfterViews
|
||||
void setUpViews() {
|
||||
BaseActivity.setToolbarAsBack(this, R.id.toolbar, getString(R.string.text_please_choose_a_script));
|
||||
initScriptListRecyclerView();
|
||||
ViewBinder.bind(this);
|
||||
}
|
||||
|
||||
|
||||
private void initScriptListRecyclerView() {
|
||||
mStorageScriptProvider = StorageScriptProvider.getExternalStorageProvider();
|
||||
ScriptListWithProgressBarView scriptList = (ScriptListWithProgressBarView) findViewById(R.id.script_list);
|
||||
@ -54,8 +54,8 @@ public class TaskPrefEditActivity extends AbstractAppCompatPluginActivity {
|
||||
}
|
||||
|
||||
|
||||
@ViewBinding.Click(R.id.edit_script)
|
||||
private void editPreExecuteScript() {
|
||||
@Click(R.id.edit_script)
|
||||
void editPreExecuteScript() {
|
||||
TaskerScriptEditActivity.edit(this, getString(R.string.text_pre_execute_script), getString(R.string.summary_pre_execute_script), mPreExecuteScript == null ? "" : mPreExecuteScript);
|
||||
}
|
||||
|
||||
|
||||
@ -18,21 +18,24 @@ import com.stardust.scriptdroid.ui.edit.editor920.Editor920Activity;
|
||||
import com.stardust.scriptdroid.ui.edit.editor920.Editor920Utils;
|
||||
import com.stardust.theme.ThemeColorManager;
|
||||
import com.stardust.theme.ThemeColorManagerCompat;
|
||||
import com.stardust.view.ViewBinder;
|
||||
import com.stardust.view.ViewBinding;
|
||||
import com.stardust.widget.ToolbarMenuItem;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.Click;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/4/5.
|
||||
*/
|
||||
|
||||
@EActivity(R.layout.activity_tasker_script_edit)
|
||||
public class TaskerScriptEditActivity extends Editor920Activity {
|
||||
|
||||
public static final int REQUEST_CODE = "Love you. Can we go back?".hashCode() >> 16;
|
||||
public static final String EXTRA_CONTENT = "Still Love Eating 17.4.5";
|
||||
|
||||
public static void edit(Activity activity, String title, String summary, String content) {
|
||||
activity.startActivityForResult(new Intent(activity, TaskerScriptEditActivity.class)
|
||||
activity.startActivityForResult(new Intent(activity, TaskerScriptEditActivity_.class)
|
||||
.putExtra(EXTRA_CONTENT, content)
|
||||
.putExtra("summary", summary)
|
||||
.putExtra("title", title), REQUEST_CODE);
|
||||
@ -40,25 +43,24 @@ public class TaskerScriptEditActivity extends Editor920Activity {
|
||||
|
||||
private EditorDelegate mEditorDelegate;
|
||||
private String mTitle, mSummary;
|
||||
private ToolbarMenuItem mRedo, mUndo;
|
||||
@ViewById(R.id.redo)
|
||||
ToolbarMenuItem mRedo;
|
||||
@ViewById(R.id.undo)
|
||||
ToolbarMenuItem mUndo;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setTheme(R.style.EditorTheme);
|
||||
handleIntent(getIntent());
|
||||
setUpUI();
|
||||
BaseActivity.setToolbarAsBack(this, R.id.toolbar, mTitle);
|
||||
setUpEditor();
|
||||
ViewBinder.bind(this);
|
||||
}
|
||||
|
||||
private void setUpUI() {
|
||||
setTheme(R.style.EditorTheme);
|
||||
setContentView(R.layout.activity_tasker_script_edit);
|
||||
@AfterViews
|
||||
void setUpViews() {
|
||||
((TextView) findViewById(R.id.summary)).setText(mSummary);
|
||||
mRedo = (ToolbarMenuItem) findViewById(R.id.redo);
|
||||
mUndo = (ToolbarMenuItem) findViewById(R.id.undo);
|
||||
ThemeColorManager.addActivityStatusBar(this);
|
||||
BaseActivity.setToolbarAsBack(this, R.id.toolbar, mTitle);
|
||||
setUpEditor();
|
||||
}
|
||||
|
||||
private void handleIntent(Intent intent) {
|
||||
@ -81,14 +83,14 @@ public class TaskerScriptEditActivity extends Editor920Activity {
|
||||
inputMethodEnhanceBar.setEditTextBridge(new EditActivity.InputMethodEnhanceBarBridge(this, editorView.getEditText()));
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.undo)
|
||||
private void undo() {
|
||||
@Click(R.id.undo)
|
||||
void undo() {
|
||||
Command command = new Command(Command.CommandEnum.UNDO);
|
||||
mEditorDelegate.doCommand(command);
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.redo)
|
||||
private void redo() {
|
||||
@Click(R.id.redo)
|
||||
void redo() {
|
||||
Command command = new Command(Command.CommandEnum.REDO);
|
||||
mEditorDelegate.doCommand(command);
|
||||
}
|
||||
|
||||
@ -15,6 +15,8 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.stardust.scriptdroid.BuildConfig;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
|
||||
@ -95,7 +97,7 @@ public class UpdateChecker implements Response.Listener<String>, Response.ErrorL
|
||||
mRequestQueue.cancelAll("update-check");
|
||||
}
|
||||
|
||||
public static class UpdateInfo {
|
||||
public static class UpdateInfo extends JSONObject {
|
||||
|
||||
public int versionCode;
|
||||
public String releaseNotes;
|
||||
@ -133,7 +135,7 @@ public class UpdateChecker implements Response.Listener<String>, Response.ErrorL
|
||||
}
|
||||
}
|
||||
|
||||
public static class OldVersion {
|
||||
public static class OldVersion extends JSONObject {
|
||||
|
||||
public int versionCode;
|
||||
public String issues;
|
||||
@ -147,7 +149,7 @@ public class UpdateChecker implements Response.Listener<String>, Response.ErrorL
|
||||
}
|
||||
}
|
||||
|
||||
public static class Download {
|
||||
public static class Download extends JSONObject {
|
||||
|
||||
public String name;
|
||||
public String url;
|
||||
|
||||
@ -30,11 +30,15 @@ import com.stardust.scriptdroid.ui.main.MainActivity;
|
||||
import com.stardust.theme.ThemeColorManager;
|
||||
import com.stardust.util.AssetsCache;
|
||||
import com.stardust.util.SparseArrayEntries;
|
||||
import com.stardust.view.ViewBinder;
|
||||
import com.stardust.view.ViewBinding;
|
||||
import com.stardust.widget.ToolbarMenuItem;
|
||||
|
||||
|
||||
import org.androidannotations.annotations.Click;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import static com.stardust.scriptdroid.script.Scripts.ACTION_ON_EXECUTION_FINISHED;
|
||||
import static com.stardust.scriptdroid.script.Scripts.EXTRA_EXCEPTION_MESSAGE;
|
||||
|
||||
@ -42,7 +46,6 @@ import static com.stardust.scriptdroid.script.Scripts.EXTRA_EXCEPTION_MESSAGE;
|
||||
/**
|
||||
* Created by Stardust on 2017/4/29.
|
||||
*/
|
||||
|
||||
public class ViewSampleActivity extends Editor920Activity implements OnActivityResultDelegate.DelegateHost {
|
||||
|
||||
|
||||
@ -93,7 +96,7 @@ public class ViewSampleActivity extends Editor920Activity implements OnActivityR
|
||||
ThemeColorManager.addActivityStatusBar(this);
|
||||
setUpToolbar();
|
||||
initMenuItem();
|
||||
ViewBinder.bind(this);
|
||||
ButterKnife.bind(this);
|
||||
}
|
||||
|
||||
private void setUpEditor() {
|
||||
@ -108,8 +111,8 @@ public class ViewSampleActivity extends Editor920Activity implements OnActivityR
|
||||
BaseActivity.setToolbarAsBack(this, R.id.toolbar, mSample.name);
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.run)
|
||||
private void run() {
|
||||
@OnClick(R.id.run)
|
||||
void run() {
|
||||
Snackbar.make(mView, R.string.text_start_running, Snackbar.LENGTH_SHORT).show();
|
||||
setMenuStatus(R.id.run, MenuDef.STATUS_DISABLED);
|
||||
mScriptExecution = Scripts.runWithBroadcastSender(new StringScriptSource(mSample.name, mEditorDelegate.getText()));
|
||||
|
||||
@ -1,128 +0,0 @@
|
||||
package com.stardust.scriptdroid.ui.edit.sidemenu;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.stardust.app.Fragment;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.external.floatingwindow.FloatingWindowManger;
|
||||
import com.stardust.scriptdroid.external.floatingwindow.menu.HoverMenuService;
|
||||
import com.stardust.scriptdroid.ui.console.LogActivity_;
|
||||
import com.stardust.scriptdroid.ui.help.HelpCatalogueActivity;
|
||||
import com.stardust.view.ViewBinder;
|
||||
import com.stardust.view.ViewBinding;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/2/4.
|
||||
*/
|
||||
|
||||
public class EditSideMenuFragment extends Fragment {
|
||||
|
||||
|
||||
private FunctionListRecyclerView.OnFunctionClickListener mOnFunctionClickListener;
|
||||
|
||||
public static EditSideMenuFragment setFragment(AppCompatActivity activity, int viewId) {
|
||||
EditSideMenuFragment fragment = new EditSideMenuFragment();
|
||||
activity.getSupportFragmentManager().beginTransaction().replace(viewId, fragment).commit();
|
||||
return fragment;
|
||||
}
|
||||
|
||||
private SwitchCompat mFloatingWindowSwitch;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_edit_side_menu, container, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setUpUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
syncSwitchState();
|
||||
}
|
||||
|
||||
private void setUpUI() {
|
||||
setUpSwitchCompat();
|
||||
setUpFunctionList();
|
||||
ViewBinder.bind(this);
|
||||
}
|
||||
|
||||
|
||||
private void setUpFunctionList() {
|
||||
FunctionListRecyclerView functionListRecyclerView = $(R.id.function_list);
|
||||
functionListRecyclerView.setOnFunctionClickListener(mOnFunctionClickListener);
|
||||
|
||||
}
|
||||
|
||||
private void syncSwitchState() {
|
||||
mFloatingWindowSwitch.setChecked(FloatingWindowManger.isHoverMenuShowing());
|
||||
}
|
||||
|
||||
private void setUpSwitchCompat() {
|
||||
mFloatingWindowSwitch = $(R.id.sw_floating_window);
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.syntax_and_api)
|
||||
private void startSyntaxHelpActivity() {
|
||||
HelpCatalogueActivity.showMainCatalogue(getActivity());
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.console)
|
||||
private void startConsoleActivity() {
|
||||
startActivity(new Intent(getContext(), LogActivity_.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
|
||||
@ViewBinding.Check(R.id.sw_floating_window)
|
||||
private void setFloatingWindowEnable(boolean enable) {
|
||||
if (enable && !FloatingWindowManger.isHoverMenuShowing()) {
|
||||
FloatingWindowManger.showHoverMenu();
|
||||
} else if (!enable && FloatingWindowManger.isHoverMenuShowing()) {
|
||||
FloatingWindowManger.hideHoverMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.floating_window)
|
||||
private void toggleAssistServiceSwitch() {
|
||||
mFloatingWindowSwitch.toggle();
|
||||
}
|
||||
|
||||
public EditSideMenuFragment setOnFunctionClickListener(FunctionListRecyclerView.OnFunctionClickListener onFunctionClickListener) {
|
||||
mOnFunctionClickListener = onFunctionClickListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onHoverMenuServiceStateChanged(HoverMenuService.ServiceStateChangedEvent event) {
|
||||
mFloatingWindowSwitch.setChecked(event.state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
}
|
||||
@ -1,150 +0,0 @@
|
||||
package com.stardust.scriptdroid.ui.edit.sidemenu;
|
||||
|
||||
import android.workground.WrapContentLinearLayoutManager;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.stardust.pio.PFile;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.widget.ExpandableRecyclerView;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/2/4.
|
||||
*/
|
||||
|
||||
public class FunctionListRecyclerView extends ExpandableRecyclerView {
|
||||
|
||||
public interface OnFunctionClickListener {
|
||||
void onClick(Function function, int position);
|
||||
}
|
||||
|
||||
public static class Function {
|
||||
public String name;
|
||||
String description;
|
||||
|
||||
public Function(String name, String description) {
|
||||
this.description = description;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static final List<Function> FUNCTION_LIST = new ArrayList<>();
|
||||
|
||||
static {
|
||||
initFunctionList();
|
||||
}
|
||||
|
||||
private List<Function> mFunctionList;
|
||||
private OnFunctionClickListener mOnFunctionClickListener;
|
||||
|
||||
public FunctionListRecyclerView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public FunctionListRecyclerView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public FunctionListRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setLayoutManager(new WrapContentLinearLayoutManager(getContext()));
|
||||
setAdapter(new Adapter());
|
||||
setFunctionList(FUNCTION_LIST);
|
||||
setOnChildClickListener(new OnChildClickListener() {
|
||||
@Override
|
||||
public void onClick(View view, int position) {
|
||||
if (mOnFunctionClickListener != null) {
|
||||
mOnFunctionClickListener.onClick(mFunctionList.get(position), position);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setFunctionList(List<Function> functionList) {
|
||||
mFunctionList = functionList;
|
||||
}
|
||||
|
||||
public void setOnFunctionClickListener(OnFunctionClickListener onFunctionClickListener) {
|
||||
mOnFunctionClickListener = onFunctionClickListener;
|
||||
}
|
||||
|
||||
|
||||
private class Adapter extends ExpandableRecyclerView.DefaultTitleAdapter {
|
||||
|
||||
Adapter() {
|
||||
setIcon(R.drawable.ic_function_mathematical_green);
|
||||
setTitle(R.string.text_common_function);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RecyclerView.ViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) {
|
||||
return new ChildViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.function_list_recycler_view_item, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindChildViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
ChildViewHolder viewHolder = (ChildViewHolder) holder;
|
||||
Function function = mFunctionList.get(position);
|
||||
viewHolder.mFunctionName.setText(function.name);
|
||||
viewHolder.mDescription.setText(function.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getChildItemCount() {
|
||||
return mFunctionList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getChildItemViewType(int position) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public class ChildViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView mFunctionName, mDescription;
|
||||
|
||||
public ChildViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mFunctionName = (TextView) itemView.findViewById(R.id.function_name);
|
||||
mDescription = (TextView) itemView.findViewById(R.id.description);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void initFunctionList() {
|
||||
String[] functions = PFile.read(App.getApp().getResources().openRawResource(R.raw.edit_side_menu_functions)).split("\n");
|
||||
for (String f : functions) {
|
||||
String[] str = f.split(" ");
|
||||
FUNCTION_LIST.add(new Function(str[0], str[1]));
|
||||
}
|
||||
final Comparator cmp = Collator.getInstance();
|
||||
Collections.sort(FUNCTION_LIST, new Comparator<Function>() {
|
||||
@Override
|
||||
public int compare(Function f1, Function f2) {
|
||||
return cmp.compare(f1.description, f2.description);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package com.stardust.scriptdroid.ui.edit.sidemenu;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.stardust.app.Fragment;
|
||||
import com.stardust.scriptdroid.R;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/4/18.
|
||||
*/
|
||||
|
||||
public class HelpSideMenuFragment extends Fragment {
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_help_side_menu, container, false);
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.stardust.scriptdroid.ui.help;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Keep;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
@ -53,7 +54,9 @@ public class HelpCatalogueActivity extends BaseActivity {
|
||||
|
||||
String title;
|
||||
String summary;
|
||||
@Keep
|
||||
private String type;
|
||||
@Keep
|
||||
private String path;
|
||||
|
||||
Item(String title, String summary) {
|
||||
|
||||
@ -38,6 +38,7 @@ import com.stardust.scriptdroid.external.floatingwindow.FloatingWindowManger;
|
||||
import com.stardust.scriptdroid.script.ScriptFile;
|
||||
import com.stardust.scriptdroid.script.StorageScriptProvider;
|
||||
import com.stardust.scriptdroid.script.sample.Sample;
|
||||
import com.stardust.scriptdroid.ui.main.task.TaskManagerFragment_;
|
||||
import com.stardust.view.accessibility.AccessibilityService;
|
||||
import com.stardust.scriptdroid.tool.AccessibilityServiceTool;
|
||||
import com.stardust.scriptdroid.tool.DrawableSaver;
|
||||
@ -192,7 +193,7 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
||||
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)
|
||||
.add(new TaskManagerFragment_(), R.string.text_task_manage)
|
||||
.build();
|
||||
mViewPager.setAdapter(mPagerAdapter);
|
||||
tabLayout.setupWithViewPager(mViewPager);
|
||||
|
||||
@ -10,6 +10,7 @@ import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
@ -29,9 +30,11 @@ import com.stardust.scriptdroid.ui.console.LogActivity_;
|
||||
import com.stardust.scriptdroid.ui.help.HelpCatalogueActivity;
|
||||
import com.stardust.util.IntentUtil;
|
||||
import com.stardust.util.UnderuseExecutors;
|
||||
import com.stardust.view.ViewBinder;
|
||||
import com.stardust.view.ViewBinding;
|
||||
|
||||
import org.androidannotations.annotations.CheckedChange;
|
||||
import org.androidannotations.annotations.Click;
|
||||
import org.androidannotations.annotations.EFragment;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
@ -42,17 +45,21 @@ import java.util.concurrent.Executor;
|
||||
/**
|
||||
* Created by Stardust on 2017/1/30.
|
||||
*/
|
||||
|
||||
public class SideMenuFragment extends Fragment {
|
||||
@EFragment(R.layout.fragment_side_menu)
|
||||
public class SideMenuFragment extends android.support.v4.app.Fragment {
|
||||
|
||||
|
||||
public static void setFragment(FragmentActivity activity, int viewId) {
|
||||
SideMenuFragment fragment = new SideMenuFragment();
|
||||
SideMenuFragment fragment = new SideMenuFragment_();
|
||||
activity.getSupportFragmentManager().beginTransaction().replace(viewId, fragment).commit();
|
||||
}
|
||||
|
||||
private SwitchCompat mAccessibilityServiceSwitch, mFloatingWindowSwitch;
|
||||
private SwitchCompat mDebugSwitch;
|
||||
@ViewById(R.id.sw_auto_operate_service)
|
||||
SwitchCompat mAccessibilityServiceSwitch;
|
||||
@ViewById(R.id.sw_floating_window)
|
||||
SwitchCompat mFloatingWindowSwitch;
|
||||
@ViewById(R.id.sw_debug)
|
||||
SwitchCompat mDebugSwitch;
|
||||
private Executor mExecutor = UnderuseExecutors.getExecutor();
|
||||
|
||||
@Override
|
||||
@ -61,19 +68,6 @@ public class SideMenuFragment extends Fragment {
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_slide_menu, container, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
setUpSwitchCompat();
|
||||
ViewBinder.bind(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
@ -102,30 +96,24 @@ public class SideMenuFragment extends Fragment {
|
||||
mFloatingWindowSwitch.setChecked(FloatingWindowManger.isHoverMenuShowing());
|
||||
}
|
||||
|
||||
private void setUpSwitchCompat() {
|
||||
mAccessibilityServiceSwitch = $(R.id.sw_auto_operate_service);
|
||||
mFloatingWindowSwitch = $(R.id.sw_floating_window);
|
||||
mDebugSwitch = $(R.id.sw_debug);
|
||||
}
|
||||
|
||||
|
||||
@ViewBinding.Click(R.id.console)
|
||||
private void startConsoleActivity() {
|
||||
@Click(R.id.console)
|
||||
void startConsoleActivity() {
|
||||
startActivity(new Intent(getActivity(), LogActivity_.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.syntax_and_api)
|
||||
private void startSyntaxHelpActivity() {
|
||||
@Click(R.id.syntax_and_api)
|
||||
void startSyntaxHelpActivity() {
|
||||
HelpCatalogueActivity.showMainCatalogue(getActivity());
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.auto_operate_service)
|
||||
private void clickAutoOperateServiceSwitch() {
|
||||
@Click(R.id.auto_operate_service)
|
||||
void clickAutoOperateServiceSwitch() {
|
||||
mAccessibilityServiceSwitch.toggle();
|
||||
}
|
||||
|
||||
@ViewBinding.Check(R.id.sw_auto_operate_service)
|
||||
private void setAutoOperateServiceEnable(boolean enable) {
|
||||
@CheckedChange(R.id.sw_auto_operate_service)
|
||||
void setAutoOperateServiceEnable(CompoundButton button, boolean enable) {
|
||||
boolean isAccessibilityServiceEnabled = AccessibilityService.isEnable(App.getApp());
|
||||
if (enable && !isAccessibilityServiceEnabled) {
|
||||
AccessibilityServiceTool.enableAccessibilityService();
|
||||
@ -136,8 +124,8 @@ public class SideMenuFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBinding.Check(R.id.sw_floating_window)
|
||||
private void setFloatingWindowEnable(boolean enable) {
|
||||
@CheckedChange(R.id.sw_floating_window)
|
||||
void setFloatingWindowEnable(CompoundButton button, boolean enable) {
|
||||
if (enable && !FloatingWindowManger.isHoverMenuShowing()) {
|
||||
FloatingWindowManger.showHoverMenu();
|
||||
} else if (!enable && FloatingWindowManger.isHoverMenuShowing()) {
|
||||
@ -145,18 +133,18 @@ public class SideMenuFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.floating_window)
|
||||
private void toggleAssistServiceSwitch() {
|
||||
@Click(R.id.floating_window)
|
||||
void toggleAssistServiceSwitch() {
|
||||
mFloatingWindowSwitch.toggle();
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.debug)
|
||||
private void toggleDebugSwitch() {
|
||||
@Click(R.id.debug)
|
||||
void toggleDebugSwitch() {
|
||||
mDebugSwitch.toggle();
|
||||
}
|
||||
|
||||
@ViewBinding.Check(R.id.sw_debug)
|
||||
private void setDebugEnabled(boolean enabled) {
|
||||
@CheckedChange(R.id.sw_debug)
|
||||
void setDebugEnabled(CompoundButton button, boolean enabled) {
|
||||
if (enabled && !SublimePluginService.isConnected()) {
|
||||
new MaterialDialog.Builder(getActivity())
|
||||
.title(R.string.text_server_address)
|
||||
@ -184,8 +172,8 @@ public class SideMenuFragment extends Fragment {
|
||||
return Pref.getServerAddressOrDefault(WifiTool.getWifiAddress(getActivity()));
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.stop_all_running_scripts)
|
||||
private void stopAllRunningScripts() {
|
||||
@Click(R.id.stop_all_running_scripts)
|
||||
void stopAllRunningScripts() {
|
||||
int n = AutoJs.getInstance().getScriptEngineService().stopAll();
|
||||
if (n > 0)
|
||||
Snackbar.make(getView(), String.format(getString(R.string.text_already_stop_n_scripts), n), Snackbar.LENGTH_SHORT).show();
|
||||
|
||||
@ -23,8 +23,6 @@ import com.stardust.scriptdroid.script.StorageScriptProvider;
|
||||
import com.stardust.scriptdroid.ui.edit.EditActivity;
|
||||
import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||
import com.stardust.util.UnderuseExecutors;
|
||||
import com.stardust.view.ViewBinder;
|
||||
import com.stardust.view.ViewBinding;
|
||||
import com.stardust.widget.SimpleAdapterDataObserver;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
@ -18,6 +19,8 @@ import com.stardust.scriptdroid.script.ScriptFile;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.script.Scripts;
|
||||
import com.stardust.scriptdroid.script.StorageScriptProvider;
|
||||
import com.stardust.util.ViewUtil;
|
||||
import com.stardust.util.ViewUtils;
|
||||
import com.stardust.widget.ViewHolderMutableAdapter;
|
||||
import com.stardust.widget.ViewHolderSupplier;
|
||||
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;
|
||||
@ -111,7 +114,10 @@ public class ScriptAndFolderListRecyclerView extends RecyclerView {
|
||||
private OnClickListener mOnRunClickListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int position = getChildViewHolder((View) v.getParent()).getAdapterPosition();
|
||||
View item = ViewUtils.findParentById(v, R.id.item);
|
||||
if (item == null)
|
||||
return;
|
||||
int position = getChildViewHolder(item).getAdapterPosition();
|
||||
ScriptFile file = mAdapter.getScriptFileAt(position);
|
||||
if (file == null)
|
||||
return;
|
||||
@ -236,13 +242,8 @@ public class ScriptAndFolderListRecyclerView extends RecyclerView {
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setLayoutManager(new WrapContentLinearLayoutManager(getContext()));
|
||||
addItemDecoration(new HorizontalDividerItemDecoration.Builder(getContext())
|
||||
.color(0xffd9d9d9)
|
||||
.size(2)
|
||||
.marginResId(R.dimen.script_and_folder_list_divider_left_margin, R.dimen.script_and_folder_list_divider_right_margin)
|
||||
.showLastDivider()
|
||||
.build());
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 2);
|
||||
setLayoutManager(layoutManager);//new WrapContentLinearLayoutManager(getContext()));
|
||||
mAdapter = new Adapter(mDefaultViewHolderSupplier);
|
||||
setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import com.stardust.scriptdroid.script.StorageScriptProvider;
|
||||
|
||||
public class ScriptListWithProgressBarView extends FrameLayout {
|
||||
|
||||
private View mProgressBar;
|
||||
private ScriptAndFolderListRecyclerView mScriptAndFolderListRecyclerView;
|
||||
private SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
|
||||
@ -51,7 +50,6 @@ public class ScriptListWithProgressBarView extends FrameLayout {
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.script_and_folder_list_view, this);
|
||||
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
|
||||
mProgressBar = findViewById(R.id.progressBar);
|
||||
mScriptAndFolderListRecyclerView = (ScriptAndFolderListRecyclerView) findViewById(R.id.script_list_recycler_view);
|
||||
mScriptAndFolderListRecyclerView.setFileProcessListener(new ScriptAndFolderListRecyclerView.FileProcessListener() {
|
||||
@Override
|
||||
|
||||
@ -1,41 +1,35 @@
|
||||
package com.stardust.scriptdroid.ui.main.task;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.stardust.app.Fragment;
|
||||
import com.stardust.autojs.ScriptEngineService;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.view.ViewBinder;
|
||||
import com.stardust.view.ViewBinding;
|
||||
import com.stardust.widget.SimpleAdapterDataObserver;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.Click;
|
||||
import org.androidannotations.annotations.EFragment;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/24.
|
||||
*/
|
||||
|
||||
@EFragment(R.layout.fragment_task_manager)
|
||||
public class TaskManagerFragment extends Fragment {
|
||||
|
||||
private TaskListRecyclerView mTaskListRecyclerView;
|
||||
private View mCloseAllView;
|
||||
private View mNoRunningScriptNotice;
|
||||
@ViewById(R.id.task_list)
|
||||
TaskListRecyclerView mTaskListRecyclerView;
|
||||
@ViewById(R.id.close_all)
|
||||
View mCloseAllView;
|
||||
@ViewById(R.id.notice_no_running_script)
|
||||
View mNoRunningScriptNotice;
|
||||
@ViewById(R.id.swipe_refresh_layout)
|
||||
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_task_manager, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
ViewBinder.bind(this, view);
|
||||
@AfterViews
|
||||
void setUpViews() {
|
||||
init();
|
||||
final boolean noRunningScript = mTaskListRecyclerView.getAdapter().getItemCount() == 0;
|
||||
mNoRunningScriptNotice.setVisibility(noRunningScript ? View.VISIBLE : View.GONE);
|
||||
@ -43,9 +37,6 @@ public class TaskManagerFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mNoRunningScriptNotice = $(R.id.notice_no_running_script);
|
||||
mCloseAllView = $(R.id.close_all);
|
||||
mTaskListRecyclerView = $(R.id.task_list);
|
||||
mTaskListRecyclerView.getAdapter().registerAdapterDataObserver(new SimpleAdapterDataObserver() {
|
||||
|
||||
@Override
|
||||
@ -61,23 +52,23 @@ public class TaskManagerFragment extends Fragment {
|
||||
}
|
||||
|
||||
});
|
||||
final SwipeRefreshLayout swipeRefreshLayout = $(R.id.swipe_refresh_layout);
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
mTaskListRecyclerView.updateEngineList();
|
||||
mTaskListRecyclerView.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
if (mSwipeRefreshLayout != null)
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
}, 800);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ViewBinding.Click(R.id.close_all)
|
||||
private void closeAllRunningScripts() {
|
||||
@Click(R.id.close_all)
|
||||
void closeAllRunningScripts() {
|
||||
AutoJs.getInstance().getScriptEngineService().stopAll();
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||
import com.stardust.util.IntentUtil;
|
||||
import com.stardust.scriptdroid.BuildConfig;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.view.ViewBinder;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.Click;
|
||||
@ -44,7 +43,6 @@ public class AboutActivity extends BaseActivity {
|
||||
void setUpViews() {
|
||||
setVersionName();
|
||||
setToolbarAsBack(getString(R.string.text_about));
|
||||
ViewBinder.bind(this);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
|
||||
@ -1,129 +0,0 @@
|
||||
package com.stardust.view;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/30.
|
||||
* <p>
|
||||
* 哈?你说我为什么不用AA框架?之前还不知道嘛所以现在用了。
|
||||
*/
|
||||
|
||||
public class ViewBinder {
|
||||
|
||||
public interface ViewSupplier {
|
||||
View findViewById(int id);
|
||||
}
|
||||
|
||||
|
||||
public static void bind(final Object o) {
|
||||
final Method findViewById;
|
||||
try {
|
||||
findViewById = o.getClass().getMethod("findViewById", int.class);
|
||||
findViewById.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException("You must implement findViewById to use view binding", e);
|
||||
}
|
||||
bind(o, new ViewSupplier() {
|
||||
@Override
|
||||
public View findViewById(int id) {
|
||||
try {
|
||||
return (View) findViewById.invoke(o, id);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void bind(Object o, final View view) {
|
||||
bind(o, new ViewSupplier() {
|
||||
@Override
|
||||
public View findViewById(int id) {
|
||||
return view.findViewById(id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static void bind(Object o, ViewSupplier viewSupplier) {
|
||||
Method[] methods = o.getClass().getDeclaredMethods();
|
||||
bindId(o, viewSupplier);
|
||||
for (Method method : methods) {
|
||||
method.setAccessible(true);
|
||||
bindClick(o, method, viewSupplier);
|
||||
bindCheck(o, method, viewSupplier);
|
||||
}
|
||||
}
|
||||
|
||||
public static void bindId(Object o, final View v) {
|
||||
bindId(o, new ViewSupplier() {
|
||||
@Override
|
||||
public View findViewById(int id) {
|
||||
return v.findViewById(id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void bindId(Object o, ViewSupplier viewSupplier) {
|
||||
for (Field field : o.getClass().getDeclaredFields()) {
|
||||
field.setAccessible(true);
|
||||
ViewBinding.Id id = field.getAnnotation(ViewBinding.Id.class);
|
||||
if (id == null || id.value() == 0)
|
||||
continue;
|
||||
try {
|
||||
field.set(o, viewSupplier.findViewById(id.value()));
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void bindCheck(final Object o, final Method method, ViewSupplier viewSupplier) {
|
||||
ViewBinding.Check annotation = method.getAnnotation(ViewBinding.Check.class);
|
||||
if (annotation == null || annotation.value() == 0)
|
||||
return;
|
||||
int id = annotation.value();
|
||||
CompoundButton button = (CompoundButton) viewSupplier.findViewById(id);
|
||||
button.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
try {
|
||||
method.invoke(o, isChecked);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void bindClick(final Object o, final Method method, ViewSupplier viewSupplier) {
|
||||
ViewBinding.Click annotation = method.getAnnotation(ViewBinding.Click.class);
|
||||
if (annotation == null || annotation.value() == 0)
|
||||
return;
|
||||
int id = annotation.value();
|
||||
View view = viewSupplier.findViewById(id);
|
||||
if (view == null)
|
||||
return;
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
invokeMethod(o, method);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void invokeMethod(Object o, Method method) {
|
||||
try {
|
||||
method.invoke(o);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
package com.stardust.view;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/30.
|
||||
*/
|
||||
|
||||
@Target({ElementType.TYPE, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ViewBinding {
|
||||
|
||||
@interface Multi {
|
||||
ViewBinding[] value();
|
||||
}
|
||||
|
||||
String click() default "";
|
||||
|
||||
int id();
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface Click {
|
||||
int value();
|
||||
}
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface Check {
|
||||
int value();
|
||||
}
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface Id {
|
||||
int value();
|
||||
}
|
||||
}
|
||||
10
app/src/main/res/drawable/card_shadow.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<gradient
|
||||
android:angle="90"
|
||||
android:endColor="#dedede"
|
||||
android:startColor="@android:color/transparent"/>
|
||||
|
||||
</shape>
|
||||
BIN
app/src/main/res/drawable/ic_edit_gray.png
Normal file
|
After Width: | Height: | Size: 592 B |
BIN
app/src/main/res/drawable/ic_mode_edit_black_24dp.png
Normal file
|
After Width: | Height: | Size: 222 B |
BIN
app/src/main/res/drawable/ic_more_gray.png
Normal file
|
After Width: | Height: | Size: 787 B |
BIN
app/src/main/res/drawable/ic_more_vert_black_24dp.png
Normal file
|
After Width: | Height: | Size: 155 B |
BIN
app/src/main/res/drawable/ic_play_arrow_black_24dp.png
Normal file
|
After Width: | Height: | Size: 208 B |
BIN
app/src/main/res/drawable/ic_run_gray.png
Normal file
|
After Width: | Height: | Size: 485 B |
BIN
app/src/main/res/drawable/ic_share_black_24dp.png
Normal file
|
After Width: | Height: | Size: 483 B |
BIN
app/src/main/res/drawable/ic_share_gray.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
@ -7,7 +7,8 @@
|
||||
<com.stardust.scriptdroid.ui.main.script_list.ScriptListWithProgressBarView
|
||||
android:id="@+id/script_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:background="#f2f3f5"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hint_no_script"
|
||||
|
||||
@ -1,56 +1,99 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:foreground="?android:selectableItemBackground">
|
||||
<LinearLayout 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/item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="2dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:contentDescription="@string/_app_name"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_node_js_black"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="80dp"
|
||||
android:layout_toRightOf="@id/icon"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="@android:color/secondary_text_light"
|
||||
android:textSize="16sp"
|
||||
tools:text="正在运行的服务"/>
|
||||
app:cardBackgroundColor="#ffffff"
|
||||
app:cardCornerRadius="4dp"
|
||||
app:cardElevation="1.5dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="10dp"
|
||||
android:textColor="#99000000"
|
||||
android:textSize="14sp"
|
||||
tools:text="正在运行的服务"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="34dp"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/run"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:src="@drawable/ic_run_gray"
|
||||
android:tint="#767886"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:src="@drawable/ic_mode_edit_black_24dp"
|
||||
android:tint="#767886"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:src="@drawable/ic_share_black_24dp"
|
||||
android:tint="#767886"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:src="@drawable/ic_more_vert_black_24dp"
|
||||
android:tint="#767886"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/run"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="12dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/_app_name"
|
||||
android:src="@drawable/ic_ali_run"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#fefefe">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh_layout"
|
||||
@ -12,22 +11,11 @@
|
||||
<com.stardust.scriptdroid.ui.main.script_list.ScriptAndFolderListRecyclerView
|
||||
android:id="@+id/script_list_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingRight="4dp"
|
||||
android:paddingTop="8dp"/>
|
||||
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent"
|
||||
android:clickable="true"
|
||||
android:visibility="gone">
|
||||
|
||||
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"/>
|
||||
</FrameLayout>
|
||||
</merge>
|
||||
@ -188,6 +188,8 @@
|
||||
<string name="text_show_widget_infomation">查看控件信息</string>
|
||||
<string name="text_show_layout_hierarchy">在布局层次中查看</string>
|
||||
<string name="text_show_layout_bounds">在布局范围中查看</string>
|
||||
<string name="text_more">更多</string>
|
||||
<string name="text_share">分享</string>
|
||||
|
||||
<string-array name="record_control_keys">
|
||||
<item>无</item>
|
||||
|
||||
@ -32,40 +32,18 @@ import static org.junit.Assert.assertTrue;
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
// TODO: 2017/3/3 自定义函数 ×
|
||||
// TODO: 2017/3/19 exist函数 √
|
||||
// TODO: 2017/3/23 tasker插件 √
|
||||
// TODO: 2017/3/23 任务管理与控制台 √
|
||||
// TODO: 2017/3/23 悬浮窗加入控制台 √
|
||||
// TODO: 2017/3/24 文件读写api ---
|
||||
// TODO: 2017/3/24 网络读写api
|
||||
// TODO: 2017/3/24 常驻后台api ×
|
||||
// TODO: 2017/3/24 ui。E4x ---
|
||||
// TODO: 2017/3/24 编辑界面文档和自动补全 ×
|
||||
// TODO: 2017/3/24 驻留模式 ×
|
||||
//// TODO: 2017/3/26 NODEJS ×
|
||||
// TODO: 2017/3/31 自定义快捷方式图标
|
||||
|
||||
|
||||
// FIXME: 2017/3/23 死机重启问题
|
||||
// TODO: 2017/7/2 卡片式脚本
|
||||
// TODO: 2017/7/2 底部导航栏
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Matcher matcher = Pattern.compile("\\S+").matcher("001 华为 6800");
|
||||
while (matcher.find()){
|
||||
System.out.println(matcher.group());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoReorder() {
|
||||
Context context = Context.enter();
|
||||
Scriptable scriptable = context.initStandardObjects();
|
||||
context.setOptimizationLevel(-1);
|
||||
Object o = context.evaluateString(scriptable, " (<xml id=\"foo\"></xml>).attributes()[0].name()", "<e4x>", 1, null);
|
||||
System.out.println(o);
|
||||
Context.exit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
>
|
||||
|
||||
<application
|
||||
android:label="@string/_app_name"
|
||||
>
|
||||
<activity android:name=".execution.ScriptExecuteActivity"/>
|
||||
<service
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.stardust.autojs.runtime.api.image;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
@ -15,7 +16,7 @@ import com.stardust.app.OnActivityResultDelegate;
|
||||
*/
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public class ScreenCaptureRequestActivity extends AppCompatActivity {
|
||||
public class ScreenCaptureRequestActivity extends Activity {
|
||||
|
||||
|
||||
private static ScreenCaptureRequester.Callback sCallback;
|
||||
@ -42,8 +43,8 @@ public class ScreenCaptureRequestActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
mOnActivityResultDelegateMediator.onActivityResult(requestCode, resultCode, data);
|
||||
finish();
|
||||
sCallback = null;
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -57,7 +57,8 @@ public interface ScreenCaptureRequester {
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
mMediator.removeDelegate(this);
|
||||
mCallback.onRequestResult(resultCode, data);
|
||||
if (mCallback != null)
|
||||
mCallback.onRequestResult(resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import android.os.Build;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.WindowManager;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
|
||||
@ -56,7 +57,9 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
|
||||
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
|
||||
|| event.getEventType() == AccessibilityEvent.TYPE_VIEW_HOVER_ENTER
|
||||
|| event.getEventType() == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT) {
|
||||
mRootInActiveWindow = super.getRootInActiveWindow();
|
||||
if (!event.getPackageName().equals(getPackageName())) {
|
||||
mRootInActiveWindow = super.getRootInActiveWindow();
|
||||
}
|
||||
}
|
||||
if (!containsAllEventTypes && !eventTypes.contains(event.getEventType()))
|
||||
return;
|
||||
@ -74,11 +77,7 @@ public class AccessibilityService extends android.accessibilityservice.Accessibi
|
||||
|
||||
@Override
|
||||
public AccessibilityNodeInfo getRootInActiveWindow() {
|
||||
try {
|
||||
return super.getRootInActiveWindow();
|
||||
} catch (IllegalStateException ignored) {
|
||||
return mRootInActiveWindow;
|
||||
}
|
||||
return mRootInActiveWindow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
23
common/src/main/java/com/stardust/util/ViewUtils.java
Normal file
@ -0,0 +1,23 @@
|
||||
package com.stardust.util;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/7/2.
|
||||
*/
|
||||
|
||||
public class ViewUtils {
|
||||
|
||||
public static View findParentById(View view, int id) {
|
||||
ViewParent parent = view.getParent();
|
||||
if (parent == null || !(parent instanceof View))
|
||||
return null;
|
||||
View viewParent = (View) parent;
|
||||
if (viewParent.getId() == id) {
|
||||
return viewParent;
|
||||
}
|
||||
return findParentById(viewParent, id);
|
||||
}
|
||||
|
||||
}
|
||||
@ -15,6 +15,6 @@
|
||||
#Mon Jan 23 10:16:46 CST 2017
|
||||
systemProp.https.proxyPort=1080
|
||||
systemProp.http.proxyHost=127.0.0.1
|
||||
org.gradle.jvmargs=-Xmx1536m -Dfile.encoding=UTF-8
|
||||
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
|
||||
systemProp.https.proxyHost=127.0.0.1
|
||||
systemProp.http.proxyPort=1080
|
||||
|
||||