add editor (modified by 920 text editor)
@ -64,9 +64,7 @@ dependencies {
|
||||
compile(name:'920-file_explorer-release', ext:'aar'){
|
||||
transitive = true
|
||||
}
|
||||
compile(name:'920-app-debug', ext:'aar'){
|
||||
transitive = true
|
||||
}
|
||||
compile(name:'920-app-debug', ext:'aar')
|
||||
|
||||
|
||||
}
|
||||
|
||||
BIN
app/libs/920-styles-release.aar
Normal file
@ -72,7 +72,9 @@
|
||||
android:resource="@xml/provider_paths"/>
|
||||
</provider>
|
||||
|
||||
<activity android:name=".TestActivity"/>
|
||||
<activity android:name=".EditActivity"/>
|
||||
|
||||
<activity android:name="com.jecelyin.editor.v2.ui.MainActivity"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
287
app/src/main/java/com/stardust/scriptdroid/EditActivity.java
Normal file
@ -0,0 +1,287 @@
|
||||
package com.stardust.scriptdroid;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.afollestad.materialdialogs.folderselector.FolderChooserDialog;
|
||||
import com.jecelyin.editor.v2.Pref;
|
||||
import com.jecelyin.editor.v2.common.Command;
|
||||
import com.jecelyin.editor.v2.common.SaveListener;
|
||||
import com.jecelyin.editor.v2.ui.EditorDelegate;
|
||||
import com.jecelyin.editor.v2.ui.IActivity;
|
||||
import com.jecelyin.editor.v2.ui.TabManager;
|
||||
import com.jecelyin.editor.v2.view.EditorView;
|
||||
import com.jecelyin.editor.v2.view.menu.MenuDef;
|
||||
import com.stardust.scriptdroid.droid.Droid;
|
||||
import com.stardust.scriptdroid.widget.ToolbarMenuItem;
|
||||
import com.stardust.util.SparseArrayEntries;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/29.
|
||||
*/
|
||||
|
||||
public class EditActivity extends IActivity {
|
||||
|
||||
|
||||
public static void editFile(Context context, String path) {
|
||||
editFile(context, null, path);
|
||||
}
|
||||
|
||||
public static void editFile(Context context, String name, String path) {
|
||||
context.startActivity(new Intent(context, EditActivity.class)
|
||||
.putExtra("path", path)
|
||||
.putExtra("name", name));
|
||||
}
|
||||
|
||||
private String mName;
|
||||
private File mFile;
|
||||
private View mView;
|
||||
private EditorDelegate mEditorDelegate;
|
||||
private ToolbarMenuItem mSaveMenuItem, mRedoMenuItem, mUndoMenuItem, mRunMenuItem;
|
||||
private SparseArray<ToolbarMenuItem> mMenuMap;
|
||||
|
||||
public void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
handleIntent();
|
||||
setUpUI();
|
||||
setUpEditor();
|
||||
}
|
||||
|
||||
private void setUpEditor() {
|
||||
if (mFile != null) {
|
||||
Pref.getInstance(this).setReadOnly(false);
|
||||
mEditorDelegate = new EditorDelegate(0, mFile, 0, null);
|
||||
EditorView editorView = (EditorView) findViewById(R.id.editor);
|
||||
mEditorDelegate.setEditorView(editorView);
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpUI() {
|
||||
setTheme(R.style.EditorTheme);
|
||||
mView = View.inflate(this, R.layout.activity_edit, null);
|
||||
setContentView(mView);
|
||||
initMenuItem();
|
||||
setUpToolbar();
|
||||
setUpListener();
|
||||
}
|
||||
|
||||
private void initMenuItem() {
|
||||
mRedoMenuItem = (ToolbarMenuItem) findViewById(R.id.redo);
|
||||
mUndoMenuItem = (ToolbarMenuItem) findViewById(R.id.undo);
|
||||
mSaveMenuItem = (ToolbarMenuItem) findViewById(R.id.save);
|
||||
mRunMenuItem = (ToolbarMenuItem) findViewById(R.id.run);
|
||||
mMenuMap = new SparseArrayEntries<ToolbarMenuItem>()
|
||||
.entry(com.jecelyin.editor.v2.R.id.m_redo, mRedoMenuItem)
|
||||
.entry(com.jecelyin.editor.v2.R.id.m_undo, mUndoMenuItem)
|
||||
.entry(com.jecelyin.editor.v2.R.id.m_save, mSaveMenuItem)
|
||||
.entry(R.id.run, mRunMenuItem)
|
||||
.sparseArray();
|
||||
}
|
||||
|
||||
private void setUpListener() {
|
||||
mUndoMenuItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
undo();
|
||||
}
|
||||
});
|
||||
mRedoMenuItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
redo();
|
||||
}
|
||||
});
|
||||
mSaveMenuItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
saveFile(false, null);
|
||||
}
|
||||
});
|
||||
mRunMenuItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mEditorDelegate.isChanged()) {
|
||||
saveFile(false, new SaveListener() {
|
||||
@Override
|
||||
public void onSaved() {
|
||||
run();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
run();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void run() {
|
||||
Snackbar.make(mView, "开始运行", Snackbar.LENGTH_SHORT).show();
|
||||
setMenuStatus(R.id.run, MenuDef.STATUS_DISABLED);
|
||||
Droid.getInstance().runScriptFile(mFile, new Droid.OnRunFinishedListener() {
|
||||
@Override
|
||||
public void onRunFinished(Object result, final Exception e) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setMenuStatus(R.id.run, MenuDef.STATUS_NORMAL);
|
||||
if (e != null)
|
||||
Snackbar.make(mView, "错误: " + e.getMessage(), Snackbar.LENGTH_INDEFINITE).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void handleIntent() {
|
||||
String path = getIntent().getStringExtra("path");
|
||||
mName = getIntent().getStringExtra("name");
|
||||
if (path == null) {
|
||||
finish();
|
||||
} else {
|
||||
mFile = new File(path);
|
||||
if (mName == null) {
|
||||
mName = mFile.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpToolbar() {
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(mName);
|
||||
setSupportActionBar(toolbar);
|
||||
if (getSupportActionBar() != null) {
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveFile(boolean toast, SaveListener listener) {
|
||||
Command command = new Command(Command.CommandEnum.SAVE);
|
||||
command.args = new Bundle();
|
||||
command.args.putBoolean("is_cluster", !toast);
|
||||
command.object = listener;
|
||||
mEditorDelegate.doCommand(command);
|
||||
}
|
||||
|
||||
private void undo() {
|
||||
Command command = new Command(Command.CommandEnum.UNDO);
|
||||
mEditorDelegate.doCommand(command);
|
||||
}
|
||||
|
||||
private void redo() {
|
||||
Command command = new Command(Command.CommandEnum.REDO);
|
||||
mEditorDelegate.doCommand(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPickPathActivity(String s, String s1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
if (mEditorDelegate.isChanged()) {
|
||||
showExitConfirmDialog();
|
||||
} else {
|
||||
super.finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void showExitConfirmDialog() {
|
||||
new MaterialDialog.Builder(this)
|
||||
.title(R.string.text_alert)
|
||||
.content(R.string.edit_exit_without_save_warn)
|
||||
.positiveText(R.string.text_cancel)
|
||||
.negativeText(R.string.text_save_and_exit)
|
||||
.neutralText(R.string.text_exit_directly )
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
saveFile(true, null);
|
||||
EditActivity.super.finish();
|
||||
}
|
||||
})
|
||||
.onNeutral(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
EditActivity.super.finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doNextCommand() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setMenuStatus(int menuResId, int status) {
|
||||
ToolbarMenuItem menuItem = mMenuMap.get(menuResId);
|
||||
if (menuItem == null)
|
||||
return;
|
||||
boolean disabled = status == MenuDef.STATUS_DISABLED;
|
||||
menuItem.setEnabled(!disabled);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDocumentChanged(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCommand(Command command) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFile(String s, String s1, int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFindFolderCallback(FolderChooserDialog.FolderCallback folderCallback) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabManager getTabManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertText(CharSequence charSequence) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFolderSelection(@NonNull FolderChooserDialog dialog, @NonNull File folder) {
|
||||
|
||||
}
|
||||
|
||||
protected void onDestroy() {
|
||||
try {
|
||||
super.onDestroy();
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -3,9 +3,12 @@ package com.stardust.scriptdroid;
|
||||
import android.Manifest;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.InputType;
|
||||
import android.view.Menu;
|
||||
@ -14,7 +17,6 @@ import android.view.View;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.jecelyin.editor.v2.core.widget.JecEditText;
|
||||
import com.stardust.scriptdroid.droid.runtime.action.ActionPerformService;
|
||||
import com.stardust.scriptdroid.droid.script.file.ScriptFile;
|
||||
import com.stardust.scriptdroid.droid.script.file.ScriptFileList;
|
||||
@ -38,6 +40,7 @@ public class MainActivity extends BaseActivity {
|
||||
private ScriptListRecyclerView mScriptListRecyclerView;
|
||||
private ScriptFileList mScriptFileList;
|
||||
private FileChooser mFileChooser;
|
||||
private DrawerLayout mDrawerLayout;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -48,22 +51,17 @@ public class MainActivity extends BaseActivity {
|
||||
setUpFileChooser();
|
||||
|
||||
checkPermissions();
|
||||
|
||||
}
|
||||
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
private void checkPermissions() {
|
||||
checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||
goToAccessibilityPermissionSettingIfDisabled();
|
||||
JecEditText jecEditText = new JecEditText(this);
|
||||
}
|
||||
|
||||
private void goToAccessibilityPermissionSettingIfDisabled() {
|
||||
if (!AccessibilityServiceUtils.isAccessibilityServiceEnabled(this, ActionPerformService.class)) {
|
||||
new MaterialDialog.Builder(this)
|
||||
.title(R.string.text_alert)
|
||||
.content(R.string.explain_accessibility_permission)
|
||||
.positiveText(R.string.text_go_to_setting)
|
||||
.negativeText(R.string.text_cancel)
|
||||
@ -110,6 +108,7 @@ public class MainActivity extends BaseActivity {
|
||||
mView = View.inflate(this, R.layout.activity_main, null);
|
||||
setContentView(mView);
|
||||
mSlidingUpPanel = $(R.id.bottom_menu);
|
||||
mDrawerLayout = $(R.id.drawer_layout);
|
||||
|
||||
setUpToolbar();
|
||||
setUpScriptList();
|
||||
@ -119,8 +118,12 @@ public class MainActivity extends BaseActivity {
|
||||
private void setUpToolbar() {
|
||||
Toolbar toolbar = $(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
toolbar.setNavigationIcon(R.drawable.ic_script_droid_40);
|
||||
toolbar.setTitle(R.string.app_name);
|
||||
|
||||
ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.text_drawer_open,
|
||||
R.string.text_drawer_close);
|
||||
drawerToggle.syncState();
|
||||
mDrawerLayout.addDrawerListener(drawerToggle);
|
||||
}
|
||||
|
||||
private void setUpScriptList() {
|
||||
@ -204,7 +207,7 @@ public class MainActivity extends BaseActivity {
|
||||
.entry(R.id.action_test, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startActivity(new Intent(MainActivity.this, TestActivity.class));
|
||||
startActivity(new Intent(MainActivity.this, EditActivity.class));
|
||||
}
|
||||
})
|
||||
.map();
|
||||
@ -216,7 +219,7 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void disableAccessibilityService() {
|
||||
if (ActionPerformService.getInstance() != null) {
|
||||
if (ActionPerformService.getInstance() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
ActionPerformService.getInstance().disableSelf();
|
||||
}
|
||||
Snackbar.make(mView, R.string.text_service_disabled, Snackbar.LENGTH_SHORT).show();
|
||||
|
||||
@ -1,61 +0,0 @@
|
||||
package com.stardust.scriptdroid;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.jecelyin.editor.v2.Pref;
|
||||
import com.jecelyin.editor.v2.common.Command;
|
||||
import com.jecelyin.editor.v2.ui.EditorDelegate;
|
||||
import com.jecelyin.editor.v2.ui.IActivity;
|
||||
import com.jecelyin.editor.v2.ui.TabManager;
|
||||
import com.jecelyin.editor.v2.view.EditorView;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/29.
|
||||
*/
|
||||
|
||||
public class TestActivity extends BaseActivity implements IActivity{
|
||||
|
||||
public void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
Pref.getInstance(this).setTheme(0);
|
||||
setContentView(R.layout.edit_layout);
|
||||
EditorDelegate editorDelegate = new EditorDelegate(0, "Hello 920 Editor", "Hello 920");
|
||||
EditorView editorView = $(R.id.editor);
|
||||
editorDelegate.setEditorView(editorView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPickPathActivity(String s, String s1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doNextCommand() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabManager getTabManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMenuStatus(int i, int i1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDocumentChanged(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCommand(Command command) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFile(String s, String s1, int i) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -14,8 +14,20 @@ import java.io.FileNotFoundException;
|
||||
|
||||
public class Droid {
|
||||
|
||||
public interface OnRunFinishedListener {
|
||||
void onRunFinished(Object result, Exception e);
|
||||
}
|
||||
|
||||
private static final DroidRuntime RUNTIME = DroidRuntime.getRuntime();
|
||||
private static final JavaScriptEngine JAVA_SCRIPT_ENGINE = new GBJDuktapeJavaScriptEngine(RUNTIME);
|
||||
private static final OnRunFinishedListener DEFAULT_LISTENER = new OnRunFinishedListener() {
|
||||
@Override
|
||||
public void onRunFinished(Object result, Exception e) {
|
||||
if (e != null) {
|
||||
RUNTIME.toast("错误: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
private static Droid instance = new Droid();
|
||||
|
||||
protected Droid() {
|
||||
@ -31,18 +43,30 @@ public class Droid {
|
||||
runScript(FileUtils.readString(file));
|
||||
}
|
||||
|
||||
public void runScriptFile(File file, OnRunFinishedListener listener) {
|
||||
checkFile(file);
|
||||
runScript(FileUtils.readString(file), listener);
|
||||
}
|
||||
|
||||
private void runScript(String script) {
|
||||
runScript(script, null);
|
||||
}
|
||||
|
||||
public void runScriptFile(String path) {
|
||||
runScriptFile(new File(path));
|
||||
}
|
||||
|
||||
public void runScript(final String script) {
|
||||
public void runScript(final String script, OnRunFinishedListener listener) {
|
||||
if (listener == null)
|
||||
listener = DEFAULT_LISTENER;
|
||||
final OnRunFinishedListener finalListener = listener;
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
JAVA_SCRIPT_ENGINE.execute(script);
|
||||
finalListener.onRunFinished(JAVA_SCRIPT_ENGINE.execute(script), null);
|
||||
} catch (Exception e) {
|
||||
RUNTIME.toast("错误" + e.getMessage());
|
||||
finalListener.onRunFinished(null, e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
@ -9,6 +9,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.droid.runtime.action.Action;
|
||||
import com.stardust.scriptdroid.droid.runtime.action.ActionFactory;
|
||||
import com.stardust.scriptdroid.droid.runtime.action.ActionPerformService;
|
||||
@ -101,11 +102,11 @@ public class DroidRuntime implements IDroidRuntime {
|
||||
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD));
|
||||
}
|
||||
|
||||
public boolean scrollAllUp(){
|
||||
public boolean scrollAllUp() {
|
||||
return performAction(ActionFactory.createScrollAllAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD));
|
||||
}
|
||||
|
||||
public boolean scrollAllDown(){
|
||||
public boolean scrollAllDown() {
|
||||
return performAction(ActionFactory.createScrollAllAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD));
|
||||
}
|
||||
|
||||
@ -132,8 +133,8 @@ public class DroidRuntime implements IDroidRuntime {
|
||||
|
||||
private boolean performAction(Action action) {
|
||||
if (ActionPerformService.getInstance() == null) {
|
||||
toast("没有权限");
|
||||
return false;
|
||||
toast(App.getApp().getString(R.string.text_no_accessibility_permission));
|
||||
throw new PermissionDeniedException(App.getApp().getString(R.string.text_no_accessibility_permission));
|
||||
}
|
||||
ActionPerformService.setAction(action);
|
||||
synchronized (mLock) {
|
||||
@ -159,7 +160,7 @@ public class DroidRuntime implements IDroidRuntime {
|
||||
|
||||
@Override
|
||||
public void sleep(long millis) {
|
||||
try{
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package com.stardust.scriptdroid.droid.runtime;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/29.
|
||||
*/
|
||||
public class PermissionDeniedException extends RuntimeException {
|
||||
public PermissionDeniedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@ -30,8 +30,8 @@ public class DuktapeJavaScriptEngine implements JavaScriptEngine {
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(String script) {
|
||||
mDuktape.evaluate(script);
|
||||
public Object execute(String script) {
|
||||
return mDuktape.evaluate(script);
|
||||
}
|
||||
|
||||
public <T> void set(String varName, Class<T> c, T value) {
|
||||
|
||||
@ -22,7 +22,11 @@ public class GBJDuktapeJavaScriptEngine implements JavaScriptEngine {
|
||||
public GBJDuktapeJavaScriptEngine(IDroidRuntime runtime) {
|
||||
setRuntime(runtime);
|
||||
mDuktapeEngine.put("context", App.getApp());
|
||||
execute(init);
|
||||
try {
|
||||
execute(init);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setRuntime(IDroidRuntime runtime) {
|
||||
@ -30,12 +34,8 @@ public class GBJDuktapeJavaScriptEngine implements JavaScriptEngine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String script) {
|
||||
try {
|
||||
mDuktapeEngine.execute(JSTransformer.parse(new StringReader(script)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public Object execute(String script) throws IOException {
|
||||
return mDuktapeEngine.execute(JSTransformer.parse(new StringReader(script)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -3,13 +3,15 @@ package com.stardust.scriptdroid.droid.script;
|
||||
import com.stardust.scriptdroid.App;
|
||||
import com.stardust.scriptdroid.droid.script.file.AssetScript;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/27.
|
||||
*/
|
||||
|
||||
public interface JavaScriptEngine {
|
||||
|
||||
void execute(String script);
|
||||
Object execute(String script) throws IOException;
|
||||
|
||||
<T> void set(String varName, Class<T> c, T value);
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ public class ScriptFile {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void run(Context context) {
|
||||
public void run() {
|
||||
Droid.getInstance().runScriptFile(toFile());
|
||||
}
|
||||
|
||||
|
||||
@ -167,7 +167,7 @@ public class ScriptListRecyclerView extends RecyclerView {
|
||||
}
|
||||
|
||||
private static void loadScriptFileOperations() {
|
||||
ClassTool.loadClasses(Run.class, Edit.class, Rename.class, CreateShortcut.class, Remove.class, Delete.class);
|
||||
ClassTool.loadClasses(Run.class, Rename.class, OpenByOtherApp.class, CreateShortcut.class, Remove.class, Delete.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
package com.stardust.scriptdroid.widget;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.stardust.scriptdroid.R;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/29.
|
||||
*/
|
||||
|
||||
public class ToolbarMenuItem extends LinearLayout {
|
||||
|
||||
private static final int COLOR_DISABLED = 0X77e0e0e0;
|
||||
private ImageView mImageView;
|
||||
private TextView mTextView;
|
||||
private Drawable mEnabledDrawable, mDisabledDrawable;
|
||||
|
||||
public ToolbarMenuItem(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
public ToolbarMenuItem(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public ToolbarMenuItem(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(attrs);
|
||||
}
|
||||
|
||||
private void init(AttributeSet attrs) {
|
||||
inflate(getContext(), R.layout.toolbar_menu_item, this);
|
||||
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ToolbarMenuItem);
|
||||
String text = a.getString(R.styleable.ToolbarMenuItem_text);
|
||||
int iconResId = a.getResourceId(R.styleable.ToolbarMenuItem_icon, 0);
|
||||
int iconColor = a.getColor(R.styleable.ToolbarMenuItem_icon_color, Color.TRANSPARENT);
|
||||
a.recycle();
|
||||
mImageView = (ImageView) findViewById(R.id.icon);
|
||||
mTextView = (TextView) findViewById(R.id.text);
|
||||
mTextView.setText(text);
|
||||
mImageView.setImageResource(iconResId);
|
||||
if (iconColor != Color.TRANSPARENT) {
|
||||
mImageView.setImageDrawable(convertDrawableToGrayScale(mImageView.getDrawable(), iconColor));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (enabled == isEnabled())
|
||||
return;
|
||||
super.setEnabled(enabled);
|
||||
ensureEnabledDrawable();
|
||||
ensureDisabledDrawable();
|
||||
mImageView.setImageDrawable(enabled ? mEnabledDrawable : mDisabledDrawable);
|
||||
mTextView.setTextColor(enabled ? Color.WHITE : COLOR_DISABLED);
|
||||
}
|
||||
|
||||
private void ensureDisabledDrawable() {
|
||||
if (mDisabledDrawable == null) {
|
||||
mDisabledDrawable = convertDrawableToGrayScale(mEnabledDrawable, COLOR_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureEnabledDrawable() {
|
||||
if (mEnabledDrawable == null) {
|
||||
mEnabledDrawable = mImageView.getDrawable();
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable convertDrawableToGrayScale(Drawable drawable, int color) {
|
||||
if (drawable == null || drawable.getConstantState() == null)
|
||||
return null;
|
||||
Drawable res = drawable.getConstantState().newDrawable().mutate();
|
||||
res.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable/ic_open_in_new_green_48dp.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/drawable/ic_play_arrow_green_48dp.png
Normal file
|
After Width: | Height: | Size: 604 B |
BIN
app/src/main/res/drawable/ic_play_arrow_white_48dp.png
Normal file
|
After Width: | Height: | Size: 220 B |
BIN
app/src/main/res/drawable/ic_redo_white_48dp.png
Normal file
|
After Width: | Height: | Size: 354 B |
BIN
app/src/main/res/drawable/ic_save_white_48dp.png
Normal file
|
After Width: | Height: | Size: 273 B |
BIN
app/src/main/res/drawable/ic_undo_white_48dp.png
Normal file
|
After Width: | Height: | Size: 339 B |
BIN
app/src/main/res/drawable/slide_menu_img.png
Normal file
|
After Width: | Height: | Size: 58 KiB |
67
app/src/main/res/layout/activity_edit.xml
Normal file
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".EditActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:title="@string/app_name"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.stardust.scriptdroid.widget.ToolbarMenuItem
|
||||
android:id="@+id/run"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
app:icon="@drawable/ic_play_arrow_white_48dp"
|
||||
app:icon_color="@android:color/white"
|
||||
app:text="@string/text_run"/>
|
||||
|
||||
<com.stardust.scriptdroid.widget.ToolbarMenuItem
|
||||
android:id="@+id/undo"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
app:icon="@drawable/ic_undo_white_48dp"
|
||||
app:text="@string/text_undo"/>
|
||||
|
||||
<com.stardust.scriptdroid.widget.ToolbarMenuItem
|
||||
android:id="@+id/redo"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
app:icon="@drawable/ic_redo_white_48dp"
|
||||
app:text="@string/text_redo"/>
|
||||
|
||||
<com.stardust.scriptdroid.widget.ToolbarMenuItem
|
||||
android:id="@+id/save"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
app:icon="@drawable/ic_save_white_48dp"
|
||||
app:text="@string/text_save"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_edit"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
@ -1,97 +1,110 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="com.stardust.scriptdroid.MainActivity">
|
||||
<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"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="com.stardust.scriptdroid.MainActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:title="@string/app_name"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_main"/>
|
||||
|
||||
<com.stardust.scriptdroid.ui.SlidingUpPanel
|
||||
android:id="@+id/bottom_menu"
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:background="@android:color/white"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:title="@string/app_name"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_main"/>
|
||||
|
||||
<com.stardust.scriptdroid.ui.SlidingUpPanel
|
||||
android:id="@+id/bottom_menu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<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:layout_width="match_parent"
|
||||
android:layout_height="160dp"
|
||||
android:background="@android:color/white"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="600dp"
|
||||
android:layout_height="60dp"
|
||||
android:src="@drawable/ic_create_new_folder_black_48dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
<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:text="@string/text_new_file"
|
||||
android:textColor="@android:color/secondary_text_light"
|
||||
android:textSize="16sp"/>
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="600dp"
|
||||
android:layout_height="60dp"
|
||||
android:src="@drawable/ic_create_new_folder_black_48dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_new_file"
|
||||
android:textColor="@android:color/secondary_text_light"
|
||||
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">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_sdcard_black"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_import_from_file"
|
||||
android:textColor="@android:color/secondary_text_light"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.stardust.scriptdroid.ui.SlidingUpPanel>
|
||||
|
||||
<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">
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/ic_sdcard_black"/>
|
||||
<include
|
||||
layout="@layout/slide_menu"
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"/>
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/text_import_from_file"
|
||||
android:textColor="@android:color/secondary_text_light"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.stardust.scriptdroid.ui.SlidingUpPanel>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
@ -1,14 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#ffffffff"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
tools:showIn="@layout/activity_edit">
|
||||
|
||||
<com.jecelyin.editor.v2.view.EditorView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/editor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="?android:attr/actionBarSize">
|
||||
|
||||
|
||||
<com.jecelyin.editor.v2.core.widget.JecEditText
|
||||
android:id="@+id/edit_text"
|
||||
@ -19,7 +23,6 @@
|
||||
android:gravity="start|top"
|
||||
android:inputType="textMultiLine"
|
||||
android:padding="5dp"
|
||||
android:scrollbarAlwaysDrawVerticalTrack="false"
|
||||
android:scrollbarThumbVertical="@android:color/transparent"
|
||||
android:scrollbarTrackVertical="@null"
|
||||
android:scrollbars="vertical"/>
|
||||
14
app/src/main/res/layout/slide_menu.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="156dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/slide_menu_img"/>
|
||||
|
||||
</LinearLayout>
|
||||
23
app/src/main/res/layout/toolbar_menu_item.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:paddingBottom="20dp"
|
||||
android:paddingTop="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-20dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12sp"/>
|
||||
</LinearLayout>
|
||||
26
app/src/main/res/menu/menu_editor.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_redo"
|
||||
android:icon="@drawable/ic_undo_white_48dp"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/text_undo"
|
||||
app:showAsAction="ifRoom|withText"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_undo"
|
||||
android:icon="@drawable/ic_redo_white_48dp"
|
||||
android:orderInCategory="200"
|
||||
android:title="@string/text_redo"
|
||||
app:showAsAction="ifRoom|withText"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_save"
|
||||
android:icon="@drawable/ic_save_white_48dp"
|
||||
android:orderInCategory="300"
|
||||
android:title="@string/text_save"
|
||||
app:showAsAction="ifRoom|withText"/>
|
||||
|
||||
</menu>
|
||||
@ -1,6 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<declare-styleable name="MaterialEditText"><attr format="color" name="met_baseColor"/><attr format="color" name="met_primaryColor"/><attr name="met_floatingLabel"><enum name="none" value="0"/><enum name="normal" value="1"/><enum name="highlight" value="2"/></attr><attr format="color" name="met_errorColor"/><attr format="integer" name="met_minCharacters"/><attr format="integer" name="met_maxCharacters"/><attr format="boolean" name="met_singleLineEllipsis"/><attr format="integer" name="met_minBottomTextLines"/><attr format="string" name="met_helperText"/><attr format="color" name="met_helperTextColor"/><attr format="string" name="met_accentTypeface"/><attr format="string" name="met_typeface"/><attr format="string" name="met_floatingLabelText"/><attr format="dimension" name="met_floatingLabelPadding"/><attr format="boolean" name="met_hideUnderline"/><attr format="color" name="met_underlineColor"/><attr format="boolean" name="met_autoValidate"/><attr format="reference" name="met_iconLeft"/><attr format="reference" name="met_iconRight"/><attr format="dimension" name="met_iconPadding"/><attr format="boolean" name="met_clearButton"/><attr format="dimension" name="met_floatingLabelTextSize"/><attr format="color" name="met_floatingLabelTextColor"/><attr format="dimension" name="met_bottomTextSize"/><attr format="boolean" name="met_floatingLabelAlwaysShown"/><attr format="boolean" name="met_helperTextAlwaysShown"/><attr format="boolean" name="met_floatingLabelAnimating"/><attr format="color" name="met_textColor"/><attr format="color" name="met_textColorHint"/></declare-styleable>
|
||||
<declare-styleable name="ToolbarMenuItem">
|
||||
<attr name="text" format="string|reference"/>
|
||||
<attr name="icon" format="reference"/>
|
||||
<attr name="icon_color" format="color|reference"/>
|
||||
</declare-styleable>
|
||||
|
||||
|
||||
<declare-styleable name="MaterialEditText">
|
||||
<attr name="met_baseColor" format="color"/>
|
||||
<attr name="met_primaryColor" format="color"/>
|
||||
<attr name="met_floatingLabel">
|
||||
<enum name="none" value="0"/>
|
||||
<enum name="normal" value="1"/>
|
||||
<enum name="highlight" value="2"/>
|
||||
</attr>
|
||||
<attr name="met_errorColor" format="color"/>
|
||||
<attr name="met_minCharacters" format="integer"/>
|
||||
<attr name="met_maxCharacters" format="integer"/>
|
||||
<attr name="met_singleLineEllipsis" format="boolean"/>
|
||||
<attr name="met_minBottomTextLines" format="integer"/>
|
||||
<attr name="met_helperText" format="string"/>
|
||||
<attr name="met_helperTextColor" format="color"/>
|
||||
<attr name="met_accentTypeface" format="string"/>
|
||||
<attr name="met_typeface" format="string"/>
|
||||
<attr name="met_floatingLabelText" format="string"/>
|
||||
<attr name="met_floatingLabelPadding" format="dimension"/>
|
||||
<attr name="met_hideUnderline" format="boolean"/>
|
||||
<attr name="met_underlineColor" format="color"/>
|
||||
<attr name="met_autoValidate" format="boolean"/>
|
||||
<attr name="met_iconLeft" format="reference"/>
|
||||
<attr name="met_iconRight" format="reference"/>
|
||||
<attr name="met_iconPadding" format="dimension"/>
|
||||
<attr name="met_clearButton" format="boolean"/>
|
||||
<attr name="met_floatingLabelTextSize" format="dimension"/>
|
||||
<attr name="met_floatingLabelTextColor" format="color"/>
|
||||
<attr name="met_bottomTextSize" format="dimension"/>
|
||||
<attr name="met_floatingLabelAlwaysShown" format="boolean"/>
|
||||
<attr name="met_helperTextAlwaysShown" format="boolean"/>
|
||||
<attr name="met_floatingLabelAnimating" format="boolean"/>
|
||||
<attr name="met_textColor" format="color"/>
|
||||
<attr name="met_textColorHint" format="color"/>
|
||||
</declare-styleable>
|
||||
<!-- From: file:/Users/rengwuxian/projects/MaterialEditText/library/src/main/res/values/dimens.xml -->
|
||||
<eat-comment/>
|
||||
<dimen name="bottom_ellipsis_height">4dp</dimen>
|
||||
@ -12,7 +53,33 @@
|
||||
<dimen name="inner_padding_left">0dp</dimen>
|
||||
<dimen name="inner_padding_right">0dp</dimen>
|
||||
|
||||
<declare-styleable name="RoundedImageView"><attr format="dimension" name="riv_corner_radius"/><attr format="dimension" name="riv_corner_radius_top_left"/><attr format="dimension" name="riv_corner_radius_top_right"/><attr format="dimension" name="riv_corner_radius_bottom_left"/><attr format="dimension" name="riv_corner_radius_bottom_right"/><attr format="dimension" name="riv_border_width"/><attr format="color" name="riv_border_color"/><attr format="boolean" name="riv_mutate_background"/><attr format="boolean" name="riv_oval"/><attr name="android:scaleType"/><attr name="riv_tile_mode"><enum name="clamp" value="0"/><enum name="repeat" value="1"/><enum name="mirror" value="2"/></attr><attr name="riv_tile_mode_x"><enum name="clamp" value="0"/><enum name="repeat" value="1"/><enum name="mirror" value="2"/></attr><attr name="riv_tile_mode_y"><enum name="clamp" value="0"/><enum name="repeat" value="1"/><enum name="mirror" value="2"/></attr></declare-styleable>
|
||||
<declare-styleable name="RoundedImageView">
|
||||
<attr name="riv_corner_radius" format="dimension"/>
|
||||
<attr name="riv_corner_radius_top_left" format="dimension"/>
|
||||
<attr name="riv_corner_radius_top_right" format="dimension"/>
|
||||
<attr name="riv_corner_radius_bottom_left" format="dimension"/>
|
||||
<attr name="riv_corner_radius_bottom_right" format="dimension"/>
|
||||
<attr name="riv_border_width" format="dimension"/>
|
||||
<attr name="riv_border_color" format="color"/>
|
||||
<attr name="riv_mutate_background" format="boolean"/>
|
||||
<attr name="riv_oval" format="boolean"/>
|
||||
<attr name="android:scaleType"/>
|
||||
<attr name="riv_tile_mode">
|
||||
<enum name="clamp" value="0"/>
|
||||
<enum name="repeat" value="1"/>
|
||||
<enum name="mirror" value="2"/>
|
||||
</attr>
|
||||
<attr name="riv_tile_mode_x">
|
||||
<enum name="clamp" value="0"/>
|
||||
<enum name="repeat" value="1"/>
|
||||
<enum name="mirror" value="2"/>
|
||||
</attr>
|
||||
<attr name="riv_tile_mode_y">
|
||||
<enum name="clamp" value="0"/>
|
||||
<enum name="repeat" value="1"/>
|
||||
<enum name="mirror" value="2"/>
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
<!-- From: file:/Users/vince/Documents/vinc3m1/RoundedImageView/roundedimageview/src/main/res/values/about_libraries_def.xml -->
|
||||
<eat-comment/>
|
||||
<string name="define_roundedimageview"/>
|
||||
|
||||
@ -18,4 +18,15 @@
|
||||
<string name="text_file_not_exists">文件不存在</string>
|
||||
<string name="text_no_file_rw_permission">无文件读写权限</string>
|
||||
<string name="action_test">内嵌920测试</string>
|
||||
<string name="text_no_accessibility_permission">辅助性服务未启动</string>
|
||||
<string name="text_drawer_close">关闭侧拉菜单</string>
|
||||
<string name="text_drawer_open">打开侧拉菜单</string>
|
||||
<string name="text_undo">撤销</string>
|
||||
<string name="text_redo">重做</string>
|
||||
<string name="text_save">保存</string>
|
||||
<string name="text_run">运行</string>
|
||||
<string name="text_alert">提示</string>
|
||||
<string name="edit_exit_without_save_warn">内容尚未保存,您确定要退出吗?</string>
|
||||
<string name="text_save_and_exit">保存并退出</string>
|
||||
<string name="text_exit_directly">直接退出</string>
|
||||
</resources>
|
||||
|
||||
85
app/src/main/res/values/theme_editor.xml
Normal file
@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="defaultColorControlNormal">#009688</color>
|
||||
|
||||
<style name="EditorTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- 工具栏背景 -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<!--状态栏背景-->
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<!--按钮类默认颜色-->
|
||||
<item name="colorControlNormal">@color/defaultColorControlNormal</item>
|
||||
|
||||
<!--按钮类选中颜色-->
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<!--导航栏背景-->
|
||||
<!--<item name="android:navigationBarColor">@color/navigationBarColor</item>-->
|
||||
<!-- 浮在toolbar上面 -->
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
|
||||
<!--<item name="android:actionBarStyle">@style/Toolbar</item>-->
|
||||
<item name="actionBarStyle">@style/Toolbar</item>
|
||||
<!--使用方式 app:theme="?attr/actionBarTheme"-->
|
||||
<item name="actionBarTheme">@style/ToolbarTheme</item>
|
||||
<item name="actionBarPopupTheme">@style/DefaultToolbarPopupTheme</item>
|
||||
<!--菜单字体颜色-->
|
||||
<item name="actionMenuTextColor">@android:color/white</item>
|
||||
<!--<item name="actionMenuTextAppearance">@style/Toolbar.Item</item>-->
|
||||
|
||||
<item name="actionModeStyle">@style/ActionMode</item>
|
||||
<item name="actionModeFindDrawable">@drawable/find_white</item>
|
||||
<item name="actionModeCloseDrawable">@drawable/back_btn</item>
|
||||
|
||||
<item name="dividerColor">#10000000</item>
|
||||
<item name="android:listDivider">@drawable/divider</item>
|
||||
|
||||
<item name="android:textViewStyle">@style/TextViewStyle</item>
|
||||
<item name="android:editTextStyle">@style/EditTextStyle</item>
|
||||
|
||||
<!--App自定义-->
|
||||
<item name="netLoadingDrawable">@drawable/loading_icon</item>
|
||||
<item name="tabBackground">@drawable/drawer_tab_item_background</item>
|
||||
<item name="listItemBackground">@drawable/white_selectable_item_background</item>
|
||||
<item name="toolbarIconNormalColor">#ffffff</item>
|
||||
<item name="toolbarIconDisabledColor">#50ffffff</item>
|
||||
<item name="menuIconNormalColor">#23c5dd</item>
|
||||
|
||||
<!--编辑器样式-->
|
||||
<item name="textForeground">#000000</item>
|
||||
<item name="textBackground">#FFFFFF</item>
|
||||
<item name="caret">#000000</item>
|
||||
<item name="selection">#4D97FF54</item>
|
||||
<item name="invisibles">#dddddd</item>
|
||||
<item name="gutterForeground">#000000</item>
|
||||
<item name="gutterBackground">#dfdfdf</item>
|
||||
<item name="gutterDivider">#000000</item>
|
||||
|
||||
<!--高亮-->
|
||||
<item name="hlComment1">#cc0000</item>
|
||||
<item name="hlComment2">#ff8400</item>
|
||||
<item name="hlComment3">#cc6600</item>
|
||||
<item name="hlComment4">#cc6600</item>
|
||||
<item name="hlDigit">#ff0000</item>
|
||||
<item name="hlFoldLine0">#000000</item>
|
||||
<item name="hlFoldLine1">#000000</item>
|
||||
<item name="hlFoldLine2">#000000</item>
|
||||
<item name="hlFoldLine3">#000000</item>
|
||||
<item name="hlFunction">#9966ff</item>
|
||||
<item name="hlInvalid">#ff0066</item>
|
||||
<item name="hlKeyword1">#006699</item>
|
||||
<item name="hlKeyword2">#009966</item>
|
||||
<item name="hlKeyword3">#0099ff</item>
|
||||
<item name="hlKeyword4">#66ccff</item>
|
||||
<item name="hlLabel">#02b902</item>
|
||||
<item name="hlLiteral1">#ff00cc</item>
|
||||
<item name="hlLiteral2">#cc00cc</item>
|
||||
<item name="hlLiteral3">#9900cc</item>
|
||||
<item name="hlLiteral4">#9900cc</item>
|
||||
<item name="hlMarkup">#0000ff</item>
|
||||
<item name="hlOperator">#000000</item>
|
||||
</style>
|
||||
|
||||
<style name="DefaultToolbarPopupTheme" parent="@style/ThemeOverlay.AppCompat.Light">
|
||||
<item name="colorControlNormal">@color/defaultColorControlNormal</item>
|
||||
</style>
|
||||
</resources>
|
||||