mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-21 21:01:43 +08:00
fix issues of Tasker Plugin Pref Editor
This commit is contained in:
parent
2138d4ef32
commit
0fa8c110fc
@ -9,8 +9,8 @@ android {
|
||||
applicationId "com.stardust.scriptdroid"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 23
|
||||
versionCode 203
|
||||
versionName "3.0.0 Alpha4"
|
||||
versionCode 204
|
||||
versionName "3.0.0 Alpha5"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -21,6 +21,9 @@ import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.Click;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
|
||||
import static com.stardust.scriptdroid.ui.edit.EditorView.EXTRA_CONTENT;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/3/27.
|
||||
*/
|
||||
@ -115,7 +118,7 @@ public class TaskPrefEditActivity extends AbstractAppCompatPluginActivity {
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
mPreExecuteScript = data.getStringExtra(TaskerScriptEditActivity.EXTRA_CONTENT);
|
||||
mPreExecuteScript = data.getStringExtra(EXTRA_CONTENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.ui.BaseActivity;
|
||||
import com.stardust.scriptdroid.ui.edit.EditorView;
|
||||
import com.stardust.theme.ThemeColorManager;
|
||||
import com.stardust.widget.ToolbarMenuItem;
|
||||
|
||||
@ -16,59 +17,50 @@ import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.functions.Consumer;
|
||||
|
||||
import static com.stardust.scriptdroid.ui.edit.EditorView.EXTRA_CONTENT;
|
||||
import static com.stardust.scriptdroid.ui.edit.EditorView.EXTRA_NAME;
|
||||
import static com.stardust.scriptdroid.ui.edit.EditorView.EXTRA_RUN_ENABLED;
|
||||
import static com.stardust.scriptdroid.ui.edit.EditorView.EXTRA_SAVE_ENABLED;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/4/5.
|
||||
*/
|
||||
@EActivity(R.layout.activity_tasker_script_edit)
|
||||
public class TaskerScriptEditActivity extends AppCompatActivity {
|
||||
public class TaskerScriptEditActivity extends BaseActivity {
|
||||
|
||||
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)
|
||||
.putExtra(EXTRA_CONTENT, content)
|
||||
.putExtra("summary", summary)
|
||||
.putExtra("title", title), REQUEST_CODE);
|
||||
.putExtra(EXTRA_NAME, title), REQUEST_CODE);
|
||||
}
|
||||
|
||||
private String mTitle, mSummary;
|
||||
@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());
|
||||
}
|
||||
@ViewById(R.id.editor_view)
|
||||
EditorView mEditorView;
|
||||
|
||||
@AfterViews
|
||||
void setUpViews() {
|
||||
((TextView) findViewById(R.id.summary)).setText(mSummary);
|
||||
ThemeColorManager.addActivityStatusBar(this);
|
||||
BaseActivity.setToolbarAsBack(this, R.id.toolbar, mTitle);
|
||||
setUpEditor();
|
||||
mEditorView.handleIntent(getIntent()
|
||||
.putExtra(EXTRA_RUN_ENABLED, false)
|
||||
.putExtra(EXTRA_SAVE_ENABLED, false));
|
||||
BaseActivity.setToolbarAsBack(this, R.id.toolbar, mEditorView.getName());
|
||||
}
|
||||
|
||||
private void handleIntent(Intent intent) {
|
||||
mTitle = intent.getStringExtra("title");
|
||||
mSummary = intent.getStringExtra("summary");
|
||||
String content = intent.getStringExtra(EXTRA_CONTENT);
|
||||
}
|
||||
|
||||
private void setUpEditor() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
mEditorView.getEditor().getText().subscribe(new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(@NonNull String s) throws Exception {
|
||||
setResult(RESULT_OK, new Intent().putExtra(EXTRA_CONTENT, s));
|
||||
TaskerScriptEditActivity.super.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setMenuStatus(int menuResId, int status) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,11 +26,10 @@ import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
* Created by Stardust on 2017/1/23.
|
||||
*/
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity implements BackPressedHandler.HostActivity {
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
protected static final int PERMISSION_REQUEST_CODE = 11186;
|
||||
private BackPressedHandler.Observer mBackPressObserver = new BackPressedHandler.Observer();
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@ -80,17 +79,6 @@ public abstract class BaseActivity extends AppCompatActivity implements BackPres
|
||||
setToolbarAsBack(this, R.id.toolbar, title);
|
||||
}
|
||||
|
||||
public void registerBackPressedHandler(BackPressedHandler handler) {
|
||||
mBackPressObserver.registerHandler(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!mBackPressObserver.onBackPressed(this)) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setToolbarAsBack(final AppCompatActivity activity, int id, String title) {
|
||||
Toolbar toolbar = (Toolbar) activity.findViewById(id);
|
||||
toolbar.setTitle(title);
|
||||
@ -112,8 +100,4 @@ public abstract class BaseActivity extends AppCompatActivity implements BackPres
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackPressedHandler.Observer getBackPressedObserver() {
|
||||
return mBackPressObserver;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,100 +1,41 @@
|
||||
package com.stardust.scriptdroid.ui.edit;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.stardust.app.OnActivityResultDelegate;
|
||||
import com.stardust.autojs.engine.JavaScriptEngine;
|
||||
import com.stardust.autojs.execution.ScriptExecution;
|
||||
import com.stardust.autojs.script.JavaScriptFileSource;
|
||||
import com.stardust.pio.PFile;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.scriptdroid.script.ScriptFile;
|
||||
import com.stardust.scriptdroid.script.Scripts;
|
||||
import com.stardust.scriptdroid.ui.BaseActivity;
|
||||
import com.stardust.scriptdroid.ui.edit.completion.CodeCompletions;
|
||||
import com.stardust.scriptdroid.ui.edit.completion.InputMethodEnhanceBar;
|
||||
import com.stardust.scriptdroid.ui.help.HelpCatalogueActivity;
|
||||
import com.stardust.theme.ThemeColorManager;
|
||||
import com.stardust.theme.dialog.ThemeColorMaterialDialogBuilder;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.Click;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import static com.stardust.scriptdroid.ui.edit.EditorView.EXTRA_NAME;
|
||||
import static com.stardust.scriptdroid.ui.edit.EditorView.EXTRA_PATH;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/29.
|
||||
*/
|
||||
@EActivity(R.layout.activity_edit)
|
||||
public class EditActivity extends AppCompatActivity implements OnActivityResultDelegate.DelegateHost {
|
||||
|
||||
public static final String EXTRA_PATH = "Still Love Eating 17.4.5";
|
||||
private static final String EXTRA_NAME = "Still love you 17.6.29 But....(ಥ_ಥ)";
|
||||
private static final String KEY_EDITOR_THEME = "I really really really really love you dee";
|
||||
public class EditActivity extends BaseActivity {
|
||||
|
||||
|
||||
@ViewById(R.id.content_view)
|
||||
View mView;
|
||||
|
||||
@ViewById(R.id.editor)
|
||||
CodeMirrorEditor mEditor;
|
||||
@ViewById(R.id.editor_view)
|
||||
EditorView mEditor;
|
||||
|
||||
@ViewById(R.id.input_method_enhance_bar)
|
||||
InputMethodEnhanceBar mInputMethodEnhanceBar;
|
||||
|
||||
private String mName;
|
||||
private File mFile;
|
||||
private boolean mReadOnly = false;
|
||||
private OnActivityResultDelegate.Mediator mActivityResultMediator = new OnActivityResultDelegate.Mediator();
|
||||
private BroadcastReceiver mOnRunFinishedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(Scripts.ACTION_ON_EXECUTION_FINISHED)) {
|
||||
mScriptExecution = null;
|
||||
setMenuItemStatus(R.id.run, true);
|
||||
String msg = intent.getStringExtra(Scripts.EXTRA_EXCEPTION_MESSAGE);
|
||||
if (msg != null) {
|
||||
Snackbar.make(mView, getString(R.string.text_error) + ": " + msg, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private ScriptExecution mScriptExecution;
|
||||
private boolean mTextChanged = false;
|
||||
|
||||
public void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
registerReceiver(mOnRunFinishedReceiver, new IntentFilter(Scripts.ACTION_ON_EXECUTION_FINISHED));
|
||||
}
|
||||
private EditorMenu mEditorMenu;
|
||||
|
||||
public static void editFile(Context context, String path) {
|
||||
editFile(context, null, path);
|
||||
@ -113,117 +54,13 @@ public class EditActivity extends AppCompatActivity implements OnActivityResultD
|
||||
|
||||
@AfterViews
|
||||
void setUpViews() {
|
||||
ThemeColorManager.addActivityStatusBar(this);
|
||||
mEditor.handleIntent(getIntent());
|
||||
mEditorMenu = new EditorMenu(mEditor);
|
||||
setUpToolbar();
|
||||
setUpEditor();
|
||||
handleIntent(getIntent());
|
||||
setMenuItemStatus(R.id.save, false);
|
||||
}
|
||||
|
||||
private void handleIntent(Intent intent) {
|
||||
String path = intent.getStringExtra(EXTRA_PATH);
|
||||
mName = intent.getStringExtra(EXTRA_NAME);
|
||||
mReadOnly = intent.getBooleanExtra("readOnly", false);
|
||||
boolean saveEnabled = intent.getBooleanExtra("saveEnabled", true);
|
||||
if (mReadOnly || !saveEnabled) {
|
||||
findViewById(R.id.save).setVisibility(View.GONE);
|
||||
}
|
||||
String content = intent.getStringExtra("content");
|
||||
if (content != null) {
|
||||
mEditor.setText(content);
|
||||
} else {
|
||||
mFile = new File(path);
|
||||
if (mName == null) {
|
||||
mName = mFile.getName();
|
||||
}
|
||||
mEditor.setText(PFile.read(mFile));
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpEditor() {
|
||||
mEditor.setTheme(PreferenceManager.getDefaultSharedPreferences(EditActivity.this)
|
||||
.getString(KEY_EDITOR_THEME, mEditor.getTheme()));
|
||||
mEditor.setCallback(new CodeMirrorEditor.Callback() {
|
||||
@Override
|
||||
public void onChange() {
|
||||
mTextChanged = true;
|
||||
setMenuItemStatus(R.id.save, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCodeCompletion(int fromLine, int fromCh, int toLine, int toCh, final String[] list) {
|
||||
mInputMethodEnhanceBar.setCodeCompletions(new CodeCompletions(
|
||||
new CodeCompletions.Pos(fromLine, fromCh),
|
||||
new CodeCompletions.Pos(toLine, toCh),
|
||||
Arrays.asList(list)
|
||||
));
|
||||
}
|
||||
});
|
||||
mInputMethodEnhanceBar.setOnHintClickListener(new InputMethodEnhanceBar.OnHintClickListener() {
|
||||
@Override
|
||||
public void onHintClick(CodeCompletions completions, int pos) {
|
||||
mEditor.replace(completions.getHints().get(pos), completions.getFrom().line, completions.getFrom().ch,
|
||||
completions.getTo().line, completions.getTo().ch);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setUpToolbar() {
|
||||
BaseActivity.setToolbarAsBack(this, R.id.toolbar, mName);
|
||||
}
|
||||
|
||||
@Click(R.id.run)
|
||||
void runAndSaveFileIFNeeded() {
|
||||
save().observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(@io.reactivex.annotations.NonNull String s) throws Exception {
|
||||
run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void run() {
|
||||
Snackbar.make(mView, R.string.text_start_running, Snackbar.LENGTH_SHORT).show();
|
||||
mScriptExecution = Scripts.runWithBroadcastSender(new JavaScriptFileSource(mName, mFile), mFile.getParent());
|
||||
setMenuItemStatus(R.id.run, false);
|
||||
}
|
||||
|
||||
|
||||
@Click(R.id.undo)
|
||||
void undo() {
|
||||
mEditor.undo();
|
||||
}
|
||||
|
||||
@Click(R.id.redo)
|
||||
void redo() {
|
||||
mEditor.redo();
|
||||
}
|
||||
|
||||
public Observable<String> save() {
|
||||
return mEditor.getText()
|
||||
.observeOn(Schedulers.io())
|
||||
.doOnNext(new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(@io.reactivex.annotations.NonNull String s) throws Exception {
|
||||
PFile.write(mFile, s);
|
||||
}
|
||||
})
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext(new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(@io.reactivex.annotations.NonNull String s) throws Exception {
|
||||
mTextChanged = false;
|
||||
setMenuItemStatus(R.id.save, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Click(R.id.save)
|
||||
void saveFile() {
|
||||
save().subscribe();
|
||||
BaseActivity.setToolbarAsBack(this, R.id.toolbar, mEditor.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -234,81 +71,12 @@ public class EditActivity extends AppCompatActivity implements OnActivityResultD
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_console:
|
||||
showConsole();
|
||||
return true;
|
||||
case R.id.action_log:
|
||||
showLog();
|
||||
return true;
|
||||
case R.id.action_editor_theme:
|
||||
selectEditorTheme();
|
||||
return true;
|
||||
case R.id.action_beautify:
|
||||
beautifyCode();
|
||||
return true;
|
||||
case R.id.action_open_by_other_apps:
|
||||
openByOtherApps();
|
||||
return true;
|
||||
case R.id.action_force_stop:
|
||||
forceStop();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void setMenuItemStatus(int id, boolean enabled) {
|
||||
findViewById(id).setEnabled(enabled);
|
||||
}
|
||||
|
||||
private void showLog() {
|
||||
AutoJs.getInstance().getScriptEngineService().getGlobalConsole().show();
|
||||
}
|
||||
|
||||
private void showConsole() {
|
||||
if (mScriptExecution != null) {
|
||||
((JavaScriptEngine) mScriptExecution.getEngine()).getRuntime().console.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void selectEditorTheme() {
|
||||
String[] themes = mEditor.getAvailableThemes();
|
||||
int i = Arrays.asList(themes).indexOf(mEditor.getTheme());
|
||||
new MaterialDialog.Builder(this)
|
||||
.items((CharSequence[]) themes)
|
||||
.itemsCallbackSingleChoice(i, new MaterialDialog.ListCallbackSingleChoice() {
|
||||
@Override
|
||||
public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
|
||||
PreferenceManager.getDefaultSharedPreferences(EditActivity.this).edit()
|
||||
.putString(KEY_EDITOR_THEME, text.toString())
|
||||
.apply();
|
||||
mEditor.setTheme(text.toString());
|
||||
return true;
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
|
||||
private void forceStop() {
|
||||
if (mScriptExecution != null) {
|
||||
mScriptExecution.getEngine().forceStop();
|
||||
}
|
||||
}
|
||||
|
||||
private void openByOtherApps() {
|
||||
if (mFile != null)
|
||||
Scripts.openByOtherApps(mFile);
|
||||
}
|
||||
|
||||
private void beautifyCode() {
|
||||
mEditor.beautifyCode();
|
||||
return mEditorMenu.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
if (mTextChanged) {
|
||||
if (mEditor.isTextChanged()) {
|
||||
showExitConfirmDialog();
|
||||
return;
|
||||
}
|
||||
@ -325,7 +93,7 @@ public class EditActivity extends AppCompatActivity implements OnActivityResultD
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
saveFile();
|
||||
mEditor.saveFile();
|
||||
EditActivity.super.finish();
|
||||
}
|
||||
})
|
||||
@ -338,21 +106,9 @@ public class EditActivity extends AppCompatActivity implements OnActivityResultD
|
||||
.show();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
mActivityResultMediator.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnActivityResultDelegate.Mediator getOnActivityResultDelegateMediator() {
|
||||
return mActivityResultMediator;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
unregisterReceiver(mOnRunFinishedReceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,68 @@
|
||||
package com.stardust.scriptdroid.ui.edit;
|
||||
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.stardust.autojs.engine.JavaScriptEngine;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.scriptdroid.script.Scripts;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/9/28.
|
||||
*/
|
||||
|
||||
public class EditorMenu {
|
||||
|
||||
private EditorView mEditorView;
|
||||
|
||||
public EditorMenu(EditorView editor) {
|
||||
mEditorView = editor;
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_console:
|
||||
showConsole();
|
||||
return true;
|
||||
case R.id.action_log:
|
||||
showLog();
|
||||
return true;
|
||||
case R.id.action_editor_theme:
|
||||
mEditorView.selectEditorTheme();
|
||||
return true;
|
||||
case R.id.action_beautify:
|
||||
beautifyCode();
|
||||
return true;
|
||||
case R.id.action_open_by_other_apps:
|
||||
openByOtherApps();
|
||||
return true;
|
||||
case R.id.action_force_stop:
|
||||
forceStop();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void showLog() {
|
||||
AutoJs.getInstance().getScriptEngineService().getGlobalConsole().show();
|
||||
}
|
||||
|
||||
private void showConsole() {
|
||||
mEditorView.showConsole();
|
||||
}
|
||||
|
||||
|
||||
private void forceStop() {
|
||||
mEditorView.forceStop();
|
||||
}
|
||||
|
||||
private void openByOtherApps() {
|
||||
mEditorView.openByOtherApps();
|
||||
}
|
||||
|
||||
private void beautifyCode() {
|
||||
mEditorView.beautifyCode();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,276 @@
|
||||
package com.stardust.scriptdroid.ui.edit;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.stardust.autojs.engine.JavaScriptEngine;
|
||||
import com.stardust.autojs.execution.ScriptExecution;
|
||||
import com.stardust.autojs.script.JavaScriptFileSource;
|
||||
import com.stardust.pio.PFile;
|
||||
import com.stardust.scriptdroid.R;
|
||||
import com.stardust.scriptdroid.script.Scripts;
|
||||
import com.stardust.scriptdroid.ui.edit.completion.CodeCompletions;
|
||||
import com.stardust.scriptdroid.ui.edit.completion.InputMethodEnhanceBar;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.Click;
|
||||
import org.androidannotations.annotations.EViewGroup;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static com.stardust.scriptdroid.script.Scripts.ACTION_ON_EXECUTION_FINISHED;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/9/28.
|
||||
*/
|
||||
@EViewGroup(R.layout.editor_view)
|
||||
public class EditorView extends FrameLayout {
|
||||
|
||||
public static final String EXTRA_PATH = "Still Love Eating 17.4.5";
|
||||
public static final String EXTRA_NAME = "Still love you 17.6.29 But....(ಥ_ಥ)";
|
||||
public static final String EXTRA_CONTENT = "It's hard...............";
|
||||
public static final String EXTRA_READ_ONLY = "Miss you more every day、、、";
|
||||
public static final String EXTRA_SAVE_ENABLED = "But you won't...but you won't...";
|
||||
public static final String EXTRA_RUN_ENABLED = "Love you with my life...really...17.9.28";
|
||||
|
||||
@ViewById(R.id.editor)
|
||||
CodeMirrorEditor mEditor;
|
||||
|
||||
@ViewById(R.id.input_method_enhance_bar)
|
||||
InputMethodEnhanceBar mInputMethodEnhanceBar;
|
||||
|
||||
private static final String KEY_EDITOR_THEME = "我...深爱着...你呀...17.9.28";
|
||||
|
||||
private String mName;
|
||||
private File mFile;
|
||||
private boolean mReadOnly = false;
|
||||
|
||||
private ScriptExecution mScriptExecution;
|
||||
private boolean mTextChanged = false;
|
||||
private BroadcastReceiver mOnRunFinishedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(ACTION_ON_EXECUTION_FINISHED)) {
|
||||
mScriptExecution = null;
|
||||
setMenuItemStatus(R.id.run, true);
|
||||
String msg = intent.getStringExtra(Scripts.EXTRA_EXCEPTION_MESSAGE);
|
||||
if (msg != null) {
|
||||
Snackbar.make(EditorView.this, getResources().getString(R.string.text_error) + ": " + msg, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void setMenuItemStatus(int id, boolean enabled) {
|
||||
findViewById(id).setEnabled(enabled);
|
||||
}
|
||||
|
||||
|
||||
public EditorView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public EditorView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public EditorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
getContext().registerReceiver(mOnRunFinishedReceiver, new IntentFilter(ACTION_ON_EXECUTION_FINISHED));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
getContext().unregisterReceiver(mOnRunFinishedReceiver);
|
||||
}
|
||||
|
||||
public void handleIntent(Intent intent) {
|
||||
mName = intent.getStringExtra(EXTRA_NAME);
|
||||
handleText(intent);
|
||||
mReadOnly = intent.getBooleanExtra(EXTRA_READ_ONLY, false);
|
||||
boolean saveEnabled = intent.getBooleanExtra(EXTRA_SAVE_ENABLED, true);
|
||||
if (mReadOnly || !saveEnabled) {
|
||||
findViewById(R.id.save).setVisibility(View.GONE);
|
||||
}
|
||||
if (!intent.getBooleanExtra(EXTRA_RUN_ENABLED, true)) {
|
||||
findViewById(R.id.run).setVisibility(GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleText(Intent intent) {
|
||||
String path = intent.getStringExtra(EXTRA_PATH);
|
||||
String content = intent.getStringExtra(EXTRA_CONTENT);
|
||||
if (content != null) {
|
||||
mEditor.setText(content);
|
||||
} else {
|
||||
mFile = new File(path);
|
||||
if (mName == null) {
|
||||
mName = mFile.getName();
|
||||
}
|
||||
mEditor.setText(PFile.read(mFile));
|
||||
}
|
||||
}
|
||||
|
||||
@AfterViews
|
||||
void init() {
|
||||
setUpEditor();
|
||||
}
|
||||
|
||||
private void setUpEditor() {
|
||||
mEditor.setTheme(PreferenceManager.getDefaultSharedPreferences(getContext())
|
||||
.getString(KEY_EDITOR_THEME, mEditor.getTheme()));
|
||||
mEditor.setCallback(new CodeMirrorEditor.Callback() {
|
||||
@Override
|
||||
public void onChange() {
|
||||
mTextChanged = true;
|
||||
setMenuItemStatus(R.id.save, true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateCodeCompletion(int fromLine, int fromCh, int toLine, int toCh, final String[] list) {
|
||||
mInputMethodEnhanceBar.setCodeCompletions(new CodeCompletions(
|
||||
new CodeCompletions.Pos(fromLine, fromCh),
|
||||
new CodeCompletions.Pos(toLine, toCh),
|
||||
Arrays.asList(list)
|
||||
));
|
||||
}
|
||||
});
|
||||
mInputMethodEnhanceBar.setOnHintClickListener(new InputMethodEnhanceBar.OnHintClickListener() {
|
||||
@Override
|
||||
public void onHintClick(CodeCompletions completions, int pos) {
|
||||
mEditor.replace(completions.getHints().get(pos), completions.getFrom().line, completions.getFrom().ch,
|
||||
completions.getTo().line, completions.getTo().ch);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Click(R.id.run)
|
||||
public void runAndSaveFileIfNeeded() {
|
||||
save().observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(@io.reactivex.annotations.NonNull String s) throws Exception {
|
||||
run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void run() {
|
||||
Snackbar.make(this, R.string.text_start_running, Snackbar.LENGTH_SHORT).show();
|
||||
mScriptExecution = Scripts.runWithBroadcastSender(new JavaScriptFileSource(mName, mFile), mFile.getParent());
|
||||
setMenuItemStatus(R.id.run, false);
|
||||
}
|
||||
|
||||
|
||||
@Click(R.id.undo)
|
||||
public void undo() {
|
||||
mEditor.undo();
|
||||
}
|
||||
|
||||
@Click(R.id.redo)
|
||||
public void redo() {
|
||||
mEditor.redo();
|
||||
}
|
||||
|
||||
public Observable<String> save() {
|
||||
return mEditor.getText()
|
||||
.observeOn(Schedulers.io())
|
||||
.doOnNext(new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(@io.reactivex.annotations.NonNull String s) throws Exception {
|
||||
PFile.write(mFile, s);
|
||||
}
|
||||
})
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext(new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(@io.reactivex.annotations.NonNull String s) throws Exception {
|
||||
mTextChanged = false;
|
||||
setMenuItemStatus(R.id.save, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void forceStop() {
|
||||
if (mScriptExecution != null) {
|
||||
mScriptExecution.getEngine().forceStop();
|
||||
}
|
||||
}
|
||||
|
||||
@Click(R.id.save)
|
||||
public void saveFile() {
|
||||
save().subscribe();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public boolean isTextChanged() {
|
||||
return mTextChanged;
|
||||
}
|
||||
|
||||
public void showConsole() {
|
||||
if (mScriptExecution != null) {
|
||||
((JavaScriptEngine) mScriptExecution.getEngine()).getRuntime().console.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void openByOtherApps() {
|
||||
if (mFile != null)
|
||||
Scripts.openByOtherApps(mFile);
|
||||
}
|
||||
|
||||
public void beautifyCode() {
|
||||
mEditor.beautifyCode();
|
||||
}
|
||||
|
||||
public void selectEditorTheme() {
|
||||
String[] themes = mEditor.getAvailableThemes();
|
||||
int i = Arrays.asList(themes).indexOf(mEditor.getTheme());
|
||||
new MaterialDialog.Builder(getContext())
|
||||
.title(R.string.text_editor_theme)
|
||||
.items((CharSequence[]) themes)
|
||||
.itemsCallbackSingleChoice(i, new MaterialDialog.ListCallbackSingleChoice() {
|
||||
@Override
|
||||
public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
|
||||
PreferenceManager.getDefaultSharedPreferences(getContext()).edit()
|
||||
.putString(KEY_EDITOR_THEME, text.toString())
|
||||
.apply();
|
||||
mEditor.setTheme(text.toString());
|
||||
return true;
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
public CodeMirrorEditor getEditor() {
|
||||
return mEditor;
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ import org.androidannotations.annotations.EActivity;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
@EActivity(R.layout.activity_main)
|
||||
public class MainActivity extends BaseActivity implements OnActivityResultDelegate.DelegateHost {
|
||||
public class MainActivity extends BaseActivity implements OnActivityResultDelegate.DelegateHost, BackPressedHandler.HostActivity {
|
||||
|
||||
private static final String LOG_TAG = "MainActivity";
|
||||
|
||||
@ -64,6 +64,7 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
||||
private FragmentPagerAdapterBuilder.StoredFragmentPagerAdapter mPagerAdapter;
|
||||
private OnActivityResultDelegate.Mediator mActivityResultMediator = new OnActivityResultDelegate.Mediator();
|
||||
private VersionGuard mVersionGuard;
|
||||
private BackPressedHandler.Observer mBackPressObserver = new BackPressedHandler.Observer();
|
||||
|
||||
|
||||
@Override
|
||||
@ -99,8 +100,8 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
||||
|
||||
|
||||
private void registerBackPressHandlers() {
|
||||
registerBackPressedHandler(new DrawerAutoClose(mDrawerLayout, Gravity.START));
|
||||
registerBackPressedHandler(new BackPressedHandler.DoublePressExit(this, R.string.text_press_again_to_exit));
|
||||
mBackPressObserver.registerHandler(new DrawerAutoClose(mDrawerLayout, Gravity.START));
|
||||
mBackPressObserver.registerHandler(new BackPressedHandler.DoublePressExit(this, R.string.text_press_again_to_exit));
|
||||
}
|
||||
|
||||
private void checkPermissions() {
|
||||
@ -228,4 +229,17 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
||||
return mActivityResultMediator;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!mBackPressObserver.onBackPressed(this)) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackPressedHandler.Observer getBackPressedObserver() {
|
||||
return mBackPressObserver;
|
||||
}
|
||||
|
||||
}
|
||||
@ -109,7 +109,7 @@ public class MyScriptListFragment extends ViewPagerFragment implements BackPress
|
||||
@Override
|
||||
public boolean onBackPressed(Activity activity) {
|
||||
if (mFloatingActionMenu != null && mFloatingActionMenu.isExpanded()) {
|
||||
mFloatingActionMenu.expand();
|
||||
mFloatingActionMenu.collapse();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -85,7 +85,7 @@ public class ScriptListView extends SwipeRefreshLayout implements SwipeRefreshLa
|
||||
initScriptListRecyclerView();
|
||||
mStorageFileProvider = StorageFileProvider.getDefault();
|
||||
setCurrentDirectory(mStorageFileProvider.getInitialDirectory());
|
||||
mStorageFileProvider.registerDirectoryChangeListener(this);
|
||||
//mStorageFileProvider.registerDirectoryChangeListener(this);
|
||||
}
|
||||
|
||||
private void initScriptListRecyclerView() {
|
||||
@ -175,7 +175,7 @@ public class ScriptListView extends SwipeRefreshLayout implements SwipeRefreshLa
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mStorageFileProvider.unregisterDirectoryChangeListener(this);
|
||||
// mStorageFileProvider.unregisterDirectoryChangeListener(this);
|
||||
}
|
||||
|
||||
private class ScriptListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
@ -1,88 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<com.stardust.scriptdroid.ui.edit.EditorView_
|
||||
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/content_view"
|
||||
android:id="@+id/editor_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="com.stardust.scriptdroid.ui.edit.EditActivity">
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorToolbar
|
||||
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.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.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.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.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>
|
||||
|
||||
</com.stardust.theme.widget.ThemeColorToolbar>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
|
||||
<com.stardust.scriptdroid.ui.edit.CodeMirrorEditor
|
||||
android:id="@+id/editor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:bufferType="spannable"
|
||||
android:cursorVisible="true"
|
||||
android:gravity="top|start"
|
||||
android:text=""
|
||||
android:textCursorDrawable="@null"
|
||||
android:textIsSelectable="true"/>
|
||||
|
||||
<com.stardust.scriptdroid.ui.edit.completion.InputMethodEnhanceBar
|
||||
android:id="@+id/input_method_enhance_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:background="#e7ebec"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -1,71 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<com.stardust.scriptdroid.ui.edit.EditorView_
|
||||
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/editor_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="com.stardust.scriptdroid.ui.edit.EditActivity">
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||
app:title="@string/_app_name">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:orientation="horizontal"
|
||||
android:paddingRight="8dp">
|
||||
|
||||
<com.stardust.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.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"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</com.stardust.theme.widget.ThemeColorToolbar>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/toolbar"
|
||||
android:layout_marginLeft="72dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="10sp"
|
||||
tools:text="@string/summary_pre_execute_script"/>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_edit"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
<?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"
|
||||
tools:showIn="@layout/activity_edit">
|
||||
|
||||
<com.stardust.scriptdroid.ui.edit.CodeMirrorEditor
|
||||
android:id="@+id/editor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:bufferType="spannable"
|
||||
android:cursorVisible="true"
|
||||
android:gravity="top|start"
|
||||
android:text=""
|
||||
android:textCursorDrawable="@null"
|
||||
android:textIsSelectable="true"/>
|
||||
|
||||
|
||||
<com.stardust.scriptdroid.ui.edit.completion.InputMethodEnhanceBar
|
||||
android:id="@+id/input_method_enhance_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:background="#e7ebec"/>
|
||||
|
||||
</LinearLayout>
|
||||
76
app/src/main/res/layout/editor_view.xml
Normal file
76
app/src/main/res/layout/editor_view.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<com.stardust.theme.widget.ThemeColorToolbar
|
||||
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.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.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.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.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>
|
||||
|
||||
</com.stardust.theme.widget.ThemeColorToolbar>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
|
||||
<com.stardust.scriptdroid.ui.edit.CodeMirrorEditor
|
||||
android:id="@+id/editor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<com.stardust.scriptdroid.ui.edit.completion.InputMethodEnhanceBar
|
||||
android:id="@+id/input_method_enhance_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:background="#e7ebec"/>
|
||||
|
||||
</LinearLayout>
|
||||
Loading…
Reference in New Issue
Block a user